├── Document ├── 00.SQLite的执行过程.md ├── 00.存储模型.md ├── 01.01.Pager模块.md ├── 01.02.testpcache.md ├── 01.03.pcache1.md ├── 02.01.btree模块.md ├── 02.02.Commit&&Rollback.md ├── 02.03.Savepoint.md ├── 03.00.VDBE.md ├── 03.01.VDBEAUX.md ├── 04.00.OPCODE.md ├── 04.01.example.md ├── 04.02.Mem.md ├── 04.03.VDBESort.md ├── 05.Query.md ├── Inside SQLite │ ├── 01.Overview.md │ ├── 02.DatabaseFileFormat.md │ ├── 03.PageCacheManagement.md │ ├── 04.TransactionManagement.md │ ├── 05.TableAndIndexManagement.md │ ├── 06.SQLiteEngine.md │ ├── inside-sqlite.pdf │ └── pic │ │ ├── 01.Overview │ │ └── image-20221215235156535.png │ │ ├── 02.DatabaseFileFormat │ │ ├── Figure2-1.StructureOfAFeelist.png │ │ └── Table2-1.StructureOfDatabaseFileHeader.png │ │ ├── 03.PageCacheManagement │ │ ├── Figure3-2.PageCache.png │ │ └── image-20221216000151176.png │ │ ├── 04.TransactionManagement │ │ ├── image-20221216001522354.png │ │ ├── image-20221216001605998.png │ │ ├── image-20221216001730060.png │ │ ├── image-20221216001821207.png │ │ ├── image-20221216001908144.png │ │ ├── image-20221216001943276.png │ │ └── image-20221216002008616.png │ │ ├── 05.TableAndIndexManagement │ │ ├── image-20221216002351264.png │ │ ├── image-20221216002417501.png │ │ ├── image-20221216002445701.png │ │ ├── image-20221216002513608.png │ │ ├── image-20221216002535476.png │ │ └── image-20221216002553922.png │ │ └── 06.SQLiteEngine │ │ ├── image-20221216003031972.png │ │ ├── image-20221216003139270.png │ │ ├── image-20221216003201352.png │ │ ├── image-20221216003241603.png │ │ ├── image-20221216003308375.png │ │ ├── image-20221216003326391.png │ │ ├── image-20221216003341202.png │ │ ├── image-20221216003526646.png │ │ └── image-20221216003609318.png ├── Q&A.md ├── SQLite Database System Design and Implementation.pdf ├── SQLite源码分析 │ ├── analyze.c解析.md │ ├── build.c解析.md │ ├── delete.c解析.md │ ├── insert.c解析.md │ ├── pic │ │ ├── Analyze 命令分析过程.jpg │ │ ├── analyzeDatabase 调用过程.jpg │ │ ├── analyzeTable 调用过程.jpg │ │ ├── autoindex1.png │ │ ├── autoindex2.png │ │ ├── between.png │ │ ├── build │ │ │ ├── img1-10.jpg │ │ │ ├── img1-11.jpg │ │ │ ├── img1-12.jpg │ │ │ ├── img1-13.jpg │ │ │ ├── img1-14.jpg │ │ │ ├── img1-15.jpg │ │ │ ├── img1-16.jpg │ │ │ ├── img1-17.jpg │ │ │ ├── img1-18.jpg │ │ │ ├── img1-19.jpg │ │ │ ├── img1-2.jpg │ │ │ ├── img1-20.jpg │ │ │ ├── img1-21.jpg │ │ │ ├── img1-22.jpg │ │ │ ├── img1-23.jpg │ │ │ ├── img1-24.jpg │ │ │ ├── img1-25.jpg │ │ │ ├── img1-26.jpg │ │ │ ├── img1-3.jpg │ │ │ ├── img1-4.jpg │ │ │ ├── img1-5.jpg │ │ │ ├── img1-6.jpg │ │ │ ├── img1-7.jpg │ │ │ ├── img1-8.jpg │ │ │ └── img1-9.jpg │ │ ├── coverindex.png │ │ ├── like.png │ │ ├── or.png │ │ ├── picture2-1.png │ │ ├── process.png │ │ ├── selmultindex.png │ │ ├── sqliteWhereBegin.png │ │ ├── sqliteWhereEnd.png │ │ ├── structRelation.png │ │ ├── whereAnalyze.png │ │ ├── whereClause.png │ │ └── whereTerm.png │ ├── update.c解析.md │ ├── where.c解析.md │ └── 查询优化器.md ├── imgs │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 6.png │ ├── 7.png │ └── 8.png ├── official_documents │ ├── Architecture.md │ ├── Database File Format.md │ ├── SQLite怎样实现原子性.md │ ├── SQLite查询计划.md │ ├── Write-Ahead-Logging.md │ ├── imgs │ │ ├── explain1.png │ │ └── image-20210828173741457.png │ ├── pic │ │ ├── SQLite怎样实现原子性 │ │ │ ├── commit-0.gif │ │ │ ├── commit-1.gif │ │ │ ├── commit-2.gif │ │ │ ├── commit-3.gif │ │ │ ├── commit-4.gif │ │ │ ├── commit-5.gif │ │ │ ├── commit-6.gif │ │ │ ├── commit-7.gif │ │ │ ├── commit-8.gif │ │ │ ├── commit-9.gif │ │ │ ├── commit-A.gif │ │ │ ├── commit-B.gif │ │ │ ├── rollback-0.gif │ │ │ ├── rollback-1.gif │ │ │ ├── rollback-2.gif │ │ │ ├── rollback-3.gif │ │ │ ├── rollback-4.gif │ │ │ └── rollback-5.gif │ │ ├── fruitobstate.gif │ │ ├── fruitobstate0.gif │ │ ├── fullscan.gif │ │ ├── idx1.gif │ │ ├── idx1lu1.gif │ │ ├── idx1lu2.gif │ │ ├── idx1lu3.gif │ │ ├── idx2.gif │ │ ├── idx2lu1.gif │ │ ├── idx3.gif │ │ ├── idx3lu1.gif │ │ ├── idx3lu2.gif │ │ ├── idx4.gif │ │ ├── idx4lu1.gif │ │ ├── obfruitidx1.gif │ │ ├── obfruitidx4.gif │ │ ├── obfruitnoidx.gif │ │ ├── obrowid.gif │ │ ├── orquery.gif │ │ ├── partial-sort.gif │ │ ├── rowidlu.gif │ │ └── tab.gif │ └── vdbe opcode.md ├── pic │ ├── 00.SQLite的执行过程 │ │ ├── 3-1.jpg │ │ ├── 3-2.jpg │ │ ├── 3-3.jpg │ │ └── 3-4.jpg │ ├── 02.btree │ │ └── image-20221211113450762.png │ ├── 02.btree模块 │ │ ├── 3B+tree组织结构.jpg │ │ ├── 4hierarchicalorganization.jpg │ │ ├── 5overflow.jpg │ │ ├── Insert.jpg │ │ ├── SQLiteBlockGraph.jpg │ │ ├── btreeCreateTable.jpg │ │ ├── droptable.jpg │ │ ├── 典型的B-tree.jpg │ │ ├── 存取及事务函数.jpg │ │ ├── 游标函数.jpg │ │ ├── 表函数.jpg │ │ ├── 记录函数.jpg │ │ └── 配置管理函数.jpg │ ├── 03.VDBE │ │ ├── 4-1.jpg │ │ ├── 4-2.jpg │ │ ├── 4-3.jpg │ │ ├── 4-4.jpg │ │ ├── opc.png │ │ └── vdbe.jpg │ ├── 03.文件格式 │ │ ├── image-20221204104309388.png │ │ ├── image-20221204130343634.png │ │ ├── image-20221204130740586.png │ │ ├── image-20221204143609569.png │ │ ├── image-20221204150016759.png │ │ ├── image-20221204164246302.png │ │ └── image-20221204194550993.png │ ├── sqlite10-1.jpeg │ ├── sqlite10-2.jpeg │ ├── sqlite10-3.jpeg │ ├── sqlite10-4.jpeg │ └── sqlite10-5.jpeg └── wal.md ├── README.md └── sqlite-version-3.7.14.1 ├── Makefile.arm-wince-mingw32ce-gcc ├── Makefile.in ├── Makefile.linux-gcc ├── Makefile.msc ├── Makefile.vxworks ├── README ├── 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_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 └── 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 ├── main.mk ├── manifest ├── manifest.uuid ├── mkdll.sh ├── mkextu.sh ├── mkextw.sh ├── mkopcodec.awk ├── mkopcodeh.awk ├── mkso.sh ├── publish.sh ├── publish_osx.sh ├── 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 ├── 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.h ├── 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_func.c ├── test_fuzzer.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_spellfix.c ├── test_stat.c ├── test_superlock.c ├── test_syscall.c ├── test_tclvar.c ├── test_thread.c ├── test_vfs.c ├── test_vfstrace.c ├── test_wholenumber.c ├── test_wsd.c ├── tokenize.c ├── trigger.c ├── update.c ├── utf.c ├── util.c ├── vacuum.c ├── vdbe.c ├── vdbe.c.pre ├── 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 ├── 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 ├── busy.test ├── cache.test ├── capi2.test ├── capi3.test ├── capi3b.test ├── capi3c.test ├── capi3d.test ├── capi3e.test ├── cast.test ├── check.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 ├── 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 ├── 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 ├── 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 ├── fts4aa.test ├── fts4check.test ├── fts4content.test ├── fts4langid.test ├── fts4merge.test ├── fts4merge2.test ├── fts4merge3.test ├── fts4unicode.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 ├── incrblob.test ├── incrblob2.test ├── incrblob3.test ├── incrblob4.test ├── incrblob_err.test ├── incrblobfault.test ├── incrvacuum.test ├── incrvacuum2.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 ├── intarray.test ├── interrupt.test ├── intpkey.test ├── io.test ├── ioerr.test ├── ioerr2.test ├── ioerr3.test ├── ioerr4.test ├── ioerr5.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 ├── multiplex.test ├── multiplex2.test ├── multiplex3.test ├── mutex1.test ├── mutex2.test ├── nan.test ├── notify1.test ├── notify2.test ├── notify3.test ├── notnull.test ├── null.test ├── openv2.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 ├── reindex.test ├── releasetest.mk ├── releasetest.tcl ├── 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 ├── server1.test ├── shared.test ├── shared2.test ├── shared3.test ├── shared4.test ├── shared6.test ├── shared7.test ├── shared8.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-54844eea3f.test ├── tkt-5d863f876e.test ├── tkt-5e10420e8d.test ├── tkt-5ee23731f.test ├── tkt-752e1646fc.test ├── tkt-78e04e52ea.test ├── tkt-7bbfb7d442.test ├── tkt-80ba201079.test ├── tkt-80e031a00f.test ├── tkt-8454a207b9.test ├── tkt-91e2e8ba6f.test ├── tkt-94c04eaadb.test ├── tkt-9d68c883.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 ├── 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 ├── 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 ├── 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 ├── 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 ├── symbols-mingw.sh ├── symbols.sh ├── tostr.awk ├── vdbe-compress.tcl ├── warnings-clang.sh ├── warnings.sh └── win └── sqlite.vsix /Document/00.SQLite的执行过程.md: -------------------------------------------------------------------------------- 1 | 使用SQLite的C API函数可以对SQLite执行的过程有一个清晰的了解,就像SQLite结构图(图1-1)中一样,SQLite执行有三个大的步骤,具体过程如图3-1所示: 2 | 3 | ![img](pic/00.SQLite的执行过程/3-1.jpg) 4 | 5 | SQLite首先创建或者打开一个数据库,然后执行相应的SQL语句,最后关闭数据库,这也是数据库操作的一般步骤。在执行SQL命令过程中,又分为了三个阶段,在Prepare阶段,输入的SQL语句通过分析器(parser),分词器(tokenizer)和代码生成器(code generator)编译成VDBE字节码。传入sqlite3VdbeExec函数的Vdbe类型指针变量p中,已经包含了所有需要执行的操作码(如图3-2)。p中的aOp的官方解释为:Space to hold the virtual machine‘s program,根据图3-3可以看出,aOp是存放操作符的空间。 6 | 7 | ![img](pic/00.SQLite的执行过程/3-2.jpg) 8 | 9 | ![img](pic/00.SQLite的执行过程/3-3.jpg) 10 | 11 | 在执行阶段,虚拟机执行操作符,执行过程是一个步进的过程,每一步都是由sqlite3_step函数启动,并由sqlite3VdbeExec函数执行由Prepare阶段编译的操作符。在Final阶段,先是执行sqlite3VdbeFinalize函数关闭VDBE,然后执行sqlite_finalize()函数结束SQLite的执行。通过下图3-4可以更容易理 解这个过程。 12 | 13 | ![img](pic/00.SQLite的执行过程/3-4.jpg) -------------------------------------------------------------------------------- /Document/Inside SQLite/inside-sqlite.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/inside-sqlite.pdf -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/01.Overview/image-20221215235156535.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/01.Overview/image-20221215235156535.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/02.DatabaseFileFormat/Figure2-1.StructureOfAFeelist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/02.DatabaseFileFormat/Figure2-1.StructureOfAFeelist.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/02.DatabaseFileFormat/Table2-1.StructureOfDatabaseFileHeader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/02.DatabaseFileFormat/Table2-1.StructureOfDatabaseFileHeader.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/03.PageCacheManagement/Figure3-2.PageCache.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/03.PageCacheManagement/Figure3-2.PageCache.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/03.PageCacheManagement/image-20221216000151176.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/03.PageCacheManagement/image-20221216000151176.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001522354.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001522354.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001605998.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001605998.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001730060.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001730060.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001821207.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001821207.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001908144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001908144.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001943276.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/04.TransactionManagement/image-20221216001943276.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/04.TransactionManagement/image-20221216002008616.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/04.TransactionManagement/image-20221216002008616.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002351264.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002351264.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002417501.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002417501.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002445701.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002445701.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002513608.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002513608.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002535476.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002535476.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002553922.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/05.TableAndIndexManagement/image-20221216002553922.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003031972.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003031972.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003139270.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003139270.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003201352.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003201352.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003241603.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003241603.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003308375.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003308375.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003326391.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003326391.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003341202.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003341202.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003526646.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003526646.png -------------------------------------------------------------------------------- /Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003609318.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/Inside SQLite/pic/06.SQLiteEngine/image-20221216003609318.png -------------------------------------------------------------------------------- /Document/Q&A.md: -------------------------------------------------------------------------------- 1 | # sqlite相关问题 2 | 3 | ## 我们知道,sqlite存储的底层是b+树,那么一张普通的表,是按照什么顺序,或者说,以什么为key,写入数据库的呢? 4 | 5 | 答案是 `rowid` , 如果表存在整数类型的主键(主键中只有一列,而且列的类型为整数),那么将此列作为所谓的 `rowid` ,如果不存在,那么 `sqlite` 自己构建一列rowid.`rowid` 是唯一的,在一张表中绝不重复. 6 | 7 | 具体可以查看函数 `sqlite3Insert`. 8 | 9 | -------------------------------------------------------------------------------- /Document/SQLite Database System Design and Implementation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite Database System Design and Implementation.pdf -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/Analyze 命令分析过程.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/Analyze 命令分析过程.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/analyzeDatabase 调用过程.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/analyzeDatabase 调用过程.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/analyzeTable 调用过程.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/analyzeTable 调用过程.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/autoindex1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/autoindex1.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/autoindex2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/autoindex2.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/between.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/between.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-10.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-11.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-12.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-13.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-14.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-15.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-16.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-17.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-18.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-19.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-2.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-20.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-21.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-22.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-23.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-24.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-25.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-26.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-3.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-4.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-5.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-6.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-7.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-8.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/build/img1-9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/build/img1-9.jpg -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/coverindex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/coverindex.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/like.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/like.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/or.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/or.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/picture2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/picture2-1.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/process.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/selmultindex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/selmultindex.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/sqliteWhereBegin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/sqliteWhereBegin.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/sqliteWhereEnd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/sqliteWhereEnd.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/structRelation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/structRelation.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/whereAnalyze.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/whereAnalyze.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/whereClause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/whereClause.png -------------------------------------------------------------------------------- /Document/SQLite源码分析/pic/whereTerm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/SQLite源码分析/pic/whereTerm.png -------------------------------------------------------------------------------- /Document/imgs/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/imgs/1.png -------------------------------------------------------------------------------- /Document/imgs/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/imgs/2.png -------------------------------------------------------------------------------- /Document/imgs/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/imgs/3.png -------------------------------------------------------------------------------- /Document/imgs/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/imgs/4.png -------------------------------------------------------------------------------- /Document/imgs/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/imgs/6.png -------------------------------------------------------------------------------- /Document/imgs/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/imgs/7.png -------------------------------------------------------------------------------- /Document/imgs/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/imgs/8.png -------------------------------------------------------------------------------- /Document/official_documents/Write-Ahead-Logging.md: -------------------------------------------------------------------------------- 1 |

