├── .gitignore ├── Makefile ├── Makefile.arm-wince-mingw32ce-gcc ├── Makefile.in ├── Makefile.linux-gcc ├── Makefile.msc ├── Makefile.vxworks ├── README ├── README.md ├── VERSION ├── aclocal.m4 ├── addopcodes.awk ├── art ├── sqlite370.eps ├── sqlite370.ico └── sqlite370.jpg ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.ac ├── contrib └── sqlitecon.tcl ├── doc ├── lemon.html ├── pager-invariants.txt └── vfs-shm.txt ├── ext ├── README.txt ├── async │ ├── README.txt │ ├── sqlite3async.c │ └── sqlite3async.h ├── fts1 │ ├── README.txt │ ├── ft_hash.c │ ├── ft_hash.h │ ├── fts1.c │ ├── fts1.h │ ├── fts1_hash.c │ ├── fts1_hash.h │ ├── fts1_porter.c │ ├── fts1_tokenizer.h │ ├── fts1_tokenizer1.c │ ├── fulltext.c │ ├── fulltext.h │ ├── simple_tokenizer.c │ └── tokenizer.h ├── fts2 │ ├── README.tokenizers │ ├── README.txt │ ├── fts2.c │ ├── fts2.h │ ├── fts2_hash.c │ ├── fts2_hash.h │ ├── fts2_icu.c │ ├── fts2_porter.c │ ├── fts2_tokenizer.c │ ├── fts2_tokenizer.h │ ├── fts2_tokenizer1.c │ └── mkfts2amal.tcl ├── fts3 │ ├── README.content │ ├── README.syntax │ ├── README.tokenizers │ ├── README.txt │ ├── fts3.c │ ├── fts3.h │ ├── fts3Int.h │ ├── fts3_aux.c │ ├── fts3_expr.c │ ├── fts3_hash.c │ ├── fts3_hash.h │ ├── fts3_icu.c │ ├── fts3_porter.c │ ├── fts3_snippet.c │ ├── fts3_term.c │ ├── fts3_test.c │ ├── fts3_tokenize_vtab.c │ ├── fts3_tokenizer.c │ ├── fts3_tokenizer.h │ ├── fts3_tokenizer1.c │ ├── fts3_unicode.c │ ├── fts3_unicode2.c │ ├── fts3_write.c │ ├── fts3speed.tcl │ ├── mkfts3amal.tcl │ ├── tool │ │ └── fts3view.c │ └── unicode │ │ ├── CaseFolding.txt │ │ ├── UnicodeData.txt │ │ └── mkunicode.tcl ├── icu │ ├── README.txt │ ├── icu.c │ └── sqliteicu.h ├── misc │ ├── amatch.c │ ├── closure.c │ ├── fuzzer.c │ ├── ieee754.c │ ├── nextchar.c │ ├── regexp.c │ ├── rot13.c │ ├── spellfix.c │ └── wholenumber.c └── rtree │ ├── README │ ├── rtree.c │ ├── rtree.h │ ├── rtree1.test │ ├── rtree2.test │ ├── rtree3.test │ ├── rtree4.test │ ├── rtree5.test │ ├── rtree6.test │ ├── rtree7.test │ ├── rtree8.test │ ├── rtree9.test │ ├── rtreeA.test │ ├── rtreeB.test │ ├── rtree_perf.tcl │ ├── rtree_util.tcl │ ├── sqlite3rtree.h │ ├── tkt3363.test │ └── viewrtree.tcl ├── install-sh ├── ltmain.sh ├── magic.txt ├── main.mk ├── manifest ├── manifest.uuid ├── mkdll.sh ├── mkextu.sh ├── mkextw.sh ├── mkopcodec.awk ├── mkopcodeh.awk ├── mkso.sh ├── mptest ├── config01.test ├── config02.test ├── crash01.test ├── crash02.subtest ├── mptest.c └── multiwrite01.test ├── spec.template ├── sqlite.pc.in ├── sqlite3.1 ├── sqlite3.pc.in ├── src ├── alter.c ├── analyze.c ├── attach.c ├── auth.c ├── backup.c ├── bitvec.c ├── btmutex.c ├── btree.c ├── btree.h ├── btreeInt.h ├── build.c ├── callback.c ├── complete.c ├── ctime.c ├── date.c ├── delete.c ├── expr.c ├── fault.c ├── fkey.c ├── func.c ├── global.c ├── hash.c ├── hash.h ├── hwtime.h ├── insert.c ├── journal.c ├── legacy.c ├── lempar.c ├── loadext.c ├── main.c ├── malloc.c ├── mem0.c ├── mem1.c ├── mem2.c ├── mem3.c ├── mem5.c ├── memjournal.c ├── mutex.c ├── mutex.h ├── mutex_noop.c ├── mutex_unix.c ├── mutex_w32.c ├── notify.c ├── os.c ├── os.h ├── os_common.h ├── os_unix.c ├── os_win.c ├── pager.c ├── pager.h ├── parse.y ├── pcache.c ├── pcache.h ├── pcache1.c ├── pragma.c ├── prepare.c ├── printf.c ├── random.c ├── resolve.c ├── rowset.c ├── select.c ├── shell.c ├── sqlite.h.in ├── sqlite3.rc ├── sqlite3ext.h ├── sqliteInt.h ├── sqliteLimit.h ├── status.c ├── table.c ├── tclsqlite.c ├── test1.c ├── test2.c ├── test3.c ├── test4.c ├── test5.c ├── test6.c ├── test7.c ├── test8.c ├── test9.c ├── test_async.c ├── test_autoext.c ├── test_backup.c ├── test_btree.c ├── test_config.c ├── test_demovfs.c ├── test_devsym.c ├── test_fs.c ├── test_func.c ├── test_hexio.c ├── test_init.c ├── test_intarray.c ├── test_intarray.h ├── test_journal.c ├── test_loadext.c ├── test_malloc.c ├── test_multiplex.c ├── test_multiplex.h ├── test_mutex.c ├── test_onefile.c ├── test_osinst.c ├── test_pcache.c ├── test_quota.c ├── test_quota.h ├── test_rtree.c ├── test_schema.c ├── test_server.c ├── test_sqllog.c ├── test_stat.c ├── test_superlock.c ├── test_syscall.c ├── test_tclvar.c ├── test_thread.c ├── test_vfs.c ├── test_vfstrace.c ├── test_wsd.c ├── tokenize.c ├── trigger.c ├── update.c ├── utf.c ├── util.c ├── vacuum.c ├── vdbe.c ├── vdbe.h ├── vdbeInt.h ├── vdbeapi.c ├── vdbeaux.c ├── vdbeblob.c ├── vdbemem.c ├── vdbesort.c ├── vdbetrace.c ├── vtab.c ├── wal.c ├── wal.h ├── walker.c └── where.c ├── test ├── 8_3_names.test ├── aggerror.test ├── aggnested.test ├── alias.test ├── all.test ├── alter.test ├── alter2.test ├── alter3.test ├── alter4.test ├── altermalloc.test ├── analyze.test ├── analyze3.test ├── analyze4.test ├── analyze5.test ├── analyze6.test ├── analyze7.test ├── analyze8.test ├── async.test ├── async2.test ├── async3.test ├── async4.test ├── async5.test ├── atof1.test ├── attach.test ├── attach2.test ├── attach3.test ├── attach4.test ├── attachmalloc.test ├── auth.test ├── auth2.test ├── auth3.test ├── autoinc.test ├── autoindex1.test ├── autovacuum.test ├── autovacuum_ioerr2.test ├── avtrans.test ├── backcompat.test ├── backup.test ├── backup2.test ├── backup4.test ├── backup_ioerr.test ├── backup_malloc.test ├── badutf.test ├── badutf2.test ├── bc_common.tcl ├── between.test ├── bigfile.test ├── bigfile2.test ├── bigrow.test ├── bind.test ├── bindxfer.test ├── bitvec.test ├── blob.test ├── boundary1.tcl ├── boundary1.test ├── boundary2.tcl ├── boundary2.test ├── boundary3.tcl ├── boundary3.test ├── boundary4.tcl ├── boundary4.test ├── btreefault.test ├── busy.test ├── cache.test ├── capi2.test ├── capi3.test ├── capi3b.test ├── capi3c.test ├── capi3d.test ├── capi3e.test ├── cast.test ├── check.test ├── close.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 ├── corrupt.test ├── corrupt2.test ├── corrupt3.test ├── corrupt4.test ├── corrupt5.test ├── corrupt6.test ├── corrupt7.test ├── corrupt8.test ├── corrupt9.test ├── corruptA.test ├── corruptB.test ├── corruptC.test ├── corruptD.test ├── corruptE.test ├── corruptF.test ├── count.test ├── coveridxscan.test ├── crash.test ├── crash2.test ├── crash3.test ├── crash4.test ├── crash5.test ├── crash6.test ├── crash7.test ├── crash8.test ├── crashtest1.c ├── createtab.test ├── cse.test ├── ctime.test ├── date.test ├── dbstatus.test ├── dbstatus2.test ├── default.test ├── delete.test ├── delete2.test ├── delete3.test ├── descidx1.test ├── descidx2.test ├── descidx3.test ├── diskfull.test ├── distinct.test ├── distinctagg.test ├── e_createtable.test ├── e_delete.test ├── e_droptrigger.test ├── e_dropview.test ├── e_expr.test ├── e_fkey.test ├── e_fts3.test ├── e_insert.test ├── e_reindex.test ├── e_resolve.test ├── e_select.test ├── e_select2.test ├── e_update.test ├── e_uri.test ├── e_vacuum.test ├── enc.test ├── enc2.test ├── enc3.test ├── enc4.test ├── eqp.test ├── errmsg.test ├── eval.test ├── exclusive.test ├── exclusive2.test ├── exec.test ├── exists.test ├── expr.test ├── fallocate.test ├── filectrl.test ├── filefmt.test ├── fkey1.test ├── fkey2.test ├── fkey3.test ├── fkey4.test ├── fkey5.test ├── fkey_malloc.test ├── format4.test ├── fts-9fd058691.test ├── fts1a.test ├── fts1b.test ├── fts1c.test ├── fts1d.test ├── fts1e.test ├── fts1f.test ├── fts1i.test ├── fts1j.test ├── fts1k.test ├── fts1l.test ├── fts1m.test ├── fts1n.test ├── fts1o.test ├── fts1porter.test ├── fts2.test ├── fts2a.test ├── fts2b.test ├── fts2c.test ├── fts2d.test ├── fts2e.test ├── fts2f.test ├── fts2g.test ├── fts2h.test ├── fts2i.test ├── fts2j.test ├── fts2k.test ├── fts2l.test ├── fts2m.test ├── fts2n.test ├── fts2o.test ├── fts2p.test ├── fts2q.test ├── fts2r.test ├── fts2token.test ├── fts3.test ├── fts3_common.tcl ├── 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 ├── fts3b.test ├── fts3c.test ├── fts3comp1.test ├── fts3conf.test ├── fts3corrupt.test ├── fts3corrupt2.test ├── fts3cov.test ├── fts3d.test ├── fts3defer.test ├── fts3defer2.test ├── fts3drop.test ├── fts3e.test ├── fts3expr.test ├── fts3expr2.test ├── fts3expr3.test ├── fts3fault.test ├── fts3fault2.test ├── fts3first.test ├── fts3malloc.test ├── fts3matchinfo.test ├── fts3near.test ├── fts3prefix.test ├── fts3prefix2.test ├── fts3query.test ├── fts3rnd.test ├── fts3shared.test ├── fts3snippet.test ├── fts3sort.test ├── fts3tok1.test ├── fts3tok_err.test ├── fts4aa.test ├── fts4check.test ├── fts4content.test ├── fts4langid.test ├── fts4merge.test ├── fts4merge2.test ├── fts4merge3.test ├── fts4unicode.test ├── full.test ├── func.test ├── func2.test ├── func3.test ├── fuzz-oss1.test ├── fuzz.test ├── fuzz2.test ├── fuzz3.test ├── fuzz_common.tcl ├── fuzz_malloc.test ├── fuzzer1.test ├── fuzzerfault.test ├── hook.test ├── icu.test ├── in.test ├── in2.test ├── in3.test ├── in4.test ├── in5.test ├── incrblob.test ├── incrblob2.test ├── incrblob3.test ├── incrblob4.test ├── incrblob_err.test ├── incrblobfault.test ├── incrvacuum.test ├── incrvacuum2.test ├── incrvacuum3.test ├── incrvacuum_ioerr.test ├── index.test ├── index2.test ├── index3.test ├── index4.test ├── index5.test ├── indexedby.test ├── indexfault.test ├── init.test ├── insert.test ├── insert2.test ├── insert3.test ├── insert4.test ├── insert5.test ├── instr.test ├── intarray.test ├── interrupt.test ├── intpkey.test ├── io.test ├── ioerr.test ├── ioerr2.test ├── ioerr3.test ├── ioerr4.test ├── ioerr5.test ├── ioerr6.test ├── join.test ├── join2.test ├── join3.test ├── join4.test ├── join5.test ├── join6.test ├── journal1.test ├── journal2.test ├── journal3.test ├── jrnlmode.test ├── jrnlmode2.test ├── jrnlmode3.test ├── keyword1.test ├── lastinsert.test ├── laststmtchanges.test ├── like.test ├── like2.test ├── limit.test ├── loadext.test ├── loadext2.test ├── lock.test ├── lock2.test ├── lock3.test ├── lock4.test ├── lock5.test ├── lock6.test ├── lock7.test ├── lock_common.tcl ├── lookaside.test ├── main.test ├── make-where7.tcl ├── malloc.test ├── malloc3.test ├── malloc4.test ├── malloc5.test ├── malloc6.test ├── malloc7.test ├── malloc8.test ├── malloc9.test ├── mallocA.test ├── mallocAll.test ├── mallocB.test ├── mallocC.test ├── mallocD.test ├── mallocE.test ├── mallocF.test ├── mallocG.test ├── mallocH.test ├── mallocI.test ├── mallocJ.test ├── mallocK.test ├── malloc_common.tcl ├── manydb.test ├── mem5.test ├── memdb.test ├── memleak.test ├── memsubsys1.test ├── memsubsys2.test ├── minmax.test ├── minmax2.test ├── minmax3.test ├── minmax4.test ├── misc1.test ├── misc2.test ├── misc3.test ├── misc4.test ├── misc5.test ├── misc6.test ├── misc7.test ├── misuse.test ├── mmap1.test ├── mmap2.test ├── multiplex.test ├── multiplex2.test ├── multiplex3.test ├── mutex1.test ├── mutex2.test ├── nan.test ├── notify1.test ├── notify2.test ├── notify3.test ├── notnull.test ├── null.test ├── numcast.test ├── openv2.test ├── orderby1.test ├── orderby2.test ├── orderby3.test ├── orderby4.test ├── oserror.test ├── pager1.test ├── pager2.test ├── pager3.test ├── pagerfault.test ├── pagerfault2.test ├── pagerfault3.test ├── pageropt.test ├── pagesize.test ├── pcache.test ├── pcache2.test ├── permutations.test ├── pragma.test ├── pragma2.test ├── printf.test ├── progress.test ├── ptrchng.test ├── quick.test ├── quota-glob.test ├── quota.test ├── quota2.test ├── quote.test ├── randexpr1.tcl ├── randexpr1.test ├── rdonly.test ├── regexp1.test ├── reindex.test ├── releasetest.mk ├── releasetest.tcl ├── resolver01.test ├── rollback.test ├── rowhash.test ├── rowid.test ├── rtree.test ├── savepoint.test ├── savepoint2.test ├── savepoint3.test ├── savepoint4.test ├── savepoint5.test ├── savepoint6.test ├── savepoint7.test ├── schema.test ├── schema2.test ├── schema3.test ├── schema4.test ├── schema5.test ├── securedel.test ├── securedel2.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 ├── server1.test ├── shared.test ├── shared2.test ├── shared3.test ├── shared4.test ├── shared6.test ├── shared7.test ├── shared8.test ├── shared9.test ├── sharedA.test ├── shared_err.test ├── sharedlock.test ├── shell1.test ├── shell2.test ├── shell3.test ├── shell4.test ├── shell5.test ├── shortread1.test ├── shrink.test ├── sidedelete.test ├── soak.test ├── softheap1.test ├── sort.test ├── speed1.test ├── speed1p.explain ├── speed1p.test ├── speed2.test ├── speed3.test ├── speed4.test ├── speed4p.explain ├── speed4p.test ├── spellfix.test ├── sqllimits1.test ├── stat.test ├── stmt.test ├── subquery.test ├── subquery2.test ├── subselect.test ├── substr.test ├── superlock.test ├── sync.test ├── syscall.test ├── sysfault.test ├── table.test ├── tableapi.test ├── tclsqlite.test ├── tempdb.test ├── temptable.test ├── temptrigger.test ├── tester.tcl ├── thread001.test ├── thread002.test ├── thread003.test ├── thread004.test ├── thread005.test ├── thread1.test ├── thread2.test ├── thread_common.tcl ├── threadtest1.c ├── threadtest2.c ├── threadtest3.c ├── tkt-02a8e81d44.test ├── tkt-26ff0c2d1e.test ├── tkt-2a5629202f.test ├── tkt-2d1a5c67d.test ├── tkt-2ea2425d34.test ├── tkt-31338dca7e.test ├── tkt-313723c356.test ├── tkt-385a5b56b9.test ├── tkt-38cb5df375.test ├── tkt-3998683a16.test ├── tkt-3a77c9714e.test ├── tkt-3fe897352e.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 ├── 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 ├── tkt2767.test ├── tkt2817.test ├── tkt2820.test ├── tkt2822.test ├── tkt2832.test ├── tkt2854.test ├── tkt2920.test ├── tkt2927.test ├── tkt2942.test ├── tkt3080.test ├── tkt3093.test ├── tkt3121.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 ├── tkt3871.test ├── tkt3879.test ├── tkt3911.test ├── tkt3918.test ├── tkt3922.test ├── tkt3929.test ├── tkt3935.test ├── tkt3992.test ├── tkt3997.test ├── tkt4018.test ├── tokenize.test ├── trace.test ├── trace2.test ├── trans.test ├── trans2.test ├── trans3.test ├── transitive1.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 ├── tt3_checkpoint.c ├── types.test ├── types2.test ├── types3.test ├── unique.test ├── unixexcl.test ├── unordered.test ├── update.test ├── uri.test ├── utf16align.test ├── vacuum.test ├── vacuum2.test ├── vacuum3.test ├── vacuum4.test ├── varint.test ├── veryquick.test ├── view.test ├── vtab1.test ├── vtab2.test ├── vtab3.test ├── vtab4.test ├── vtab5.test ├── vtab6.test ├── vtab7.test ├── vtab8.test ├── vtab9.test ├── vtabA.test ├── vtabB.test ├── vtabC.test ├── vtabD.test ├── vtabE.test ├── vtabF.test ├── vtab_alter.test ├── vtab_err.test ├── vtab_shared.test ├── wal.test ├── wal2.test ├── wal3.test ├── wal4.test ├── wal5.test ├── wal6.test ├── wal7.test ├── wal8.test ├── wal9.test ├── wal_common.tcl ├── walbak.test ├── walbig.test ├── walcksum.test ├── walcrash.test ├── walcrash2.test ├── walcrash3.test ├── walfault.test ├── walhook.test ├── walmode.test ├── walnoshm.test ├── walpersist.test ├── walro.test ├── walshared.test ├── walslow.test ├── walthread.test ├── where.test ├── where2.test ├── where3.test ├── where4.test ├── where5.test ├── where6.test ├── where7.test ├── where8.test ├── where8m.test ├── where9.test ├── whereA.test ├── whereB.test ├── whereC.test ├── whereD.test ├── whereE.test ├── whereF.test ├── wherelimit.test ├── win32lock.test ├── zeroblob.test └── zerodamage.test └── tool ├── build-all-msvc.bat ├── build-shell.sh ├── checkSpacing.c ├── diffdb.c ├── extract.c ├── fragck.tcl ├── genfkey.README ├── genfkey.test ├── getlock.c ├── lemon.c ├── lempar.c ├── mkkeywordhash.c ├── mkopts.tcl ├── mkspeedsql.tcl ├── mksqlite3c-noext.tcl ├── mksqlite3c.tcl ├── mksqlite3h.tcl ├── mksqlite3internalh.tcl ├── mkvsix.tcl ├── offsets.c ├── omittest.tcl ├── opcodeDoc.awk ├── restore_jrnl.tcl ├── rollback-test.c ├── showdb.c ├── showjournal.c ├── showwal.c ├── soak1.tcl ├── space_used.tcl ├── spaceanal.tcl ├── speedtest.tcl ├── speedtest16.c ├── speedtest2.tcl ├── speedtest8.c ├── speedtest8inst1.c ├── split-sqlite3c.tcl ├── stack_usage.tcl ├── symbols-mingw.sh ├── symbols.sh ├── tostr.awk ├── vdbe-compress.tcl ├── warnings-clang.sh ├── warnings.sh └── win └── sqlite.vsix /.gitignore: -------------------------------------------------------------------------------- 1 | _FOSSIL_ 2 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This directory contains source code to 2 | 3 | SQLite: An Embeddable SQL Database Engine 4 | 5 | To compile the project, first create a directory in which to place 6 | the build products. It is recommended, but not required, that the 7 | build directory be separate from the source directory. Cd into the 8 | build directory and then from the build directory run the configure 9 | script found at the root of the source tree. Then run "make". 10 | 11 | For example: 12 | 13 | tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" 14 | mkdir bld ;# Build will occur in a sibling directory 15 | cd bld ;# Change to the build directory 16 | ../sqlite/configure ;# Run the configure script 17 | make ;# Run the makefile. 18 | make install ;# (Optional) Install the build products 19 | 20 | The configure script uses autoconf 2.61 and libtool. If the configure 21 | script does not work out for you, there is a generic makefile named 22 | "Makefile.linux-gcc" in the top directory of the source tree that you 23 | can copy and edit to suit your needs. Comments on the generic makefile 24 | show what changes are needed. 25 | 26 | The linux binaries on the website are created using the generic makefile, 27 | not the configure script. The windows binaries on the website are created 28 | using MinGW32 configured as a cross-compiler running under Linux. For 29 | details, see the ./publish.sh script at the top-level of the source tree. 30 | The developers do not use teh configure script. 31 | 32 | SQLite does not require TCL to run, but a TCL installation is required 33 | by the makefiles. SQLite contains a lot of generated code and TCL is 34 | used to do much of that code generation. The makefile also requires 35 | AWK. 36 | 37 | Contacts: 38 | 39 | http://www.sqlite.org/ 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SQLite3 ported to use LMDB instead of its original Btree code. 2 | 3 | To set the LMDB mapsize in pages, use: 4 | 5 | PRAGMA max_page_count=; 6 | 7 | Using tool/speedtest.tcl in the SQLite source tree, the time to insert 1000 records on my laptop SSD was 22.42 seconds using the original code, and only 1.06 seconds using LMDB. Both tests were run 3 times, with results averaged. The actual runtimes were 8 | 9 | Original MDB 10 | 23.14 1.07 11 | 22.02 1.05 12 | 22.12 1.08 13 | 14 | Tested at version 3.7.7.1. 15 | 16 | More recent test results using 3.7.17 are on [pastebin](http://pastebin.com/B5SfEieL), summarized below: 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
SQLiteSQLightning
Operation times in microseconds, lower is better
Sync Seq Write8175.3716171.233
Sync Rand Write8308.7066231.249
Seq Write25.58731.778
Batch Seq Write7.4027.087
Rand Write33.23532.902
Batch Rand Write18.84713.754
Rand Read22.6457.685
Seq Read7.5571.551
Rev Seq Read7.4561.531
31 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 3.7.17 2 | -------------------------------------------------------------------------------- /addopcodes.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk 2 | # 3 | # This script appends additional token codes to the end of the 4 | # parse.h file that lemon generates. These extra token codes are 5 | # not used by the parser. But they are used by the tokenizer and/or 6 | # the code generator. 7 | # 8 | # 9 | BEGIN { 10 | max = 0 11 | } 12 | /^#define TK_/ { 13 | print $0 14 | if( max<$3 ) max = $3 15 | } 16 | END { 17 | printf "#define TK_%-29s %4d\n", "TO_TEXT", ++max 18 | printf "#define TK_%-29s %4d\n", "TO_BLOB", ++max 19 | printf "#define TK_%-29s %4d\n", "TO_NUMERIC", ++max 20 | printf "#define TK_%-29s %4d\n", "TO_INT", ++max 21 | printf "#define TK_%-29s %4d\n", "TO_REAL", ++max 22 | printf "#define TK_%-29s %4d\n", "ISNOT", ++max 23 | printf "#define TK_%-29s %4d\n", "END_OF_FILE", ++max 24 | printf "#define TK_%-29s %4d\n", "ILLEGAL", ++max 25 | printf "#define TK_%-29s %4d\n", "SPACE", ++max 26 | printf "#define TK_%-29s %4d\n", "UNCLOSED_STRING", ++max 27 | printf "#define TK_%-29s %4d\n", "FUNCTION", ++max 28 | printf "#define TK_%-29s %4d\n", "COLUMN", ++max 29 | printf "#define TK_%-29s %4d\n", "AGG_FUNCTION", ++max 30 | printf "#define TK_%-29s %4d\n", "AGG_COLUMN", ++max 31 | printf "#define TK_%-29s %4d\n", "CONST_FUNC", ++max 32 | printf "#define TK_%-29s %4d\n", "UMINUS", ++max 33 | printf "#define TK_%-29s %4d\n", "UPLUS", ++max 34 | } 35 | -------------------------------------------------------------------------------- /art/sqlite370.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMDB/sqlightning/bb8144e10a985f83b6973a38078dd19ed2b0c711/art/sqlite370.ico -------------------------------------------------------------------------------- /art/sqlite370.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMDB/sqlightning/bb8144e10a985f83b6973a38078dd19ed2b0c711/art/sqlite370.jpg -------------------------------------------------------------------------------- /ext/README.txt: -------------------------------------------------------------------------------- 1 | Version loadable extensions to SQLite are found in subfolders 2 | of this folder. 3 | -------------------------------------------------------------------------------- /ext/fts1/README.txt: -------------------------------------------------------------------------------- 1 | This folder contains source code to the first full-text search 2 | extension for SQLite. 3 | -------------------------------------------------------------------------------- /ext/fts1/fts1.h: -------------------------------------------------------------------------------- 1 | #include "sqlite3.h" 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif /* __cplusplus */ 6 | 7 | int sqlite3Fts1Init(sqlite3 *db); 8 | 9 | #ifdef __cplusplus 10 | } /* extern "C" */ 11 | #endif /* __cplusplus */ 12 | -------------------------------------------------------------------------------- /ext/fts1/fulltext.h: -------------------------------------------------------------------------------- 1 | #include "sqlite3.h" 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif /* __cplusplus */ 6 | 7 | int fulltext_init(sqlite3 *db); 8 | 9 | #ifdef __cplusplus 10 | } /* extern "C" */ 11 | #endif /* __cplusplus */ 12 | -------------------------------------------------------------------------------- /ext/fts2/README.txt: -------------------------------------------------------------------------------- 1 | This folder contains source code to the second full-text search 2 | extension for SQLite. While the API is the same, this version uses a 3 | substantially different storage schema from fts1, so tables will need 4 | to be rebuilt. 5 | -------------------------------------------------------------------------------- /ext/fts2/fts2.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 2006 Oct 10 3 | ** 4 | ** The author disclaims copyright to this source code. In place of 5 | ** a legal notice, here is a blessing: 6 | ** 7 | ** May you do good and not evil. 8 | ** May you find forgiveness for yourself and forgive others. 9 | ** May you share freely, never taking more than you give. 10 | ** 11 | ****************************************************************************** 12 | ** 13 | ** This header file is used by programs that want to link against the 14 | ** FTS2 library. All it does is declare the sqlite3Fts2Init() interface. 15 | */ 16 | #include "sqlite3.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif /* __cplusplus */ 21 | 22 | int sqlite3Fts2Init(sqlite3 *db); 23 | 24 | #ifdef __cplusplus 25 | } /* extern "C" */ 26 | #endif /* __cplusplus */ 27 | -------------------------------------------------------------------------------- /ext/fts3/README.txt: -------------------------------------------------------------------------------- 1 | This folder contains source code to the second full-text search 2 | extension for SQLite. While the API is the same, this version uses a 3 | substantially different storage schema from fts1, so tables will need 4 | to be rebuilt. 5 | -------------------------------------------------------------------------------- /ext/fts3/fts3.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 2006 Oct 10 3 | ** 4 | ** The author disclaims copyright to this source code. In place of 5 | ** a legal notice, here is a blessing: 6 | ** 7 | ** May you do good and not evil. 8 | ** May you find forgiveness for yourself and forgive others. 9 | ** May you share freely, never taking more than you give. 10 | ** 11 | ****************************************************************************** 12 | ** 13 | ** This header file is used by programs that want to link against the 14 | ** FTS3 library. All it does is declare the sqlite3Fts3Init() interface. 15 | */ 16 | #include "sqlite3.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif /* __cplusplus */ 21 | 22 | int sqlite3Fts3Init(sqlite3 *db); 23 | 24 | #ifdef __cplusplus 25 | } /* extern "C" */ 26 | #endif /* __cplusplus */ 27 | -------------------------------------------------------------------------------- /ext/icu/sqliteicu.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 2008 May 26 3 | ** 4 | ** The author disclaims copyright to this source code. In place of 5 | ** a legal notice, here is a blessing: 6 | ** 7 | ** May you do good and not evil. 8 | ** May you find forgiveness for yourself and forgive others. 9 | ** May you share freely, never taking more than you give. 10 | ** 11 | ****************************************************************************** 12 | ** 13 | ** This header file is used by programs that want to link against the 14 | ** ICU extension. All it does is declare the sqlite3IcuInit() interface. 15 | */ 16 | #include "sqlite3.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif /* __cplusplus */ 21 | 22 | int sqlite3IcuInit(sqlite3 *db); 23 | 24 | #ifdef __cplusplus 25 | } /* extern "C" */ 26 | #endif /* __cplusplus */ 27 | 28 | -------------------------------------------------------------------------------- /ext/rtree/rtree.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 2008 May 26 3 | ** 4 | ** The author disclaims copyright to this source code. In place of 5 | ** a legal notice, here is a blessing: 6 | ** 7 | ** May you do good and not evil. 8 | ** May you find forgiveness for yourself and forgive others. 9 | ** May you share freely, never taking more than you give. 10 | ** 11 | ****************************************************************************** 12 | ** 13 | ** This header file is used by programs that want to link against the 14 | ** RTREE library. All it does is declare the sqlite3RtreeInit() interface. 15 | */ 16 | #include "sqlite3.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif /* __cplusplus */ 21 | 22 | int sqlite3RtreeInit(sqlite3 *db); 23 | 24 | #ifdef __cplusplus 25 | } /* extern "C" */ 26 | #endif /* __cplusplus */ 27 | -------------------------------------------------------------------------------- /ext/rtree/sqlite3rtree.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 2010 August 30 3 | ** 4 | ** The author disclaims copyright to this source code. In place of 5 | ** a legal notice, here is a blessing: 6 | ** 7 | ** May you do good and not evil. 8 | ** May you find forgiveness for yourself and forgive others. 9 | ** May you share freely, never taking more than you give. 10 | ** 11 | ************************************************************************* 12 | */ 13 | 14 | #ifndef _SQLITE3RTREE_H_ 15 | #define _SQLITE3RTREE_H_ 16 | 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; 24 | 25 | /* 26 | ** Register a geometry callback named zGeom that can be used as part of an 27 | ** R-Tree geometry query as follows: 28 | ** 29 | ** SELECT ... FROM WHERE MATCH $zGeom(... params ...) 30 | */ 31 | int sqlite3_rtree_geometry_callback( 32 | sqlite3 *db, 33 | const char *zGeom, 34 | #ifdef SQLITE_RTREE_INT_ONLY 35 | int (*xGeom)(sqlite3_rtree_geometry*, int n, sqlite3_int64 *a, int *pRes), 36 | #else 37 | int (*xGeom)(sqlite3_rtree_geometry*, int n, double *a, int *pRes), 38 | #endif 39 | void *pContext 40 | ); 41 | 42 | 43 | /* 44 | ** A pointer to a structure of the following type is passed as the first 45 | ** argument to callbacks registered using rtree_geometry_callback(). 46 | */ 47 | struct sqlite3_rtree_geometry { 48 | void *pContext; /* Copy of pContext passed to s_r_g_c() */ 49 | int nParam; /* Size of array aParam[] */ 50 | double *aParam; /* Parameters passed to SQL geom function */ 51 | void *pUser; /* Callback implementation user data */ 52 | void (*xDelUser)(void *); /* Called by SQLite to clean up pUser */ 53 | }; 54 | 55 | 56 | #ifdef __cplusplus 57 | } /* end of the 'extern "C"' block */ 58 | #endif 59 | 60 | #endif /* ifndef _SQLITE3RTREE_H_ */ 61 | -------------------------------------------------------------------------------- /ext/rtree/tkt3363.test: -------------------------------------------------------------------------------- 1 | # 2008 Sep 08 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # The focus of this file is testing that ticket #3363 is fixed. 13 | # 14 | 15 | if {![info exists testdir]} { 16 | set testdir [file join [file dirname [info script]] .. .. test] 17 | } 18 | source [file join [file dirname [info script]] rtree_util.tcl] 19 | source $testdir/tester.tcl 20 | 21 | ifcapable !rtree { 22 | finish_test 23 | return 24 | } 25 | 26 | do_test tkt3363.1.1 { 27 | execsql { CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2) } 28 | } {} 29 | 30 | do_test tkt3363.1.2 { 31 | for {set ii 1} {$ii < 50} {incr ii} { 32 | set x 1000000 33 | set y [expr 4000000 + $ii*10] 34 | execsql { INSERT INTO t1 VALUES($ii, $x, $x, $y, $y) } 35 | } 36 | } {} 37 | 38 | do_test tkt3363.1.3 { 39 | execsql { 40 | SELECT count(*) FROM t1 WHERE +y2>4000425.0; 41 | } 42 | } {7} 43 | 44 | do_test tkt3363.1.4 { 45 | execsql { 46 | SELECT count(*) FROM t1 WHERE y2>4000425.0; 47 | } 48 | } {7} 49 | 50 | finish_test 51 | -------------------------------------------------------------------------------- /magic.txt: -------------------------------------------------------------------------------- 1 | # This file contains suggested magic(5) text for the unix file(1) 2 | # utility for recognizing SQLite3 databases. 3 | # 4 | # When SQLite is used as an application file format, it is desirable to 5 | # have file(1) recognize the database file as being with the specific 6 | # application. You can set the application_id for a database file 7 | # using: 8 | # 9 | # PRAGMA application_id = INTEGER; 10 | # 11 | # INTEGER can be any signed 32-bit integer. That integer is written as 12 | # a 4-byte big-endian integer into offset 68 of the database header. 13 | # 14 | # The Monotone application used "PRAGMA user_version=1598903374;" to set 15 | # its identifier long before "PRAGMA application_id" became available. 16 | # The user_version is very similar to application_id except that it is 17 | # stored at offset 68 instead of offset 60. The application_id pragma 18 | # is preferred. The rule using offset 60 for Monotone is for historical 19 | # compatibility only. 20 | # 21 | 0 string =SQLite\ format\ 3 22 | >68 belong =0x0f055111 Fossil repository - 23 | >68 belong =0x0f055112 Fossil checkout - 24 | >68 belong =0x0f055113 Fossil global configuration - 25 | >68 belong =0x42654462 Bentley Systems BeSQLite Database - 26 | >68 belong =0x42654c6e Bentley Systems Localization File - 27 | >60 belong =0x5f4d544e Monotone source repository - 28 | >0 string =SQLite SQLite3 database 29 | -------------------------------------------------------------------------------- /manifest.uuid: -------------------------------------------------------------------------------- 1 | 118a3b35693b134d56ebd780123b7fd6f1497668 2 | -------------------------------------------------------------------------------- /mkdll.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile SQLite into a DLL. 4 | # 5 | # Two separate DLLs are generated. "sqlite3.dll" is the core 6 | # library. "tclsqlite3.dll" contains the TCL bindings and is the 7 | # library that is loaded into TCL in order to run SQLite. 8 | # 9 | make sqlite3.c 10 | PATH=$PATH:/opt/mingw/bin 11 | TCLDIR=/home/drh/tcltk/846/win/846win 12 | TCLSTUBLIB=$TCLDIR/libtcl84stub.a 13 | OPTS='-DUSE_TCL_STUBS=1 -DBUILD_sqlite=1 -DSQLITE_OS_WIN=1' 14 | OPTS="$OPTS -DSQLITE_THREADSAFE=1" 15 | OPTS="$OPTS -DSQLITE_ENABLE_FTS3=1" 16 | OPTS="$OPTS -DSQLITE_ENABLE_RTREE=1" 17 | OPTS="$OPTS -DSQLITE_ENABLE_COLUMN_METADATA=1" 18 | CC="i386-mingw32msvc-gcc -Os $OPTS -Itsrc -I$TCLDIR" 19 | NM="i386-mingw32msvc-nm" 20 | CMD="$CC -c sqlite3.c" 21 | echo $CMD 22 | $CMD 23 | CMD="$CC -c tclsqlite3.c" 24 | echo $CMD 25 | $CMD 26 | echo 'EXPORTS' >tclsqlite3.def 27 | $NM tclsqlite3.o | grep ' T ' >temp1 28 | grep '_Init$' temp1 >temp2 29 | grep '_SafeInit$' temp1 >>temp2 30 | grep ' T _sqlite3_' temp1 >>temp2 31 | echo 'EXPORTS' >tclsqlite3.def 32 | sed 's/^.* T _//' temp2 | sort | uniq >>tclsqlite3.def 33 | i386-mingw32msvc-dllwrap \ 34 | --def tclsqlite3.def -v --export-all \ 35 | --driver-name i386-mingw32msvc-gcc \ 36 | --dlltool-name i386-mingw32msvc-dlltool \ 37 | --as i386-mingw32msvc-as \ 38 | --target i386-mingw32 \ 39 | -dllname tclsqlite3.dll -lmsvcrt tclsqlite3.o $TCLSTUBLIB 40 | $NM sqlite3.o | grep ' T ' >temp1 41 | echo 'EXPORTS' >sqlite3.def 42 | grep ' _sqlite3_' temp1 | sed 's/^.* _//' >>sqlite3.def 43 | i386-mingw32msvc-dllwrap \ 44 | --def sqlite3.def -v --export-all \ 45 | --driver-name i386-mingw32msvc-gcc \ 46 | --dlltool-name i386-mingw32msvc-dlltool \ 47 | --as i386-mingw32msvc-as \ 48 | --target i386-mingw32 \ 49 | -dllname sqlite3.dll -lmsvcrt sqlite3.o 50 | -------------------------------------------------------------------------------- /mkextu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile SQLite into a shared library on Linux. 4 | # 5 | # Two separate shared libraries are generated. "sqlite3.so" is the core 6 | # library. "tclsqlite3.so" contains the TCL bindings and is the 7 | # library that is loaded into TCL in order to run SQLite. 8 | # 9 | CFLAGS=-O2 -Wall 10 | make fts2amal.c 11 | echo gcc $CFLAGS -shared fts2amal.c -o fts2.so 12 | gcc $CFLAGS -shared fts2amal.c -o fts2.so 13 | strip fts2.so 14 | -------------------------------------------------------------------------------- /mkextw.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile SQLite extensions into DLLs. 4 | # 5 | make fts2amal.c 6 | PATH=$PATH:/opt/mingw/bin 7 | OPTS='-DTHREADSAFE=1 -DBUILD_sqlite=1 -DSQLITE_OS_WIN=1' 8 | CC="i386-mingw32msvc-gcc -O2 $OPTS -Itsrc" 9 | NM="i386-mingw32msvc-nm" 10 | CMD="$CC -c fts2amal.c" 11 | echo $CMD 12 | $CMD 13 | echo 'EXPORTS' >fts2.def 14 | echo 'sqlite3_extension_init' >>fts2.def 15 | i386-mingw32msvc-dllwrap \ 16 | --def fts2.def -v --export-all \ 17 | --driver-name i386-mingw32msvc-gcc \ 18 | --dlltool-name i386-mingw32msvc-dlltool \ 19 | --as i386-mingw32msvc-as \ 20 | --target i386-mingw32 \ 21 | -dllname fts2.dll -lmsvcrt fts2amal.o 22 | zip fts2dll.zip fts2.dll fts2.def 23 | -------------------------------------------------------------------------------- /mkopcodec.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk -f 2 | # 3 | # This AWK script scans the opcodes.h file (which is itself generated by 4 | # another awk script) and uses the information gleaned to create the 5 | # opcodes.c source file. 6 | # 7 | # Opcodes.c contains strings which are the symbolic names for the various 8 | # opcodes used by the VDBE. These strings are used when disassembling a 9 | # VDBE program during tracing or as a result of the EXPLAIN keyword. 10 | # 11 | BEGIN { 12 | print "/* Automatically generated. Do not edit */" 13 | print "/* See the mkopcodec.awk script for details. */" 14 | printf "#if !defined(SQLITE_OMIT_EXPLAIN)" 15 | printf " || !defined(NDEBUG)" 16 | printf " || defined(VDBE_PROFILE)" 17 | print " || defined(SQLITE_DEBUG)" 18 | print "const char *sqlite3OpcodeName(int i){" 19 | print " static const char *const azName[] = { \"?\"," 20 | mx = 0 21 | } 22 | /define OP_/ { 23 | sub("OP_","",$2) 24 | i = $3+0 25 | label[i] = $2 26 | if( mxreal conversions get exactly same ieee754 floating- 30 | # point value in SQLite as they do in TCL. 31 | # 32 | do_test atof1-1.$i.1 { 33 | set y [db eval "SELECT $xf=\$x"] 34 | if {!$y} { 35 | puts -nonewline \173[db eval "SELECT real2hex($xf), real2hex(\$x)"]\175 36 | db eval "SELECT $xf+0.0 AS a, \$x AS b" { 37 | puts [format "\n%.60e\n%.60e\n%.60e" $x $a $b] 38 | } 39 | } 40 | set y 41 | } {1} 42 | 43 | # Verify that round-trip real->text->real conversions using the quote() 44 | # function preserve the bits of the numeric value exactly. 45 | # 46 | do_test atof1-1.$i.2 { 47 | set y [db eval {SELECT $x=CAST(quote($x) AS real)}] 48 | if {!$y} { 49 | db eval {SELECT real2hex($x) a, real2hex(CAST(quote($x) AS real)) b} {} 50 | puts "\nIN: $a $xf" 51 | puts [format {QUOTE: %16s %s} {} [db eval {SELECT quote($x)}]] 52 | db eval {SELECT CAST(quote($x) AS real) c} {} 53 | puts "OUT: $b [format %.32e $c]" 54 | } 55 | set y 56 | } {1} 57 | } 58 | 59 | 60 | finish_test 61 | -------------------------------------------------------------------------------- /test/bigfile2.test: -------------------------------------------------------------------------------- 1 | # 2011 December 20 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this script testing the ability of SQLite to handle database 13 | # files larger than 4GB. 14 | # 15 | 16 | if {[file exists skip-big-file]} return 17 | if {$tcl_platform(os)=="Darwin"} return 18 | 19 | set testdir [file dirname $argv0] 20 | source $testdir/tester.tcl 21 | set testprefix bigfile2 22 | 23 | # Create a small database. 24 | # 25 | do_execsql_test 1.1 { 26 | CREATE TABLE t1(a, b); 27 | INSERT INTO t1 VALUES(1, 2); 28 | } 29 | 30 | # Pad the file out to 4GB in size. Then clear the file-size field in the 31 | # db header. This will cause SQLite to assume that the first 4GB of pages 32 | # are actually in use and new pages will be appended to the file. 33 | # 34 | db close 35 | if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} { 36 | puts "**** Unable to create a file larger than 4096 MB. *****" 37 | finish_test 38 | return 39 | } 40 | hexio_write test.db 28 00000000 41 | 42 | do_test 1.2 { 43 | file size test.db 44 | } [expr 14 + 4096 * (1<<20)] 45 | 46 | # Now insert a large row. The overflow pages will be located past the 4GB 47 | # boundary. Then, after opening and closing the database, test that the row 48 | # can be read back in. 49 | # 50 | set str [string repeat k 30000] 51 | do_test 1.3 { 52 | sqlite3 db test.db 53 | execsql { INSERT INTO t1 VALUES(3, $str) } 54 | db close 55 | sqlite3 db test.db 56 | db one { SELECT b FROM t1 WHERE a = 3 } 57 | } $str 58 | 59 | db close 60 | file delete test.db 61 | 62 | finish_test 63 | -------------------------------------------------------------------------------- /test/busy.test: -------------------------------------------------------------------------------- 1 | # 2005 july 8 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file test the busy handler 12 | # 13 | # $Id: busy.test,v 1.3 2008/03/15 02:09:22 drh Exp $ 14 | 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | do_test busy-1.1 { 20 | sqlite3 db2 test.db 21 | execsql { 22 | CREATE TABLE t1(x); 23 | INSERT INTO t1 VALUES(1); 24 | SELECT * FROM t1 25 | } 26 | } 1 27 | proc busy x { 28 | lappend ::busyargs $x 29 | if {$x>2} {return 1} 30 | return 0 31 | } 32 | set busyargs {} 33 | do_test busy-1.2 { 34 | db busy busy 35 | db2 eval {BEGIN EXCLUSIVE} 36 | catchsql {BEGIN IMMEDIATE} 37 | } {1 {database is locked}} 38 | do_test busy-1.3 { 39 | set busyargs 40 | } {0 1 2 3} 41 | do_test busy-1.4 { 42 | set busyargs {} 43 | catchsql {BEGIN IMMEDIATE} 44 | set busyargs 45 | } {0 1 2 3} 46 | 47 | do_test busy-2.1 { 48 | db2 eval {COMMIT} 49 | db eval {BEGIN; INSERT INTO t1 VALUES(5)} 50 | db2 eval {BEGIN; SELECT * FROM t1} 51 | set busyargs {} 52 | catchsql COMMIT 53 | } {1 {database is locked}} 54 | do_test busy-2.2 { 55 | set busyargs 56 | } {0 1 2 3} 57 | 58 | 59 | db2 close 60 | 61 | finish_test 62 | -------------------------------------------------------------------------------- /test/capi3e.test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMDB/sqlightning/bb8144e10a985f83b6973a38078dd19ed2b0c711/test/capi3e.test -------------------------------------------------------------------------------- /test/corrupt5.test: -------------------------------------------------------------------------------- 1 | # 2008 Jan 22 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to make sure SQLite does not crash or 14 | # segfault if it sees a corrupt database file. Checks for 15 | # malformed schema. 16 | # 17 | # $Id: corrupt5.test,v 1.3 2009/06/04 02:47:04 shane Exp $ 18 | 19 | set testdir [file dirname $argv0] 20 | source $testdir/tester.tcl 21 | 22 | # We must have the page_size pragma for these tests to work. 23 | # 24 | ifcapable !pager_pragmas { 25 | finish_test 26 | return 27 | } 28 | 29 | # Create a database with a freelist containing at least two pages. 30 | # 31 | do_test corrupt5-1.1 { 32 | execsql { 33 | CREATE TABLE t1(a,b,c); 34 | CREATE INDEX i1 ON t1(a,b); 35 | PRAGMA writable_schema=ON; 36 | UPDATE sqlite_master SET name=NULL, sql=NULL WHERE name='i1'; 37 | } 38 | db close 39 | sqlite3 db test.db 40 | catchsql { 41 | SELECT * FROM t1 42 | } 43 | } {1 {malformed database schema (?)}} 44 | 45 | finish_test 46 | -------------------------------------------------------------------------------- /test/default.test: -------------------------------------------------------------------------------- 1 | # 2005 August 18 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #************************************************************************* 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this file is testing corner cases of the DEFAULT syntax 13 | # on table definitions. 14 | # 15 | # $Id: default.test,v 1.3 2009/02/19 14:39:25 danielk1977 Exp $ 16 | # 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | ifcapable bloblit { 22 | do_test default-1.1 { 23 | execsql { 24 | CREATE TABLE t1( 25 | a INTEGER, 26 | b BLOB DEFAULT x'6869' 27 | ); 28 | INSERT INTO t1(a) VALUES(1); 29 | SELECT * from t1; 30 | } 31 | } {1 hi} 32 | } 33 | do_test default-1.2 { 34 | execsql { 35 | CREATE TABLE t2( 36 | x INTEGER, 37 | y INTEGER DEFAULT NULL 38 | ); 39 | INSERT INTO t2(x) VALUES(1); 40 | SELECT * FROM t2; 41 | } 42 | } {1 {}} 43 | do_test default-1.3 { 44 | catchsql { 45 | CREATE TABLE t3( 46 | x INTEGER, 47 | y INTEGER DEFAULT (max(x,5)) 48 | ) 49 | } 50 | } {1 {default value of column [y] is not constant}} 51 | 52 | ifcapable pragma { 53 | do_test default-2.1 { 54 | execsql { 55 | CREATE TABLE t4(c DEFAULT 'abc'); 56 | PRAGMA table_info(t4); 57 | } 58 | } {0 c {} 0 'abc' 0} 59 | do_test default-2.2 { 60 | execsql { 61 | INSERT INTO t4 DEFAULT VALUES; 62 | PRAGMA table_info(t4); 63 | } 64 | } {0 c {} 0 'abc' 0} 65 | } 66 | 67 | finish_test 68 | -------------------------------------------------------------------------------- /test/exec.test: -------------------------------------------------------------------------------- 1 | # 2008 Jan 21 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests for the sqlite3_exec interface 14 | # 15 | # $Id: exec.test,v 1.1 2008/01/21 16:22:46 drh Exp $ 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test exec-1.1 { 21 | execsql { 22 | CREATE TABLE t1(a,b); 23 | INSERT INTO t1 VALUES(1,2); 24 | SELECT * FROM t1; 25 | } 26 | } {1 2} 27 | do_test exec-1.2 { 28 | sqlite3_exec db {/* comment */;;; SELECT * FROM t1; /* comment */} 29 | } {0 {a b 1 2}} 30 | do_test exec-1.3 { 31 | sqlite3 db2 test.db 32 | db2 eval {CREATE TABLE t2(x, y);} 33 | db2 close 34 | sqlite3_exec db {SELECT * FROM t1} 35 | } {0 {a b 1 2}} 36 | 37 | finish_test 38 | -------------------------------------------------------------------------------- /test/filectrl.test: -------------------------------------------------------------------------------- 1 | # 2008 Jan 22 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # $Id: filectrl.test,v 1.2 2008/11/21 00:10:35 aswift Exp $ 13 | 14 | set testdir [file dirname $argv0] 15 | source $testdir/tester.tcl 16 | 17 | 18 | do_test filectrl-1.1 { 19 | file_control_test db 20 | } {} 21 | do_test filectrl-1.2 { 22 | db eval {CREATE TEMP TABLE x(y);} 23 | file_control_test db 24 | } {} 25 | do_test filectrl-1.3 { 26 | db close 27 | sqlite3 db :memory: 28 | file_control_test db 29 | } {} 30 | do_test filectrl-1.4 { 31 | sqlite3 db test.db 32 | file_control_lasterrno_test db 33 | } {} 34 | do_test filectrl-1.5 { 35 | db close 36 | sqlite3 db test_control_lockproxy.db 37 | file_control_lockproxy_test db [get_pwd] 38 | } {} 39 | do_test filectrl-1.6 { 40 | sqlite3 db test.db 41 | set fn [file_control_tempfilename db] 42 | puts -nonewline \[$fn\] 43 | set fn 44 | } {/etilqs_/} 45 | db close 46 | forcedelete .test_control_lockproxy.db-conch test.proxy 47 | finish_test 48 | -------------------------------------------------------------------------------- /test/fkey4.test: -------------------------------------------------------------------------------- 1 | # 2011 Feb 04 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file test deferred foreign key constraint processing to make 14 | # sure that when a statement not within BEGIN...END fails a constraint, 15 | # that statement doesn't hold the transaction open thus allowing 16 | # a subsequent statement to fail a deferred constraint with impunity. 17 | # 18 | 19 | set testdir [file dirname $argv0] 20 | source $testdir/tester.tcl 21 | 22 | ifcapable {!foreignkey||!trigger} { 23 | finish_test 24 | return 25 | } 26 | 27 | # Create a table and some data to work with. 28 | # 29 | do_test fkey4-1.1 { 30 | execsql { 31 | PRAGMA foreign_keys = ON; 32 | CREATE TABLE t1(a PRIMARY KEY, b); 33 | CREATE TABLE t2(c REFERENCES t1 DEFERRABLE INITIALLY DEFERRED, d); 34 | INSERT INTO t1 VALUES(1,2); 35 | INSERT INTO t2 VALUES(1,3); 36 | } 37 | } {} 38 | 39 | do_test fkey4-1.2 { 40 | set ::DB [sqlite3_connection_pointer db] 41 | set ::SQL {INSERT INTO t2 VALUES(2,4)} 42 | set ::STMT1 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL] 43 | sqlite3_step $::STMT1 44 | } {SQLITE_CONSTRAINT} 45 | verify_ex_errcode fkey4-1.2b SQLITE_CONSTRAINT_FOREIGNKEY 46 | do_test fkey4-1.3 { 47 | set ::STMT2 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL] 48 | sqlite3_step $::STMT2 49 | } {SQLITE_CONSTRAINT} 50 | verify_ex_errcode fkey4-1.3b SQLITE_CONSTRAINT_FOREIGNKEY 51 | do_test fkey4-1.4 { 52 | db eval {SELECT * FROM t2} 53 | } {1 3} 54 | sqlite3_finalize $::STMT1 55 | sqlite3_finalize $::STMT2 56 | 57 | finish_test 58 | -------------------------------------------------------------------------------- /test/format4.test: -------------------------------------------------------------------------------- 1 | # 2005 December 29 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that the new serial_type 14 | # values of 8 (integer 0) and 9 (integer 1) work correctly. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | db eval {PRAGMA legacy_file_format=OFF} 21 | 22 | # The size of the database depends on whether or not autovacuum 23 | # is enabled. 24 | # 25 | ifcapable autovacuum { 26 | if {[db one {PRAGMA auto_vacuum}]} { 27 | set small 3072 28 | set large 5120 29 | } else { 30 | set small 2048 31 | set large 4096 32 | } 33 | } else { 34 | set small 2048 35 | set large 4096 36 | } 37 | 38 | do_test format4-1.1 { 39 | execsql { 40 | CREATE TABLE t1(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9); 41 | INSERT INTO t1 VALUES(0,0,0,0,0,0,0,0,0,0); 42 | INSERT INTO t1 SELECT * FROM t1; 43 | INSERT INTO t1 SELECT * FROM t1; 44 | INSERT INTO t1 SELECT * FROM t1; 45 | INSERT INTO t1 SELECT * FROM t1; 46 | INSERT INTO t1 SELECT * FROM t1; 47 | INSERT INTO t1 SELECT * FROM t1; 48 | } 49 | file size test.db 50 | } $small 51 | do_test format4-1.2 { 52 | execsql { 53 | UPDATE t1 SET x0=1, x1=1, x2=1, x3=1, x4=1, x5=1, x6=1, x7=1, x8=1, x9=1 54 | } 55 | file size test.db 56 | } $small 57 | do_test format4-1.3 { 58 | execsql { 59 | UPDATE t1 SET x0=2, x1=2, x2=2, x3=2, x4=2, x5=2, x6=2, x7=2, x8=2, x9=2 60 | } 61 | file size test.db 62 | } $large 63 | 64 | 65 | finish_test 66 | -------------------------------------------------------------------------------- /test/fts-9fd058691.test: -------------------------------------------------------------------------------- 1 | # 2011 October 13 2 | # 3 | # May you do good and not evil. 4 | # May you find forgiveness for yourself and forgive others. 5 | # May you share freely, never taking more than you give. 6 | # 7 | #*********************************************************************** 8 | # 9 | # This file implements regression tests for the FTS SQLite module. 10 | # 11 | # This file implements tests to verify that ticket [9fd058691] has been 12 | # fixed. 13 | # 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/tester.tcl 17 | 18 | # If SQLITE_ENABLE_FTS3 is defined, omit this file. 19 | ifcapable !fts3 { 20 | finish_test 21 | return 22 | } 23 | 24 | set ::testprefix fts3-9fd058691 25 | 26 | do_execsql_test 1.0 { 27 | CREATE VIRTUAL TABLE fts USING fts3( tags TEXT); 28 | INSERT INTO fts (tags) VALUES ('tag1'); 29 | SELECT * FROM fts WHERE tags MATCH 'tag1'; 30 | } {tag1} 31 | 32 | do_test 1.1 { 33 | db close 34 | sqlite3 db test.db 35 | execsql { 36 | UPDATE fts SET tags = 'tag1' WHERE rowid = 1; 37 | SELECT * FROM fts WHERE tags MATCH 'tag1'; 38 | } 39 | } {tag1} 40 | 41 | db close 42 | forcedelete test.db 43 | sqlite3 db test.db 44 | 45 | do_execsql_test 2.0 { 46 | CREATE VIRTUAL TABLE fts USING fts3(tags TEXT); 47 | INSERT INTO fts (docid, tags) VALUES (1, 'tag1'); 48 | INSERT INTO fts (docid, tags) VALUES (2, NULL); 49 | INSERT INTO fts (docid, tags) VALUES (3, 'three'); 50 | } {} 51 | 52 | do_test 2.1 { 53 | execsql { 54 | UPDATE fts SET tags = 'two' WHERE rowid = 2; 55 | SELECT * FROM fts WHERE tags MATCH 'two'; 56 | } 57 | } {two} 58 | 59 | finish_test 60 | -------------------------------------------------------------------------------- /test/fts1l.test: -------------------------------------------------------------------------------- 1 | # 2007 April 9 2 | # 3 | # The author disclaims copyright to this source code. 4 | # 5 | #************************************************************************* 6 | # This file implements regression tests for SQLite library. fts1 7 | # DELETE handling assumed all fields were non-null. This was not 8 | # the intention at all. 9 | # 10 | # $Id: fts1l.test,v 1.1 2007/04/09 20:45:42 shess Exp $ 11 | # 12 | 13 | set testdir [file dirname $argv0] 14 | source $testdir/tester.tcl 15 | 16 | # If SQLITE_ENABLE_FTS1 is defined, omit this file. 17 | ifcapable !fts1 { 18 | finish_test 19 | return 20 | } 21 | 22 | db eval { 23 | CREATE VIRTUAL TABLE t1 USING fts1(col_a, col_b); 24 | 25 | INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing'); 26 | INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null); 27 | INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b'); 28 | INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null); 29 | } 30 | 31 | do_test fts1m-1.0 { 32 | execsql { 33 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 34 | } 35 | } {2 2 4} 36 | 37 | do_test fts1m-1.1 { 38 | execsql { 39 | DELETE FROM t1 WHERE rowid = 1; 40 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 41 | } 42 | } {1 1 3} 43 | 44 | do_test fts1m-1.2 { 45 | execsql { 46 | DELETE FROM t1 WHERE rowid = 2; 47 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 48 | } 49 | } {0 1 2} 50 | 51 | do_test fts1m-1.3 { 52 | execsql { 53 | DELETE FROM t1 WHERE rowid = 3; 54 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 55 | } 56 | } {0 0 1} 57 | 58 | do_test fts1m-1.4 { 59 | execsql { 60 | DELETE FROM t1 WHERE rowid = 4; 61 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 62 | } 63 | } {0 0 0} 64 | 65 | finish_test 66 | -------------------------------------------------------------------------------- /test/fts1m.test: -------------------------------------------------------------------------------- 1 | # 2007 July 27 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #************************************************************************* 11 | # This file implements regression tests for SQLite library. The focus 12 | # of this script is testing the FTS1 module, specifically snippet 13 | # generation. Extracted from fts2o.test. 14 | # 15 | # $Id: fts1m.test,v 1.1 2007/07/25 00:25:20 shess Exp $ 16 | # 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | # If SQLITE_ENABLE_FTS1 is not defined, omit this file. 22 | ifcapable !fts1 { 23 | finish_test 24 | return 25 | } 26 | 27 | #--------------------------------------------------------------------- 28 | # These tests, fts1m-1.*, test that ticket #2429 is fixed. 29 | # 30 | db eval { 31 | CREATE VIRTUAL TABLE t1 USING fts1(a, b, c); 32 | INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two'); 33 | } 34 | do_test fts1m-1.1 { 35 | execsql { 36 | SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four'; 37 | } 38 | } {1 {one four two}} 39 | do_test fts1m-1.2 { 40 | execsql { 41 | SELECT rowid, snippet(t1) FROM t1 WHERE b MATCH 'four'; 42 | } 43 | } {1 {one four}} 44 | do_test fts1m-1.3 { 45 | execsql { 46 | SELECT rowid, snippet(t1) FROM t1 WHERE a MATCH 'four'; 47 | } 48 | } {1 {one three four}} 49 | 50 | finish_test 51 | -------------------------------------------------------------------------------- /test/fts1n.test: -------------------------------------------------------------------------------- 1 | # 2007 July 24 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #************************************************************************* 11 | # This file implements regression tests for SQLite library. The focus 12 | # of this script is testing the FTS1 module for errors in the handling 13 | # of SQLITE_SCHEMA. 14 | # 15 | # $Id: fts1n.test,v 1.1 2007/07/25 00:38:06 shess Exp $ 16 | # 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | # If SQLITE_ENABLE_FTS1 is not defined, omit this file. 22 | ifcapable !fts1 { 23 | finish_test 24 | return 25 | } 26 | 27 | do_test fts1m-1.1 { 28 | execsql { 29 | CREATE VIRTUAL TABLE t1 USING fts1(a, b, c); 30 | INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two'); 31 | SELECT a, b, c FROM t1 WHERE c MATCH 'two'; 32 | } 33 | } {{one three four} {one four} {one two}} 34 | 35 | # This test was crashing at one point. 36 | # 37 | do_test fts1m-1.2 { 38 | execsql { 39 | SELECT a, b, c FROM t1 WHERE c MATCH 'two'; 40 | CREATE TABLE t3(a, b, c); 41 | SELECT a, b, c FROM t1 WHERE c MATCH 'two'; 42 | } 43 | } {{one three four} {one four} {one two} {one three four} {one four} {one two}} 44 | 45 | finish_test 46 | -------------------------------------------------------------------------------- /test/fts2.test: -------------------------------------------------------------------------------- 1 | # 2008 July 22 2 | # 3 | # May you do good and not evil. 4 | # May you find forgiveness for yourself and forgive others. 5 | # May you share freely, never taking more than you give. 6 | # 7 | #*********************************************************************** 8 | # This file runs all tests. 9 | # 10 | # $Id: fts2.test,v 1.2 2008/07/23 18:17:32 drh Exp $ 11 | 12 | proc lshift {lvar} { 13 | upvar $lvar l 14 | set ret [lindex $l 0] 15 | set l [lrange $l 1 end] 16 | return $ret 17 | } 18 | while {[set arg [lshift argv]] != ""} { 19 | switch -- $arg { 20 | -sharedpagercache { 21 | sqlite3_enable_shared_cache 1 22 | } 23 | -soak { 24 | set G(issoak) 1 25 | } 26 | default { 27 | set argv [linsert $argv 0 $arg] 28 | break 29 | } 30 | } 31 | } 32 | 33 | set testdir [file dirname $argv0] 34 | source $testdir/tester.tcl 35 | # If SQLITE_ENABLE_FTS2 is defined, omit this file. 36 | ifcapable !fts2 { 37 | return 38 | } 39 | rename finish_test really_finish_test 40 | proc finish_test {} {} 41 | set G(isquick) 1 42 | 43 | set EXCLUDE { 44 | fts2.test 45 | } 46 | 47 | # Files to include in the test. If this list is empty then everything 48 | # that is not in the EXCLUDE list is run. 49 | # 50 | set INCLUDE { 51 | } 52 | 53 | foreach testfile [lsort -dictionary [glob $testdir/fts2*.test]] { 54 | set tail [file tail $testfile] 55 | if {[lsearch -exact $EXCLUDE $tail]>=0} continue 56 | if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue 57 | source $testfile 58 | catch {db close} 59 | if {$sqlite_open_file_count>0} { 60 | puts "$tail did not close all files: $sqlite_open_file_count" 61 | fail_test $tail 62 | set sqlite_open_file_count 0 63 | } 64 | } 65 | 66 | set sqlite_open_file_count 0 67 | really_finish_test 68 | -------------------------------------------------------------------------------- /test/fts2m.test: -------------------------------------------------------------------------------- 1 | # 2007 April 9 2 | # 3 | # The author disclaims copyright to this source code. 4 | # 5 | #************************************************************************* 6 | # This file implements regression tests for SQLite library. fts2 7 | # DELETE handling assumed all fields were non-null. This was not 8 | # the intention at all. 9 | # 10 | # $Id: fts2m.test,v 1.1 2007/04/09 20:45:42 shess Exp $ 11 | # 12 | 13 | set testdir [file dirname $argv0] 14 | source $testdir/tester.tcl 15 | 16 | # If SQLITE_ENABLE_FTS2 is defined, omit this file. 17 | ifcapable !fts2 { 18 | finish_test 19 | return 20 | } 21 | 22 | db eval { 23 | CREATE VIRTUAL TABLE t1 USING fts2(col_a, col_b); 24 | 25 | INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing'); 26 | INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null); 27 | INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b'); 28 | INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null); 29 | } 30 | 31 | do_test fts2m-1.0 { 32 | execsql { 33 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 34 | } 35 | } {2 2 4} 36 | 37 | do_test fts2m-1.1 { 38 | execsql { 39 | DELETE FROM t1 WHERE rowid = 1; 40 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 41 | } 42 | } {1 1 3} 43 | 44 | do_test fts2m-1.2 { 45 | execsql { 46 | DELETE FROM t1 WHERE rowid = 2; 47 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 48 | } 49 | } {0 1 2} 50 | 51 | do_test fts2m-1.3 { 52 | execsql { 53 | DELETE FROM t1 WHERE rowid = 3; 54 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 55 | } 56 | } {0 0 1} 57 | 58 | do_test fts2m-1.4 { 59 | execsql { 60 | DELETE FROM t1 WHERE rowid = 4; 61 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 62 | } 63 | } {0 0 0} 64 | 65 | finish_test 66 | -------------------------------------------------------------------------------- /test/fts3.test: -------------------------------------------------------------------------------- 1 | # 2007 November 23 2 | # 3 | # May you do good and not evil. 4 | # May you find forgiveness for yourself and forgive others. 5 | # May you share freely, never taking more than you give. 6 | # 7 | #*********************************************************************** 8 | # This file runs all tests. 9 | # 10 | # $Id: fts3.test,v 1.2 2008/07/23 18:17:32 drh Exp $ 11 | 12 | set testdir [file dirname $argv0] 13 | source $testdir/permutations.test 14 | 15 | ifcapable fts3 { 16 | run_test_suite fts3 17 | } 18 | 19 | finish_test 20 | -------------------------------------------------------------------------------- /test/fts3am.test: -------------------------------------------------------------------------------- 1 | # 2007 April 9 2 | # 3 | # The author disclaims copyright to this source code. 4 | # 5 | #************************************************************************* 6 | # This file implements regression tests for SQLite library. fts3 7 | # DELETE handling assumed all fields were non-null. This was not 8 | # the intention at all. 9 | # 10 | # $Id: fts3am.test,v 1.1 2007/08/20 17:38:42 shess Exp $ 11 | # 12 | 13 | set testdir [file dirname $argv0] 14 | source $testdir/tester.tcl 15 | 16 | # If SQLITE_ENABLE_FTS3 is defined, omit this file. 17 | ifcapable !fts3 { 18 | finish_test 19 | return 20 | } 21 | 22 | db eval { 23 | CREATE VIRTUAL TABLE t1 USING fts3(col_a, col_b); 24 | 25 | INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing'); 26 | INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null); 27 | INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b'); 28 | INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null); 29 | } 30 | 31 | do_test fts3am-1.0 { 32 | execsql { 33 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 34 | } 35 | } {2 2 4} 36 | 37 | do_test fts3am-1.1 { 38 | execsql { 39 | DELETE FROM t1 WHERE rowid = 1; 40 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 41 | } 42 | } {1 1 3} 43 | 44 | do_test fts3am-1.2 { 45 | execsql { 46 | DELETE FROM t1 WHERE rowid = 2; 47 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 48 | } 49 | } {0 1 2} 50 | 51 | do_test fts3am-1.3 { 52 | execsql { 53 | DELETE FROM t1 WHERE rowid = 3; 54 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 55 | } 56 | } {0 0 1} 57 | 58 | do_test fts3am-1.4 { 59 | execsql { 60 | DELETE FROM t1 WHERE rowid = 4; 61 | SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1; 62 | } 63 | } {0 0 0} 64 | 65 | finish_test 66 | -------------------------------------------------------------------------------- /test/fts3drop.test: -------------------------------------------------------------------------------- 1 | # 2011 October 29 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #************************************************************************* 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this script is testing the FTS3 module. More specifically, 13 | # that DROP TABLE commands can co-exist with savepoints inside transactions. 14 | # See ticket [48f299634a] for details. 15 | # 16 | 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | set testprefix fts3drop 21 | 22 | # If SQLITE_ENABLE_FTS3 is defined, omit this file. 23 | ifcapable !fts3 { 24 | finish_test 25 | return 26 | } 27 | 28 | do_execsql_test 1.1 { 29 | CREATE VIRTUAL TABLE f1 USING fts3; 30 | INSERT INTO f1 VALUES('a b c'); 31 | } 32 | 33 | do_execsql_test 1.2 { 34 | BEGIN; 35 | INSERT INTO f1 VALUES('d e f'); 36 | SAVEPOINT one; 37 | INSERT INTO f1 VALUES('g h i'); 38 | DROP TABLE f1; 39 | ROLLBACK TO one; 40 | COMMIT; 41 | } 42 | 43 | do_execsql_test 1.3 { 44 | SELECT * FROM f1; 45 | } {{a b c} {d e f}} 46 | 47 | do_execsql_test 1.4 { 48 | BEGIN; 49 | INSERT INTO f1 VALUES('g h i'); 50 | SAVEPOINT one; 51 | INSERT INTO f1 VALUES('j k l'); 52 | DROP TABLE f1; 53 | RELEASE one; 54 | ROLLBACK; 55 | } 56 | 57 | do_execsql_test 1.5 { 58 | SELECT * FROM f1; 59 | } {{a b c} {d e f}} 60 | 61 | finish_test 62 | -------------------------------------------------------------------------------- /test/fts3tok_err.test: -------------------------------------------------------------------------------- 1 | # 2013 April 22 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #************************************************************************* 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this script is testing the "fts3tokenize" virtual table 13 | # that is part of the FTS3 module. 14 | # 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | source $testdir/malloc_common.tcl 19 | ifcapable !fts3 { finish_test ; return } 20 | set ::testprefix fts3tok_err 21 | 22 | 23 | faultsim_save_and_close 24 | do_faultsim_test fts3tok_err-1 -faults oom* -prep { 25 | faultsim_restore_and_reopen 26 | } -body { 27 | execsql { CREATE VIRTUAL TABLE t1 USING fts3tokenize("simple"); } 28 | } -test { 29 | faultsim_test_result {0 {}} 30 | } 31 | 32 | do_test fts3tok_err-2.prep { 33 | faultsim_delete_and_reopen 34 | execsql { CREATE VIRTUAL TABLE t1 USING fts3tokenize("simple"); } 35 | faultsim_save_and_close 36 | } {} 37 | 38 | do_faultsim_test fts3tok_err-2 -faults oom* -prep { 39 | faultsim_restore_and_reopen 40 | } -body { 41 | execsql { SELECT token FROM t1 WHERE input = 'A galaxy far, far away' } 42 | } -test { 43 | faultsim_test_result {0 {a galaxy far far away}} 44 | } 45 | 46 | 47 | finish_test 48 | 49 | 50 | -------------------------------------------------------------------------------- /test/fts4merge2.test: -------------------------------------------------------------------------------- 1 | 2 | 3 | set testdir [file dirname $argv0] 4 | source $testdir/tester.tcl 5 | source $testdir/fts3_common.tcl 6 | source $testdir/malloc_common.tcl 7 | set ::testprefix fts4merge2 8 | 9 | # If SQLITE_ENABLE_FTS3 is defined, omit this file. 10 | ifcapable !fts3 { 11 | finish_test 12 | return 13 | } 14 | 15 | do_test 1.0 { 16 | fts3_build_db_1 1000 17 | faultsim_save_and_close 18 | } {} 19 | 20 | do_faultsim_test 1.1 -faults oom-* -prep { 21 | faultsim_restore_and_reopen 22 | } -body { 23 | execsql { INSERT INTO t1(t1) VALUES('merge=32,4') } 24 | } -test { 25 | faultsim_test_result {0 {}} 26 | } 27 | 28 | do_faultsim_test 1.2 -faults oom-t* -prep { 29 | if {$iFail<100} {set iFail 803} 30 | faultsim_restore_and_reopen 31 | } -body { 32 | execsql { INSERT INTO t1(t1) VALUES('merge=1,2') } 33 | execsql { INSERT INTO t1(t1) VALUES('merge=1,2') } 34 | } -test { 35 | faultsim_test_result {0 {}} 36 | } 37 | 38 | finish_test 39 | -------------------------------------------------------------------------------- /test/full.test: -------------------------------------------------------------------------------- 1 | # 2012 September 12 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file runs the "full" test suite. It is a peer of the quick.test 12 | # and all.test scripts. 13 | # 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/permutations.test 17 | 18 | run_test_suite full 19 | 20 | finish_test 21 | -------------------------------------------------------------------------------- /test/index3.test: -------------------------------------------------------------------------------- 1 | # 2005 February 14 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this file is testing the CREATE INDEX statement. 13 | # 14 | # $Id: index3.test,v 1.3 2008/03/19 13:03:34 drh Exp $ 15 | 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | # Ticket #1115. Make sure that when a UNIQUE index is created on a 21 | # non-unique column (or columns) that it fails and that it leaves no 22 | # residue behind. 23 | # 24 | do_test index3-1.1 { 25 | execsql { 26 | CREATE TABLE t1(a); 27 | INSERT INTO t1 VALUES(1); 28 | INSERT INTO t1 VALUES(1); 29 | SELECT * FROM t1; 30 | } 31 | } {1 1} 32 | do_test index3-1.2 { 33 | catchsql { 34 | BEGIN; 35 | CREATE UNIQUE INDEX i1 ON t1(a); 36 | } 37 | } {1 {indexed columns are not unique}} 38 | do_test index3-1.3 { 39 | catchsql COMMIT; 40 | } {0 {}} 41 | integrity_check index3-1.4 42 | 43 | # This test corrupts the database file so it must be the last test 44 | # in the series. 45 | # 46 | do_test index3-99.1 { 47 | execsql { 48 | PRAGMA writable_schema=on; 49 | UPDATE sqlite_master SET sql='nonsense'; 50 | } 51 | db close 52 | catch { sqlite3 db test.db } 53 | catchsql { DROP INDEX i1 } 54 | } {1 {malformed database schema (t1) - near "nonsense": syntax error}} 55 | 56 | finish_test 57 | -------------------------------------------------------------------------------- /test/index5.test: -------------------------------------------------------------------------------- 1 | # 2012 August 6 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | 13 | 14 | set testdir [file dirname $argv0] 15 | source $testdir/tester.tcl 16 | set ::testprefix index5 17 | 18 | do_test 1.1 { 19 | execsql { 20 | PRAGMA page_size = 1024; 21 | CREATE TABLE t1(x); 22 | BEGIN; 23 | } 24 | for {set i 0} {$i < 100000} {incr i} { 25 | execsql { INSERT INTO t1 VALUES(randstr(100,100)) } 26 | } 27 | execsql COMMIT 28 | execsql { 29 | CREATE INDEX i1 ON t1(x); 30 | DROP INDEX I1; 31 | PRAGMA main.page_size; 32 | } 33 | } {1024} 34 | 35 | db close 36 | testvfs tvfs 37 | tvfs filter xWrite 38 | tvfs script write_cb 39 | proc write_cb {xCall file handle iOfst args} { 40 | if {[file tail $file]=="test.db"} { 41 | lappend ::write_list [expr $iOfst/1024] 42 | } 43 | } 44 | 45 | do_test 1.2 { 46 | sqlite3 db test.db -vfs tvfs 47 | set ::write_list [list] 48 | execsql { CREATE INDEX i1 ON t1(x) } 49 | } {} 50 | 51 | do_test 1.3 { 52 | set nForward 0 53 | set nBackward 0 54 | set nNoncont 0 55 | set iPrev [lindex $::write_list 0] 56 | for {set i 1} {$i < [llength $::write_list]} {incr i} { 57 | set iNext [lindex $::write_list $i] 58 | if {$iNext==($iPrev+1)} { 59 | incr nForward 60 | } elseif {$iNext==($iPrev-1)} { 61 | incr nBackward 62 | } else { 63 | incr nNoncont 64 | } 65 | set iPrev $iNext 66 | } 67 | puts -nonewline \ 68 | " (forward=$nForward, back=$nBackward, noncontiguous=$nNoncont)" 69 | 70 | expr {$nForward > 2*($nBackward + $nNoncont)} 71 | } {1} 72 | db close 73 | tvfs delete 74 | 75 | finish_test 76 | -------------------------------------------------------------------------------- /test/ioerr3.test: -------------------------------------------------------------------------------- 1 | # 2007 December 19 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this file is testing for correct handling of I/O errors 13 | # in conjunction with very small soft-heap-limit values. 14 | # 15 | # $Id: ioerr3.test,v 1.2 2008/01/19 23:50:26 drh Exp $ 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_ioerr_test ioerr3-1 -sqlprep { 21 | CREATE TABLE t1(id INTEGER, name TEXT); 22 | } -tclbody { 23 | sqlite3_soft_heap_limit 8192 24 | db cache size 0 25 | execsql BEGIN 26 | for {set ii 0} {$ii < 100} {incr ii} { 27 | execsql { 28 | INSERT INTO t1(id, name) VALUES (1, 29 | 'A1234567890B1234567890C1234567890D1234567890E1234567890F1234567890G1234567890H1234567890I1234567890J1234567890K1234567890L1234567890M1234567890N1234567890O1234567890P1234567890Q1234567890R1234567890' 30 | ); 31 | } 32 | } 33 | execsql COMMIT 34 | } 35 | 36 | do_ioerr_test ioerr3-2 -sqlbody { 37 | CREATE TEMP TABLE t1(x,y); 38 | } 39 | 40 | sqlite3_soft_heap_limit 0 41 | 42 | finish_test 43 | -------------------------------------------------------------------------------- /test/join3.test: -------------------------------------------------------------------------------- 1 | # 2002 May 24 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests for joins, including outer joins, where 14 | # there are a large number of tables involved in the join. 15 | # 16 | # $Id: join3.test,v 1.4 2005/01/19 23:24:51 drh Exp $ 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | # An unrestricted join 22 | # 23 | catch {unset ::result} 24 | set result {} 25 | for {set N 1} {$N<=$bitmask_size} {incr N} { 26 | lappend result $N 27 | do_test join3-1.$N { 28 | execsql "CREATE TABLE t${N}(x);" 29 | execsql "INSERT INTO t$N VALUES($N)" 30 | set sql "SELECT * FROM t1" 31 | for {set i 2} {$i<=$N} {incr i} {append sql ", t$i"} 32 | execsql $sql 33 | } $result 34 | } 35 | 36 | # Joins with a comparison 37 | # 38 | set result {} 39 | for {set N 1} {$N<=$bitmask_size} {incr N} { 40 | lappend result $N 41 | do_test join3-2.$N { 42 | set sql "SELECT * FROM t1" 43 | for {set i 2} {$i<=$N} {incr i} {append sql ", t$i"} 44 | set sep WHERE 45 | for {set i 1} {$i<$N} {incr i} { 46 | append sql " $sep t[expr {$i+1}].x==t$i.x+1" 47 | set sep AND 48 | } 49 | execsql $sql 50 | } $result 51 | } 52 | 53 | # Error of too many tables in the join 54 | # 55 | do_test join3-3.1 { 56 | set sql "SELECT * FROM t1 AS t0, t1" 57 | for {set i 2} {$i<=$bitmask_size} {incr i} {append sql ", t$i"} 58 | catchsql $sql 59 | } [list 1 "at most $bitmask_size tables in a join"] 60 | 61 | 62 | finish_test 63 | -------------------------------------------------------------------------------- /test/lock7.test: -------------------------------------------------------------------------------- 1 | # 2009 August 17 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Check that reading the database schema from within an active transaction 13 | # does not establish a SHARED lock on the database file if one is not 14 | # already held (or, more accurately, that the SHARED lock is released after 15 | # reading the database schema). 16 | # 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | do_test lock7-1.1 { 22 | execsql { CREATE TABLE t1(a, b) } 23 | db close 24 | 25 | sqlite3 db1 test.db 26 | sqlite3 db2 test.db 27 | 28 | db1 eval {BEGIN} 29 | db2 eval {BEGIN} 30 | } {} 31 | 32 | do_test lock7-1.2 { 33 | execsql { PRAGMA lock_status } db1 34 | } {main unlocked temp closed} 35 | do_test lock7-1.3 { 36 | execsql { PRAGMA lock_status } db2 37 | } {main unlocked temp closed} 38 | 39 | do_test lock7-1.4 { 40 | catchsql { INSERT INTO t1 VALUES(1, 1) } db1 41 | } {0 {}} 42 | do_test lock7-1.5 { 43 | catchsql { INSERT INTO t1 VALUES(2, 2) } db2 44 | } {1 {database is locked}} 45 | 46 | do_test lock7-1.6 { 47 | execsql { PRAGMA lock_status } db1 48 | } {main reserved temp closed} 49 | do_test lock7-1.7 { 50 | execsql { PRAGMA lock_status } db2 51 | } {main unlocked temp closed} 52 | 53 | do_test lock7-1.8 { 54 | execsql { COMMIT } db1 55 | } {} 56 | 57 | db1 close 58 | db2 close 59 | 60 | finish_test 61 | 62 | -------------------------------------------------------------------------------- /test/malloc6.test: -------------------------------------------------------------------------------- 1 | # 2006 June 25 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file attempts to check the library in an out-of-memory situation. 12 | # 13 | # $Id: malloc6.test,v 1.5 2008/02/18 22:24:58 drh Exp $ 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/tester.tcl 17 | source $testdir/malloc_common.tcl 18 | 19 | # Only run these tests if memory debugging is turned on. 20 | # 21 | if {!$MEMDEBUG} { 22 | puts "Skipping malloc6 tests: not compiled with -DSQLITE_MEMDEBUG..." 23 | finish_test 24 | return 25 | } 26 | 27 | 28 | set sqlite_os_trace 0 29 | do_malloc_test malloc6-1 -tclprep { 30 | db close 31 | } -tclbody { 32 | if {[catch {sqlite3 db test.db}]} { 33 | error "out of memory" 34 | } 35 | sqlite3_extended_result_codes db 1 36 | } -sqlbody { 37 | DROP TABLE IF EXISTS t1; 38 | CREATE TABLE IF NOT EXISTS t1( 39 | a int, b float, c double, d text, e varchar(20), 40 | primary key(a,b,c) 41 | ); 42 | CREATE TABLE IF NOT EXISTS t1( 43 | a int, b float, c double, d text, e varchar(20), 44 | primary key(a,b,c) 45 | ); 46 | DROP TABLE IF EXISTS t1; 47 | } 48 | 49 | # Ensure that no file descriptors were leaked. 50 | do_test malloc6-1.X { 51 | catch {db close} 52 | set sqlite_open_file_count 53 | } {0} 54 | 55 | finish_test 56 | -------------------------------------------------------------------------------- /test/malloc7.test: -------------------------------------------------------------------------------- 1 | # 2006 July 26 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file contains additional out-of-memory checks (see malloc.tcl) 12 | # added to expose a bug in out-of-memory handling for sqlite3_prepare16(). 13 | # 14 | # $Id: malloc7.test,v 1.5 2008/02/18 22:24:58 drh Exp $ 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | source $testdir/malloc_common.tcl 19 | 20 | # Only run these tests if memory debugging is turned on. 21 | # 22 | if {!$MEMDEBUG} { 23 | puts "Skipping malloc7 tests: not compiled with -DSQLITE_MEMDEBUG..." 24 | finish_test 25 | return 26 | } 27 | 28 | 29 | do_malloc_test malloc7-1 -sqlprep { 30 | CREATE TABLE t1(a,b,c,d); 31 | CREATE INDEX i1 ON t1(b,c); 32 | } -tclbody { 33 | set sql16 [encoding convertto unicode "SELECT * FROM sqlite_master"] 34 | append sql16 "\00\00" 35 | set nbyte [string length $sql16] 36 | set ::STMT [sqlite3_prepare16 db $sql16 $nbyte DUMMY] 37 | sqlite3_finalize $::STMT 38 | } 39 | 40 | 41 | # Ensure that no file descriptors were leaked. 42 | do_test malloc-99.X { 43 | catch {db close} 44 | set sqlite_open_file_count 45 | } {0} 46 | 47 | puts open-file-count=$sqlite_open_file_count 48 | finish_test 49 | -------------------------------------------------------------------------------- /test/malloc9.test: -------------------------------------------------------------------------------- 1 | # 2007 April 30 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file contains additional out-of-memory checks (see malloc.tcl) 12 | # added to expose a bug in out-of-memory handling for sqlite3_prepare(). 13 | # 14 | # $Id: malloc9.test,v 1.5 2008/04/04 12:21:26 drh Exp $ 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | source $testdir/malloc_common.tcl 19 | 20 | # Only run these tests if memory debugging is turned on. 21 | # 22 | if {!$MEMDEBUG} { 23 | puts "Skipping malloc9 tests: not compiled with -DSQLITE_MEMDEBUG..." 24 | finish_test 25 | return 26 | } 27 | 28 | 29 | do_malloc_test malloc-9.1 -tclprep { 30 | set sql {CREATE TABLE t1(x)} 31 | set sqlbytes [string length $sql] 32 | append sql {; INSERT INTO t1 VALUES(1)} 33 | } -tclbody { 34 | if {[catch {sqlite3_prepare db $sql $sqlbytes TAIL} STMT]} { 35 | set msg $STMT 36 | set STMT {} 37 | error $msg 38 | } 39 | } -cleanup { 40 | if {$STMT!=""} { 41 | sqlite3_finalize $STMT 42 | } 43 | } 44 | 45 | # Ensure that no file descriptors were leaked. 46 | do_test malloc9-99.X { 47 | catch {db close} 48 | set sqlite_open_file_count 49 | } {0} 50 | 51 | finish_test 52 | -------------------------------------------------------------------------------- /test/mallocAll.test: -------------------------------------------------------------------------------- 1 | # 2 | # May you do good and not evil. 3 | # May you find forgiveness for yourself and forgive others. 4 | # May you share freely, never taking more than you give. 5 | # 6 | #*********************************************************************** 7 | # This file runs all out-of-memory tests. 8 | # 9 | # $Id: mallocAll.test,v 1.1 2007/11/26 13:36:00 drh Exp $ 10 | 11 | proc lshift {lvar} { 12 | upvar $lvar l 13 | set ret [lindex $l 0] 14 | set l [lrange $l 1 end] 15 | return $ret 16 | } 17 | while {[set arg [lshift argv]] != ""} { 18 | switch -- $arg { 19 | -sharedpagercache { 20 | sqlite3_enable_shared_cache 1 21 | } 22 | default { 23 | set argv [linsert $argv 0 $arg] 24 | break 25 | } 26 | } 27 | } 28 | 29 | set testdir [file dirname $argv0] 30 | source $testdir/tester.tcl 31 | rename finish_test really_finish_test 32 | proc finish_test {} {} 33 | set G(isquick) 1 34 | 35 | set EXCLUDE { 36 | mallocAll.test 37 | } 38 | 39 | if {[sqlite3 -has-codec]} { 40 | # lappend EXCLUDE \ 41 | # conflict.test 42 | } 43 | 44 | 45 | # Files to include in the test. If this list is empty then everything 46 | # that is not in the EXCLUDE list is run. 47 | # 48 | set INCLUDE { 49 | } 50 | 51 | foreach testfile [lsort -dictionary [glob $testdir/*malloc*.test]] { 52 | set tail [file tail $testfile] 53 | if {[lsearch -exact $EXCLUDE $tail]>=0} continue 54 | if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue 55 | source $testfile 56 | catch {db close} 57 | if {$sqlite_open_file_count>0} { 58 | puts "$tail did not close all files: $sqlite_open_file_count" 59 | fail_test $tail 60 | set sqlite_open_file_count 0 61 | } 62 | } 63 | source $testdir/misuse.test 64 | 65 | set sqlite_open_file_count 0 66 | really_finish_test 67 | -------------------------------------------------------------------------------- /test/mallocB.test: -------------------------------------------------------------------------------- 1 | # 2007 May 30 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file contains additional out-of-memory checks (see malloc.tcl). 12 | # These were all discovered by fuzzy generation of SQL. Apart from 13 | # that they have little in common. 14 | # 15 | # 16 | # $Id: mallocB.test,v 1.9 2008/02/18 22:24:58 drh Exp $ 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | source $testdir/malloc_common.tcl 21 | 22 | # Only run these tests if memory debugging is turned on. 23 | # 24 | if {!$MEMDEBUG} { 25 | puts "Skipping mallocB tests: not compiled with -DSQLITE_MEMDEBUG..." 26 | finish_test 27 | return 28 | } 29 | source $testdir/malloc_common.tcl 30 | 31 | do_malloc_test mallocB-1 -sqlbody {SELECT - 456} 32 | do_malloc_test mallocB-2 -sqlbody {SELECT - 456.1} 33 | do_malloc_test mallocB-3 -sqlbody {SELECT random()} 34 | do_malloc_test mallocB-4 -sqlbody {SELECT length(zeroblob(1000))} 35 | ifcapable subquery { 36 | do_malloc_test mallocB-5 -sqlbody {SELECT * FROM (SELECT 1) GROUP BY 1;} 37 | } 38 | 39 | # The following test checks that there are no resource leaks following a 40 | # malloc() failure in sqlite3_set_auxdata(). 41 | # 42 | # Note: This problem was not discovered by fuzzy generation of SQL. Not 43 | # that it really matters. 44 | # 45 | do_malloc_test mallocB-6 -sqlbody { SELECT test_auxdata('hello world'); } 46 | 47 | do_malloc_test mallocB-7 -sqlbody { 48 | SELECT strftime(hex(randomblob(50)) || '%Y', 'now') 49 | } 50 | 51 | finish_test 52 | -------------------------------------------------------------------------------- /test/mallocD.test: -------------------------------------------------------------------------------- 1 | # 2007 Aug 29 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # $Id: mallocD.test,v 1.6 2008/02/18 22:24:58 drh Exp $ 13 | 14 | set testdir [file dirname $argv0] 15 | source $testdir/tester.tcl 16 | source $testdir/malloc_common.tcl 17 | 18 | # Only run these tests if memory debugging is turned on. 19 | # 20 | if {!$MEMDEBUG} { 21 | puts "Skipping mallocD tests: not compiled with -DSQLITE_MEMDEBUG..." 22 | finish_test 23 | return 24 | } 25 | 26 | db close 27 | sqlite3_simulate_device -char atomic 28 | sqlite3 db test.db -vfs devsym 29 | 30 | set PREP { 31 | PRAGMA page_size = 1024; 32 | CREATE TABLE abc(a, b, c); 33 | } 34 | 35 | do_malloc_test mallocD-1 -sqlprep $PREP -sqlbody { 36 | INSERT INTO abc VALUES(1, 2, 3); 37 | } 38 | 39 | do_malloc_test mallocD-2 -sqlprep $PREP -sqlbody { 40 | BEGIN; 41 | INSERT INTO abc VALUES(1, 2, 3); 42 | INSERT INTO abc VALUES(4, 5, 6); 43 | ROLLBACK; 44 | } 45 | 46 | do_malloc_test mallocD-3 -sqlprep $PREP -sqlbody { 47 | BEGIN; 48 | INSERT INTO abc VALUES(1, 2, 3); 49 | INSERT INTO abc VALUES(4, 5, randstr(1500,1500)); 50 | COMMIT; 51 | } 52 | 53 | ifcapable attach { 54 | do_malloc_test mallocD-4 -sqlprep $PREP -sqlbody { 55 | ATTACH 'test2.db' AS aux; 56 | BEGIN; 57 | CREATE TABLE aux.def(d, e, f); 58 | INSERT INTO abc VALUES(4, 5, 6); 59 | COMMIT; 60 | } 61 | } 62 | 63 | sqlite3_simulate_device -char {} 64 | 65 | finish_test 66 | -------------------------------------------------------------------------------- /test/mallocE.test: -------------------------------------------------------------------------------- 1 | # 2007 Aug 29 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This test script checks that tickets #2784 and #2789 have been fixed. 13 | # 14 | # $Id: mallocE.test,v 1.3 2008/02/18 22:24:58 drh Exp $ 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | source $testdir/malloc_common.tcl 19 | 20 | # Only run these tests if memory debugging is turned on. 21 | # 22 | if {!$MEMDEBUG} { 23 | puts "Skipping mallocE tests: not compiled with -DSQLITE_MEMDEBUG..." 24 | finish_test 25 | return 26 | } 27 | 28 | # ticket #2784 29 | # 30 | set PREP { 31 | PRAGMA page_size = 1024; 32 | CREATE TABLE t1(a, b, c); 33 | CREATE TABLE t2(x, y, z); 34 | } 35 | do_malloc_test mallocE-1 -sqlprep $PREP -sqlbody { 36 | SELECT p, q FROM (SELECT a+b AS p, b+c AS q FROM t1, t2 WHERE c>5) 37 | LEFT JOIN t2 ON p=x; 38 | } 39 | 40 | # Ticket #2789 41 | # 42 | do_malloc_test mallocE-2 -sqlprep $PREP -sqlbody { 43 | SELECT x, y2 FROM (SELECT a+b AS x, b+c AS y2 FROM t1, t2 WHERE c>5) 44 | LEFT JOIN t2 USING(x) WHERE y2>11; 45 | } 46 | 47 | 48 | finish_test 49 | -------------------------------------------------------------------------------- /test/mallocI.test: -------------------------------------------------------------------------------- 1 | # 2008 August 01 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This test script checks malloc failures in various obscure operations. 13 | # 14 | # $Id: mallocI.test,v 1.3 2009/08/10 04:26:39 danielk1977 Exp $ 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | source $testdir/malloc_common.tcl 19 | 20 | # Malloc failures in a view. 21 | # 22 | do_malloc_test mallocI-1 -sqlprep { 23 | CREATE TABLE t1(a,b,c,d); 24 | CREATE VIEW v1 AS SELECT a*b, c*d FROM t1 ORDER BY b-d; 25 | } -sqlbody { 26 | SELECT * FROM v1 27 | } 28 | 29 | # Malloc failure while trying to service a pragma on a TEMP database. 30 | # 31 | do_malloc_test mallocI-2 -sqlbody { 32 | PRAGMA temp.page_size 33 | } 34 | 35 | # Malloc failure while creating a table from a SELECT statement. 36 | # 37 | do_malloc_test mallocI-3 -sqlprep { 38 | CREATE TABLE t1(a,b,c); 39 | } -sqlbody { 40 | CREATE TABLE t2 AS SELECT b,c FROM t1; 41 | } 42 | 43 | # This tests that a malloc failure that occurs while passing the schema 44 | # does not result in a SHARED lock being left on the database file. 45 | # 46 | do_malloc_test mallocI-4 -tclprep { 47 | sqlite3 db2 test.db 48 | db2 eval { 49 | CREATE TABLE t1(a, b, c); 50 | CREATE TABLE t2(a, b, c); 51 | } 52 | } -sqlbody { 53 | SELECT * FROM t1 54 | } -cleanup { 55 | do_test mallocI-4.$::n.2 { 56 | # If this INSERT is possible then [db] does not hold a shared lock 57 | # on the database file. 58 | catchsql { INSERT INTO t1 VALUES(1, 2, 3) } db2 59 | } {0 {}} 60 | catch {db2 close} 61 | } 62 | catch { db2 close } 63 | 64 | finish_test 65 | -------------------------------------------------------------------------------- /test/mem5.test: -------------------------------------------------------------------------------- 1 | # 2011 March 9 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This file contains tests of the mem5 allocation subsystem. 13 | # 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/tester.tcl 17 | 18 | ifcapable !mem5 { 19 | finish_test 20 | return 21 | } 22 | 23 | # The tests in this file configure the lookaside allocator after a 24 | # connection is opened. This will not work if there is any "presql" 25 | # configured (SQL run within the [sqlite3] wrapper in tester.tcl). 26 | if {[info exists ::G(perm:presql)]} { 27 | finish_test 28 | return 29 | } 30 | 31 | do_test mem5-1.1 { 32 | catch {db close} 33 | sqlite3_shutdown 34 | sqlite3_config_heap 25000000 0 35 | sqlite3_config_lookaside 0 0 36 | sqlite3_initialize 37 | } {SQLITE_OK} 38 | 39 | # try with min request size = 2^30 40 | do_test mem5-1.2 { 41 | catch {db close} 42 | sqlite3_shutdown 43 | sqlite3_config_heap 1 1073741824 44 | sqlite3_config_lookaside 0 0 45 | sqlite3_initialize 46 | } {SQLITE_NOMEM} 47 | 48 | # try with min request size = 2^30+1 49 | # previously this was causing the memsys5Log() func to infinitely loop. 50 | do_test mem5-1.3 { 51 | catch {db close} 52 | sqlite3_shutdown 53 | sqlite3_config_heap 1 1073741825 54 | sqlite3_config_lookaside 0 0 55 | sqlite3_initialize 56 | } {SQLITE_NOMEM} 57 | 58 | do_test mem5-1.4 { 59 | catch {db close} 60 | sqlite3_shutdown 61 | sqlite3_config_heap 0 0 62 | sqlite3_config_lookaside 0 0 63 | sqlite3_initialize 64 | } {SQLITE_OK} 65 | 66 | finish_test 67 | -------------------------------------------------------------------------------- /test/misc6.test: -------------------------------------------------------------------------------- 1 | # 2006 September 4 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to make sure sqlite3_value_text() 14 | # always returns a null-terminated string. 15 | # 16 | # $Id: misc6.test,v 1.3 2007/04/23 23:56:32 drh Exp $ 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | do_test misc6-1.1 { 22 | set DB [sqlite3_connection_pointer db] 23 | sqlite3_create_function $DB 24 | set STMT [sqlite3_prepare $DB {SELECT hex8(?)} -1 DUMMY] 25 | set sqlite_static_bind_value {0123456789} 26 | set sqlite_static_bind_nbyte 5 27 | sqlite_bind $STMT 1 {} static-nbytes 28 | sqlite3_step $STMT 29 | } SQLITE_ROW 30 | do_test misc6-1.2 { 31 | sqlite3_column_text $STMT 0 32 | } {3031323334} 33 | ifcapable utf16 { 34 | do_test misc6-1.3 { 35 | sqlite3_finalize $STMT 36 | set STMT [sqlite3_prepare $DB {SELECT hex16(?)} -1 DUMMY] 37 | set sqlite_static_bind_value {0123456789} 38 | set sqlite_static_bind_nbyte 5 39 | sqlite_bind $STMT 1 {} static-nbytes 40 | sqlite3_step $STMT 41 | } SQLITE_ROW 42 | do_test misc6-1.4 { 43 | sqlite3_column_text $STMT 0 44 | } {00300031003200330034} 45 | } 46 | sqlite3_finalize $STMT 47 | 48 | finish_test 49 | -------------------------------------------------------------------------------- /test/numcast.test: -------------------------------------------------------------------------------- 1 | # 2013 March 20 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # This particular file does testing of casting strings into numeric 13 | # values. 14 | # 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | foreach enc {utf8 utf16le utf16be} { 20 | do_test numcast-$enc.0 { 21 | db close 22 | sqlite3 db :memory: 23 | db eval "PRAGMA encoding='$enc'" 24 | set x [db eval {PRAGMA encoding}] 25 | string map {- {}} [string tolower $x] 26 | } $enc 27 | foreach {idx str rval ival} { 28 | 1 12345.0 12345.0 12345 29 | 2 12345.0e0 12345.0 12345 30 | 3 -12345.0e0 -12345.0 -12345 31 | 4 -12345.25 -12345.25 -12345 32 | 5 { -12345.0} -12345.0 -12345 33 | 6 { 876xyz} 876.0 876 34 | 7 { 456ķ89} 456.0 456 35 | 8 { Ġ 321.5} 0.0 0 36 | } { 37 | do_test numcast-$enc.$idx.1 { 38 | db eval {SELECT CAST($str AS real)} 39 | } $rval 40 | do_test numcast-$enc.$idx.2 { 41 | db eval {SELECT CAST($str AS integer)} 42 | } $ival 43 | } 44 | } 45 | 46 | finish_test 47 | -------------------------------------------------------------------------------- /test/openv2.test: -------------------------------------------------------------------------------- 1 | # 2007 Sep 3 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Tests on the sqlite3_open_v2() interface. 13 | # 14 | # $Id: openv2.test,v 1.2 2009/06/11 17:32:45 drh Exp $ 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | db close 20 | forcedelete test.db test.db-journal 21 | do_test openv2-1.1 { 22 | set rc [catch {sqlite3 db test.db -create 0} msg] 23 | lappend rc $msg 24 | } {1 {unable to open database file}} 25 | do_test openv2-1.2 { 26 | info commands db 27 | } {} 28 | do_test openv2-1.3 { 29 | sqlite3 db test.db 30 | db eval {CREATE TABLE t1(x)} 31 | db close 32 | sqlite3 db test.db -readonly 1 33 | db eval {SELECT name FROM sqlite_master} 34 | } {t1} 35 | do_test openv2-1.4 { 36 | catchsql { 37 | INSERT INTO t1 VALUES(123) 38 | } 39 | } {1 {attempt to write a readonly database}} 40 | 41 | # Ticket #3908 42 | # Honor SQLITE_OPEN_READONLY even on an in-memory database, even though 43 | # this is pointless. 44 | # 45 | do_test openv2-2.1 { 46 | db close 47 | sqlite3 db :memory: -readonly 1 48 | db eval {SELECT * FROM sqlite_master} 49 | } {} 50 | do_test openv2-2.2 { 51 | catchsql {CREATE TABLE t1(x)} 52 | } {1 {attempt to write a readonly database}} 53 | 54 | 55 | finish_test 56 | -------------------------------------------------------------------------------- /test/pager3.test: -------------------------------------------------------------------------------- 1 | # 2010 June 15 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | 13 | set testdir [file dirname $argv0] 14 | source $testdir/tester.tcl 15 | source $testdir/lock_common.tcl 16 | source $testdir/malloc_common.tcl 17 | source $testdir/wal_common.tcl 18 | 19 | 20 | foreach {tn sql res j} { 21 | 1 "PRAGMA journal_mode = DELETE" delete 0 22 | 2 "CREATE TABLE t1(a, b)" {} 0 23 | 3 "PRAGMA locking_mode=EXCLUSIVE" {exclusive} 0 24 | 4 "INSERT INTO t1 VALUES(1, 2)" {} 1 25 | 5 "PRAGMA locking_mode=NORMAL" {normal} 1 26 | 6 "SELECT * FROM t1" {1 2} 0 27 | } { 28 | do_execsql_test pager3-1.$tn.1 $sql $res 29 | do_test pager3-1.$tn.2 { file exists test.db-journal } $j 30 | } 31 | 32 | 33 | finish_test 34 | -------------------------------------------------------------------------------- /test/pagerfault3.test: -------------------------------------------------------------------------------- 1 | # 2011 January 28 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | 13 | set testdir [file dirname $argv0] 14 | source $testdir/tester.tcl 15 | source $testdir/lock_common.tcl 16 | source $testdir/malloc_common.tcl 17 | 18 | if {[permutation] == "inmemory_journal"} { 19 | finish_test 20 | return 21 | } 22 | 23 | # Create a database with page-size 2048 bytes that uses 2 pages. Populate 24 | # it so that if the page-size is changed to 1024 bytes and the db vacuumed, 25 | # the new db size is 3 pages. 26 | # 27 | do_test pagerfault3-pre1 { 28 | execsql { 29 | PRAGMA auto_vacuum = 0; 30 | PRAGMA page_size = 2048; 31 | CREATE TABLE t1(x); 32 | INSERT INTO t1 VALUES(randomblob(1200)); 33 | PRAGMA page_count; 34 | } 35 | } {2} 36 | do_test pagerfault3-pre2 { 37 | faultsim_save_and_close 38 | faultsim_restore_and_reopen 39 | execsql { 40 | PRAGMA page_size = 1024; 41 | VACUUM; 42 | PRAGMA page_count; 43 | } 44 | } {3} 45 | 46 | # Now do the page-size change and VACUUM with IO error injection. When 47 | # an IO error is injected into the final xSync() of the commit, the pager 48 | # will have to extend the db file from 3072 to 4096 byts when rolling 49 | # back the hot-journal file. This is a special case in pager_truncate(). 50 | # 51 | do_faultsim_test pagerfault3-1 -faults ioerr-transient -prep { 52 | faultsim_restore_and_reopen 53 | } -body { 54 | execsql { 55 | PRAGMA page_size = 1024; 56 | VACUUM; 57 | } 58 | } -test { 59 | faultsim_test_result {0 {}} 60 | faultsim_integrity_check 61 | } 62 | 63 | finish_test 64 | 65 | -------------------------------------------------------------------------------- /test/quick.test: -------------------------------------------------------------------------------- 1 | # 2 | # May you do good and not evil. 3 | # May you find forgiveness for yourself and forgive others. 4 | # May you share freely, never taking more than you give. 5 | # 6 | #*********************************************************************** 7 | # This file runs all tests. 8 | # 9 | 10 | set testdir [file dirname $argv0] 11 | source $testdir/permutations.test 12 | 13 | run_test_suite quick 14 | 15 | finish_test 16 | -------------------------------------------------------------------------------- /test/releasetest.mk: -------------------------------------------------------------------------------- 1 | ######################################################## 2 | TOP=/home/drh/sqlite/sqlite 3 | 4 | TCL_FLAGS=-I/home/drh/tcltk/86linux 5 | LIBTCL=/home/drh/tcltk/86linux/libtcl8.6.a -lm -ldl -lpthread 6 | 7 | BCC = gcc 8 | TCC = gcc -ansi -g $(CFLAGS) 9 | NAWK = awk 10 | AR = ar cr 11 | RANLIB = ranlib 12 | THREADLIB = -lpthread -ldl -lz 13 | include $(TOP)/main.mk 14 | ######################################################## 15 | -------------------------------------------------------------------------------- /test/resolver01.test: -------------------------------------------------------------------------------- 1 | # 2013-04-13 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This file tests features of the name resolver (the component that 13 | # figures out what identifiers in the SQL statement refer to) that 14 | # were fixed by ticket [2500cdb9be] 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test resolver01-1.1 { 21 | catchsql { 22 | CREATE TABLE t1(x, y); INSERT INTO t1 VALUES(11,22); 23 | CREATE TABLE t2(y, z); INSERT INTO t2 VALUES(33,44); 24 | SELECT 1 AS y FROM t1, t2 ORDER BY y; 25 | } 26 | } {0 1} 27 | do_test resolver01-1.2 { 28 | catchsql { 29 | SELECT 2 AS y FROM t1, t2 ORDER BY y COLLATE nocase; 30 | } 31 | } {0 2} 32 | do_test resolver01-1.3 { 33 | catchsql { 34 | SELECT 3 AS y FROM t1, t2 ORDER BY +y; 35 | } 36 | } {0 3} 37 | 38 | 39 | finish_test 40 | -------------------------------------------------------------------------------- /test/rowhash.test: -------------------------------------------------------------------------------- 1 | # 2009 April 17 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This file implements regression tests for SQLite library. The 13 | # focus of this file is the code in rowhash.c. 14 | # 15 | # NB: The rowhash.c module is no longer part of the source tree. But 16 | # we might as well keep this test. 17 | # 18 | 19 | set testdir [file dirname $argv0] 20 | source $testdir/tester.tcl 21 | 22 | do_test rowhash-1.1 { 23 | execsql { 24 | CREATE TABLE t1(id INTEGER PRIMARY KEY, a, b, c); 25 | CREATE INDEX i1 ON t1(a); 26 | CREATE INDEX i2 ON t1(b); 27 | CREATE INDEX i3 ON t1(c); 28 | } 29 | } {} 30 | 31 | proc do_keyset_test {name lKey} { 32 | db transaction { 33 | execsql { DELETE FROM t1 } 34 | foreach key $lKey { 35 | execsql { INSERT OR IGNORE INTO t1 VALUES($key, 'a', 'b', 'c') } 36 | } 37 | } 38 | do_test $name { 39 | lsort -integer [execsql { 40 | SELECT id FROM t1 WHERE a = 'a' OR b = 'b' OR c = 'c'; 41 | }] 42 | } [lsort -integer -unique $lKey] 43 | } 44 | 45 | do_keyset_test rowhash-2.1 {1 2 3} 46 | do_keyset_test rowhash-2.2 {0 1 2 3} 47 | do_keyset_test rowhash-2.3 {62 125 188} 48 | if {[working_64bit_int]} { 49 | expr srand(1) 50 | unset -nocomplain i L 51 | for {set i 4} {$i < 10} {incr i} { 52 | for {set j 0} {$j < 5000} {incr j} { 53 | lappend L [expr int(rand()*1000000000)] 54 | } 55 | do_keyset_test rowhash-2.$i $L 56 | } 57 | } 58 | 59 | finish_test 60 | -------------------------------------------------------------------------------- /test/rtree.test: -------------------------------------------------------------------------------- 1 | # 2008 June 23 2 | # 3 | # May you do good and not evil. 4 | # May you find forgiveness for yourself and forgive others. 5 | # May you share freely, never taking more than you give. 6 | # 7 | #*********************************************************************** 8 | # This file runs all rtree related tests. 9 | # 10 | 11 | set testdir [file dirname $argv0] 12 | source $testdir/permutations.test 13 | 14 | ifcapable rtree { 15 | run_test_suite rtree 16 | } 17 | 18 | finish_test 19 | -------------------------------------------------------------------------------- /test/savepoint5.test: -------------------------------------------------------------------------------- 1 | # 2009 January 2 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Verify that a SAVEPOINT on a new, empty database followed by a 13 | # ROLLBACK TO that savepoint starts over again with another new 14 | # empty database. 15 | # 16 | # $Id: savepoint5.test,v 1.1 2009/01/02 21:08:09 drh Exp $ 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | do_test savepoint5-1.1 { 22 | db eval { 23 | SAVEPOINT sp1; 24 | CREATE TABLE t1(x); 25 | INSERT INTO t1 VALUES(1); 26 | SELECT count(*) FROM sqlite_master; 27 | SELECT * FROM t1; 28 | } 29 | } {1 1} 30 | do_test savepoint5-1.2 { 31 | db eval { 32 | ROLLBACK TO sp1; 33 | SELECT count(*) FROM sqlite_master; 34 | } 35 | } {0} 36 | do_test savepoint5-1.3 { 37 | db eval { 38 | CREATE TABLE t1(x); 39 | INSERT INTO t1 VALUES(1); 40 | SELECT count(*) FROM sqlite_master; 41 | SELECT * FROM t1; 42 | } 43 | } {1 1} 44 | 45 | 46 | finish_test 47 | -------------------------------------------------------------------------------- /test/securedel.test: -------------------------------------------------------------------------------- 1 | # 2010 January 12 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #************************************************************************* 11 | # 12 | # Tests for the secure_delete pragma. 13 | # 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/tester.tcl 17 | 18 | unset -nocomplain DEFAULT_SECDEL 19 | set DEFAULT_SECDEL 0 20 | ifcapable secure_delete { 21 | set DEFAULT_SECDEL 1 22 | } 23 | 24 | 25 | do_test securedel-1.0 { 26 | db eval {PRAGMA secure_delete;} 27 | } $DEFAULT_SECDEL 28 | 29 | forcedelete test2.db test2.db-journal 30 | do_test securedel-1.1 { 31 | db eval { 32 | ATTACH 'test2.db' AS db2; 33 | PRAGMA main.secure_delete=ON; 34 | PRAGMA db2.secure_delete; 35 | } 36 | } [list 1 $DEFAULT_SECDEL] 37 | do_test securedel-1.2 { 38 | db eval { 39 | PRAGMA main.secure_delete=OFF; 40 | PRAGMA db2.secure_delete; 41 | } 42 | } [list 0 $DEFAULT_SECDEL] 43 | do_test securedel-1.3 { 44 | db eval { 45 | PRAGMA secure_delete=OFF; 46 | PRAGMA db2.secure_delete; 47 | } 48 | } {0 0} 49 | do_test securedel-1.4 { 50 | breakpoint 51 | db eval { 52 | PRAGMA secure_delete=ON; 53 | PRAGMA db2.secure_delete; 54 | } 55 | } {1 1} 56 | 57 | do_test securedel-2.1 { 58 | db eval { 59 | DETACH db2; 60 | ATTACH 'test2.db' AS db2; 61 | PRAGMA db2.secure_delete; 62 | } 63 | } 1 64 | do_test securedel-2.2 { 65 | db eval { 66 | DETACH db2; 67 | PRAGMA main.secure_delete=OFF; 68 | ATTACH 'test2.db' AS db2; 69 | PRAGMA db2.secure_delete; 70 | } 71 | } {0 0} 72 | 73 | finish_test 74 | -------------------------------------------------------------------------------- /test/shared7.test: -------------------------------------------------------------------------------- 1 | # 2009 April 30 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Make sure that attaching the same database multiple times in 13 | # shared cache mode fails. 14 | # 15 | # $Id: shared7.test,v 1.1 2009/04/30 13:30:33 drh Exp $ 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | ifcapable !shared_cache { finish_test ; return } 20 | 21 | do_test shared7-1.1 { 22 | set ::enable_shared_cache [sqlite3_enable_shared_cache 1] 23 | sqlite3_enable_shared_cache 24 | } {1} 25 | 26 | do_test shared7-1.2 { 27 | db close 28 | sqlite3 db test.db 29 | db eval { 30 | CREATE TABLE t1(x); 31 | } 32 | catchsql { 33 | ATTACH 'test.db' AS err1; 34 | } 35 | } {1 {database is already attached}} 36 | 37 | do_test shared7-1.3 { 38 | forcedelete test2.db test2.db-journal 39 | db eval { 40 | ATTACH 'test2.db' AS test2; 41 | CREATE TABLE test2.t2(y); 42 | } 43 | catchsql { 44 | ATTACH 'test2.db' AS err2; 45 | } 46 | } {1 {database is already attached}} 47 | do_test shared7-1.4 { 48 | catchsql { 49 | ATTACH 'test.db' AS err1; 50 | } 51 | } {1 {database is already attached}} 52 | 53 | 54 | sqlite3_enable_shared_cache $::enable_shared_cache 55 | finish_test 56 | -------------------------------------------------------------------------------- /test/sharedlock.test: -------------------------------------------------------------------------------- 1 | # 2009 July 2 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # $Id: sharedlock.test,v 1.1 2009/07/02 17:21:58 danielk1977 Exp $ 13 | 14 | set testdir [file dirname $argv0] 15 | source $testdir/tester.tcl 16 | db close 17 | 18 | ifcapable !shared_cache { 19 | finish_test 20 | return 21 | } 22 | 23 | set ::enable_shared_cache [sqlite3_enable_shared_cache 1] 24 | sqlite3 db test.db 25 | sqlite3 db2 test.db 26 | 27 | do_test sharedlock-1.1 { 28 | execsql { 29 | CREATE TABLE t1(a, b); 30 | INSERT INTO t1 VALUES(1, 'one'); 31 | INSERT INTO t1 VALUES(2, 'two'); 32 | } 33 | } {} 34 | 35 | do_test sharedlock-1.2 { 36 | set res [list] 37 | db eval { SELECT * FROM t1 ORDER BY rowid } { 38 | lappend res $a $b 39 | if {$a == 1} { catch { db eval "INSERT INTO t1 VALUES(3, 'three')" } } 40 | 41 | # This should fail. Connection [db] has a read-lock on t1, which should 42 | # prevent connection [db2] from obtaining the write-lock it needs to 43 | # modify t1. At one point there was a bug causing the previous INSERT 44 | # to drop the read-lock belonging to [db]. 45 | if {$a == 2} { catch { db2 eval "INSERT INTO t1 VALUES(4, 'four')" } } 46 | } 47 | set res 48 | } {1 one 2 two 3 three} 49 | 50 | db close 51 | db2 close 52 | 53 | sqlite3_enable_shared_cache $::enable_shared_cache 54 | finish_test 55 | 56 | -------------------------------------------------------------------------------- /test/shortread1.test: -------------------------------------------------------------------------------- 1 | # 2007 Sep 13 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This file attempts to duplicate an error scenario seen on a 13 | # customer system using version 3.2.2. The problem appears to 14 | # have been fixed (perhaps by accident) with check-in [3503]. 15 | # These tests will prevent an accidental recurrance. 16 | # 17 | # $Id: shortread1.test,v 1.1 2007/09/14 01:48:12 drh Exp $ 18 | # 19 | 20 | set testdir [file dirname $argv0] 21 | source $testdir/tester.tcl 22 | 23 | do_test shortread1-1.1 { 24 | execsql { 25 | CREATE TABLE t1(a TEXT); 26 | BEGIN; 27 | INSERT INTO t1 VALUES(hex(randomblob(5000))); 28 | INSERT INTO t1 VALUES(hex(randomblob(100))); 29 | PRAGMA freelist_count; 30 | } 31 | } {0} 32 | do_test shortread1-1.2 { 33 | execsql { 34 | DELETE FROM t1 WHERE rowid=1; 35 | PRAGMA freelist_count; 36 | } 37 | } {11} 38 | do_test shortread1-1.3 { 39 | sqlite3_release_memory [expr {1024*9}] 40 | execsql { 41 | INSERT INTO t1 VALUES(hex(randomblob(5000))); 42 | PRAGMA freelist_count; 43 | } 44 | } {0} 45 | do_test shortread1-1.4 { 46 | execsql { 47 | COMMIT; 48 | SELECT count(*) FROM t1; 49 | } 50 | } {2} 51 | 52 | finish_test 53 | -------------------------------------------------------------------------------- /test/shrink.test: -------------------------------------------------------------------------------- 1 | # 2011 November 16 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This file contains test cases for sqlite3_db_release_memory and 13 | # the PRAGMA shrink_memory statement. 14 | # 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | unset -nocomplain baseline 20 | do_test shrink-1.1 { 21 | db eval { 22 | PRAGMA cache_size = 2000; 23 | CREATE TABLE t1(x,y); 24 | INSERT INTO t1 VALUES(randomblob(1000000),1); 25 | } 26 | set ::baseline sqlite3_memory_used 27 | sqlite3_db_release_memory db 28 | expr {$::baseline > [sqlite3_memory_used]+500000} 29 | } {1} 30 | do_test shrink-1.2 { 31 | set baseline [sqlite3_memory_used] 32 | db eval { 33 | UPDATE t1 SET y=y+1; 34 | } 35 | expr {$::baseline+500000 < [sqlite3_memory_used]} 36 | } {1} 37 | do_test shrink-1.3 { 38 | set baseline [sqlite3_memory_used] 39 | db eval {PRAGMA shrink_memory} 40 | expr {$::baseline > [sqlite3_memory_used]+500000} 41 | } {1} 42 | 43 | finish_test 44 | -------------------------------------------------------------------------------- /test/softheap1.test: -------------------------------------------------------------------------------- 1 | # 2007 Aug 10 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This test script reproduces the problem reported by ticket #2565, 13 | # A database corruption bug that occurs in auto_vacuum mode when 14 | # the soft_heap_limit is set low enough to be triggered. 15 | # 16 | # $Id: softheap1.test,v 1.5 2008/07/08 17:13:59 danielk1977 Exp $ 17 | 18 | 19 | set testdir [file dirname $argv0] 20 | source $testdir/tester.tcl 21 | 22 | ifcapable !integrityck { 23 | finish_test 24 | return 25 | } 26 | 27 | sqlite3_soft_heap_limit -1 28 | sqlite3_soft_heap_limit 0 29 | sqlite3_soft_heap_limit 5000 30 | do_test softheap1-1.1 { 31 | execsql { 32 | PRAGMA auto_vacuum=1; 33 | CREATE TABLE t1(x); 34 | INSERT INTO t1 VALUES(hex(randomblob(1000))); 35 | BEGIN; 36 | } 37 | execsql { 38 | CREATE TABLE t2 AS SELECT * FROM t1; 39 | } 40 | execsql { 41 | ROLLBACK; 42 | } 43 | execsql { 44 | PRAGMA integrity_check; 45 | } 46 | } {ok} 47 | 48 | sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) 49 | finish_test 50 | -------------------------------------------------------------------------------- /test/tkt-02a8e81d44.test: -------------------------------------------------------------------------------- 1 | # 2010 April 15 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket [02a8e81d44] has been 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | ifcapable !compound { 21 | finish_test 22 | return 23 | } 24 | 25 | do_test tkt-02a838-1.1 { 26 | execsql { 27 | CREATE TABLE t1(a); 28 | INSERT INTO t1 VALUES(1); 29 | INSERT INTO t1 VALUES(2); 30 | INSERT INTO t1 VALUES(4); 31 | INSERT INTO t1 VALUES(5); 32 | SELECT * FROM (SELECT a FROM t1 LIMIT 1) UNION ALL SELECT 3; 33 | } 34 | } {1 3} 35 | 36 | finish_test 37 | -------------------------------------------------------------------------------- /test/tkt-26ff0c2d1e.test: -------------------------------------------------------------------------------- 1 | # 2010 May 12 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this script testing a bug found in the OP_Variable optimizer 13 | # 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/tester.tcl 17 | 18 | do_test bug-20100512-1 { 19 | set DB [sqlite3_connection_pointer db] 20 | set SQL {SELECT case when 1 then 99 else ? end + ?} 21 | set STMT [sqlite3_prepare_v2 $DB $SQL -1 TAIL] 22 | set TAIL 23 | } {} 24 | do_test bug-20100512-2 { 25 | sqlite3_bind_parameter_count $STMT 26 | } 2 27 | do_test bug-20100512-3 { 28 | sqlite3_bind_int $STMT 1 123 29 | sqlite3_bind_int $STMT 2 456 30 | sqlite3_step $STMT 31 | sqlite3_column_int $STMT 0 32 | } {555} 33 | sqlite3_finalize $STMT 34 | -------------------------------------------------------------------------------- /test/tkt-2ea2425d34.test: -------------------------------------------------------------------------------- 1 | # 2009 September 2 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket [2ea2425d34be] has been 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test tkt-2ea24-1.1 { 21 | db eval { 22 | PRAGMA encoding=UTF16; 23 | CREATE TABLE t1(a,b); 24 | INSERT INTO t1 VALUES(1,'abc'); 25 | INSERT INTO t1 VALUES(2,'def'); 26 | INSERT INTO t1 VALUES(3,'ghi'); 27 | SELECT a FROM t1 WHERE length(b)<10 AND b<>'def' ORDER BY a; 28 | } 29 | } {1 3} 30 | 31 | finish_test 32 | -------------------------------------------------------------------------------- /test/tkt-385a5b56b9.test: -------------------------------------------------------------------------------- 1 | # 2012 April 02 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # The tests in this file were used while developing the SQLite 4 code. 12 | # 13 | set testdir [file dirname $argv0] 14 | source $testdir/tester.tcl 15 | set testprefix tkt-385a5b56b9 16 | 17 | do_execsql_test 1.0 { 18 | CREATE TABLE t1(x, y); 19 | INSERT INTO t1 VALUES(1, NULL); 20 | INSERT INTO t1 VALUES(2, NULL); 21 | INSERT INTO t1 VALUES(1, NULL); 22 | } 23 | 24 | do_execsql_test 1.1 { SELECT DISTINCT x, y FROM t1 } {1 {} 2 {}} 25 | do_execsql_test 1.2 { CREATE UNIQUE INDEX i1 ON t1(x, y) } 26 | do_execsql_test 1.3 { SELECT DISTINCT x, y FROM t1 } {1 {} 2 {}} 27 | 28 | 29 | #------------------------------------------------------------------------- 30 | 31 | do_execsql_test 2.0 { 32 | CREATE TABLE t2(x, y NOT NULL); 33 | CREATE UNIQUE INDEX t2x ON t2(x); 34 | CREATE UNIQUE INDEX t2y ON t2(y); 35 | } 36 | 37 | do_eqp_test 2.1 { SELECT DISTINCT x FROM t2 } { 38 | 0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2x (~1000000 rows)} 39 | } 40 | 41 | do_eqp_test 2.2 { SELECT DISTINCT y FROM t2 } { 42 | 0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2y (~1000000 rows)} 43 | } 44 | 45 | do_eqp_test 2.3 { SELECT DISTINCT x, y FROM t2 WHERE y=10 } { 46 | 0 0 0 {SEARCH TABLE t2 USING INDEX t2y (y=?) (~1 rows)} 47 | } 48 | 49 | do_eqp_test 2.4 { SELECT DISTINCT x, y FROM t2 WHERE x=10 } { 50 | 0 0 0 {SEARCH TABLE t2 USING INDEX t2x (x=?) (~1 rows)} 51 | } 52 | 53 | finish_test 54 | -------------------------------------------------------------------------------- /test/tkt-3998683a16.test: -------------------------------------------------------------------------------- 1 | # 2010 September 30 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This file implements regression tests for SQLite library. Specifically, 13 | # it tests that ticket [3998683a16a7076e08f5585c1f4816414c8c653a] where in 14 | # floating point values with a decimal point at the beginning or end 15 | # of the mantissa are used. 16 | # 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | do_test tkt-3998683a16.1 { 22 | db eval { 23 | CREATE TABLE t1(x, y REAL); 24 | INSERT INTO t1 VALUES(1, '1.0'); 25 | INSERT INTO t1 VALUES(2, '.125'); 26 | INSERT INTO t1 VALUES(3, '123.'); 27 | INSERT INTO t1 VALUES(4, '123.e+2'); 28 | INSERT INTO t1 VALUES(5, '.125e+3'); 29 | INSERT INTO t1 VALUES(6, '123e4'); 30 | INSERT INTO t1 VALUES(11, ' 1.0'); 31 | INSERT INTO t1 VALUES(12, ' .125'); 32 | INSERT INTO t1 VALUES(13, ' 123.'); 33 | INSERT INTO t1 VALUES(14, ' 123.e+2'); 34 | INSERT INTO t1 VALUES(15, ' .125e+3'); 35 | INSERT INTO t1 VALUES(16, ' 123e4'); 36 | INSERT INTO t1 VALUES(21, '1.0 '); 37 | INSERT INTO t1 VALUES(22, '.125 '); 38 | INSERT INTO t1 VALUES(23, '123. '); 39 | INSERT INTO t1 VALUES(24, '123.e+2 '); 40 | INSERT INTO t1 VALUES(25, '.125e+3 '); 41 | INSERT INTO t1 VALUES(26, '123e4 '); 42 | SELECT x FROM t1 WHERE typeof(y)=='real' ORDER BY x; 43 | } 44 | } {1 2 3 4 5 6 11 12 13 14 15 16 21 22 23 24 25 26} 45 | 46 | finish_test 47 | -------------------------------------------------------------------------------- /test/tkt-3fe897352e.test: -------------------------------------------------------------------------------- 1 | # 2009 October 23 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket [3fe897352e8d8] has been 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | # The following tests use hex_to_utf16be() and hex_to_utf16le() which 21 | # which are only available if SQLite is built with UTF16 support. 22 | ifcapable {!utf16} { 23 | finish_test 24 | return 25 | } 26 | 27 | do_test tkt-3fe89-1.1 { 28 | db close 29 | sqlite3 db :memory: 30 | db eval { 31 | PRAGMA encoding=UTF8; 32 | CREATE TABLE t1(x); 33 | INSERT INTO t1 VALUES(hex_to_utf16be('D800')); 34 | SELECT hex(x) FROM t1; 35 | } 36 | } {EDA080} 37 | do_test tkt-3fe89-1.2 { 38 | db eval { 39 | DELETE FROM t1; 40 | INSERT INTO t1 VALUES(hex_to_utf16le('00D8')); 41 | SELECT hex(x) FROM t1; 42 | } 43 | } {EDA080} 44 | do_test tkt-3fe89-1.3 { 45 | db eval { 46 | DELETE FROM t1; 47 | INSERT INTO t1 VALUES(hex_to_utf16be('DFFF')); 48 | SELECT hex(x) FROM t1; 49 | } 50 | } {EDBFBF} 51 | do_test tkt-3fe89-1.4 { 52 | db eval { 53 | DELETE FROM t1; 54 | INSERT INTO t1 VALUES(hex_to_utf16le('FFDF')); 55 | SELECT hex(x) FROM t1; 56 | } 57 | } {EDBFBF} 58 | 59 | 60 | finish_test 61 | -------------------------------------------------------------------------------- /test/tkt-4a03edc4c8.test: -------------------------------------------------------------------------------- 1 | # 2009 September 23 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that 14 | # ticket [4a03edc4c8c028c93e9269f64fc5e97f632c1166] has been fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test tkt-4a03ed-1.1 { 21 | db eval { 22 | CREATE TABLE t1( 23 | a INTEGER PRIMARY KEY ON CONFLICT REPLACE, 24 | b UNIQUE ON CONFLICT FAIL 25 | ); 26 | INSERT INTO t1 VALUES(1, 1); 27 | INSERT INTO t1 VALUES(2, 2); 28 | } 29 | catchsql { 30 | BEGIN; 31 | INSERT INTO t1 VALUES(1, 2); 32 | COMMIT; 33 | } 34 | } {1 {column b is not unique}} 35 | do_test tkt-4a03ed-1.2 { 36 | db eval { 37 | PRAGMA integrity_check; 38 | } 39 | } {ok} 40 | do_test tkt-4a03ed-1.3 { 41 | db eval { 42 | SELECT * FROM t1 ORDER BY a; 43 | } 44 | } {1 1 2 2} 45 | 46 | finish_test 47 | -------------------------------------------------------------------------------- /test/tkt-5d863f876e.test: -------------------------------------------------------------------------------- 1 | # 2011 January 15 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket [5d863f876e] has been 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | source $testdir/lock_common.tcl 20 | set ::testprefix tkt-5d863f876e 21 | ifcapable !wal {finish_test ; return } 22 | 23 | do_multiclient_test tn { 24 | do_test $tn.1 { 25 | sql1 { 26 | CREATE TABLE t1(a, b); 27 | CREATE INDEX i1 ON t1(a, b); 28 | INSERT INTO t1 VALUES(1, 2); 29 | INSERT INTO t1 VALUES(3, 4); 30 | PRAGMA journal_mode = WAL; 31 | VACUUM; 32 | PRAGMA journal_mode = DELETE; 33 | } 34 | } {wal delete} 35 | 36 | do_test $tn.2 { 37 | sql2 { SELECT * FROM t1 } 38 | } {1 2 3 4} 39 | 40 | do_test $tn.3 { 41 | sql1 { 42 | INSERT INTO t1 VALUES(5, 6); 43 | PRAGMA journal_mode = WAL; 44 | VACUUM; 45 | PRAGMA journal_mode = DELETE; 46 | } 47 | } {wal delete} 48 | 49 | do_test $tn.2 { 50 | sql2 { PRAGMA integrity_check } 51 | } {ok} 52 | } 53 | 54 | 55 | finish_test 56 | -------------------------------------------------------------------------------- /test/tkt-5e10420e8d.test: -------------------------------------------------------------------------------- 1 | # 2010 August 23 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | 13 | set testdir [file dirname $argv0] 14 | source $testdir/tester.tcl 15 | 16 | do_execsql_test tkt-5e10420e8d.1 { 17 | PRAGMA page_size = 1024; 18 | PRAGMA auto_vacuum = incremental; 19 | 20 | CREATE TABLE t1(x); 21 | CREATE TABLE t2(x); 22 | CREATE TABLE t3(x); 23 | } {} 24 | 25 | do_execsql_test tkt-5e10420e8d.2 { 26 | INSERT INTO t3 VALUES(randomblob(500 + 1024*248)); 27 | INSERT INTO t1 VALUES(randomblob(1500)); 28 | INSERT INTO t2 VALUES(randomblob(500 + 1024*248)); 29 | 30 | DELETE FROM t3; 31 | DELETE FROM t2; 32 | DELETE FROM t1; 33 | } {} 34 | 35 | do_execsql_test tkt-5e10420e8d.3 { 36 | PRAGMA incremental_vacuum(248) 37 | } {} 38 | 39 | do_execsql_test tkt-5e10420e8d.4 { 40 | PRAGMA incremental_vacuum(1) 41 | } {} 42 | 43 | db close 44 | sqlite3 db test.db 45 | 46 | do_execsql_test tkt-5e10420e8d.5 { 47 | PRAGMA integrity_check; 48 | } {ok} 49 | 50 | finish_test 51 | -------------------------------------------------------------------------------- /test/tkt-5ee23731f.test: -------------------------------------------------------------------------------- 1 | # 2009 October 13 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket [5ee23731f15] has been 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test tkt-5ee237-1.1 { 21 | db close 22 | forcedelete test.db 23 | sqlite3 db test.db 24 | db eval { 25 | CREATE TABLE t1(x UNIQUE); 26 | INSERT INTO t1 VALUES(1); 27 | INSERT INTO t1 VALUES(2); 28 | INSERT INTO t1 SELECT x+2 FROM t1; 29 | INSERT INTO t1 SELECT x+4 FROM t1; 30 | INSERT INTO t1 SELECT x+8 FROM t1; 31 | } 32 | db close 33 | sqlite3 db test.db -readonly 1 34 | set rc [catch { 35 | db eval {SELECT rowid, x FROM t1 ORDER BY x} { 36 | db eval {UPDATE t1 SET x=x+1 WHERE rowid=:rowid} 37 | } 38 | } msg] 39 | lappend rc $msg 40 | } {1 {attempt to write a readonly database}} 41 | 42 | finish_test 43 | -------------------------------------------------------------------------------- /test/tkt-752e1646fc.test: -------------------------------------------------------------------------------- 1 | # 2010 April 15 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket [752e1646fc] has been 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test tkt-752e1646fc-1.1 { 21 | execsql { 22 | CREATE TABLE "test" ("letter" VARCHAR(1) PRIMARY KEY, "number" INTEGER NOT NULL); 23 | INSERT INTO "test" ("letter", "number") VALUES('b', 1); 24 | INSERT INTO "test" ("letter", "number") VALUES('a', 2); 25 | INSERT INTO "test" ("letter", "number") VALUES('c', 2); 26 | SELECT DISTINCT "number" FROM (SELECT "letter", "number" FROM "test" ORDER BY "letter", "number" LIMIT 1) AS "test"; 27 | } 28 | } {2} 29 | 30 | finish_test 31 | -------------------------------------------------------------------------------- /test/tkt-78e04e52ea.test: -------------------------------------------------------------------------------- 1 | # 2009 December 8 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # Verify that we can create zero-length tables. 14 | # 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | do_test tkt-78e04-1.0 { 20 | execsql { 21 | CREATE TABLE ""("" UNIQUE); 22 | CREATE TABLE t2(x); 23 | INSERT INTO "" VALUES(1); 24 | INSERT INTO t2 VALUES(2); 25 | SELECT * FROM "", t2; 26 | } 27 | } {1 2} 28 | do_test tkt-78e04-1.1 { 29 | catchsql { 30 | INSERT INTO "" VALUES(1); 31 | } 32 | } {1 {column is not unique}} 33 | do_test tkt-78e04-1.2 { 34 | execsql { 35 | PRAGMA table_info(""); 36 | } 37 | } {0 {} {} 0 {} 0} 38 | do_test tkt-78e04-1.3 { 39 | execsql { 40 | CREATE INDEX i1 ON ""("" COLLATE nocase); 41 | } 42 | } {} 43 | do_test tkt-78e04-1.4 { 44 | execsql { 45 | EXPLAIN QUERY PLAN SELECT * FROM "" WHERE "" LIKE 'abc%'; 46 | } 47 | } {0 0 0 {SCAN TABLE USING COVERING INDEX i1 (~500000 rows)}} 48 | do_test tkt-78e04-1.5 { 49 | execsql { 50 | DROP TABLE ""; 51 | SELECT name FROM sqlite_master; 52 | } 53 | } {t2} 54 | 55 | do_test tkt-78e04-2.1 { 56 | execsql { 57 | CREATE INDEX "" ON t2(x); 58 | EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=5; 59 | } 60 | } {0 0 0 {SEARCH TABLE t2 USING COVERING INDEX (x=?) (~10 rows)}} 61 | do_test tkt-78e04-2.2 { 62 | execsql { 63 | DROP INDEX ""; 64 | EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=2; 65 | } 66 | } {0 0 0 {SCAN TABLE t2 (~100000 rows)}} 67 | 68 | finish_test 69 | -------------------------------------------------------------------------------- /test/tkt-7a31705a7e6.test: -------------------------------------------------------------------------------- 1 | # 2013 February 26 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This file implements regression tests for SQLite library. Specifically, 13 | # it tests that ticket [7a31705a7e6c95d514e6f20a6900f436bbc9fed8] in the 14 | # name resolver has been fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_execsql_test tkt-7a31705a7e6-1.1 { 21 | CREATE TABLE t1 (a INTEGER PRIMARY KEY); 22 | CREATE TABLE t2 (a INTEGER PRIMARY KEY, b INTEGER); 23 | CREATE TABLE t2x (b INTEGER PRIMARY KEY); 24 | SELECT t1.a FROM ((t1 JOIN t2 ON t1.a=t2.a) AS x JOIN t2x ON x.b=t2x.b) as y; 25 | } {} 26 | 27 | -------------------------------------------------------------------------------- /test/tkt-91e2e8ba6f.test: -------------------------------------------------------------------------------- 1 | # 2011 June 23 2 | # 3 | # May you do good and not evil. 4 | # May you find forgiveness for yourself and forgive others. 5 | # May you share freely, never taking more than you give. 6 | # 7 | #*********************************************************************** 8 | # 9 | # This file contains tests for SQLite. Specifically, it tests that SQLite 10 | # does not crash and an error is returned if localhost() fails. This 11 | # is the problem reported by ticket 91e2e8ba6f. 12 | # 13 | 14 | set testdir [file dirname $argv0] 15 | source $testdir/tester.tcl 16 | 17 | set testprefix tkt-91e2e8ba6f 18 | 19 | 20 | do_execsql_test 1.1 { 21 | CREATE TABLE t1(x INTEGER, y REAL); 22 | INSERT INTO t1 VALUES(11, 11); 23 | } {} 24 | 25 | do_execsql_test 1.2 { 26 | SELECT x/10, y/10 FROM t1; 27 | } {1 1.1} 28 | 29 | do_execsql_test 1.3 { 30 | SELECT x/10, y/10 FROM (SELECT * FROM t1); 31 | } {1 1.1} 32 | 33 | do_execsql_test 1.4 { 34 | SELECT x/10, y/10 FROM (SELECT * FROM t1 LIMIT 5 OFFSET 0); 35 | } {1 1.1} 36 | 37 | do_execsql_test 1.5 { 38 | SELECT x/10, y/10 FROM (SELECT * FROM t1 LIMIT 5 OFFSET 0) LIMIT 5 OFFSET 0; 39 | } {1 1.1} 40 | 41 | do_execsql_test 1.6 { 42 | SELECT a.x/10, a.y/10 FROM 43 | (SELECT * FROM t1 LIMIT 5 OFFSET 0) AS a, t1 AS b WHERE a.x = b.x 44 | LIMIT 5 OFFSET 0; 45 | } {1 1.1} 46 | 47 | do_execsql_test 1.7 { 48 | CREATE VIEW v1 AS SELECT * FROM t1 LIMIT 5; 49 | SELECT a.x/10, a.y/10 FROM v1 AS a, t1 AS b WHERE a.x = b.x LIMIT 5 OFFSET 0; 50 | } {1 1.1} 51 | 52 | finish_test 53 | -------------------------------------------------------------------------------- /test/tkt-9d68c883.test: -------------------------------------------------------------------------------- 1 | # 2010 April 10 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file tests that bug 9d68c883132c8e9ffcd5b0c148c990807b5df1b7 12 | # is fixed. 13 | # 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/tester.tcl 17 | 18 | do_test tkt-9d68c88-1.1 { 19 | execsql { 20 | PRAGMA page_size = 1024; 21 | PRAGMA auto_vacuum = 2; 22 | CREATE TABLE t3(x); 23 | CREATE TABLE t4(x); 24 | CREATE TABLE t5(x); 25 | INSERT INTO t5 VALUES(randomblob(1500)); 26 | CREATE TABLE t7(x); 27 | CREATE TABLE t8(x); 28 | } 29 | } {} 30 | 31 | 32 | for {set i 0} {$i < 100} {incr i} { 33 | db close 34 | sqlite3_simulate_device -sectorsize 8192 35 | sqlite3 db test.db -vfs devsym 36 | 37 | do_test tkt-9d68c88-2.$i { 38 | execsql { 39 | BEGIN; 40 | DELETE FROM t5; 41 | INSERT INTO t8 VALUES('hello world'); 42 | } 43 | 44 | sqlite3_memdebug_fail $i -repeat 0 45 | catchsql { DROP TABLE t7; } 46 | sqlite3_memdebug_fail -1 47 | 48 | catchsql { ROLLBACK } 49 | execsql { PRAGMA integrity_check } 50 | } {ok} 51 | } 52 | 53 | finish_test 54 | -------------------------------------------------------------------------------- /test/tkt-b351d95f9.test: -------------------------------------------------------------------------------- 1 | # 2010 September 28 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. Specifically, 12 | # it tests that ticket [b351d95f9cd5ef17e9d9dbae18f5ca8611190001] has been 13 | # resolved. 14 | # 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | source $testdir/lock_common.tcl 19 | source $testdir/malloc_common.tcl 20 | 21 | do_test tkt-b351d95.1 { 22 | execsql { 23 | CREATE table t1(a,b); 24 | INSERT INTO t1 VALUES('name1','This is a test'); 25 | INSERT INTO t1 VALUES('name2','xyz'); 26 | CREATE TABLE t2(x,y); 27 | INSERT INTO t2 SELECT a, CASE b WHEN 'xyz' THEN null ELSE b END FROM t1; 28 | SELECT x, y FROM t2 ORDER BY x; 29 | } 30 | } {name1 {This is a test} name2 {}} 31 | 32 | do_test tkt-b351d95.2 { 33 | execsql { 34 | DELETE FROM t2; 35 | INSERT INTO t2 SELECT a, coalesce(b,a) FROM t1; 36 | SELECT x, y FROM t2 ORDER BY x; 37 | } 38 | } {name1 {This is a test} name2 xyz} 39 | do_test tkt-b351d95.3 { 40 | execsql { 41 | DELETE FROM t2; 42 | INSERT INTO t2 SELECT a, coalesce(b,a) FROM t1; 43 | SELECT x, y BETWEEN 'xy' AND 'xz' FROM t2 ORDER BY x; 44 | } 45 | } {name1 0 name2 1} 46 | 47 | finish_test 48 | -------------------------------------------------------------------------------- /test/tkt-bd484a090c.test: -------------------------------------------------------------------------------- 1 | # 2011 June 21 2 | # 3 | # May you do good and not evil. 4 | # May you find forgiveness for yourself and forgive others. 5 | # May you share freely, never taking more than you give. 6 | # 7 | #*********************************************************************** 8 | # 9 | # This file contains tests for SQLite. Specifically, it tests that SQLite 10 | # does not crash and an error is returned if localhost() fails. This 11 | # is the problem reported by ticket bd484a090c. 12 | # 13 | 14 | set testdir [file dirname $argv0] 15 | source $testdir/tester.tcl 16 | 17 | set testprefix tkt-bd484a090c 18 | 19 | 20 | do_test 1.1 { 21 | lindex [catchsql { SELECT datetime('now', 'localtime') }] 0 22 | } {0} 23 | do_test 1.2 { 24 | lindex [catchsql { SELECT datetime('now', 'utc') }] 0 25 | } {0} 26 | 27 | sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 1 28 | 29 | do_test 2.1 { 30 | catchsql { SELECT datetime('now', 'localtime') } 31 | } {1 {local time unavailable}} 32 | do_test 2.2 { 33 | catchsql { SELECT datetime('now', 'utc') } 34 | } {1 {local time unavailable}} 35 | 36 | sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 0 37 | 38 | finish_test 39 | -------------------------------------------------------------------------------- /test/tkt-c48d99d690.test: -------------------------------------------------------------------------------- 1 | 2 | set testdir [file dirname $argv0] 3 | source $testdir/tester.tcl 4 | 5 | set ::testprefix tkt-c48d99d690 6 | 7 | do_test 1.0 { 8 | execsql { 9 | CREATE TABLE t1(a, b); 10 | CREATE TABLE t2(a, b); 11 | INSERT INTO t1 VALUES('one' , 1); 12 | INSERT INTO t1 VALUES('two' , 5); 13 | INSERT INTO t1 VALUES('two' , 2); 14 | INSERT INTO t1 VALUES('three', 3); 15 | PRAGMA count_changes = 1; 16 | } 17 | } {} 18 | 19 | do_test 1.1 { 20 | execsql { INSERT INTO t2 SELECT * FROM t1 } 21 | } {4} 22 | 23 | do_test 1.2 { execsql VACUUM } {} 24 | 25 | finish_test 26 | 27 | -------------------------------------------------------------------------------- /test/tkt-d11f09d36e.test: -------------------------------------------------------------------------------- 1 | # 2010 June 26 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Test that the bug reported by ticket d11f09d36e7cb0821e01f4 has 13 | # been fixed. 14 | # 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | set a_string_counter 1 20 | proc a_string {n} { 21 | global a_string_counter 22 | incr a_string_counter 23 | string range [string repeat "${a_string_counter}." $n] 1 $n 24 | } 25 | db func a_string a_string 26 | 27 | do_test tkt-d11f09d36e.1 { 28 | execsql { 29 | PRAGMA synchronous = NORMAL; 30 | PRAGMA cache_size = 10; 31 | CREATE TABLE t1(x, y, UNIQUE(x, y)); 32 | BEGIN; 33 | } 34 | for {set i 0} {$i < 10000} {incr i} { 35 | execsql { INSERT INTO t1 VALUES($i, $i) } 36 | } 37 | execsql COMMIT 38 | } {} 39 | do_test tkt-d11f09d36e.2 { 40 | execsql { 41 | BEGIN; 42 | UPDATE t1 set x = x+10000; 43 | ROLLBACK; 44 | } 45 | } {} 46 | do_test tkt-d11f09d36e.3 { 47 | execsql { PRAGMA integrity_check } 48 | } {ok} 49 | do_test tkt-d11f09d36e.4 { 50 | execsql { 51 | SAVEPOINT tr; 52 | UPDATE t1 set x = x+10000; 53 | ROLLBACK TO tr; 54 | RELEASE tr; 55 | } 56 | } {} 57 | do_test tkt-d11f09d36e.5 { 58 | execsql { PRAGMA integrity_check } 59 | } {ok} 60 | 61 | finish_test 62 | 63 | -------------------------------------------------------------------------------- /test/tkt-d635236375.test: -------------------------------------------------------------------------------- 1 | # 2011 August 3 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this file is testing that bug [d63523637517386191d634e] 13 | # has been fixed. 14 | # 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | set ::testprefix tkt-d635236375 20 | 21 | do_test 1.0 { 22 | execsql { 23 | CREATE TABLE t1(id1 INTEGER PRIMARY KEY); 24 | INSERT INTO t1 VALUES(9999); 25 | CREATE TABLE t2(id2 INTEGER PRIMARY KEY); 26 | INSERT INTO t2 VALUES(12345); 27 | INSERT INTO t2 VALUES(54321); 28 | SELECT DISTINCT id1 AS x, id1 AS y FROM t1, t2; 29 | } 30 | } {9999 9999} 31 | do_test 1.1 { 32 | execsql { 33 | SELECT count(*) FROM t1, t2 GROUP BY id1, id1; 34 | } 35 | } {2} 36 | 37 | 38 | finish_test 39 | -------------------------------------------------------------------------------- /test/tkt-fa7bf5ec.test: -------------------------------------------------------------------------------- 1 | # 2011 October 13 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. Specifically, 12 | # it tests that ticket [fa7bf5ec94801e7e2030e41eefe5d9dd96eaacfd] has 13 | # been resolved. 14 | # 15 | # The problem described by this ticket was that the sqlite3ExprCompare() 16 | # function was saying that expressions (x='a') and (x='A') were identical 17 | # because it was using sqlite3StrICmp() instead of strcmp() to compare string 18 | # literals. That was causing the query optimizer for aggregate queries to 19 | # believe that both count() operations were identical, and thus only 20 | # computing the first count() and making a copy of the result for the 21 | # second count(). 22 | # 23 | 24 | set testdir [file dirname $argv0] 25 | source $testdir/tester.tcl 26 | 27 | do_test tkt-fa7bf5ec-1 { 28 | execsql { 29 | CREATE TABLE t1(x); 30 | INSERT INTO t1 VALUES ('a'); 31 | INSERT INTO t1 VALUES ('A'); 32 | INSERT INTO t1 VALUES ('A'); 33 | SELECT count(CASE WHEN x='a' THEN 1 END), 34 | count(CASE WHEN x='A' THEN 1 END) 35 | FROM t1; 36 | } 37 | } {1 2} 38 | 39 | finish_test 40 | -------------------------------------------------------------------------------- /test/tkt1444.test: -------------------------------------------------------------------------------- 1 | # 2005 September 19 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket #1444 has been 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | ifcapable !compound||!view { 21 | finish_test 22 | return 23 | } 24 | 25 | # The use of a VIEW that contained an ORDER BY clause within a UNION ALL 26 | # was causing problems. See ticket #1444. 27 | # 28 | do_test tkt1444-1.1 { 29 | execsql { 30 | CREATE TABLE DemoTable (x INTEGER, TextKey TEXT, DKey Real); 31 | CREATE INDEX DemoTableIdx ON DemoTable (TextKey); 32 | INSERT INTO DemoTable VALUES(9,8,7); 33 | INSERT INTO DemoTable VALUES(1,2,3); 34 | CREATE VIEW DemoView AS SELECT * FROM DemoTable ORDER BY TextKey; 35 | SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView ORDER BY 1; 36 | } 37 | } {1 2 3.0 1 2 3.0 9 8 7.0 9 8 7.0} 38 | do_test tkt1444-1.2 { 39 | execsql { 40 | SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView; 41 | } 42 | } {9 8 7.0 1 2 3.0 1 2 3.0 9 8 7.0} 43 | do_test tkt1444-1.3 { 44 | execsql { 45 | DROP VIEW DemoView; 46 | CREATE VIEW DemoView AS SELECT * FROM DemoTable; 47 | SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView ORDER BY 1; 48 | } 49 | } {1 2 3.0 1 2 3.0 9 8 7.0 9 8 7.0} 50 | do_test tkt1444-1.4 { 51 | execsql { 52 | SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView; 53 | } 54 | } {9 8 7.0 1 2 3.0 9 8 7.0 1 2 3.0} 55 | 56 | finish_test 57 | -------------------------------------------------------------------------------- /test/tkt1501.test: -------------------------------------------------------------------------------- 1 | # 2005 November 16 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket #1501 is 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | ifcapable !compound { 21 | finish_test 22 | return 23 | } 24 | 25 | do_test tkt1501-1.1 { 26 | execsql { 27 | CREATE TABLE t1(a,b); 28 | INSERT INTO t1 VALUES(1,2); 29 | SELECT a, b, 'abc' FROM t1 30 | UNION 31 | SELECT b, a, 'xyz' FROM t1 32 | ORDER BY 2, 3; 33 | } 34 | } {2 1 xyz 1 2 abc} 35 | 36 | finish_test 37 | -------------------------------------------------------------------------------- /test/tkt1512.test: -------------------------------------------------------------------------------- 1 | # 2005 September 19 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket #1512 is 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | ifcapable {!vacuum || !autovacuum} { 21 | finish_test 22 | return 23 | } 24 | if {[db one {PRAGMA auto_vacuum}]} { 25 | finish_test 26 | return 27 | } 28 | 29 | do_test tkt1512-1.1 { 30 | execsql { 31 | CREATE TABLE t1(a,b); 32 | INSERT INTO t1 VALUES(1,2); 33 | INSERT INTO t1 VALUES(3,4); 34 | SELECT * FROM t1 35 | } 36 | } {1 2 3 4} 37 | do_test tkt1512-1.2 { 38 | file size test.db 39 | } {2048} 40 | do_test tkt1512-1.3 { 41 | execsql { 42 | DROP TABLE t1; 43 | } 44 | file size test.db 45 | } {2048} 46 | do_test tkt1512-1.4 { 47 | execsql { 48 | VACUUM; 49 | } 50 | file size test.db 51 | } {1024} 52 | 53 | 54 | finish_test 55 | -------------------------------------------------------------------------------- /test/tkt1514.test: -------------------------------------------------------------------------------- 1 | # 2005 November 16 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket #1514 is 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test tkt1514-1.1 { 21 | catchsql { 22 | CREATE TABLE t1(a,b); 23 | SELECT a FROM t1 WHERE max(b)<10 GROUP BY a; 24 | } 25 | } {1 {misuse of aggregate: max()}} 26 | 27 | finish_test 28 | -------------------------------------------------------------------------------- /test/tkt1536.test: -------------------------------------------------------------------------------- 1 | # 2005 November 24 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket #1536 is 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test tkt1536-1.1 { 21 | execsql { 22 | CREATE TABLE t1( 23 | a INTEGER PRIMARY KEY, 24 | b TEXT 25 | ); 26 | INSERT INTO t1 VALUES(1,'01'); 27 | SELECT typeof(a), typeof(b) FROM t1; 28 | } 29 | } {integer text} 30 | do_test tkt1536-1.2 { 31 | execsql { 32 | INSERT INTO t1(b) SELECT b FROM t1; 33 | SELECT b FROM t1 WHERE rowid=2; 34 | } 35 | } {01} 36 | 37 | 38 | finish_test 39 | -------------------------------------------------------------------------------- /test/tkt1567.test: -------------------------------------------------------------------------------- 1 | # 2005 December 19 2005 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket #1567 is 14 | # fixed. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test tkt1567-1.1 { 21 | execsql { 22 | CREATE TABLE t1(a TEXT PRIMARY KEY); 23 | } 24 | set bigstr abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 25 | for {set i 0} {$i<100} {incr i} { 26 | set x [format %5d [expr $i*2]] 27 | set sql "INSERT INTO t1 VALUES('$x-$bigstr')" 28 | execsql $sql 29 | } 30 | } {} 31 | integrity_check tkt1567-1.2 32 | 33 | do_test tkt1567-1.3 { 34 | execsql { 35 | BEGIN; 36 | UPDATE t1 SET a = a||'x' WHERE rowid%2==0; 37 | } 38 | } {} 39 | do_test tkt1567-1.4 { 40 | catchsql { 41 | UPDATE t1 SET a = CASE WHEN rowid<90 THEN substr(a,1,10) ELSE '9999' END; 42 | } 43 | } {1 {column a is not unique}} 44 | do_test tkt1567-1.5 { 45 | execsql { 46 | COMMIT; 47 | } 48 | } {} 49 | integrity_check tkt1567-1.6 50 | 51 | finish_test 52 | -------------------------------------------------------------------------------- /test/tkt1873.test: -------------------------------------------------------------------------------- 1 | # 2006 June 27 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket #1873 has been 14 | # fixed. 15 | # 16 | # 17 | # $Id: tkt1873.test,v 1.2 2007/10/09 08:29:33 danielk1977 Exp $ 18 | 19 | set testdir [file dirname $argv0] 20 | source $testdir/tester.tcl 21 | 22 | ifcapable !attach { 23 | finish_test 24 | return 25 | } 26 | 27 | forcedelete test2.db test2.db-journal 28 | 29 | do_test tkt1873-1.1 { 30 | execsql { 31 | CREATE TABLE t1(x, y); 32 | ATTACH 'test2.db' AS aux; 33 | CREATE TABLE aux.t2(x, y); 34 | INSERT INTO t1 VALUES(1, 2); 35 | INSERT INTO t1 VALUES(3, 4); 36 | INSERT INTO t2 VALUES(5, 6); 37 | INSERT INTO t2 VALUES(7, 8); 38 | } 39 | } {} 40 | 41 | do_test tkt1873-1.2 { 42 | set rc [catch { 43 | db eval {SELECT * FROM t2 LIMIT 1} { 44 | db eval {DETACH aux} 45 | } 46 | } msg] 47 | list $rc $msg 48 | } {1 {database aux is locked}} 49 | 50 | do_test tkt1873-1.3 { 51 | set rc [catch { 52 | db eval {SELECT * FROM t1 LIMIT 1} { 53 | db eval {DETACH aux} 54 | } 55 | } msg] 56 | list $rc $msg 57 | } {0 {}} 58 | 59 | do_test tkt1873-1.4 { 60 | catchsql { 61 | select * from t2; 62 | } 63 | } {1 {no such table: t2}} 64 | 65 | do_test tkt1873-1.5 { 66 | catchsql { 67 | ATTACH 'test2.db' AS aux; 68 | select * from t2; 69 | } 70 | } {0 {5 6 7 8}} 71 | 72 | finish_test 73 | -------------------------------------------------------------------------------- /test/tkt2213.test: -------------------------------------------------------------------------------- 1 | # 2007 Febuary 05 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket #2213 has been 14 | # fixed. 15 | # 16 | # 17 | # $Id: tkt2213.test,v 1.2 2008/07/12 14:52:20 drh Exp $ 18 | 19 | set testdir [file dirname $argv0] 20 | source $testdir/tester.tcl 21 | 22 | do_test tkt2213-1 { 23 | sqlite3_create_function db 24 | catchsql { 25 | SELECT tkt2213func(tkt2213func('abcd')); 26 | } 27 | } {0 abcd} 28 | 29 | finish_test 30 | -------------------------------------------------------------------------------- /test/tkt2285.test: -------------------------------------------------------------------------------- 1 | # 2005 September 17 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. Specifically. 12 | # it contains tests to verify that ticket #2285 has been fixed. 13 | # 14 | # $Id: tkt2285.test,v 1.2 2008/07/12 14:52:20 drh Exp $ 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | ifcapable !tempdb { 20 | finish_test 21 | return 22 | } 23 | 24 | do_test tkt2285-1.1 { 25 | execsql { 26 | PRAGMA locking_mode = EXCLUSIVE; 27 | } 28 | execsql { 29 | BEGIN; 30 | CREATE TABLE abc(a, b, c); 31 | ROLLBACK; 32 | } 33 | } {} 34 | 35 | do_test tkt2285-1.2 { 36 | execsql { 37 | SELECT * FROM sqlite_master; 38 | } 39 | } {} 40 | 41 | ifcapable tempdb { 42 | do_test tkt2285-2.1 { 43 | execsql { 44 | BEGIN; 45 | CREATE TEMP TABLE abc(a, b, c); 46 | ROLLBACK; 47 | } 48 | } {} 49 | do_test tkt2285-2.2 { 50 | execsql { 51 | SELECT * FROM sqlite_temp_master; 52 | } 53 | } {} 54 | } 55 | 56 | finish_test 57 | -------------------------------------------------------------------------------- /test/tkt2332.test: -------------------------------------------------------------------------------- 1 | # 2007 May 3 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # $Id: tkt2332.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $ 13 | # 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/tester.tcl 17 | 18 | ifcapable !incrblob||!tclvar { 19 | finish_test 20 | return 21 | } 22 | 23 | do_test tkt2332.1 { 24 | execsql { 25 | CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB); 26 | PRAGMA cache_size = 100; 27 | } 28 | } {} 29 | 30 | set ::iKey 1 31 | foreach Len [list 10000 100000 1000000] { 32 | do_test tkt2332.$Len.1 { 33 | set val "[expr rand()][expr rand()][expr rand()][expr rand()][expr rand()]" 34 | set ::blobstr [string range \ 35 | [string repeat $val [expr ($Len/[string length $val])+1]] 0 [expr $Len-1] 36 | ] 37 | 38 | db eval { INSERT INTO blobs VALUES($::iKey, zeroblob($Len)) } 39 | } {} 40 | 41 | do_test tkt2332.$Len.2 { 42 | execsql { 43 | SELECT length(v) FROM blobs WHERE k = $::iKey; 44 | } 45 | } $Len 46 | 47 | do_test tkt2332.$Len.3 { 48 | set ::fd [db incrblob blobs v $::iKey] 49 | puts -nonewline $::fd $::blobstr 50 | close $::fd 51 | } {} 52 | 53 | do_test tkt2332.$Len.4 { 54 | execsql { SELECT length(v) FROM blobs WHERE k = $::iKey; } 55 | } $Len 56 | 57 | do_test tkt2332.$Len.5 { 58 | lindex [execsql {SELECT v FROM blobs WHERE k = $::iKey}] 0 59 | } $::blobstr 60 | 61 | incr ::iKey 62 | } 63 | 64 | # Free memory: 65 | unset ::blobstr 66 | 67 | finish_test 68 | -------------------------------------------------------------------------------- /test/tkt2391.test: -------------------------------------------------------------------------------- 1 | # 2 | # 2007 May 28 3 | # 4 | # The author disclaims copyright to this source code. In place of 5 | # a legal notice, here is a blessing: 6 | # 7 | # May you do good and not evil. 8 | # May you find forgiveness for yourself and forgive others. 9 | # May you share freely, never taking more than you give. 10 | # 11 | #*********************************************************************** 12 | # $Id: tkt2391.test,v 1.1 2007/05/29 12:11:30 danielk1977 Exp $ 13 | 14 | set testdir [file dirname $argv0] 15 | source $testdir/tester.tcl 16 | 17 | do_test tkt2391.1 { 18 | execsql { 19 | CREATE TABLE folders(folderid, parentid, foldername COLLATE binary); 20 | INSERT INTO folders VALUES(1, 3, 'FolderA'); 21 | INSERT INTO folders VALUES(1, 3, 'folderB'); 22 | INSERT INTO folders VALUES(4, 0, 'FolderC'); 23 | } 24 | } {} 25 | 26 | do_test tkt2391.2 { 27 | execsql { 28 | SELECT count(*) FROM folders WHERE foldername < 'FolderC'; 29 | } 30 | } {1} 31 | 32 | do_test tkt2391.3 { 33 | execsql { 34 | SELECT count(*) FROM folders WHERE foldername < 'FolderC' COLLATE nocase; 35 | } 36 | } {2} 37 | 38 | # This demonstrates the bug. Creating the index causes SQLite to ignore 39 | # the "COLLATE nocase" clause and use the default collation sequence 40 | # for column "foldername" instead (happens to be BINARY in this case). 41 | # 42 | do_test tkt2391.4 { 43 | execsql { 44 | CREATE INDEX f_i ON folders(foldername); 45 | SELECT count(*) FROM folders WHERE foldername < 'FolderC' COLLATE nocase; 46 | } 47 | } {2} 48 | 49 | finish_test 50 | -------------------------------------------------------------------------------- /test/tkt2450.test: -------------------------------------------------------------------------------- 1 | # 2007 June 24 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This file is to test that ticket #2450 has been fixed. 13 | # 14 | # $Id: tkt2450.test,v 1.1 2007/06/24 06:32:18 danielk1977 Exp $ 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test tkt2450-1 { 21 | execsql { 22 | CREATE TABLE "t a" ("""cb"""); 23 | INSERT INTO "t a" ("""cb""") VALUES (1); 24 | SELECT """cb""" FROM "t a"; 25 | } 26 | } {1} 27 | 28 | do_test tkt2450-2 { 29 | execsql { 30 | SELECT * FROM "t a"; 31 | } 32 | } {1} 33 | 34 | do_test tkt2450-3 { 35 | execsql { 36 | SELECT "t a".* FROM "t a"; 37 | } 38 | } {1} 39 | 40 | do_test tkt2450-3 { 41 | execsql { 42 | CREATE TABLE t1(a); 43 | INSERT INTO t1 VALUES(2); 44 | SELECT * FROM "t a", t1; 45 | } 46 | } {1 2} 47 | 48 | finish_test 49 | -------------------------------------------------------------------------------- /test/tkt2643.test: -------------------------------------------------------------------------------- 1 | # 2007 Sep 12 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This file is to test that ticket #2643 has been fixed. 13 | # 14 | # $Id: tkt2643.test,v 1.1 2007/09/13 17:54:41 drh Exp $ 15 | # 16 | 17 | # The problem in ticket #2643 has to do with the query optimizer 18 | # making bad assumptions about index cost when data from ANALYZE 19 | # is available. 20 | 21 | set testdir [file dirname $argv0] 22 | source $testdir/tester.tcl 23 | 24 | do_test tkt2643-1.1 { 25 | execsql { 26 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c); 27 | INSERT INTO t1 VALUES(1,2,3); 28 | INSERT INTO t1 VALUES(2,3,4); 29 | ANALYZE; 30 | } 31 | db close 32 | sqlite3 db test.db 33 | execsql { 34 | CREATE INDEX i1 ON t1(c); 35 | SELECT count(*) FROM t1 WHERE c IS NOT NULL 36 | } 37 | } {2} 38 | 39 | finish_test 40 | -------------------------------------------------------------------------------- /test/tkt2832.test: -------------------------------------------------------------------------------- 1 | # 2007 Dec 12 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # This file is to test that ticket #2832 has been fixed. 13 | # 14 | # $Id: tkt2832.test,v 1.5 2009/04/07 14:14:23 danielk1977 Exp $ 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | ifcapable !trigger { finish_test ; return } 21 | 22 | do_test tkt2832-1.1 { 23 | execsql { 24 | CREATE TABLE t1(a PRIMARY KEY); 25 | INSERT INTO t1 VALUES(2); 26 | INSERT INTO t1 VALUES(1); 27 | INSERT INTO t1 VALUES(3); 28 | } 29 | } {} 30 | do_test tkt2832-1.2 { 31 | execsql { 32 | UPDATE OR REPLACE t1 SET a = 1; 33 | SELECT * FROM t1; 34 | } 35 | } {1} 36 | 37 | do_test tkt2832-2.1 { 38 | execsql { 39 | CREATE TABLE t2(a, b); 40 | CREATE TRIGGER t2_t AFTER UPDATE ON t2 BEGIN 41 | DELETE FROM t2 WHERE a = new.a + 1; 42 | END; 43 | INSERT INTO t2 VALUES(1, 2); 44 | INSERT INTO t2 VALUES(2, 3); 45 | } 46 | } {} 47 | do_test tkt2832-2.2 { 48 | execsql { 49 | UPDATE t2 SET b = 5 50 | } 51 | } {} 52 | 53 | do_test tkt2832-3.1 { 54 | execsql { 55 | CREATE TABLE t3(a, b); 56 | CREATE TRIGGER t3_t AFTER DELETE ON t3 BEGIN 57 | DELETE FROM t3 WHERE a = old.a + 1; 58 | END; 59 | INSERT INTO t3 VALUES(1, 2); 60 | INSERT INTO t3 VALUES(2, 3); 61 | } 62 | } {} 63 | do_test tkt2832-3.2 { 64 | execsql { DELETE FROM t3 WHERE 1 } 65 | } {} 66 | 67 | finish_test 68 | -------------------------------------------------------------------------------- /test/tkt2942.test: -------------------------------------------------------------------------------- 1 | # 2008 February 15 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Ticket #2942. 13 | # 14 | # Queries of the form: 15 | # 16 | # SELECT group_concat(x) FROM (SELECT * FROM table ORDER BY 1); 17 | # 18 | # The ORDER BY would be dropped by the query flattener. This used 19 | # to not matter because aggregate functions sum(), min(), max(), avg(), 20 | # and so forth give the same result regardless of the order of inputs. 21 | # But with the addition of the group_concat() function, suddenly the 22 | # order does matter. 23 | # 24 | # $Id: tkt2942.test,v 1.1 2008/02/15 14:33:04 drh Exp $ 25 | # 26 | 27 | set testdir [file dirname $argv0] 28 | source $testdir/tester.tcl 29 | 30 | ifcapable !subquery { 31 | finish_test 32 | return 33 | } 34 | 35 | do_test tkt2942.1 { 36 | execsql { 37 | create table t1(num int); 38 | insert into t1 values (2); 39 | insert into t1 values (1); 40 | insert into t1 values (3); 41 | insert into t1 values (4); 42 | SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY num DESC); 43 | } 44 | } {4,3,2,1} 45 | do_test tkt2942.2 { 46 | execsql { 47 | SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY num); 48 | } 49 | } {1,2,3,4} 50 | do_test tkt2942.3 { 51 | execsql { 52 | SELECT group_concat(num) FROM (SELECT num FROM t1); 53 | } 54 | } {2,1,3,4} 55 | do_test tkt2942.4 { 56 | execsql { 57 | SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY rowid DESC); 58 | } 59 | } {4,3,1,2} 60 | 61 | 62 | finish_test 63 | -------------------------------------------------------------------------------- /test/tkt3121.test: -------------------------------------------------------------------------------- 1 | # 2008 May 16 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # $Id: tkt3121.test,v 1.2 2008/07/12 14:52:21 drh Exp $ 13 | 14 | set testdir [file dirname $argv0] 15 | source $testdir/tester.tcl 16 | 17 | ifcapable !vtab { 18 | finish_test 19 | return 20 | } 21 | 22 | # Register the module 23 | register_echo_module [sqlite3_connection_pointer db] 24 | 25 | do_test vtabD-1.1 { 26 | execsql { 27 | PRAGMA encoding = 'utf16'; 28 | 29 | CREATE TABLE r1(field); 30 | CREATE TABLE r2(col PRIMARY KEY, descr); 31 | 32 | INSERT INTO r1 VALUES('abcd'); 33 | INSERT INTO r2 VALUES('abcd', 'A nice description'); 34 | INSERT INTO r2 VALUES('efgh', 'Another description'); 35 | 36 | CREATE VIRTUAL TABLE t1 USING echo(r1); 37 | CREATE VIRTUAL TABLE t2 USING echo(r2); 38 | } 39 | } {} 40 | 41 | do_test vtabD-1.2 { 42 | execsql { 43 | select 44 | t1.field as Field, 45 | t2.descr as Descr 46 | from t1 inner join t2 on t1.field = t2.col order by t1.field 47 | } 48 | } {abcd {A nice description}} 49 | 50 | finish_test 51 | -------------------------------------------------------------------------------- /test/tkt3424.test: -------------------------------------------------------------------------------- 1 | # 2008 October 06 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # 13 | # $Id: tkt3424.test,v 1.2 2009/06/05 17:09:12 drh Exp $ 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/tester.tcl 17 | 18 | do_test tkt3424-1.1 { 19 | execsql { 20 | CREATE TABLE names(id INTEGER, data TEXT, code TEXT); 21 | INSERT INTO names VALUES(1,'E1','AAA'); 22 | INSERT INTO names VALUES(2,NULL,'BBB'); 23 | 24 | CREATE TABLE orig(code TEXT, data TEXT); 25 | INSERT INTO orig VALUES('AAA','E1'); 26 | INSERT INTO orig VALUES('AAA','E2'); 27 | INSERT INTO orig VALUES('AAA','E3'); 28 | INSERT INTO orig VALUES('AAA','E4'); 29 | INSERT INTO orig VALUES('AAA','E5'); 30 | } 31 | } {} 32 | 33 | do_test tkt3424-1.2 { 34 | execsql { 35 | SELECT * FROM 36 | names LEFT OUTER JOIN orig 37 | ON names.data = orig.data AND names.code = orig.code; 38 | } 39 | } {1 E1 AAA AAA E1 2 {} BBB {} {}} 40 | 41 | do_test tkt3424-1.3 { 42 | execsql { CREATE INDEX udx_orig_code_data ON orig(code, data) } 43 | } {} 44 | 45 | do_test tkt3424-1.4 { 46 | execsql { 47 | SELECT * FROM 48 | names LEFT OUTER JOIN orig 49 | ON names.data = orig.data AND names.code = orig.code; 50 | } 51 | } {1 E1 AAA AAA E1 2 {} BBB {} {}} 52 | 53 | finish_test 54 | -------------------------------------------------------------------------------- /test/tkt3508.test: -------------------------------------------------------------------------------- 1 | # 2008 November 22 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # $Id: tkt3508.test,v 1.5 2009/05/28 01:00:56 drh Exp $ 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/tester.tcl 17 | 18 | do_test tkt3508-1.1 { 19 | catchsql { 20 | CREATE TABLE modificationsTmp ( 21 | SUBSTRATE_HPRD_ID VARCHAR(80), 22 | SUBSTRATE_GENE_SYMBOL VARCHAR(80), 23 | SUBSTRATE_ISOFORM_ID VARCHAR(80), 24 | SUBSTRATE_REFSEQ_ID VARCHAR(80), 25 | SITE INTEGER, 26 | RESIDUE VARCHAR(80), 27 | ENZYME_NAME VARCHAR(80), 28 | ENZYME_HPRD_ID VARCHAR(80), 29 | MODIFICATION_TYPE VARCHAR(80), 30 | EXPERIMENT_TYPE VARCHAR(80), 31 | REFERENCE_ID VARCHAR(80) 32 | ); 33 | select SUBSTRATE_HPRD_ID, count(substrate_refseq_id) as c 34 | from modificationsTmp where c > 1 group by SUBSTRATE_HPRD_ID; 35 | } 36 | } {1 {misuse of aggregate: count()}} 37 | 38 | finish_test 39 | -------------------------------------------------------------------------------- /test/tkt3522.test: -------------------------------------------------------------------------------- 1 | # 2008 December 4 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file is a verification that the bugs identified in ticket 14 | # #3522 have been fixed. 15 | # 16 | # $Id: tkt3522.test,v 1.1 2008/12/05 00:00:07 drh Exp $ 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | do_test tkt3522-1.1 { 22 | db eval { 23 | CREATE TABLE tab4( 24 | col0 INTEGER, 25 | col1 INTEGER, 26 | col2 INTEGER, 27 | col3 INTEGER, 28 | col4 INTEGER 29 | ); 30 | SELECT cor1.* 31 | FROM tab4 AS cor0 32 | JOIN tab4 AS cor1 USING ( col4, col3, col2, col1, col0 ); 33 | } 34 | } {} 35 | do_test tkt3522-1.2 { 36 | db eval { 37 | CREATE TABLE tab1(col0 INTEGER); 38 | CREATE TABLE tab2(col0 INTEGER); 39 | SELECT cor0.* FROM tab1 NATURAL JOIN tab2 AS cor0; 40 | } 41 | } {} 42 | 43 | finish_test 44 | -------------------------------------------------------------------------------- /test/tkt3541.test: -------------------------------------------------------------------------------- 1 | # 2008 December 16 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file is a verification that the bugs identified in ticket 14 | # #3541 have been fixed. 15 | # 16 | # $Id: tkt3541.test,v 1.1 2008/12/15 15:27:52 drh Exp $ 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | do_test tkt3541-1.1 { 22 | db eval { 23 | CREATE TABLE t1(x); 24 | INSERT INTO t1 VALUES(123); 25 | SELECT CASE ~max(x) WHEN min(x) THEN 1 ELSE max(x) END FROM t1; 26 | } 27 | } {123} 28 | do_test tkt3541-1.2 { 29 | db eval { 30 | SELECT CASE NOT max(x) WHEN min(x) THEN 1 ELSE max(x) END FROM t1; 31 | } 32 | } {123} 33 | 34 | 35 | finish_test 36 | -------------------------------------------------------------------------------- /test/tkt3554.test: -------------------------------------------------------------------------------- 1 | # 2008 December 24 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket #3554 has been 14 | # fixed. 15 | # 16 | # $Id: tkt3554.test,v 1.2 2009/06/05 17:09:12 drh Exp $ 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | ifcapable !trigger { 22 | finish_test 23 | return 24 | } 25 | 26 | do_test tkt3544-1.1 { 27 | execsql { 28 | CREATE TABLE test ( obj, t1, t2, PRIMARY KEY(obj, t1, t2) ); 29 | 30 | CREATE TRIGGER test_insert BEFORE INSERT ON test BEGIN 31 | UPDATE test SET t1 = new.t1 32 | WHERE obj = new.obj AND new.t1 < t1 AND new.t2 >= t1; 33 | 34 | UPDATE test SET t2 = new.t2 35 | WHERE obj = new.obj AND new.t2 > t2 AND new.t1 <= t2; 36 | 37 | SELECT RAISE(IGNORE) WHERE EXISTS ( 38 | SELECT obj FROM test 39 | WHERE obj = new.obj AND new.t1 >= t1 AND new.t2 <= t2 40 | ); 41 | END; 42 | } 43 | } {} 44 | 45 | do_test tkt3544-1.2 { 46 | execsql { 47 | INSERT INTO test VALUES('a', 10000, 11000); 48 | SELECT * FROM test; 49 | } 50 | } {a 10000 11000} 51 | 52 | 53 | do_test tkt3544-1.3 { 54 | execsql { 55 | INSERT INTO test VALUES('a', 9000, 10500); 56 | } 57 | execsql { SELECT * FROM test } 58 | } {a 9000 11000} 59 | 60 | do_test tkt3544-1.4 { 61 | execsql { 62 | INSERT INTO test VALUES('a', 10000, 12000); 63 | } 64 | execsql { SELECT * FROM test } 65 | } {a 9000 12000} 66 | 67 | finish_test 68 | -------------------------------------------------------------------------------- /test/tkt3581.test: -------------------------------------------------------------------------------- 1 | # 2008 January 13 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to verify that ticket #3581 has been 14 | # fixed. 15 | # 16 | # $Id: tkt3581.test,v 1.1 2009/01/14 01:10:40 drh Exp $ 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | do_test tkt3581-1.1 { 22 | db eval { 23 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); 24 | INSERT INTO t1 VALUES(0,544,846); 25 | INSERT INTO t1 VALUES(1,345,51); 26 | CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c); 27 | INSERT INTO t2 SELECT * FROM t1; 28 | CREATE INDEX i2 on t2(c); 29 | } 30 | } {} 31 | 32 | do_test tkt3581-1.2 { 33 | db eval { 34 | SELECT a FROM t1 35 | WHERE (b > 45 AND c < 356) 36 | OR b <= 733 37 | OR b >= 557 38 | OR (b >= 614 AND c < 251) 39 | ORDER BY b; 40 | } 41 | } {1 0} 42 | 43 | do_test tkt3581-1.3 { 44 | db eval { 45 | SELECT a FROM t2 46 | WHERE (b > 45 AND c < 356) 47 | OR b <= 733 48 | OR b >= 557 49 | OR (b >= 614 AND c < 251) 50 | ORDER BY b; 51 | } 52 | } {1 0} 53 | 54 | finish_test 55 | -------------------------------------------------------------------------------- /test/tkt3630.test: -------------------------------------------------------------------------------- 1 | # 2009 February 2 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #************************************************************************* 11 | # 12 | # This file checks to make sure the "TEMP" or "TEMPORARY" keyword is 13 | # omitted from the schema of a table that is created using that 14 | # keyword. Ticket #3630. 15 | # 16 | # $Id: tkt3630.test,v 1.1 2009/02/02 18:03:22 drh Exp $ 17 | # 18 | 19 | set testdir [file dirname $argv0] 20 | 21 | source $testdir/tester.tcl 22 | 23 | do_test tkt3630-1 { 24 | db eval { 25 | CREATE TEMP TABLE temp1(a,b,c); 26 | SELECT * FROM sqlite_temp_master WHERE sql GLOB '*TEMP*'; 27 | } 28 | } {} 29 | do_test tkt3630-2 { 30 | db eval { 31 | CREATE TABLE main1(a,b,c); 32 | CREATE TEMP TABLE temp2 AS SELECT * FROM main1; 33 | SELECT * FROM sqlite_temp_master WHERE sql GLOB '*TEMP*'; 34 | } 35 | } {} 36 | 37 | ifcapable altertable { 38 | do_test tkt3630-3 { 39 | db eval { 40 | ALTER TABLE temp2 ADD COLUMN d; 41 | ALTER TABLE temp2 RENAME TO temp2rn; 42 | SELECT name FROM sqlite_temp_master WHERE name LIKE 'temp2%'; 43 | } 44 | } {temp2rn} 45 | } 46 | 47 | finish_test 48 | -------------------------------------------------------------------------------- /test/tkt3731.test: -------------------------------------------------------------------------------- 1 | # 2009 March 18 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # $Id: tkt3731.test,v 1.1 2009/03/17 22:33:01 drh Exp $ 13 | 14 | set testdir [file dirname $argv0] 15 | source $testdir/tester.tcl 16 | ifcapable {!trigger} { 17 | finish_test 18 | return 19 | } 20 | 21 | # The tests in this file were written before SQLite supported recursive 22 | # trigger invocation, and some tests depend on that to pass. So disable 23 | # recursive triggers for this file. 24 | catchsql { pragma recursive_triggers = off } 25 | 26 | do_test tkt3731-1.1 { 27 | execsql { 28 | CREATE TABLE t1(a PRIMARY KEY, b); 29 | CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN 30 | INSERT INTO t1 VALUES(new.a || '+', new.b || '+'); 31 | END; 32 | } 33 | } {} 34 | 35 | do_test tkt3731-1.2 { 36 | execsql { 37 | INSERT INTO t1 VALUES('a', 'b'); 38 | INSERT INTO t1 VALUES('c', 'd'); 39 | SELECT * FROM t1; 40 | } 41 | } {a b a+ b+ c d c+ d+} 42 | 43 | do_test tkt3731-1.3 { 44 | execsql { 45 | DELETE FROM t1; 46 | CREATE TABLE t2(a, b); 47 | INSERT INTO t2 VALUES('e', 'f'); 48 | INSERT INTO t2 VALUES('g', 'h'); 49 | INSERT INTO t1 SELECT * FROM t2; 50 | SELECT * FROM t1; 51 | } 52 | } {e f e+ f+ g h g+ h+} 53 | 54 | integrity_check tkt3731-1.4 55 | 56 | finish_test 57 | -------------------------------------------------------------------------------- /test/tkt3757.test: -------------------------------------------------------------------------------- 1 | # 2009 March 28 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Ticket #3757: The cost functions on the query optimizer for the 13 | # IN operator can be improved. 14 | # 15 | # $Id: tkt3757.test,v 1.1 2009/03/29 00:13:04 drh Exp $ 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | # Evaluate SQL. Return the result set followed by the 21 | # and the number of full-scan steps. 22 | # 23 | proc count_steps {sql} { 24 | set r [db eval $sql] 25 | lappend r scan [db status step] sort [db status sort] 26 | } 27 | 28 | # Construct tables 29 | # 30 | do_test tkt3757-1.1 { 31 | db eval { 32 | CREATE TABLE t1(x INTEGER, y INTEGER, z TEXT); 33 | CREATE INDEX t1i1 ON t1(y,z); 34 | INSERT INTO t1 VALUES(1,2,'three'); 35 | CREATE TABLE t2(a INTEGER, b TEXT); 36 | INSERT INTO t2 VALUES(2, 'two'); 37 | ANALYZE; 38 | SELECT * FROM sqlite_stat1 ORDER BY 1, 2; 39 | } 40 | } {t1 t1i1 {1 1 1} t2 {} 1} 41 | 42 | # Modify statistics in order to make the optimizer then that: 43 | # 44 | # (1) Table T1 has about 250K entries 45 | # (2) There are only about 5 distinct values of T1. 46 | # 47 | # Then run a query with "t1.y IN (SELECT ..)" in the WHERE clause. 48 | # Make sure the index is used. 49 | # 50 | do_test tkt3757-1.2 { 51 | db eval { 52 | DELETE FROM sqlite_stat1; 53 | INSERT INTO sqlite_stat1 VALUES('t1','t1i1','250000 50000 30'); 54 | } 55 | count_steps { 56 | SELECT * FROM t1 WHERE y IN (SELECT a FROM t2) 57 | } 58 | } {1 2 three scan 0 sort 0} 59 | 60 | finish_test 61 | -------------------------------------------------------------------------------- /test/tkt3761.test: -------------------------------------------------------------------------------- 1 | # 2009 March 30 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Ticket #3761: Make sure that an incremental vacuum on an in-memory 13 | # database can be rolled back. 14 | # 15 | # $Id: tkt3761.test,v 1.1 2009/03/31 02:54:40 drh Exp $ 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test tkt3761-1.1 { 21 | db close 22 | sqlite3 db :memory: 23 | db eval { 24 | PRAGMA auto_vacuum=INCREMENTAL; 25 | CREATE TABLE t1(x); 26 | INSERT INTO t1 VALUES(zeroblob(900)); 27 | INSERT INTO t1 VALUES(zeroblob(900)); 28 | INSERT INTO t1 SELECT x FROM t1; 29 | INSERT INTO t1 SELECT x FROM t1; 30 | INSERT INTO t1 SELECT x FROM t1; 31 | INSERT INTO t1 SELECT x FROM t1; 32 | BEGIN; 33 | DELETE FROM t1 WHERE rowid%2; 34 | PRAGMA incremental_vacuum(4); 35 | ROLLBACK; 36 | } 37 | db eval {PRAGMA integrity_check} 38 | } {ok} 39 | 40 | finish_test 41 | -------------------------------------------------------------------------------- /test/tkt3762.test: -------------------------------------------------------------------------------- 1 | # 2009 March 28 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Ticket #3762: Make sure that an incremental vacuum that reduces the 13 | # size of the database file such that if a pointer-map page is eliminated 14 | # it can be correctly rolled back. 15 | # 16 | # That ticket #3762 has been fixed has already been verified by the 17 | # savepoint6.test test script. But this script is simplier and a 18 | # redundant test never hurts. 19 | # 20 | # $Id: tkt3762.test,v 1.1 2009/03/31 00:50:36 drh Exp $ 21 | 22 | set testdir [file dirname $argv0] 23 | source $testdir/tester.tcl 24 | 25 | do_test tkt3762-1.1 { 26 | db eval { 27 | PRAGMA auto_vacuum=INCREMENTAL; 28 | PRAGMA page_size=1024; 29 | PRAGMA cache_size=10; 30 | CREATE TABLE t1(x); 31 | INSERT INTO t1 VALUES(zeroblob(900)); 32 | INSERT INTO t1 VALUES(zeroblob(900)); 33 | INSERT INTO t1 SELECT x FROM t1; 34 | INSERT INTO t1 SELECT x FROM t1; 35 | INSERT INTO t1 SELECT x FROM t1; 36 | INSERT INTO t1 SELECT x FROM t1; 37 | INSERT INTO t1 SELECT x FROM t1; 38 | INSERT INTO t1 SELECT x FROM t1; 39 | INSERT INTO t1 SELECT x FROM t1; 40 | DELETE FROM t1 WHERE rowid>202; 41 | VACUUM; 42 | 43 | BEGIN; 44 | DELETE FROM t1 WHERE rowid IN (10,11,12) ; 45 | PRAGMA incremental_vacuum(10); 46 | UPDATE t1 SET x=zeroblob(900) WHERE rowid BETWEEN 100 AND 110; 47 | INSERT INTO t1 VALUES(zeroblob(39000)); 48 | SELECT count(*) FROM t1; 49 | ROLLBACK; 50 | } 51 | db eval {PRAGMA integrity_check} 52 | } {ok} 53 | 54 | finish_test 55 | -------------------------------------------------------------------------------- /test/tkt3773.test: -------------------------------------------------------------------------------- 1 | # 2009 April 2 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Ticket #3773: Be careful not to over-optimize when a compound 13 | # subquery contains an ORDER BY clause. 14 | # 15 | # 16 | # $Id: tkt3773.test,v 1.1 2009/04/02 16:59:47 drh Exp $ 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | 21 | ifcapable !compound { 22 | finish_test 23 | return 24 | } 25 | 26 | do_test tkt3773-1.1 { 27 | db eval { 28 | CREATE TABLE t1(a,b); 29 | INSERT INTO t1 VALUES(2,1); 30 | INSERT INTO t1 VALUES(33,3); 31 | CREATE TABLE t2(x,y); 32 | INSERT INTO t2 VALUES(123,2); 33 | INSERT INTO t2 VALUES(4,4); 34 | SELECT a FROM ( 35 | SELECT a, b FROM t1 36 | UNION ALL 37 | SELECT x, y FROM t2 38 | ORDER BY 2 39 | ); 40 | } 41 | } {2 123 33 4} 42 | 43 | finish_test 44 | -------------------------------------------------------------------------------- /test/tkt3791.test: -------------------------------------------------------------------------------- 1 | # 2009 April 2 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Ticket #3791: A segfault when inserting into a table that contains 13 | # an arbitrary expression as its default value. 14 | # 15 | # $Id: tkt3791.test,v 1.1 2009/04/08 12:21:31 drh Exp $ 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | do_test tkt3791-1.1 { 21 | db eval { 22 | CREATE TABLE t1(x, y DEFAULT(datetime('now'))); 23 | INSERT INTO t1(x) VALUES(1); 24 | SELECT x, length(y) FROM t1; 25 | } 26 | } {1 19} 27 | 28 | finish_test 29 | -------------------------------------------------------------------------------- /test/tkt3832.test: -------------------------------------------------------------------------------- 1 | # 2009 April 30 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Ticket #3832 13 | # 14 | # A segfault when using a BEFORE trigger on an INSERT and inserting 15 | # a NULL into the INTEGER PRIMARY KEY. 16 | # 17 | # $Id: tkt3832.test,v 1.1 2009/05/01 02:08:04 drh Exp $ 18 | 19 | set testdir [file dirname $argv0] 20 | source $testdir/tester.tcl 21 | ifcapable {!trigger} { 22 | finish_test 23 | return 24 | } 25 | 26 | 27 | do_test tkt3832-1.1 { 28 | db eval { 29 | CREATE TABLE t1(a INT, b INTEGER PRIMARY KEY); 30 | CREATE TABLE log(x); 31 | CREATE TRIGGER t1r1 BEFORE INSERT ON t1 BEGIN 32 | INSERT INTO log VALUES(new.b); 33 | END; 34 | INSERT INTO t1 VALUES(NULL,5); 35 | INSERT INTO t1 SELECT b, a FROM t1 ORDER BY b; 36 | SELECT rowid, * FROM t1; 37 | SELECT rowid, * FROM log; 38 | } 39 | } {5 {} 5 6 5 6 1 5 2 -1} 40 | 41 | finish_test 42 | -------------------------------------------------------------------------------- /test/tkt3838.test: -------------------------------------------------------------------------------- 1 | # 2009 May 5 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Ticket #3838 13 | # 14 | # The ticket reports that the encoding is UTF8 on the DEFAULT VALUE of 15 | # a column added using ALTER TABLE even when the database is UTF16. 16 | # Verify that this has been fixed. 17 | # 18 | # $Id: tkt3838.test,v 1.1 2009/05/05 12:54:50 drh Exp $ 19 | 20 | set testdir [file dirname $argv0] 21 | source $testdir/tester.tcl 22 | 23 | ifcapable !altertable { 24 | finish_test 25 | return 26 | } 27 | 28 | do_realnum_test tkt3838-1.1 { 29 | db eval { 30 | PRAGMA encoding=UTF16; 31 | CREATE TABLE t1(x); 32 | INSERT INTO t1 VALUES(1); 33 | ALTER TABLE t1 ADD COLUMN b INTEGER DEFAULT '999'; 34 | ALTER TABLE t1 ADD COLUMN c REAL DEFAULT '9e99'; 35 | ALTER TABLE t1 ADD COLUMN d TEXT DEFAULT 'xyzzy'; 36 | UPDATE t1 SET x=x+1; 37 | SELECT * FROM t1; 38 | } 39 | } {2 999 9e+99 xyzzy} 40 | 41 | ifcapable trigger { 42 | do_test tkt3838-1.2 { 43 | db eval { 44 | CREATE TABLE log(y); 45 | CREATE TRIGGER r1 AFTER INSERT ON T1 BEGIN 46 | INSERT INTO log VALUES(new.x); 47 | END; 48 | INSERT INTO t1(x) VALUES(123); 49 | ALTER TABLE T1 RENAME TO XYZ2; 50 | INSERT INTO xyz2(x) VALUES(456); 51 | ALTER TABLE xyz2 RENAME TO pqr3; 52 | INSERT INTO pqr3(x) VALUES(789); 53 | SELECT * FROM log; 54 | } 55 | } {123 456 789} 56 | } 57 | 58 | finish_test 59 | -------------------------------------------------------------------------------- /test/tkt3841.test: -------------------------------------------------------------------------------- 1 | # 2009 May 7 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Ticket #3841 13 | # 14 | # The sqlite3_aggregate_count() is not being reset when an aggregate 15 | # functio is used in a correlated subquery. 16 | # 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | ifcapable !subquery { 21 | finish_test 22 | return 23 | } 24 | 25 | do_test tkt3841.1 { 26 | execsql { 27 | CREATE TABLE table2 (key TEXT, x TEXT); 28 | CREATE TABLE list (key TEXT, value TEXT); 29 | 30 | INSERT INTO table2 VALUES ("a", "alist"); 31 | INSERT INTO table2 VALUES ("b", "blist"); 32 | INSERT INTO list VALUES ("a", 1); 33 | INSERT INTO list VALUES ("a", 2); 34 | INSERT INTO list VALUES ("a", 3); 35 | INSERT INTO list VALUES ("b", 4); 36 | INSERT INTO list VALUES ("b", 5); 37 | INSERT INTO list VALUES ("b", 6); 38 | 39 | SELECT 40 | table2.x, 41 | (SELECT group_concat(list.value) 42 | FROM list 43 | WHERE list.key = table2.key) 44 | FROM table2; 45 | } 46 | } {alist 1,2,3 blist 4,5,6} 47 | 48 | finish_test 49 | -------------------------------------------------------------------------------- /test/tkt3871.test: -------------------------------------------------------------------------------- 1 | 2 | set testdir [file dirname $argv0] 3 | source $testdir/tester.tcl 4 | 5 | ifcapable !vtab { 6 | finish_test 7 | return 8 | } 9 | 10 | register_echo_module [sqlite3_connection_pointer db] 11 | 12 | do_test tkt3871-1.1 { 13 | execsql { 14 | BEGIN; 15 | CREATE TABLE t1(a PRIMARY KEY, b UNIQUE); 16 | } 17 | for {set i 0} {$i < 500} {incr i} { 18 | execsql { INSERT INTO t1 VALUES($i, $i*$i) } 19 | } 20 | execsql COMMIT 21 | execsql { 22 | CREATE VIRTUAL TABLE e USING echo(t1); 23 | SELECT count(*) FROM e; 24 | } 25 | } {500} 26 | 27 | do_test tkt3871-1.2 { 28 | execsql { SELECT * FROM e WHERE a = 1 OR a = 2 } 29 | } {1 1 2 4} 30 | do_test tkt3871-1.3 { 31 | set echo_module "" 32 | execsql { SELECT * FROM e WHERE a = 1 OR a = 2 } 33 | set echo_module 34 | } [list \ 35 | xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 1 \ 36 | xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 2 \ 37 | ] 38 | 39 | do_test tkt3871-1.4 { 40 | execsql { SELECT * FROM e WHERE a = 1 OR a = 2 OR b = 9 } 41 | } {1 1 2 4 3 9} 42 | do_test tkt3871-1.5 { 43 | set echo_module "" 44 | execsql { SELECT * FROM e WHERE a = 1 OR a = 2 OR b = 9 } 45 | set echo_module 46 | } [list \ 47 | xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 1 \ 48 | xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 2 \ 49 | xFilter {SELECT rowid, * FROM 't1' WHERE b = ?} 9 50 | ] 51 | 52 | 53 | finish_test 54 | -------------------------------------------------------------------------------- /test/tkt3879.test: -------------------------------------------------------------------------------- 1 | # 2009 May 25 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Tests to verify ticket #3879 is fixed. 13 | # 14 | # $Id: tkt3879.test,v 1.2 2009/06/05 17:09:12 drh Exp $ 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | do_test tkt3879.1.1 { 20 | execsql { 21 | CREATE TABLE t1 (a PRIMARY KEY, b); 22 | INSERT INTO t1 VALUES ('w', 1); 23 | INSERT INTO t1 VALUES ('z', -1); 24 | 25 | CREATE TABLE t2 (m INTEGER PRIMARY KEY, n, a, p); 26 | INSERT INTO t2 VALUES (25, 13, 'w', 1); 27 | INSERT INTO t2 VALUES (26, 25, 'z', 153); 28 | INSERT INTO t2 VALUES (27, 25, 'z', 68); 29 | 30 | CREATE TABLE t3 (m); 31 | INSERT INTO t3 VALUES (25); 32 | } 33 | } {} 34 | 35 | do_test tkt3879.1.2 { 36 | execsql { 37 | SELECT 111, t1.b*123 38 | FROM t3, t2 AS j0, t2 AS j1, t1 39 | WHERE j0.m=t3.m AND t1.a=j0.a AND j1.n=j0.m; 40 | } 41 | } {111 123 111 123} 42 | 43 | do_test tkt3879.1.3 { 44 | execsql { 45 | SELECT 222, t1.b*123 46 | FROM t3, t2 AS j0, t2 AS j1, t1 47 | WHERE j0.m=t3.m AND t1.a=j0.a AND j1.n=j0.m 48 | ORDER BY t1.b; 49 | } 50 | } {222 123 222 123} 51 | 52 | finish_test 53 | -------------------------------------------------------------------------------- /test/tkt3911.test: -------------------------------------------------------------------------------- 1 | # 2009 June 11 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Tests to verify ticket #3911 is fixed. 13 | # 14 | # $Id: tkt3911.test,v 1.1 2009/06/12 03:27:28 drh Exp $ 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | do_test tkt3911.1 { 20 | execsql { 21 | CREATE TABLE t1(a,b); 22 | INSERT INTO t1 VALUES(1,2); 23 | INSERT INTO t1 VALUES(11,12); 24 | 25 | CREATE TABLE t2(b,c); 26 | INSERT INTO t2 VALUES(2,3); 27 | INSERT INTO t2 VALUES(22,23); 28 | 29 | SELECT * FROM t1 JOIN t2 USING(b); 30 | } 31 | } {1 2 3} 32 | do_test tkt3911.2 { 33 | db eval { 34 | SELECT * FROM t1 JOIN (t2) AS x USING (b); 35 | } 36 | } {1 2 3} 37 | do_test tkt3911.3 { 38 | db eval { 39 | SELECT * FROM t1 JOIN (SELECT * FROM t2) AS x USING (b); 40 | } 41 | } {1 2 3} 42 | 43 | do_test tkt3911.4 { 44 | db eval { 45 | CREATE TABLE t3(m,a); 46 | INSERT INTO t3 VALUES('one',1); 47 | INSERT INTO t3 VALUES('two',2); 48 | 49 | SELECT * FROM t3 JOIN (SELECT * FROM t1 NATURAL JOIN t2) AS x USING(a); 50 | } 51 | } {one 1 2 3} 52 | do_test tkt3911.5 { 53 | db eval { 54 | SELECT * FROM t3 JOIN (SELECT * FROM t1 JOIN t2 USING (b)) AS x USING(a); 55 | } 56 | } {one 1 2 3} 57 | 58 | finish_test 59 | -------------------------------------------------------------------------------- /test/tkt3929.test: -------------------------------------------------------------------------------- 1 | # 2009 June 23 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Tests to verify ticket #3929 is fixed. 13 | # 14 | # $Id: tkt3929.test,v 1.1 2009/06/23 11:53:09 danielk1977 Exp $ 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | ifcapable {!trigger} { 19 | finish_test 20 | return 21 | } 22 | 23 | do_test tkt3929-1.0 { 24 | execsql { 25 | PRAGMA page_size = 1024; 26 | CREATE TABLE t1(a, b); 27 | CREATE INDEX i1 ON t1(a, b); 28 | CREATE TRIGGER t1_t1 AFTER INSERT ON t1 BEGIN 29 | UPDATE t1 SET b = 'value: ' || a WHERE t1.rowid = new.rowid; 30 | END; 31 | } 32 | } {} 33 | 34 | do_test tkt3929-1.1 { 35 | execsql { 36 | INSERT INTO t1(a) VALUES(1); 37 | INSERT INTO t1(a) VALUES(2); 38 | SELECT * FROM t1; 39 | } 40 | } {1 {value: 1} 2 {value: 2}} 41 | 42 | # Before it was fixed, the following provoked the bug, causing either an 43 | # assertion failure or a "database is malformed" error. 44 | # 45 | do_test tkt3930-1.2 { 46 | for {set i 3} {$i < 100} {incr i} { 47 | execsql { INSERT INTO t1(a) VALUES($i) } 48 | } 49 | } {} 50 | 51 | integrity_check tkt3930-1.3 52 | finish_test 53 | 54 | -------------------------------------------------------------------------------- /test/tkt3997.test: -------------------------------------------------------------------------------- 1 | # 2001 September 15 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # 12 | # Tests to make sure #3997 is fixed. 13 | # 14 | # $Id: tkt3997.test,v 1.1 2009/07/28 13:30:31 danielk1977 Exp $ 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | proc reverse {lhs rhs} { 20 | return [string compare $rhs $lhs] 21 | } 22 | proc usual {lhs rhs} { 23 | return [string compare $lhs $rhs] 24 | } 25 | 26 | db collate reverse reverse 27 | db collate usual usual 28 | 29 | do_test tkt3997-1.1 { 30 | execsql { 31 | create table mytext(name BLOB); 32 | INSERT INTO mytext VALUES('abc'); 33 | INSERT INTO mytext VALUES('acd'); 34 | INSERT INTO mytext VALUES('afe'); 35 | } 36 | } {} 37 | do_test tkt3997-1.2 { 38 | execsql { 39 | SELECT name 40 | FROM mytext 41 | ORDER BY name COLLATE reverse 42 | } 43 | } {afe acd abc} 44 | do_test tkt3997-1.3 { 45 | execsql { 46 | SELECT name 47 | FROM (SELECT name FROM mytext) 48 | ORDER BY name COLLATE reverse 49 | } 50 | } {afe acd abc} 51 | 52 | do_test tkt3997-2.1 { 53 | execsql { 54 | CREATE TABLE mytext2(name COLLATE reverse); 55 | INSERT INTO mytext2 SELECT name FROM mytext; 56 | } 57 | } {} 58 | do_test tkt3997-2.2 { 59 | execsql { 60 | SELECT name 61 | FROM (SELECT name FROM mytext2) 62 | ORDER BY name 63 | } 64 | } {afe acd abc} 65 | do_test tkt3997-2.3 { 66 | execsql { 67 | SELECT name 68 | FROM (SELECT name FROM mytext2) 69 | ORDER BY name COLLATE usual 70 | } 71 | } {abc acd afe} 72 | 73 | finish_test 74 | -------------------------------------------------------------------------------- /test/transitive1.test: -------------------------------------------------------------------------------- 1 | # 2013 April 17 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #************************************************************************* 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this script is testing of transitive WHERE clause constraints 13 | # 14 | 15 | set testdir [file dirname $argv0] 16 | source $testdir/tester.tcl 17 | 18 | do_execsql_test transitive1-100 { 19 | CREATE TABLE t1(a TEXT, b TEXT, c TEXT COLLATE NOCASE); 20 | INSERT INTO t1 VALUES('abc','abc','Abc'); 21 | INSERT INTO t1 VALUES('def','def','def'); 22 | INSERT INTO t1 VALUES('ghi','ghi','GHI'); 23 | CREATE INDEX t1a1 ON t1(a); 24 | CREATE INDEX t1a2 ON t1(a COLLATE nocase); 25 | 26 | SELECT * FROM t1 WHERE a=b AND c=b AND c='DEF'; 27 | } {def def def} 28 | do_execsql_test transitive1-110 { 29 | SELECT * FROM t1 WHERE a=b AND c=b AND c>='DEF' ORDER BY +a; 30 | } {def def def ghi ghi GHI} 31 | do_execsql_test transitive1-120 { 32 | SELECT * FROM t1 WHERE a=b AND c=b AND c<='DEF' ORDER BY +a; 33 | } {abc abc Abc def def def} 34 | 35 | do_execsql_test transitive1-200 { 36 | CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT); 37 | INSERT INTO t2 VALUES(100,100,100); 38 | INSERT INTO t2 VALUES(20,20,20); 39 | INSERT INTO t2 VALUES(3,3,3); 40 | 41 | SELECT * FROM t2 WHERE a=b AND c=b AND c=20; 42 | } {20 20 20} 43 | do_execsql_test transitive1-210 { 44 | SELECT * FROM t2 WHERE a=b AND c=b AND c>=20 ORDER BY +a; 45 | } {3 3 3 20 20 20} 46 | do_execsql_test transitive1-220 { 47 | SELECT * FROM t2 WHERE a=b AND c=b AND c<=20 ORDER BY +a; 48 | } {20 20 20 100 100 100} 49 | 50 | finish_test 51 | -------------------------------------------------------------------------------- /test/trigger5.test: -------------------------------------------------------------------------------- 1 | # The author disclaims copyright to this source code. In place of 2 | # a legal notice, here is a blessing: 3 | # 4 | # May you do good and not evil. 5 | # May you find forgiveness for yourself and forgive others. 6 | # May you share freely, never taking more than you give. 7 | # 8 | #*********************************************************************** 9 | # 10 | # This file tests the triggers of views. 11 | # 12 | 13 | set testdir [file dirname $argv0] 14 | source $testdir/tester.tcl 15 | ifcapable {!trigger} { 16 | finish_test 17 | return 18 | } 19 | 20 | # Ticket #844 21 | # 22 | do_test trigger5-1.1 { 23 | execsql { 24 | CREATE TABLE Item( 25 | a integer PRIMARY KEY NOT NULL , 26 | b double NULL , 27 | c int NOT NULL DEFAULT 0 28 | ); 29 | CREATE TABLE Undo(UndoAction TEXT); 30 | INSERT INTO Item VALUES (1,38205.60865,340); 31 | CREATE TRIGGER trigItem_UNDO_AD AFTER DELETE ON Item FOR EACH ROW 32 | BEGIN 33 | INSERT INTO Undo SELECT 'INSERT INTO Item (a,b,c) VALUES (' 34 | || coalesce(old.a,'NULL') || ',' || quote(old.b) || ',' || old.c || ');'; 35 | END; 36 | DELETE FROM Item WHERE a = 1; 37 | SELECT * FROM Undo; 38 | } 39 | } {{INSERT INTO Item (a,b,c) VALUES (1,38205.60865,340);}} 40 | 41 | integrity_check trigger5-99.9 42 | 43 | finish_test 44 | -------------------------------------------------------------------------------- /test/trigger8.test: -------------------------------------------------------------------------------- 1 | # 2006 February 27 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # This file implements tests to make sure abusively large triggers 14 | # (triggers with 100s or 1000s of statements) work. 15 | # 16 | # $Id: trigger8.test,v 1.2 2008/09/17 16:14:10 danielk1977 Exp $ 17 | 18 | set testdir [file dirname $argv0] 19 | source $testdir/tester.tcl 20 | ifcapable {!trigger} { 21 | finish_test 22 | return 23 | } 24 | 25 | # Set variable $nStatement to the number of statements to include in the 26 | # body of the trigger. On a workstation with virtually unlimited memory, 27 | # use 10000. But on symbian, which allows each application at most a 32MB 28 | # heap, use 1000. 29 | # 30 | set nStatement 10000 31 | if {$tcl_platform(platform) == "symbian"} { 32 | set nStatement 1000 33 | } 34 | 35 | set nStatement 5 36 | do_test trigger8-1.1 { 37 | execsql { 38 | CREATE TABLE t1(x); 39 | CREATE TABLE t2(y); 40 | } 41 | set sql "CREATE TRIGGER r${nStatement} AFTER INSERT ON t1 BEGIN\n" 42 | for {set i 0} {$i<$nStatement} {incr i} { 43 | append sql " INSERT INTO t2 VALUES($i);\n" 44 | } 45 | append sql "END;" 46 | execsql $sql 47 | execsql { 48 | INSERT INTO t1 VALUES(5); 49 | SELECT count(*) FROM t2; 50 | } 51 | } $nStatement 52 | 53 | finish_test 54 | -------------------------------------------------------------------------------- /test/varint.test: -------------------------------------------------------------------------------- 1 | # 2001 September 15 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this script is variable-length integer encoding scheme. 13 | # 14 | # $Id: varint.test,v 1.1 2004/05/18 15:57:42 drh Exp $ 15 | 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | # Test reading and writing of varints. 21 | # 22 | set cnt 0 23 | foreach start {0 100 10000 1000000 0x10000000} { 24 | foreach mult {1 0x10 0x100 0x1000 0x10000 0x100000 0x1000000 0x10000000} { 25 | foreach incr {1 500 10000 50000000} { 26 | incr cnt 27 | do_test varint-1.$cnt { 28 | btree_varint_test $start $mult 5000 $incr 29 | } {} 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/veryquick.test: -------------------------------------------------------------------------------- 1 | # 2 | # May you do good and not evil. 3 | # May you find forgiveness for yourself and forgive others. 4 | # May you share freely, never taking more than you give. 5 | # 6 | #*********************************************************************** 7 | # This file runs all the tests run by quick.test except for those related 8 | # to malloc or IO error simulation. With these tests omitted, the overall 9 | # run time is reduced by about 75%. 10 | # 11 | # $Id: veryquick.test,v 1.9 2008/07/12 14:52:21 drh Exp $ 12 | 13 | set testdir [file dirname $argv0] 14 | source $testdir/permutations.test 15 | 16 | run_test_suite veryquick 17 | 18 | finish_test 19 | 20 | -------------------------------------------------------------------------------- /test/vtabE.test: -------------------------------------------------------------------------------- 1 | # 2009 November 23 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # 13 | # The focus of this file making sure the register cache logic works 14 | # correctly with virtual tables. Ticket [16fbf14cb2]. 15 | # 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | ifcapable !vtab { 21 | finish_test 22 | return 23 | } 24 | 25 | register_tclvar_module [sqlite3_connection_pointer db] 26 | 27 | unset -nocomplain vtabE 28 | set vtabE(vtabE1) 11 29 | set vtabE(vtabE2) 22 30 | unset -nocomplain vtabE1 31 | set vtabE1(w) x 32 | set vtabE1(y) z 33 | unset -nocomplain vtabE2 34 | set vtabE2(a) b 35 | set vtabE2(c) d 36 | 37 | do_test vtabE-1 { 38 | db eval { 39 | CREATE VIRTUAL TABLE t1 USING tclvar; 40 | CREATE VIRTUAL TABLE t2 USING tclvar; 41 | CREATE TABLE t3(a INTEGER PRIMARY KEY, b); 42 | SELECT t1.*, t2.*, abs(t3.b + abs(t2.value + abs(t1.value))) 43 | FROM t1 LEFT JOIN t2 ON t2.name = t1.arrayname 44 | LEFT JOIN t3 ON t3.a=t2.value 45 | WHERE t1.name = 'vtabE' 46 | ORDER BY t1.value, t2.value; 47 | } 48 | } {vtabE vtabE1 11 vtabE1 w x {} vtabE vtabE1 11 vtabE1 y z {} vtabE vtabE2 22 vtabE2 a b {} vtabE vtabE2 22 vtabE2 c d {}} 49 | -------------------------------------------------------------------------------- /test/vtabF.test: -------------------------------------------------------------------------------- 1 | # 2011 Aug 1 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. 12 | # This file checks to make sure IS NOT NULL constraints work on 13 | # virtual tables. 14 | # 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | ifcapable !vtab||!schema_pragmas { finish_test ; return } 20 | 21 | # Register the echo module 22 | register_echo_module [sqlite3_connection_pointer db] 23 | 24 | do_test vtabE-1.1 { 25 | execsql { 26 | CREATE TABLE t1(a, b); 27 | CREATE INDEX i1 ON t1(a); 28 | CREATE INDEX i2 ON t1(b); 29 | INSERT INTO t1 VALUES(10,110); 30 | INSERT INTO t1 VALUES(11,111); 31 | INSERT INTO t1 SELECT a+2, b+2 FROM t1; 32 | INSERT INTO t1 SELECT null, b+4 FROM t1; 33 | INSERT INTO t1 SELECT null, b+8 FROM t1; 34 | INSERT INTO t1 SELECT null, b+16 FROM t1; 35 | ANALYZE; 36 | CREATE VIRTUAL TABLE tv1 USING echo(t1); 37 | SELECT b FROM t1 WHERE a IS NOT NULL; 38 | } 39 | } {110 111 112 113} 40 | do_test vtabE-1.2 { 41 | execsql {SELECT b FROM tv1 WHERE a IS NOT NULL} 42 | } {110 111 112 113} 43 | 44 | 45 | finish_test 46 | -------------------------------------------------------------------------------- /test/walshared.test: -------------------------------------------------------------------------------- 1 | # 2010 August 2 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. The 12 | # focus of this file is testing the operation of the library in 13 | # "PRAGMA journal_mode=WAL" mode with shared-cache turned on. 14 | # 15 | 16 | set testdir [file dirname $argv0] 17 | source $testdir/tester.tcl 18 | 19 | ifcapable !wal {finish_test ; return } 20 | 21 | db close 22 | set ::enable_shared_cache [sqlite3_enable_shared_cache 1] 23 | 24 | sqlite3 db test.db 25 | sqlite3 db2 test.db 26 | 27 | do_test walshared-1.0 { 28 | execsql { 29 | PRAGMA cache_size = 10; 30 | PRAGMA journal_mode = WAL; 31 | CREATE TABLE t1(a PRIMARY KEY, b UNIQUE); 32 | INSERT INTO t1 VALUES(randomblob(100), randomblob(200)); 33 | } 34 | } {wal} 35 | 36 | do_test walshared-1.1 { 37 | execsql { 38 | BEGIN; 39 | INSERT INTO t1 VALUES(randomblob(100), randomblob(200)); 40 | INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; 41 | INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; 42 | INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; 43 | } 44 | } {} 45 | 46 | do_test walshared-1.2 { 47 | catchsql { PRAGMA wal_checkpoint } 48 | } {1 {database table is locked}} 49 | 50 | do_test walshared-1.3 { 51 | catchsql { PRAGMA wal_checkpoint } db2 52 | } {1 {database table is locked}} 53 | 54 | do_test walshared-1.4 { 55 | execsql { COMMIT } 56 | execsql { PRAGMA integrity_check } db2 57 | } {ok} 58 | 59 | 60 | 61 | sqlite3_enable_shared_cache $::enable_shared_cache 62 | finish_test 63 | 64 | -------------------------------------------------------------------------------- /test/where8m.test: -------------------------------------------------------------------------------- 1 | # 2008 December 23 2 | # 3 | # The author disclaims copyright to this source code. In place of 4 | # a legal notice, here is a blessing: 5 | # 6 | # May you do good and not evil. 7 | # May you find forgiveness for yourself and forgive others. 8 | # May you share freely, never taking more than you give. 9 | # 10 | #*********************************************************************** 11 | # This file implements regression tests for SQLite library. The focus 12 | # is testing of where.c. More specifically, the focus is the optimization 13 | # of WHERE clauses that feature the OR operator. 14 | # 15 | # $Id: where8m.test,v 1.3 2009/06/05 17:09:12 drh Exp $ 16 | 17 | set testdir [file dirname $argv0] 18 | source $testdir/tester.tcl 19 | 20 | source $testdir/malloc_common.tcl 21 | 22 | do_malloc_test where8m-1 -sqlprep { 23 | CREATE TABLE t1(a, b, c); 24 | CREATE INDEX i1 ON t1(a); 25 | CREATE INDEX i2 ON t1(b); 26 | } -sqlbody { 27 | SELECT c FROM t1 28 | WHERE 29 | a = 2 OR b = 'three' OR a = 4 OR b = 'five' OR a = 6 OR 30 | b = 'seven' OR a = 8 OR b = 'nine' OR a = 10 31 | ORDER BY rowid; 32 | 33 | SELECT c FROM t1 WHERE 34 | a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6; 35 | 36 | SELECT c FROM t1 WHERE 37 | a BETWEEN 1 AND 3 AND b < 5 AND b > 2 AND c = 4; 38 | } 39 | 40 | do_malloc_test where8m-2 -tclprep { 41 | db eval { 42 | BEGIN; 43 | CREATE TABLE t1(a, b, c); 44 | CREATE INDEX i1 ON t1(a); 45 | CREATE INDEX i2 ON t1(b); 46 | } 47 | for {set i 0} {$i < 1000} {incr i} { 48 | set ii [expr $i*$i] 49 | set iii [expr $i*$i] 50 | db eval { INSERT INTO t1 VALUES($i, $ii, $iii) } 51 | } 52 | db eval COMMIT 53 | } -sqlbody { 54 | SELECT count(*) FROM t1 WHERE a BETWEEN 5 AND 995 OR b BETWEEN 5 AND 900000; 55 | } 56 | 57 | finish_test 58 | -------------------------------------------------------------------------------- /tool/build-shell.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script demonstrates how to do a full-featured build of the sqlite3 4 | # command-line shell on Linux. 5 | # 6 | # SQLite source code should be in a sibling directory named "sqlite". For 7 | # example, put SQLite sources in ~/sqlite/sqlite and run this script from 8 | # ~/sqlite/bld. There should be an appropriate Makefile in the current 9 | # directory as well. 10 | # 11 | make sqlite3.c 12 | gcc -o sqlite3 -g -Os -I. \ 13 | -DSQLITE_THREADSAFE=0 \ 14 | -DSQLITE_ENABLE_VFSTRACE \ 15 | -DSQLITE_ENABLE_STAT3 \ 16 | -DSQLITE_ENABLE_FTS4 \ 17 | -DSQLITE_ENABLE_RTREE \ 18 | -DHAVE_READLINE \ 19 | -DHAVE_USLEEP=1 \ 20 | ../sqlite/src/shell.c \ 21 | ../sqlite/src/test_vfstrace.c \ 22 | sqlite3.c -ldl -lreadline -lncurses 23 | -------------------------------------------------------------------------------- /tool/diffdb.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** A utility for printing the differences between two SQLite database files. 3 | */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | #define PAGESIZE 1024 14 | static int db1 = -1; 15 | static int db2 = -1; 16 | 17 | int main(int argc, char **argv){ 18 | int iPg; 19 | unsigned char a1[PAGESIZE], a2[PAGESIZE]; 20 | if( argc!=3 ){ 21 | fprintf(stderr,"Usage: %s FILENAME FILENAME\n", argv[0]); 22 | exit(1); 23 | } 24 | db1 = open(argv[1], O_RDONLY); 25 | if( db1<0 ){ 26 | fprintf(stderr,"%s: can't open %s\n", argv[0], argv[1]); 27 | exit(1); 28 | } 29 | db2 = open(argv[2], O_RDONLY); 30 | if( db2<0 ){ 31 | fprintf(stderr,"%s: can't open %s\n", argv[0], argv[2]); 32 | exit(1); 33 | } 34 | iPg = 1; 35 | while( read(db1, a1, PAGESIZE)==PAGESIZE && read(db2,a2,PAGESIZE)==PAGESIZE ){ 36 | if( memcmp(a1,a2,PAGESIZE) ){ 37 | printf("Page %d\n", iPg); 38 | } 39 | iPg++; 40 | } 41 | printf("%d pages checked\n", iPg-1); 42 | close(db1); 43 | close(db2); 44 | } 45 | -------------------------------------------------------------------------------- /tool/extract.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Extract a range of bytes from a file. 3 | ** 4 | ** Usage: 5 | ** 6 | ** extract FILENAME OFFSET AMOUNT 7 | ** 8 | ** The bytes are written to standard output. 9 | */ 10 | #include 11 | #include 12 | 13 | int main(int argc, char **argv){ 14 | FILE *f; 15 | char *zBuf; 16 | int ofst; 17 | int n; 18 | size_t got; 19 | 20 | if( argc!=4 ){ 21 | fprintf(stderr, "Usage: %s FILENAME OFFSET AMOUNT\n", *argv); 22 | return 1; 23 | } 24 | f = fopen(argv[1], "rb"); 25 | if( f==0 ){ 26 | fprintf(stderr, "cannot open \"%s\"\n", argv[1]); 27 | return 1; 28 | } 29 | ofst = atoi(argv[2]); 30 | n = atoi(argv[3]); 31 | zBuf = malloc( n ); 32 | if( zBuf==0 ){ 33 | fprintf(stderr, "out of memory\n"); 34 | return 1; 35 | } 36 | fseek(f, ofst, SEEK_SET); 37 | got = fread(zBuf, 1, n, f); 38 | fclose(f); 39 | if( got0} {puts {}} 36 | set col 0 37 | } 38 | 39 | foreach name [lsort $namelist] { 40 | put_item \"$name\", 41 | } 42 | put_item 0 43 | finalize 44 | puts " \175;" 45 | puts " enum ${prefix}_enum \173" 46 | foreach name [lsort $namelist] { 47 | regsub -all {@} $name {} name 48 | put_item ${prefix}_[string toupper $name], 49 | } 50 | finalize 51 | puts " \175;" 52 | -------------------------------------------------------------------------------- /tool/opcodeDoc.awk: -------------------------------------------------------------------------------- 1 | # 2 | # Extract opcode documentation for sqliteVdbe.c and generate HTML 3 | # 4 | BEGIN { 5 | print "" 6 | print "

SQLite Virtual Database Engine Opcodes

" 7 | print "" 8 | } 9 | / Opcode: /,/\*\// { 10 | if( $2=="Opcode:" ){ 11 | printf "\n\n" 14 | }else if( NF>1 ){ 15 | sub(/^ *\*\* /,"") 16 | gsub(/" 23 | } 24 | -------------------------------------------------------------------------------- /tool/symbols-mingw.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Run this script in a directory that contains a valid SQLite makefile in 4 | # order to verify that unintentionally exported symbols. 5 | # 6 | make sqlite3.c 7 | 8 | echo '****** Exported symbols from a build including RTREE && FTS4 ******' 9 | gcc -c -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \ 10 | -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ 11 | -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ 12 | -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ 13 | sqlite3.c 14 | nm sqlite3.o | grep " [TD] " 15 | 16 | echo '****** Surplus symbols from a build including RTREE & FTS4 ******' 17 | nm sqlite3.o | grep " [TD] " | grep -v " .*sqlite3_" 18 | 19 | echo '****** Dependencies of the core. No extensions. No OS interface *******' 20 | gcc -c -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ 21 | -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ 22 | -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ 23 | -DSQLITE_OS_OTHER -DSQLITE_THREADSAFE=0 \ 24 | sqlite3.c 25 | nm sqlite3.o | grep " U " 26 | 27 | echo '****** Dependencies including RTREE & FTS4 *******' 28 | gcc -c -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \ 29 | -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ 30 | -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ 31 | -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ 32 | sqlite3.c 33 | nm sqlite3.o | grep " U " 34 | -------------------------------------------------------------------------------- /tool/symbols.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Run this script in a directory that contains a valid SQLite makefile in 4 | # order to verify that unintentionally exported symbols. 5 | # 6 | make sqlite3.c 7 | 8 | echo '****** Exported symbols from a build including RTREE, FTS4 & ICU ******' 9 | gcc -c -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \ 10 | -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ 11 | -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ 12 | -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ 13 | -DSQLITE_ENABLE_ICU \ 14 | sqlite3.c 15 | nm sqlite3.o | grep ' [TD] ' | sort -k 3 16 | 17 | echo '****** Surplus symbols from a build including RTREE, FTS4 & ICU ******' 18 | nm sqlite3.o | grep ' [TD] ' | grep -v ' .*sqlite3_' 19 | 20 | echo '****** Dependencies of the core. No extensions. No OS interface *******' 21 | gcc -c -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ 22 | -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ 23 | -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ 24 | -DSQLITE_OS_OTHER -DSQLITE_THREADSAFE=0 \ 25 | sqlite3.c 26 | nm sqlite3.o | grep ' U ' | sort -k 3 27 | 28 | echo '****** Dependencies including RTREE & FTS4 *******' 29 | gcc -c -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \ 30 | -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ 31 | -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ 32 | -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ 33 | sqlite3.c 34 | nm sqlite3.o | grep ' U ' | sort -k 3 35 | -------------------------------------------------------------------------------- /tool/tostr.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk 2 | # 3 | # Convert input text into a C string 4 | # 5 | { 6 | gsub(/\"/,"\\\""); 7 | print "\"" $0 "\\n\""; 8 | } 9 | -------------------------------------------------------------------------------- /tool/warnings-clang.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | # 3 | # Run this script in a directory with a working makefile to check for 4 | # compiler warnings in SQLite. 5 | # 6 | rm -f sqlite3.c 7 | make sqlite3.c 8 | echo '************* FTS4 and RTREE ****************' 9 | scan-build gcc -c -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ 10 | -DSQLITE_DEBUG -DSQLITE_ENABLE_STAT3 sqlite3.c 2>&1 | grep -v 'ANALYZE:' 11 | echo '********** ENABLE_STAT3. THREADSAFE=0 *******' 12 | scan-build gcc -c -I. -DSQLITE_ENABLE_STAT3 -DSQLITE_THREADSAFE=0 \ 13 | -DSQLITE_DEBUG \ 14 | sqlite3.c ../sqlite/src/shell.c -ldl 2>&1 | grep -v 'ANALYZE:' 15 | -------------------------------------------------------------------------------- /tool/warnings.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | # 3 | # Run this script in a directory with a working makefile to check for 4 | # compiler warnings in SQLite. 5 | # 6 | rm -f sqlite3.c 7 | make sqlite3.c-debug 8 | echo '********** No optimizations. Includes FTS4 and RTREE *********' 9 | gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ 10 | -ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ 11 | sqlite3.c 12 | echo '********** No optimizations. ENABLE_STAT3. THREADSAFE=0 *******' 13 | gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ 14 | -ansi -DSQLITE_ENABLE_STAT3 -DSQLITE_THREADSAFE=0 \ 15 | sqlite3.c 16 | echo '********** Optimized -O3. Includes FTS4 and RTREE ************' 17 | gcc -O3 -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ 18 | -ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ 19 | sqlite3.c 20 | -------------------------------------------------------------------------------- /tool/win/sqlite.vsix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMDB/sqlightning/bb8144e10a985f83b6973a38078dd19ed2b0c711/tool/win/sqlite.vsix --------------------------------------------------------------------------------
%s %s %s %s\n", $3, $4, $5, $6 12 | }else if( $1=="*/" ){ 13 | printf "