Write-Ahead Logging

2 | SQLite实现原子性的默认方法是通过rollback journal. 但是从3.7.0开始, "Write-ahead logging"被作为一个新的选择加入了. 3 | 4 | 使用WAL代替rollback journal有下面这些优点: 5 | 6 | 1. WAL在大多数情况下都更快. 7 | 2. WAL提高了并发性. 读者不会阻塞写者, 写者也不会阻塞读者了. 读写操作可以并发进行. 8 | 3. 硬盘I/O操作在WAL模式下更趋近于线性, 更加连贯. 9 | 4. WAL减少了很多fsync()的使用, 因此减少了很多fsync()引发的问题. 10 | 但是也有这些缺点: 11 | 1. WAL通常需要VFS提供共享内存支持. 内置的unix和windows版本能够达到这个要求, 但是许多第三方的VFS可能就不行了. 12 | 2. 所有的进程必须在同一台主机上; WAL不支持网络文件系统. 13 | 3. 对于同时涉及多个数据库的事务, 在各个数据库内部能实现原子性, 但是相互之间可能就不一定能保持原子性了. 14 | 4. 在WAL下, 你不能改变页大小. 15 | 5. ** 16 | 6. 在读取操作很多, 写入操作很少的应用中, WAL或许会比rollbacl journal更慢一点(1% ~ 2%). 17 | 7. ** 18 | 8. ** 19 | 9. ** 20 | 21 | 22 | ### WAL怎样工作 23 | rollback journal的工作方式是在修改数据库之前, 先对需要修改的页做一份拷贝, 这样, 当错误发生后, 我们还能根据之前拷贝的内容修复数据库. 修复完或者没有确定没有错误发生后, 再将拷贝的文件删除. 24 | 25 | 而WAL反转了整个操作. 原始的内容被保留在数据库中, 被修改的内容被写到了WAL文件内. 而COMMIT的操作由一条特殊的记录表示, 也会被写入到WAL文件中. 因此, COMMIT操作能够在不修改数据库的情况下进行, 其他读者能继续读取自己需要的数据, 因为COMMIT操作都"发生"在WAL文件中了. 同时, 多个事务的还能被写入到同一个WAL文件中. 26 | 27 | ### Checkpointing 28 | 当然, 最后我们需要将WAL文件中"发生"的事务给同步到数据库文件中, 我们将这个操作称之为"checkpointing". 29 | 30 | WAL和rollback journal另一个不同的地方是: rollback journal中只有两种操作, reading和writing, 而WAL中有三种, reading, writing, checkpointing. 31 | 32 | SQLite会在WAL文件中的内容达到某个阈值时进行checkpointing, 默认为1000页. (当然你可以通过SQLITE_DEFAULT_WAL_AUTOCHECKPOINT这个宏定义在编译时设置它.) 引用在WAL模式下不需要对checkpointing做任何多余的事情. 如果你想的话, 你也可以调整自动checkpointing的阈值, 也可以关闭自动checkpointing再自己设置一个线程在程序空闲时进行checkpointing. 33 | 34 | 35 | ### 并发性 36 | -------------------------------------------------------------------------------- /Document/official_documents/imgs/explain1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/imgs/explain1.png -------------------------------------------------------------------------------- /Document/official_documents/imgs/image-20210828173741457.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/imgs/image-20210828173741457.png -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-0.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-1.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-2.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-3.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-4.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-5.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-6.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-7.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-8.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-9.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-A.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-A.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/commit-B.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/commit-B.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/rollback-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/rollback-0.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/rollback-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/rollback-1.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/rollback-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/rollback-2.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/rollback-3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/rollback-3.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/rollback-4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/rollback-4.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/SQLite怎样实现原子性/rollback-5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/SQLite怎样实现原子性/rollback-5.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/fruitobstate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/fruitobstate.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/fruitobstate0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/fruitobstate0.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/fullscan.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/fullscan.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx1.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx1lu1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx1lu1.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx1lu2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx1lu2.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx1lu3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx1lu3.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx2.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx2lu1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx2lu1.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx3.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx3lu1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx3lu1.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx3lu2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx3lu2.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx4.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/idx4lu1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/idx4lu1.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/obfruitidx1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/obfruitidx1.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/obfruitidx4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/obfruitidx4.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/obfruitnoidx.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/obfruitnoidx.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/obrowid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/obrowid.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/orquery.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/orquery.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/partial-sort.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/partial-sort.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/rowidlu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/rowidlu.gif -------------------------------------------------------------------------------- /Document/official_documents/pic/tab.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/official_documents/pic/tab.gif -------------------------------------------------------------------------------- /Document/pic/00.SQLite的执行过程/3-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/00.SQLite的执行过程/3-1.jpg -------------------------------------------------------------------------------- /Document/pic/00.SQLite的执行过程/3-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/00.SQLite的执行过程/3-2.jpg -------------------------------------------------------------------------------- /Document/pic/00.SQLite的执行过程/3-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/00.SQLite的执行过程/3-3.jpg -------------------------------------------------------------------------------- /Document/pic/00.SQLite的执行过程/3-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/00.SQLite的执行过程/3-4.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree/image-20221211113450762.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree/image-20221211113450762.png -------------------------------------------------------------------------------- /Document/pic/02.btree模块/3B+tree组织结构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/3B+tree组织结构.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/4hierarchicalorganization.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/4hierarchicalorganization.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/5overflow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/5overflow.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/Insert.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/Insert.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/SQLiteBlockGraph.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/SQLiteBlockGraph.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/btreeCreateTable.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/btreeCreateTable.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/droptable.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/droptable.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/典型的B-tree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/典型的B-tree.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/存取及事务函数.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/存取及事务函数.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/游标函数.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/游标函数.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/表函数.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/表函数.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/记录函数.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/记录函数.jpg -------------------------------------------------------------------------------- /Document/pic/02.btree模块/配置管理函数.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/02.btree模块/配置管理函数.jpg -------------------------------------------------------------------------------- /Document/pic/03.VDBE/4-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.VDBE/4-1.jpg -------------------------------------------------------------------------------- /Document/pic/03.VDBE/4-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.VDBE/4-2.jpg -------------------------------------------------------------------------------- /Document/pic/03.VDBE/4-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.VDBE/4-3.jpg -------------------------------------------------------------------------------- /Document/pic/03.VDBE/4-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.VDBE/4-4.jpg -------------------------------------------------------------------------------- /Document/pic/03.VDBE/opc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.VDBE/opc.png -------------------------------------------------------------------------------- /Document/pic/03.VDBE/vdbe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.VDBE/vdbe.jpg -------------------------------------------------------------------------------- /Document/pic/03.文件格式/image-20221204104309388.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.文件格式/image-20221204104309388.png -------------------------------------------------------------------------------- /Document/pic/03.文件格式/image-20221204130343634.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.文件格式/image-20221204130343634.png -------------------------------------------------------------------------------- /Document/pic/03.文件格式/image-20221204130740586.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.文件格式/image-20221204130740586.png -------------------------------------------------------------------------------- /Document/pic/03.文件格式/image-20221204143609569.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.文件格式/image-20221204143609569.png -------------------------------------------------------------------------------- /Document/pic/03.文件格式/image-20221204150016759.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.文件格式/image-20221204150016759.png -------------------------------------------------------------------------------- /Document/pic/03.文件格式/image-20221204164246302.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.文件格式/image-20221204164246302.png -------------------------------------------------------------------------------- /Document/pic/03.文件格式/image-20221204194550993.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/03.文件格式/image-20221204194550993.png -------------------------------------------------------------------------------- /Document/pic/sqlite10-1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/sqlite10-1.jpeg -------------------------------------------------------------------------------- /Document/pic/sqlite10-2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/sqlite10-2.jpeg -------------------------------------------------------------------------------- /Document/pic/sqlite10-3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/sqlite10-3.jpeg -------------------------------------------------------------------------------- /Document/pic/sqlite10-4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/sqlite10-4.jpeg -------------------------------------------------------------------------------- /Document/pic/sqlite10-5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/Document/pic/sqlite10-5.jpeg -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/VERSION: -------------------------------------------------------------------------------- 1 | 3.7.14.1 2 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/art/sqlite370.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/sqlite-version-3.7.14.1/art/sqlite370.ico -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/art/sqlite370.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/sqlite-version-3.7.14.1/art/sqlite370.jpg -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/ext/README.txt: -------------------------------------------------------------------------------- 1 | Version loadable extensions to SQLite are found in subfolders 2 | of this folder. 3 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/ext/fts1/README.txt: -------------------------------------------------------------------------------- 1 | This folder contains source code to the first full-text search 2 | extension for SQLite. 3 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/manifest.uuid: -------------------------------------------------------------------------------- 1 | 091570e46d04e84b67228e0bdbcd6e1fb60c6bdb -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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( mx2} {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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/test/capi3e.test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/sqlite-version-3.7.14.1/test/capi3e.test -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | db close 40 | forcedelete .test_control_lockproxy.db-conch test.proxy 41 | finish_test 42 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | do_test fkey4-1.3 { 46 | set ::STMT2 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL] 47 | sqlite3_step $::STMT2 48 | } {SQLITE_CONSTRAINT} 49 | do_test fkey4-1.4 { 50 | db eval {SELECT * FROM t2} 51 | } {1 3} 52 | sqlite3_finalize $::STMT1 53 | sqlite3_finalize $::STMT2 54 | 55 | finish_test 56 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/test/fts4unicode.test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/sqlite-version-3.7.14.1/test/fts4unicode.test -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 (~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 | 55 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | 21 | do_multiclient_test tn { 22 | do_test $tn.1 { 23 | sql1 { 24 | CREATE TABLE t1(a, b); 25 | CREATE INDEX i1 ON t1(a, b); 26 | INSERT INTO t1 VALUES(1, 2); 27 | INSERT INTO t1 VALUES(3, 4); 28 | PRAGMA journal_mode = WAL; 29 | VACUUM; 30 | PRAGMA journal_mode = DELETE; 31 | } 32 | } {wal delete} 33 | 34 | do_test $tn.2 { 35 | sql2 { SELECT * FROM t1 } 36 | } {1 2 3 4} 37 | 38 | do_test $tn.3 { 39 | sql1 { 40 | INSERT INTO t1 VALUES(5, 6); 41 | PRAGMA journal_mode = WAL; 42 | VACUUM; 43 | PRAGMA journal_mode = DELETE; 44 | } 45 | } {wal delete} 46 | 47 | do_test $tn.2 { 48 | sql2 { PRAGMA integrity_check } 49 | } {ok} 50 | } 51 | 52 | 53 | finish_test 54 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 ../sqlite/src/test_vfstrace.c \ 21 | sqlite3.c -ldl -lreadline -lncurses 22 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | { 19 | int iPg; 20 | unsigned char a1[PAGESIZE], a2[PAGESIZE]; 21 | if (argc != 3) 22 | { 23 | fprintf(stderr, "Usage: %s FILENAME FILENAME\n", argv[0]); 24 | exit(1); 25 | } 26 | db1 = open(argv[1], O_RDONLY); 27 | if (db1 < 0) 28 | { 29 | fprintf(stderr, "%s: can't open %s\n", argv[0], argv[1]); 30 | exit(1); 31 | } 32 | db2 = open(argv[2], O_RDONLY); 33 | if (db2 < 0) 34 | { 35 | fprintf(stderr, "%s: can't open %s\n", argv[0], argv[2]); 36 | exit(1); 37 | } 38 | iPg = 1; 39 | while (read(db1, a1, PAGESIZE) == PAGESIZE && read(db2, a2, PAGESIZE) == PAGESIZE) 40 | { 41 | if (memcmp(a1, a2, PAGESIZE)) 42 | { 43 | printf("Page %d\n", iPg); 44 | } 45 | iPg++; 46 | } 47 | printf("%d pages checked\n", iPg - 1); 48 | close(db1); 49 | close(db2); 50 | } 51 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | { 15 | FILE *f; 16 | char *zBuf; 17 | int ofst; 18 | int n; 19 | size_t got; 20 | 21 | if (argc != 4) 22 | { 23 | fprintf(stderr, "Usage: %s FILENAME OFFSET AMOUNT\n", *argv); 24 | return 1; 25 | } 26 | f = fopen(argv[1], "rb"); 27 | if (f == 0) 28 | { 29 | fprintf(stderr, "cannot open \"%s\"\n", argv[1]); 30 | return 1; 31 | } 32 | ofst = atoi(argv[2]); 33 | n = atoi(argv[3]); 34 | zBuf = malloc(n); 35 | if (zBuf == 0) 36 | { 37 | fprintf(stderr, "out of memory\n"); 38 | return 1; 39 | } 40 | fseek(f, ofst, SEEK_SET); 41 | got = fread(zBuf, 1, n, f); 42 | fclose(f); 43 | if (got < n) 44 | { 45 | fprintf(stderr, "got only %d of %d bytes\n", got, n); 46 | return 1; 47 | } 48 | else 49 | { 50 | fwrite(zBuf, 1, n, stdout); 51 | } 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/tool/mkopts.tcl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/tclsh 2 | # 3 | # This script is used to generate the array of strings and the enum 4 | # that appear at the beginning of the C code implementation of a 5 | # a TCL command and that define the available subcommands for that 6 | # TCL command. 7 | 8 | set prefix {} 9 | while {![eof stdin]} { 10 | set line [gets stdin] 11 | if {$line==""} continue 12 | regsub -all "\[ \t\n,\]+" [string trim $line] { } line 13 | foreach token [split $line { }] { 14 | if {![regexp {(([a-zA-Z]+)_)?([_a-zA-Z]+)} $token all px p2 name]} continue 15 | lappend namelist [string tolower $name] 16 | if {$px!=""} {set prefix $p2} 17 | } 18 | } 19 | 20 | puts " static const char *${prefix}_strs\[\] = \173" 21 | set col 0 22 | proc put_item x { 23 | global col 24 | if {$col==0} {puts -nonewline " "} 25 | if {$col<2} { 26 | puts -nonewline [format " %-21s" $x] 27 | incr col 28 | } else { 29 | puts $x 30 | set col 0 31 | } 32 | } 33 | proc finalize {} { 34 | global col 35 | if {$col>0} {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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/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 | -------------------------------------------------------------------------------- /sqlite-version-3.7.14.1/tool/win/sqlite.vsix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lishuhuakai/sqlite_reading/4bd183e611888f527d7ac4f7727d9aa3ffa3b9fe/sqlite-version-3.7.14.1/tool/win/sqlite.vsix --------------------------------------------------------------------------------
%s %s %s %s\n", $3, $4, $5, $6 12 | }else if( $1=="*/" ){ 13 | printf "