Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d6ae89c21 | |||
| 68c7fdb7c1 | |||
| 93dc177980 | |||
| 9513fc97a8 | |||
| 07444ecf8c | |||
| 6d373c89e0 |
@@ -60,8 +60,7 @@ proc fts5_source_id {zDir} {
|
||||
|
||||
set L [split [readfile [file join $top manifest]]]
|
||||
set date [lindex $L [expr [lsearch -exact $L D]+1]]
|
||||
set idx [expr {[string last . $date]-1}]
|
||||
set date [string range $date 0 $idx]
|
||||
set date [string range $date 0 [string last . $date]-1]
|
||||
set date [string map {T { }} $date]
|
||||
|
||||
return "fts5: $date $uuid"
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ do_test 1.1 {
|
||||
#
|
||||
ifcapable fts3 {
|
||||
do_execsql_test 2.0 {
|
||||
create virtual TABLE ft USING fts4(a, b, languageid='langid');
|
||||
CREATE VIRTUAL TABLE ft USING fts4(a, b, languageid='langid');
|
||||
}
|
||||
do_test 2.1 {
|
||||
apply_rbu {
|
||||
|
||||
@@ -1194,9 +1194,7 @@ static void rbuTableType(
|
||||
assert( p->rc==SQLITE_OK );
|
||||
p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[0], &p->zErrmsg,
|
||||
sqlite3_mprintf(
|
||||
"SELECT "
|
||||
" (sql COLLATE nocase BETWEEN 'CREATE VIRTUAL' AND 'CREATE VIRTUAM'),"
|
||||
" rootpage"
|
||||
"SELECT (sql LIKE 'create virtual%%'), rootpage"
|
||||
" FROM sqlite_schema"
|
||||
" WHERE name=%Q", zTab
|
||||
));
|
||||
@@ -2729,7 +2727,7 @@ static RbuState *rbuLoadState(sqlite3rbu *p){
|
||||
break;
|
||||
|
||||
case RBU_STATE_OALSZ:
|
||||
pRet->iOalSz = sqlite3_column_int64(pStmt, 1);
|
||||
pRet->iOalSz = (u32)sqlite3_column_int64(pStmt, 1);
|
||||
break;
|
||||
|
||||
case RBU_STATE_PHASEONESTEP:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
C Improved\serror\smessages\sfor\sthe\sSQLITE_CONSTRAINT_DATATYPE\serror.
|
||||
D 2021-08-20T08:05:42.509
|
||||
C Merge\sthe\slatest\senhancements\sfrom\strunk.
|
||||
D 2021-07-29T14:27:16.814
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@@ -233,7 +233,7 @@ F ext/fts5/test/fts5vocab2.test c0a8397523561eb780b4f439e75d4969fade0ac40bc73e0c
|
||||
F ext/fts5/tool/fts5speed.tcl b0056f91a55b2d1a3684ec05729de92b042e2f85
|
||||
F ext/fts5/tool/fts5txt2db.tcl c0d43c8590656f8240e622b00957b3a0facc49482411a9fdc2870b45c0c82f9f
|
||||
F ext/fts5/tool/loadfts5.tcl 95b03429ee6b138645703c6ca192c3ac96eaf093
|
||||
F ext/fts5/tool/mkfts5c.tcl 3eba8e9bee4221ed165f3304b51b2a74a705f4ec5df3d044573a2be539534af8
|
||||
F ext/fts5/tool/mkfts5c.tcl d1c2a9ab8e0ec690a52316f33dd9b1d379942f45
|
||||
F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c
|
||||
F ext/icu/README.txt 1c48ffaf7f255bd73d00a35f68f6de357c2a6594f16cb00506a151be23694706
|
||||
F ext/icu/icu.c 91c021c7e3e8bbba286960810fa303295c622e323567b2e6def4ce58e4466e60
|
||||
@@ -341,7 +341,7 @@ F ext/misc/zipfile.c b7261ef6dbc2d18924ff80c40fb5d56c9ccfee3f822a7d3d43b7c87af3d
|
||||
F ext/misc/zorder.c b0ff58fa643afa1d846786d51ea8d5c4b6b35aa0254ab5a82617db92f3adda64
|
||||
F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8
|
||||
F ext/rbu/rbu1.test c62904bd9526dcdc3496a21199aaf14ae191bbadbf67f076bf16be6b3f2115c2
|
||||
F ext/rbu/rbu10.test 06d2bc934a03a0978e750cc9c95b419d9b0bcbec1fc77128e33e377c3a73240b
|
||||
F ext/rbu/rbu10.test 0a201c32202143f23c81c0144503da339786fc20acb7a2fda11601b65659f314
|
||||
F ext/rbu/rbu11.test 5c834cf491086b45e071eabf71f708febc143e86a384a92de69e0b1a4cace144
|
||||
F ext/rbu/rbu12.test 29f8b2118f6c96fac3755bd6d2b55c2db24f878b1f11fbfbe294f3a230a3dcdc
|
||||
F ext/rbu/rbu13.test 1285298e3360ec74511764841b3c174dcfe21da2f618c22febf1a20abd0365c2
|
||||
@@ -379,7 +379,7 @@ F ext/rbu/rbuvacuum.test 55e101e90168c2b31df6c9638fe73dc7f7cc666b6142266d1563697
|
||||
F ext/rbu/rbuvacuum2.test b8e5b51dc8b2c0153373d024c0936be3f66f9234acbd6d0baab0869d56b14e6b
|
||||
F ext/rbu/rbuvacuum3.test 8addd82e4b83b4c93fa47428eae4fd0dbf410f8512c186f38e348feb49ba03dc
|
||||
F ext/rbu/rbuvacuum4.test a78898e438a44803eb2bc897ba3323373c9f277418e2d6d76e90f2f1dbccfd10
|
||||
F ext/rbu/sqlite3rbu.c d020eda938e3ed1c5227a7e1425751a9870f5d143542d806f8098c8cfa2eafa0
|
||||
F ext/rbu/sqlite3rbu.c badb52388467f58e67ef104c5276d1ac68b316a30f8ccb2f74eac733625ae236
|
||||
F ext/rbu/sqlite3rbu.h 1dc88ab7bd32d0f15890ea08d23476c4198d3da3056985403991f8c9cd389812
|
||||
F ext/rbu/test_rbu.c 03f6f177096a5f822d68d8e4069ad8907fe572c62ff2d19b141f59742821828a
|
||||
F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b1446997e0c15
|
||||
@@ -478,37 +478,37 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
|
||||
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
|
||||
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
|
||||
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
||||
F src/alter.c 38975b971a4c36dbcc8004c74b492213a851ab368d29238c531a22636508a5d4
|
||||
F src/analyze.c abbaaf7dca79d1c31c713500324fc0b55bf3eeac5b7b07001452a3d0f210de4f
|
||||
F src/alter.c a54e0a5ae778271a0bc67bdb590c1b3bba0ee59669474f976afb862ccee0026e
|
||||
F src/analyze.c 01c6c6765cb4d40b473b71d85535093730770bb186f2f473abac25f07fcdee5c
|
||||
F src/attach.c a514e81758ba7b3a3a0501faf70af6cfc509de8810235db726cfc9f25165e929
|
||||
F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf
|
||||
F src/auth.c 08954fdc4cc2da5264ba5b75cfd90b67a6fc7d1710a02ccf917c38eadec77853
|
||||
F src/backup.c 3014889fa06e20e6adfa0d07b60097eec1f6e5b06671625f476a714d2356513d
|
||||
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
|
||||
F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
|
||||
F src/btree.c e204a9c8fb4fe5dbb910a863ba487f4af9b5c501254ec4ccbfcdd6b1f65b7fb4
|
||||
F src/btree.h 74d64b8f28cfa4a894d14d4ed64fa432cd697b98b61708d4351482ae15913e22
|
||||
F src/btreeInt.h 7bc15a24a02662409ebcd6aeaa1065522d14b7fda71573a2b0568b458f514ae0
|
||||
F src/build.c 4f58fcdf5b8a7f273edd2fb07a8b7afa91f34cea4396d9b5fc438cbfe1c6b87e
|
||||
F src/build.c 9978caf1e5c6c82d04d85e290d46979abc2219fb79bcd970258d1ebe368d184e
|
||||
F src/callback.c d0b853dd413255d2e337b34545e54d888ea02f20da5ad0e63585b389624c4a6c
|
||||
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
|
||||
F src/ctime.c 8159d5f706551861c18ec6c8f6bdf105e15ea00367f05d9ab65d31a1077facc1
|
||||
F src/date.c e0632f335952b32401482d099321bbf12716b29d6e72836b53ae49683ebae4bf
|
||||
F src/dbpage.c 8a01e865bf8bc6d7b1844b4314443a6436c07c3efe1d488ed89e81719047833a
|
||||
F src/dbstat.c 3aa79fc3aed7ce906e4ea6c10e85d657299e304f6049861fe300053ac57de36c
|
||||
F src/delete.c 3ce6af6b64c8b476de51ccc32da0cb3142d42e65754e1d8118addf65b8bcba15
|
||||
F src/expr.c e98375fc63552cc8cdd36a41bdca3039cb603d9fe67abd9c9f40adae8405fbc5
|
||||
F src/delete.c 62451bba9fe641159e9c0b7d9d2bab1c48d0cff11e16de2d14000603d2af1fcf
|
||||
F src/expr.c b1bcf90afb7dcc0fae4d81116177e3d02e0803f81fd543c10fcd0691390b6adf
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c 1905af1821b88321e1bb9d6a69e704495b6844a9b6c29398d40117cc251e893c
|
||||
F src/fkey.c e9063648396c58778f77583a678342fe4a9bc82436bf23c5f9f444f2df0fdaa4
|
||||
F src/func.c c224240cbc97fa5e9c4fe9acb128716cb835ca045532bca6951b7c45b020c56c
|
||||
F src/global.c 24ba3b3e88dd2a70389388c3bc46fd55a44bfae3c44f76dad1ca00556f1c769a
|
||||
F src/global.c 25ba4d58476f6be29bba9d9d14f7f146b78476d3a4d75ebb8c3b736328afe0f9
|
||||
F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19
|
||||
F src/hash.h 9d56a9079d523b648774c1784b74b89bd93fac7b365210157482e4319a468f38
|
||||
F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c 16fa4b66709db6db5bb31475f2321d0a839269765aa2461a520c151c385e8b9d
|
||||
F src/insert.c d560dc585c50e01b015cbf924c173de88f61c8c85b3d1adb9d4865b92fff2d72
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 0aa9e7f08e168e3874cb54984408e3976dafdf5616d511952c425b5ac088ea3e
|
||||
F src/main.c aab8cefb6bfbdbecc53fd19058fa053c0c5e591b2e5067d883ef999d019dcd29
|
||||
F src/main.c 5d024b9b96d9c6809e66b7f4864c3745bc8caf2a6af3b27dc0f05328f4439dfd
|
||||
F src/malloc.c cbc93cdd429c4594912017d92ab656e2579aca64dbd1c6888551275bed46f25b
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
|
||||
@@ -529,32 +529,32 @@ F src/os.h 26890f540b475598cd9881dcc68931377b8d429d3ea3e2eeb64470cde64199f8
|
||||
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
|
||||
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
|
||||
F src/os_unix.c b11e4610769922253dec27d7af4a07ff84f65169d19bda5e9b12a152a706f7f5
|
||||
F src/os_win.c 77d39873836f1831a9b0b91894fec45ab0e9ca8e067dc8c549e1d1eca1566fe9
|
||||
F src/os_win.c f1727066bfbf4c3a4308442a6b43699e2cb3fe8905e29c0f4cb73f402d04a184
|
||||
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
|
||||
F src/pager.c 95c255256b13827caf038c8f963d334784073f38ab6ef9d70371d9d04f3c43e0
|
||||
F src/pager.h 4bf9b3213a4b2bebbced5eaa8b219cf25d4a82f385d093cd64b7e93e5285f66f
|
||||
F src/parse.y 86aa016b281f61d7664dd8cb7808cab8114d14cfaf362a9b9fc9ead8f33546b7
|
||||
F src/parse.y 6d90c816edf65e99fb978c3b5486df5e661c3534347efac2842b80eb02263e68
|
||||
F src/pcache.c 385ff064bca69789d199a98e2169445dc16e4291fa807babd61d4890c3b34177
|
||||
F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586
|
||||
F src/pcache1.c 54881292a9a5db202b2c0ac541c5e3ef9a5e8c4f1c1383adb2601d5499a60e65
|
||||
F src/pragma.c c482a8d529d91e48ebdd5aa3bbbc15edd7f1cd4f4858613be9146866741ad2b8
|
||||
F src/pcache1.c 388304fd2d91c39591080b5e0f3c62cfba87db20370e7e0554062bfb29740e9f
|
||||
F src/pragma.c 9fe75aa29e8706a2cf6b9c1600ac05a2efc55c44ce719b65aa45d10ff58acc9d
|
||||
F src/pragma.h a11b4798f9c49f156f130e1f7041a9fcc9d316a64f3501b6013acdd2e4c6f549
|
||||
F src/prepare.c 0d53d20532aada295c1690792a125adbd6435f5ce703ff0adf1b9b3605238b67
|
||||
F src/printf.c 78fabb49b9ac9a12dd1c89d744abdc9b67fd3205e62967e158f78b965a29ec4b
|
||||
F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
|
||||
F src/resolve.c 42b94d37a54200707a95566eff4f7e8a380e32d080016b699f23bd79a73a5028
|
||||
F src/resolve.c 047a822844cea769f6fdd8418a335dd4bcd8b75ab5e264f2506a0804f869b562
|
||||
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
|
||||
F src/select.c 0577308f097363b6ebac223e210418810acf74e677f580597f7d0718476fe3ef
|
||||
F src/shell.c.in f795a4ae3c35631f5edcfa754c7824ff1d8a75b23a07e22e664b50f82e826346
|
||||
F src/sqlite.h.in 4e977a5e2ed1a9e8987ff65a2cab5f99a4298ebf040ea5ff636e1753339ff45a
|
||||
F src/select.c 99c36dd4e7c2207ebdfd8c30986ab5aaeae74d0cdbbc471420807d50c417c241
|
||||
F src/shell.c.in 24b99dae8818d1a234732d73f4d5b49f12b510bc62735a41c04e314fafae09e3
|
||||
F src/sqlite.h.in 43fcf0fe2af04081f420a906fc020bde1243851ba44b0aa567a27f94bf8c3145
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h e97f4e9b509408fea4c4e9bef5a41608dfac343b4d3c7a990dedde1e19af9510
|
||||
F src/sqliteInt.h a0e00a52b90f236c77fd0c0b839cc091d9926aca7627eb6ad8cf3f55a9847a71
|
||||
F src/sqliteInt.h b3762f49d8b6b4bf7bf30d154f007d6f9421c86343042d7a246a79988d1fec1a
|
||||
F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
|
||||
F src/status.c 4b8bc2a6905163a38b739854a35b826c737333fab5b1f8e03fa7eb9a4799c4c1
|
||||
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
|
||||
F src/tclsqlite.c 05663f6b5010b044eac0ef22fc8fb5ea3406d2502700a898261683258042c88b
|
||||
F src/test1.c 63761c2be2607f1b425fde991beda48aed384f8d67f2b4ee549174c88b433009
|
||||
F src/test1.c 2100f4c28bae21ce83a9a0c5ec6827efd0e15d11b93b569b614daa5654b3fcf6
|
||||
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
|
||||
F src/test3.c 61798bb0d38b915067a8c8e03f5a534b431181f802659a6616f9b4ff7d872644
|
||||
F src/test4.c 7c4420e01c577b5c4add2cb03119743b1a357543d347773b9e717195ea967159
|
||||
@@ -610,30 +610,30 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
||||
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
|
||||
F src/tokenize.c bae853ad129d1129c063de8630a3e99e306283bc40146f359b1bb91be2c08f1e
|
||||
F src/treeview.c 43f88d0fd19976a60aee6867959213b438593276f1e8179048df85f416a1ab19
|
||||
F src/trigger.c 3f612ce5f0858b6c23460a3c799d01f408b49b0b29d931d8b8e6fc224a8667de
|
||||
F src/update.c 69c4c10bc6873a80c0a77cb578f9fc60ee90003d03f9530bc3370fa24615772d
|
||||
F src/upsert.c 8789047a8f0a601ea42fa0256d1ba3190c13746b6ba940fe2d25643a7e991937
|
||||
F src/trigger.c 7d16aa09e63226b6d8b3f0fc60b21cbfa596fc406288b2ebcf4266633d1ba222
|
||||
F src/update.c 30465f9accc854e8a7932b413578027fbb68186132abbb36e01d2022473fc83d
|
||||
F src/upsert.c df8f1727d62b5987c4fd302cd4d7c0c84ae57cd65683c5a34a740dfe24039235
|
||||
F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0
|
||||
F src/util.c eafc8cfeb66fdbf8839922d13019b7882f242ac31b383e3451aab7744c54df3e
|
||||
F src/util.c 41c7a72da1df47864faa378a1c720b38adb288c6838cb6be5594511b6287a048
|
||||
F src/vacuum.c 454973a59fb20bb982efc2df568a098616db6328a0491b6e84e2e07f7333db45
|
||||
F src/vdbe.c bf2d58ee9d12767e3aca7c29fe8c10eeea1844d5b16865d280743aee54d8c86d
|
||||
F src/vdbe.c b73a5ec9940185eb001ff8cff2cfd429bb438c7e89f2885e0bfdb56c3ff13386
|
||||
F src/vdbe.h 25dabb25c7e157b84e59260cfb5b466c3ac103ede9f36f4db371332c47601abe
|
||||
F src/vdbeInt.h 38206c8dd6b60ff03d9fd4f626b1b4fd0eef7cdc44f2fc2c1973b0f932a3f26b
|
||||
F src/vdbeapi.c aa5aaf2c37676b83af5724c6cd8207a3064ed46a217fd180957f75ac84f7a2a5
|
||||
F src/vdbeaux.c 2368a8888f17368d4040a05966f7d2a2276cac4eeeba50793828186d999e3c8f
|
||||
F src/vdbeblob.c 60a7694760e35b2bba166cf49eb6a1eb0b31581102b49de78008ca3032406065
|
||||
F src/vdbeaux.c 564622045316eb2eed1370714426e81ab96d86e7894a368e80a83e0baff23346
|
||||
F src/vdbeblob.c c6b8db50b227f66fb404215732068df76485b5b433e5f9d4d9ac27410b218193
|
||||
F src/vdbemem.c 53881aa0a7845922a075b3f375695588618098871a7a4120af4c297b80fa3e64
|
||||
F src/vdbesort.c cd5130f683706c1a43e165a74187745fb3351cb56052cf9dc91de820634bbde2
|
||||
F src/vdbetrace.c 666c6fd9f1b62be6999e072a45b913e3c2c3518bc60dfd4d54fe304130acb724
|
||||
F src/vdbevtab.c f99b275366c5fc5e2d99f734729880994ab9500bdafde7fae3b02d562b9d323c
|
||||
F src/vtab.c 88404ac1517903b3eb2abe256772ee95bb09f81ac0a17e13afe5d467df4de4ee
|
||||
F src/vtab.c 3a9a6ae1fd14f7c00af184233cb9f3bced89ae277a75a312f85fb77297a3cdfa
|
||||
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||
F src/wal.c 2be08331d798237ad5d7ae0b252700ffb2b63189cb18d993496d009a93e2f81c
|
||||
F src/wal.c c8ec20a1ca161d5635a4f19c2a4efec2e006e19a8a61f272bf6bce1c80ab7436
|
||||
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
|
||||
F src/walker.c 7342becedf3f8a26f9817f08436bdf8b56ad69af83705f6b9320a0ad3092c2ac
|
||||
F src/where.c 99b6e13664a7bd9a553c554978d0e253066995dade621f44cffa8928c8b493b5
|
||||
F src/where.c 07c63dde6ab72477b964f4c81bee61ef78a246ca149bb9a560784f2e85cd78d7
|
||||
F src/whereInt.h 9248161dd004f625ce5d3841ca9b99fed3fc8d61522cf76340fc5217dbe1375b
|
||||
F src/wherecode.c 9b33f463a279feeee69622b747b0050f0b836eb8b5ac48599ba3a6bfbea798a7
|
||||
F src/wherecode.c 9f1f65d11437b25cd0a1497a170514c785f19ce6ad9d3e6fc73719cb5a49012f
|
||||
F src/whereexpr.c 3a9144a9d52e110efdc012a73b1574e7b2b4df4bf98949387cb620295eba0975
|
||||
F src/window.c 420167512050a0dfc0f0115b9f0c7d299da9759c9bb2ae83a61fb8d730a5707f
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
@@ -747,7 +747,7 @@ F test/busy2.test dbfb61b3265e7a962d3bcd32cd542bbe3d7801edbda6438d35af5aa707cae9
|
||||
F test/cache.test 13bc046b26210471ca6f2889aceb1ea52dc717de
|
||||
F test/cacheflush.test af25bb1509df04c1da10e38d8f322d66eceedf61
|
||||
F test/cachespill.test 895997f84a25b323b166aecb69baab2d6380ea98f9e0bcc688c4493c535cfab9
|
||||
F test/capi2.test 4ee545824adc3eb33bf57ef89f77440b28188ec3da72e5425ff0fcdba32e8d5a
|
||||
F test/capi2.test 34a1a9a96d543a2ec2c209696b11b164444f57253b1f2cba1c2e53fadede6c7b
|
||||
F test/capi3.test 3910a73c38ac76d69778dd9eb481ab7cd6ed59117fc047b4f6056a5c72529de1
|
||||
F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4
|
||||
F test/capi3c.test 54e2dc0c8fd7c34ad1590d1be6864397da2438c95a9f5aee2f8fbc60c112e44b
|
||||
@@ -1062,7 +1062,7 @@ F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8
|
||||
F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14
|
||||
F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc
|
||||
F test/gcfault.test dd28c228a38976d6336a3fc42d7e5f1ad060cb8c
|
||||
F test/gencol1.test 6912c4280d0ad26d6e3d133a93c5abd6db0e00bc5c95d6159131a62ab4e6f586
|
||||
F test/gencol1.test b05e6c5edb9b10d48efb634ed07342441bddc89d225043e17095c36e567521a0
|
||||
F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98
|
||||
F test/having.test a89236dd8d55aa50c4805f82ac9daf64d477a44d712d8209c118978d0ca21ec9
|
||||
F test/hexlit.test 4a6a5f46e3c65c4bf1fa06f5dd5a9507a5627751
|
||||
@@ -1270,7 +1270,7 @@ F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
|
||||
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
|
||||
F test/permutations.test 63da39a4234eed2ccd10bf7872de58e24d53a50d11014dc8a8ab9f252368e880
|
||||
F test/pg_common.tcl 3b27542224db1e713ae387459b5d117c836a5f6e328846922993b6d2b7640d9f
|
||||
F test/pragma.test 30d5bbebd5e9cb5383155cf3f3c81297b98f6642d152e9d4100cf6888630da2c
|
||||
F test/pragma.test 50b91bedea9324d3ab48e793f908ee7d2c7dcf84bfa2281e792838be59641ec8
|
||||
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
|
||||
F test/pragma3.test 92a46bbea12322dd94a404f49edcfbfc913a2c98115f0d030a7459bb4712ef31
|
||||
F test/pragma4.test ca5e4dfc46adfe490f75d73734f70349d95a199e6510973899e502eef2c8b1f8
|
||||
@@ -1297,7 +1297,7 @@ F test/regexp1.test 0c3ff80f66b0eff80e623eb5db7a3dad512095c573d78ac23009785f6d8f
|
||||
F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed1368b5
|
||||
F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d
|
||||
F test/releasetest.tcl 6f803ef0b896f8f3f4c26eb072c0399963a5987a509a64d45f5dfbc1ebae2951 x
|
||||
F test/releasetest_data.tcl 1673991f780277748a0c7524969ae9d6f7cfb21d8c790f6081ee5c0d96ea0f28
|
||||
F test/releasetest_data.tcl f88ed29aa18366ed3956ace36c96ec6868ef5b9ee04cc05d32f4d81031e19e28
|
||||
F test/resetdb.test 8062cf10a09d8c048f8de7711e94571c38b38168db0e5877ba7561789e5eeb2b
|
||||
F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb
|
||||
F test/returning1.test f96c7245f6ac16038e802760cd90b93479369939a8a7a44e2329ee5aed28239c
|
||||
@@ -1425,8 +1425,6 @@ F test/stat.test 15a3106eddedfc882f64bc09f237b4169be4b92dd57c93031b8ff8b13af3e7c
|
||||
F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1
|
||||
F test/stmt.test 54ed2cc0764bf3e48a058331813c3dbd19fc1d0827c3d8369914a5d8f564ec75
|
||||
F test/stmtvtab1.test 6873dfb24f8e79cbb5b799b95c2e4349060eb7a3b811982749a84b359468e2d5
|
||||
F test/strict1.test 314971e166395f8d736d9ecd25c75565e6aac103f9346018c1f78df602e6e2d0
|
||||
F test/strict2.test fe1928b3768f51b39774d753ac7e71727718d1c3305eead0e5ea60f75e9e6b4c
|
||||
F test/subjournal.test 8d4e2572c0ee9a15549f0d8e40863161295107e52f07a3e8012a2e1fdd093c49
|
||||
F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f
|
||||
F test/subquery2.test 90cf944b9de8204569cf656028391e4af1ccc8c0cc02d4ef38ee3be8de1ffb12
|
||||
@@ -1448,7 +1446,7 @@ F test/tabfunc01.test d6821e7042e5653104dac0c63d75eff24a2415ab1889fc68b5db7fde59
|
||||
F test/table.test eb3463b7add9f16a5bb836badf118cf391b809d09fdccd1f79684600d07ec132
|
||||
F test/tableapi.test ecbcc29c4ab62c1912c3717c48ea5c5e59f7d64e4a91034e6148bd2b82f177f4
|
||||
F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930
|
||||
F test/tclsqlite.test 316c96f974f0e6d7480186e3f5bb53413e5ee5480596544a97484888912a365c
|
||||
F test/tclsqlite.test 79a473f5797e317c08f2c4f8192edb3eea6a67329b1087453328b66a7cb31070
|
||||
F test/tempdb.test 4cdaa23ddd8acb4d79cbb1b68ccdfd09b0537aaba909ca69a876157c2a2cbd08
|
||||
F test/tempdb2.test 353864e96fd3ae2f70773d0ffbf8b1fe48589b02c2ec05013b540879410c3440
|
||||
F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900
|
||||
@@ -1697,7 +1695,7 @@ F test/vtab6.test 8e789f526e6594cf7ae933d1adee0caa87dc9f78
|
||||
F test/vtab7.test 70c6f4a1d6177144a8236e4172d5fba92e683440374664ad1f04851fbb335d3c
|
||||
F test/vtab8.test e19fa4a538fcd1bb66c22825fa8f71618fb13583
|
||||
F test/vtab9.test ea58d2b95d61955f87226381716b2d0b1d4e4f9b
|
||||
F test/vtabA.test 325a77e7f0f80aa78ab388875c0ad6fb853acc6ac54d85514650b0ae15da24ff
|
||||
F test/vtabA.test 1317f06a03597eee29f40a49b6c21e1aaba4285f
|
||||
F test/vtabB.test 04df5dc531b9f44d9ca65b9c1b79f12b5922a796
|
||||
F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292
|
||||
F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96
|
||||
@@ -1799,7 +1797,7 @@ F test/windowerr.test a8b752402109c15aa1c5efe1b93ccb0ce1ef84fa964ae1cd6684dd0b3c
|
||||
F test/windowfault.test 21919e601f20b976ea2a73aa401220c89ed0e8d203c4f69476ea55bce3726496
|
||||
F test/windowpushd.test d8895d08870b7226f7693665bd292eb177e62ca06799184957b3ca7dc03067df
|
||||
F test/with1.test 7bc5abfe4c80c0cef8a90f5a66d60b9982e8ccd7350c8eb70611323a3b8e07ba
|
||||
F test/with2.test f803743b2c746ecdd0b638783c7235654b947b0f1c4bb551ca10e1d813317153
|
||||
F test/with2.test bbf82609bbacc0a7a01d822022aed7b2fa702436dd3d0ecf942023564d2bba13
|
||||
F test/with3.test ad32d13ad50661e6fa305f62a0717649c348792e7b658bf2644976227a9e0373
|
||||
F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205
|
||||
F test/with5.test 6248213c41fab36290b5b73aa3f937309dfba337004d9d8434c3fabc8c7d4be8
|
||||
@@ -1809,7 +1807,7 @@ F test/without_rowid1.test 6abc5d497f634520944dac0a89a6c240a48d2ee0f8353356a750e
|
||||
F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
|
||||
F test/without_rowid3.test 39ab0dd773eaa62e59b17093f875327630f54c4145458f6d2b053d68d4b2f67b
|
||||
F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
|
||||
F test/without_rowid5.test f058a97600c09c7c8754733b9d8adc428e055f815d8926d74b59b872e20d0e2b
|
||||
F test/without_rowid5.test 89b1c587bd92a0590e440da33e7666bf4891572a
|
||||
F test/without_rowid6.test efbd7add62c59bf5ca97bf8da674e734e6a70ef979234e816166824b4d258f68
|
||||
F test/without_rowid7.test d7c59a93d726b55812d620f8f284e01904a5b85f9ee9eea8f2f68571a5e8c40e
|
||||
F test/wordcount.c d721a4b6fae93e6e33449700bce1686bc23257c27425bc3ef1599dc912adec66
|
||||
@@ -1841,7 +1839,7 @@ F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
|
||||
F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5
|
||||
F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f
|
||||
F tool/lemon.c a5acddd3eec6a388872aae6efc7563336348a9c45e5563642f77e8e3a50e859d
|
||||
F tool/lempar.c bbabd74a36513a4376a6b26a35804b11adae6f335d47aab29cc3bbaaa85fa4d5
|
||||
F tool/lempar.c 1d3d075da18681c67ecc66c1f171e7094e18cd2cfba6a8a1bd4f3f639d6656e1
|
||||
F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9
|
||||
F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
|
||||
F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca
|
||||
@@ -1852,15 +1850,15 @@ F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650
|
||||
F tool/mkctimec.tcl 5ef1891ed3d0e8143ff39bad7c01ed60c2817a2fb2d9a09487f7ccad2df621e4
|
||||
F tool/mkkeywordhash.c 08b6e4d7a482a7f37a9a0032e7ba968e26624a027b6b2e9ba589be6f5e3d8c2c
|
||||
F tool/mkmsvcmin.tcl 6ecab9fe22c2c8de4d82d4c46797bda3d2deac8e763885f5a38d0c44a895ab33
|
||||
F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef
|
||||
F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c
|
||||
F tool/mkopcodeh.tcl 130b88697da6ec5b89b41844d955d08fb62c2552e889dec8c7bcecb28d8f50bd
|
||||
F tool/mkopts.tcl 680f785fdb09729fd9ac50632413da4eadbdf9071535e3f26d03795828ab07fa
|
||||
F tool/mkpragmatab.tcl 7f6db47d1995bc08247255622524567b2ab8962d98063f8aef97e35c3c54e3b8
|
||||
F tool/mkshellc.tcl df5d249617f9cc94d5c48eb0401673eb3f31f383ecbc54e8a13ca3dd97e89450
|
||||
F tool/mkshellc.tcl 5fe7e518112b262e25726f248c0f33dd153192867453984b6af0a76a88e97cb2
|
||||
F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9
|
||||
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
|
||||
F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f
|
||||
F tool/mksqlite3c.tcl bf9b40811aba68f73f2a8848fad9b1fb09fd54ab5b77e5227f18eea87ab60d92
|
||||
F tool/mksqlite3c.tcl cf5686da672bc2e62cf868b7d53fc9a2aebf1b0e497164cbb9f647ec724ce0b2
|
||||
F tool/mksqlite3h.tcl 1f5e4a1dbbbc43c83cc6e74fe32c6c620502240b66c7c0f33a51378e78fc4edf
|
||||
F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
|
||||
F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5
|
||||
@@ -1877,7 +1875,7 @@ F tool/showjournal.c 5bad7ae8784a43d2b270d953060423b8bd480818
|
||||
F tool/showlocks.c 9cc5e66d4ebbf2d194f39db2527ece92077e86ae627ddd233ee48e16e8142564
|
||||
F tool/showshm.c a0ab6ec32dd1f11218ca2a4018f8fb875b59414801ab8ceed8b2e69b7b45a809
|
||||
F tool/showstat4.c 0682ebea7abf4d3657f53c4a243f2e7eab48eab344ed36a94bb75dcd19a5c2a1
|
||||
F tool/showwal.c 0253c187ae16fdae9cde89e63e1dfcd3bb35e5416d066415f99e2f8cac6ab03d
|
||||
F tool/showwal.c ad9d768f96ca6199ad3a8c9562d679680bd032dd01204ea3e5ea6fb931d81847
|
||||
F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe
|
||||
F tool/spaceanal.tcl 1b5be34c6223cb1af06da2a10fb77863eb869b1962d055820b0a11cf2336ab45
|
||||
F tool/speed-check.sh 8ba7c7c0dba37e664679974f5954f2282275271a5b92f890756e282df0bfc458
|
||||
@@ -1922,7 +1920,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 1ed1b594d3c03ced68eb2b1285dfd8b9641cda20db1b1b7ae1afee217a3a9fe2
|
||||
R 1becdbd72e9bc3a6d98c91082fba4b52
|
||||
P d317d44fbba53883d2b85846d61d4738891bd98f8045ae58e56ddfe6f27ab01a 4d1dbfa35c7dc0f09321b2e274a00e506f4ca65322454652d5891d815a6966d3
|
||||
R 49dbd10e8caa8f5bdad813af0e201c27
|
||||
U drh
|
||||
Z c26092e6de7efa8875b0da24f3b94164
|
||||
Z f609898ce79cf103e62694adc86b9cfa
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
39abca01479c0f4f747b7b21fa05181896b00ed7559f0ab74aa575c23097ac21
|
||||
8498d7727c25859f1a48b85bec44a0b9ad6e8c48112498d6c71882458970c637
|
||||
+42
-44
@@ -135,7 +135,9 @@ void sqlite3AlterRenameTable(
|
||||
const char *zTabName; /* Original name of the table */
|
||||
Vdbe *v;
|
||||
VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */
|
||||
u32 savedDbFlags; /* Saved value of db->mDbFlags */
|
||||
|
||||
savedDbFlags = db->mDbFlags;
|
||||
if( NEVER(db->mallocFailed) ) goto exit_rename_table;
|
||||
assert( pSrc->nSrc==1 );
|
||||
assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );
|
||||
@@ -144,6 +146,7 @@ void sqlite3AlterRenameTable(
|
||||
if( !pTab ) goto exit_rename_table;
|
||||
iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
|
||||
zDb = db->aDb[iDb].zDbSName;
|
||||
db->mDbFlags |= DBFLAG_PreferBuiltin;
|
||||
|
||||
/* Get a NULL terminated version of the new table name. */
|
||||
zName = sqlite3NameFromToken(db, pName);
|
||||
@@ -172,7 +175,7 @@ void sqlite3AlterRenameTable(
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_VIEW
|
||||
if( IsView(pTab) ){
|
||||
if( pTab->pSelect ){
|
||||
sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName);
|
||||
goto exit_rename_table;
|
||||
}
|
||||
@@ -284,6 +287,7 @@ void sqlite3AlterRenameTable(
|
||||
exit_rename_table:
|
||||
sqlite3SrcListDelete(db, pSrc);
|
||||
sqlite3DbFree(db, zName);
|
||||
db->mDbFlags = savedDbFlags;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -333,7 +337,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
|
||||
zDb = db->aDb[iDb].zDbSName;
|
||||
zTab = &pNew->zName[16]; /* Skip the "sqlite_altertab_" prefix on the name */
|
||||
pCol = &pNew->aCol[pNew->nCol-1];
|
||||
pDflt = sqlite3ColumnExpr(pNew, pCol);
|
||||
pDflt = pCol->pDflt;
|
||||
pTab = sqlite3FindTable(db, zTab, zDb);
|
||||
assert( pTab );
|
||||
|
||||
@@ -367,7 +371,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
|
||||
if( pDflt && pDflt->pLeft->op==TK_NULL ){
|
||||
pDflt = 0;
|
||||
}
|
||||
if( (db->flags&SQLITE_ForeignKeys) && pNew->u.tab.pFKey && pDflt ){
|
||||
if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){
|
||||
sqlite3ErrorIfNotEmpty(pParse, zDb, zTab,
|
||||
"Cannot add a REFERENCES column with non-NULL default value");
|
||||
}
|
||||
@@ -404,21 +408,23 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
|
||||
zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);
|
||||
if( zCol ){
|
||||
char *zEnd = &zCol[pColDef->n-1];
|
||||
u32 savedDbFlags = db->mDbFlags;
|
||||
while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){
|
||||
*zEnd-- = '\0';
|
||||
}
|
||||
db->mDbFlags |= DBFLAG_PreferBuiltin;
|
||||
/* substr() operations on characters, but addColOffset is in bytes. So we
|
||||
** have to use printf() to translate between these units: */
|
||||
assert( !IsVirtual(pTab) );
|
||||
sqlite3NestedParse(pParse,
|
||||
"UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET "
|
||||
"sql = printf('%%.%ds, ',sql) || %Q"
|
||||
" || substr(sql,1+length(printf('%%.%ds',sql))) "
|
||||
"WHERE type = 'table' AND name = %Q",
|
||||
zDb, pNew->u.tab.addColOffset, zCol, pNew->u.tab.addColOffset,
|
||||
zDb, pNew->addColOffset, zCol, pNew->addColOffset,
|
||||
zTab
|
||||
);
|
||||
sqlite3DbFree(db, zCol);
|
||||
db->mDbFlags = savedDbFlags;
|
||||
}
|
||||
|
||||
v = sqlite3GetVdbe(pParse);
|
||||
@@ -494,7 +500,7 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
|
||||
#endif
|
||||
|
||||
/* Make sure this is not an attempt to ALTER a view. */
|
||||
if( IsView(pTab) ){
|
||||
if( pTab->pSelect ){
|
||||
sqlite3ErrorMsg(pParse, "Cannot add a column to a view");
|
||||
goto exit_begin_add_column;
|
||||
}
|
||||
@@ -503,7 +509,7 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
|
||||
}
|
||||
|
||||
sqlite3MayAbort(pParse);
|
||||
assert( pTab->u.tab.addColOffset>0 );
|
||||
assert( pTab->addColOffset>0 );
|
||||
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
|
||||
/* Put a copy of the Table struct in Parse.pNewTable for the
|
||||
@@ -530,13 +536,13 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
|
||||
memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol);
|
||||
for(i=0; i<pNew->nCol; i++){
|
||||
Column *pCol = &pNew->aCol[i];
|
||||
pCol->zCnName = sqlite3DbStrDup(db, pCol->zCnName);
|
||||
pCol->hName = sqlite3StrIHash(pCol->zCnName);
|
||||
pCol->zName = sqlite3DbStrDup(db, pCol->zName);
|
||||
pCol->hName = sqlite3StrIHash(pCol->zName);
|
||||
pCol->zColl = 0;
|
||||
pCol->pDflt = 0;
|
||||
}
|
||||
assert( !IsVirtual(pNew) );
|
||||
pNew->u.tab.pDfltList = sqlite3ExprListDup(db, pTab->u.tab.pDfltList, 0);
|
||||
pNew->pSchema = db->aDb[iDb].pSchema;
|
||||
pNew->u.tab.addColOffset = pTab->u.tab.addColOffset;
|
||||
pNew->addColOffset = pTab->addColOffset;
|
||||
pNew->nTabRef = 1;
|
||||
|
||||
exit_begin_add_column:
|
||||
@@ -556,7 +562,7 @@ exit_begin_add_column:
|
||||
static int isRealTable(Parse *pParse, Table *pTab, int bDrop){
|
||||
const char *zType = 0;
|
||||
#ifndef SQLITE_OMIT_VIEW
|
||||
if( IsView(pTab) ){
|
||||
if( pTab->pSelect ){
|
||||
zType = "view";
|
||||
}
|
||||
#endif
|
||||
@@ -623,7 +629,7 @@ void sqlite3AlterRenameColumn(
|
||||
zOld = sqlite3NameFromToken(db, pOld);
|
||||
if( !zOld ) goto exit_rename_column;
|
||||
for(iCol=0; iCol<pTab->nCol; iCol++){
|
||||
if( 0==sqlite3StrICmp(pTab->aCol[iCol].zCnName, zOld) ) break;
|
||||
if( 0==sqlite3StrICmp(pTab->aCol[iCol].zName, zOld) ) break;
|
||||
}
|
||||
if( iCol==pTab->nCol ){
|
||||
sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zOld);
|
||||
@@ -1469,7 +1475,7 @@ static void renameColumnFunc(
|
||||
sqlite3BtreeLeaveAll(db);
|
||||
return;
|
||||
}
|
||||
zOld = pTab->aCol[iCol].zCnName;
|
||||
zOld = pTab->aCol[iCol].zName;
|
||||
memset(&sCtx, 0, sizeof(sCtx));
|
||||
sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol);
|
||||
|
||||
@@ -1488,8 +1494,8 @@ static void renameColumnFunc(
|
||||
sCtx.pTab = pTab;
|
||||
if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
|
||||
if( sParse.pNewTable ){
|
||||
if( IsView(sParse.pNewTable) ){
|
||||
Select *pSelect = sParse.pNewTable->u.view.pSelect;
|
||||
Select *pSelect = sParse.pNewTable->pSelect;
|
||||
if( pSelect ){
|
||||
pSelect->selFlags &= ~SF_View;
|
||||
sParse.rc = SQLITE_OK;
|
||||
sqlite3SelectPrep(&sParse, pSelect, 0);
|
||||
@@ -1498,15 +1504,16 @@ static void renameColumnFunc(
|
||||
sqlite3WalkSelect(&sWalker, pSelect);
|
||||
}
|
||||
if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
|
||||
}else if( ALWAYS(IsOrdinaryTable(sParse.pNewTable)) ){
|
||||
}else{
|
||||
/* A regular table */
|
||||
int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName);
|
||||
FKey *pFKey;
|
||||
assert( sParse.pNewTable->pSelect==0 );
|
||||
sCtx.pTab = sParse.pNewTable;
|
||||
if( bFKOnly==0 ){
|
||||
if( iCol<sParse.pNewTable->nCol ){
|
||||
renameTokenFind(
|
||||
&sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zCnName
|
||||
&sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName
|
||||
);
|
||||
}
|
||||
if( sCtx.iCol<0 ){
|
||||
@@ -1521,15 +1528,12 @@ static void renameColumnFunc(
|
||||
}
|
||||
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
|
||||
for(i=0; i<sParse.pNewTable->nCol; i++){
|
||||
Expr *pExpr = sqlite3ColumnExpr(sParse.pNewTable,
|
||||
&sParse.pNewTable->aCol[i]);
|
||||
sqlite3WalkExpr(&sWalker, pExpr);
|
||||
sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
assert( !IsVirtual(sParse.pNewTable) );
|
||||
for(pFKey=sParse.pNewTable->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
for(i=0; i<pFKey->nCol; i++){
|
||||
if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){
|
||||
renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]);
|
||||
@@ -1695,31 +1699,28 @@ static void renameTableFunc(
|
||||
if( sParse.pNewTable ){
|
||||
Table *pTab = sParse.pNewTable;
|
||||
|
||||
if( IsView(pTab) ){
|
||||
if( pTab->pSelect ){
|
||||
if( isLegacy==0 ){
|
||||
Select *pSelect = pTab->u.view.pSelect;
|
||||
Select *pSelect = pTab->pSelect;
|
||||
NameContext sNC;
|
||||
memset(&sNC, 0, sizeof(sNC));
|
||||
sNC.pParse = &sParse;
|
||||
|
||||
assert( pSelect->selFlags & SF_View );
|
||||
pSelect->selFlags &= ~SF_View;
|
||||
sqlite3SelectPrep(&sParse, pTab->u.view.pSelect, &sNC);
|
||||
sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC);
|
||||
if( sParse.nErr ){
|
||||
rc = sParse.rc;
|
||||
}else{
|
||||
sqlite3WalkSelect(&sWalker, pTab->u.view.pSelect);
|
||||
sqlite3WalkSelect(&sWalker, pTab->pSelect);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
/* Modify any FK definitions to point to the new table. */
|
||||
#ifndef SQLITE_OMIT_FOREIGN_KEY
|
||||
if( (isLegacy==0 || (db->flags & SQLITE_ForeignKeys))
|
||||
&& !IsVirtual(pTab)
|
||||
){
|
||||
if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){
|
||||
FKey *pFKey;
|
||||
assert( !IsVirtual(pTab) );
|
||||
for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
|
||||
renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
|
||||
}
|
||||
@@ -1859,8 +1860,8 @@ static void renameQuotefixFunc(
|
||||
sWalker.u.pRename = &sCtx;
|
||||
|
||||
if( sParse.pNewTable ){
|
||||
if( IsView(sParse.pNewTable) ){
|
||||
Select *pSelect = sParse.pNewTable->u.view.pSelect;
|
||||
Select *pSelect = sParse.pNewTable->pSelect;
|
||||
if( pSelect ){
|
||||
pSelect->selFlags &= ~SF_View;
|
||||
sParse.rc = SQLITE_OK;
|
||||
sqlite3SelectPrep(&sParse, pSelect, 0);
|
||||
@@ -1873,9 +1874,7 @@ static void renameQuotefixFunc(
|
||||
sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck);
|
||||
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
|
||||
for(i=0; i<sParse.pNewTable->nCol; i++){
|
||||
sqlite3WalkExpr(&sWalker,
|
||||
sqlite3ColumnExpr(sParse.pNewTable,
|
||||
&sParse.pNewTable->aCol[i]));
|
||||
sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt);
|
||||
}
|
||||
#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
|
||||
}
|
||||
@@ -1958,11 +1957,11 @@ static void renameTableTest(
|
||||
rc = renameParseSql(&sParse, zDb, db, zInput, bTemp);
|
||||
db->flags |= (flags & (SQLITE_DqsDML|SQLITE_DqsDDL));
|
||||
if( rc==SQLITE_OK ){
|
||||
if( isLegacy==0 && sParse.pNewTable && IsView(sParse.pNewTable) ){
|
||||
if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){
|
||||
NameContext sNC;
|
||||
memset(&sNC, 0, sizeof(sNC));
|
||||
sNC.pParse = &sParse;
|
||||
sqlite3SelectPrep(&sParse, sParse.pNewTable->u.view.pSelect, &sNC);
|
||||
sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, &sNC);
|
||||
if( sParse.nErr ) rc = sParse.rc;
|
||||
}
|
||||
|
||||
@@ -2033,14 +2032,13 @@ static void dropColumnFunc(
|
||||
goto drop_column_done;
|
||||
}
|
||||
|
||||
pCol = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol].zCnName);
|
||||
pCol = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol].zName);
|
||||
if( iCol<pTab->nCol-1 ){
|
||||
RenameToken *pEnd;
|
||||
pEnd = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol+1].zCnName);
|
||||
pEnd = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol+1].zName);
|
||||
zEnd = (const char*)pEnd->t.z;
|
||||
}else{
|
||||
assert( !IsVirtual(pTab) );
|
||||
zEnd = (const char*)&zSql[pTab->u.tab.addColOffset];
|
||||
zEnd = (const char*)&zSql[pTab->addColOffset];
|
||||
while( ALWAYS(pCol->t.z[0]!=0) && pCol->t.z[0]!=',' ) pCol->t.z--;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -968,7 +968,7 @@ static void analyzeVdbeCommentIndexWithColumnName(
|
||||
}else if( i==XN_EXPR ){
|
||||
VdbeComment((v,"%s.expr(%d)",pIdx->zName, k));
|
||||
}else{
|
||||
VdbeComment((v,"%s.%s", pIdx->zName, pIdx->pTable->aCol[i].zCnName));
|
||||
VdbeComment((v,"%s.%s", pIdx->zName, pIdx->pTable->aCol[i].zName));
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
+2
-2
@@ -175,10 +175,10 @@ void sqlite3AuthRead(
|
||||
|
||||
if( iCol>=0 ){
|
||||
assert( iCol<pTab->nCol );
|
||||
zCol = pTab->aCol[iCol].zCnName;
|
||||
zCol = pTab->aCol[iCol].zName;
|
||||
}else if( pTab->iPKey>=0 ){
|
||||
assert( pTab->iPKey<pTab->nCol );
|
||||
zCol = pTab->aCol[pTab->iPKey].zCnName;
|
||||
zCol = pTab->aCol[pTab->iPKey].zName;
|
||||
}else{
|
||||
zCol = "ROWID";
|
||||
}
|
||||
|
||||
+87
-255
@@ -285,22 +285,20 @@ void sqlite3FinishCoding(Parse *pParse){
|
||||
/*
|
||||
** Run the parser and code generator recursively in order to generate
|
||||
** code for the SQL statement given onto the end of the pParse context
|
||||
** currently under construction. Notes:
|
||||
** currently under construction. When the parser is run recursively
|
||||
** this way, the final OP_Halt is not appended and other initialization
|
||||
** and finalization steps are omitted because those are handling by the
|
||||
** outermost parser.
|
||||
**
|
||||
** * The final OP_Halt is not appended and other initialization
|
||||
** and finalization steps are omitted because those are handling by the
|
||||
** outermost parser.
|
||||
**
|
||||
** * Built-in SQL functions always take precedence over application-defined
|
||||
** SQL functions. In other words, it is not possible to override a
|
||||
** built-in function.
|
||||
** Not everything is nestable. This facility is designed to permit
|
||||
** INSERT, UPDATE, and DELETE operations against the schema table. Use
|
||||
** care if you decide to try to use this routine for some other purposes.
|
||||
*/
|
||||
void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
|
||||
va_list ap;
|
||||
char *zSql;
|
||||
char *zErrMsg = 0;
|
||||
sqlite3 *db = pParse->db;
|
||||
u32 savedDbFlags = db->mDbFlags;
|
||||
char saveBuf[PARSE_TAIL_SZ];
|
||||
|
||||
if( pParse->nErr ) return;
|
||||
@@ -319,9 +317,7 @@ void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
|
||||
pParse->nested++;
|
||||
memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);
|
||||
memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
|
||||
db->mDbFlags |= DBFLAG_PreferBuiltin;
|
||||
sqlite3RunParser(pParse, zSql, &zErrMsg);
|
||||
db->mDbFlags = savedDbFlags;
|
||||
sqlite3DbFree(db, zErrMsg);
|
||||
sqlite3DbFree(db, zSql);
|
||||
memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ);
|
||||
@@ -671,84 +667,6 @@ void sqlite3CommitInternalChanges(sqlite3 *db){
|
||||
db->mDbFlags &= ~DBFLAG_SchemaChange;
|
||||
}
|
||||
|
||||
/*
|
||||
** Set the expression associated with a column. This is usually
|
||||
** the DEFAULT value, but might also be the expression that computes
|
||||
** the value for a generated column.
|
||||
*/
|
||||
void sqlite3ColumnSetExpr(
|
||||
Parse *pParse, /* Parsing context */
|
||||
Table *pTab, /* The table containing the column */
|
||||
Column *pCol, /* The column to receive the new DEFAULT expression */
|
||||
Expr *pExpr /* The new default expression */
|
||||
){
|
||||
ExprList *pList;
|
||||
assert( !IsVirtual(pTab) );
|
||||
pList = pTab->u.tab.pDfltList;
|
||||
if( pCol->iDflt==0
|
||||
|| NEVER(pList==0)
|
||||
|| NEVER(pList->nExpr<pCol->iDflt)
|
||||
){
|
||||
pCol->iDflt = pList==0 ? 1 : pList->nExpr+1;
|
||||
pTab->u.tab.pDfltList = sqlite3ExprListAppend(pParse, pList, pExpr);
|
||||
}else{
|
||||
sqlite3ExprDelete(pParse->db, pList->a[pCol->iDflt-1].pExpr);
|
||||
pList->a[pCol->iDflt-1].pExpr = pExpr;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the expression associated with a column. The expression might be
|
||||
** the DEFAULT clause or the AS clause of a generated column.
|
||||
** Return NULL if the column has no associated expression.
|
||||
*/
|
||||
Expr *sqlite3ColumnExpr(Table *pTab, Column *pCol){
|
||||
if( pCol->iDflt==0 ) return 0;
|
||||
if( NEVER(IsVirtual(pTab)) ) return 0;
|
||||
if( NEVER(pTab->u.tab.pDfltList==0) ) return 0;
|
||||
if( NEVER(pTab->u.tab.pDfltList->nExpr<pCol->iDflt) ) return 0;
|
||||
return pTab->u.tab.pDfltList->a[pCol->iDflt-1].pExpr;
|
||||
}
|
||||
|
||||
/*
|
||||
** Set the collating sequence name for a column.
|
||||
*/
|
||||
void sqlite3ColumnSetColl(
|
||||
sqlite3 *db,
|
||||
Column *pCol,
|
||||
const char *zColl
|
||||
){
|
||||
int nColl;
|
||||
int n;
|
||||
char *zNew;
|
||||
assert( zColl!=0 );
|
||||
n = sqlite3Strlen30(pCol->zCnName) + 1;
|
||||
if( pCol->colFlags & COLFLAG_HASTYPE ){
|
||||
n += sqlite3Strlen30(pCol->zCnName+n) + 1;
|
||||
}
|
||||
nColl = sqlite3Strlen30(zColl) + 1;
|
||||
zNew = sqlite3DbRealloc(db, pCol->zCnName, nColl+n);
|
||||
if( zNew ){
|
||||
pCol->zCnName = zNew;
|
||||
memcpy(pCol->zCnName + n, zColl, nColl);
|
||||
pCol->colFlags |= COLFLAG_HASCOLL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the collating squence name for a column
|
||||
*/
|
||||
const char *sqlite3ColumnColl(Column *pCol){
|
||||
const char *z;
|
||||
if( (pCol->colFlags & COLFLAG_HASCOLL)==0 ) return 0;
|
||||
z = pCol->zCnName;
|
||||
while( *z ){ z++; }
|
||||
if( pCol->colFlags & COLFLAG_HASTYPE ){
|
||||
do{ z++; }while( *z );
|
||||
}
|
||||
return z+1;
|
||||
}
|
||||
|
||||
/*
|
||||
** Delete memory allocated for the column names of a table or view (the
|
||||
** Table.aCol[] array).
|
||||
@@ -759,20 +677,12 @@ void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){
|
||||
assert( pTable!=0 );
|
||||
if( (pCol = pTable->aCol)!=0 ){
|
||||
for(i=0; i<pTable->nCol; i++, pCol++){
|
||||
assert( pCol->zCnName==0 || pCol->hName==sqlite3StrIHash(pCol->zCnName) );
|
||||
sqlite3DbFree(db, pCol->zCnName);
|
||||
assert( pCol->zName==0 || pCol->hName==sqlite3StrIHash(pCol->zName) );
|
||||
sqlite3DbFree(db, pCol->zName);
|
||||
sqlite3ExprDelete(db, pCol->pDflt);
|
||||
sqlite3DbFree(db, pCol->zColl);
|
||||
}
|
||||
sqlite3DbFree(db, pTable->aCol);
|
||||
if( !IsVirtual(pTable) ){
|
||||
sqlite3ExprListDelete(db, pTable->u.tab.pDfltList);
|
||||
}
|
||||
if( db==0 || db->pnBytesFreed==0 ){
|
||||
pTable->aCol = 0;
|
||||
pTable->nCol = 0;
|
||||
if( !IsVirtual(pTable) ){
|
||||
pTable->u.tab.pDfltList = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,25 +734,19 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){
|
||||
sqlite3FreeIndex(db, pIndex);
|
||||
}
|
||||
|
||||
if( IsOrdinaryTable(pTable) ){
|
||||
sqlite3FkDelete(db, pTable);
|
||||
}
|
||||
#ifndef SQLITE_OMIT_VIRTUAL_TABLE
|
||||
else if( IsVirtual(pTable) ){
|
||||
sqlite3VtabClear(db, pTable);
|
||||
}
|
||||
#endif
|
||||
else{
|
||||
assert( IsView(pTable) );
|
||||
sqlite3SelectDelete(db, pTable->u.view.pSelect);
|
||||
}
|
||||
/* Delete any foreign keys attached to this table. */
|
||||
sqlite3FkDelete(db, pTable);
|
||||
|
||||
/* Delete the Table structure itself.
|
||||
*/
|
||||
sqlite3DeleteColumnNames(db, pTable);
|
||||
sqlite3DbFree(db, pTable->zName);
|
||||
sqlite3DbFree(db, pTable->zColAff);
|
||||
sqlite3SelectDelete(db, pTable->pSelect);
|
||||
sqlite3ExprListDelete(db, pTable->pCheck);
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
sqlite3VtabClear(db, pTable);
|
||||
#endif
|
||||
sqlite3DbFree(db, pTable);
|
||||
|
||||
/* Verify that no lookaside memory was used by schema tables */
|
||||
@@ -1378,7 +1282,7 @@ begin_table_error:
|
||||
*/
|
||||
#if SQLITE_ENABLE_HIDDEN_COLUMNS
|
||||
void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){
|
||||
if( sqlite3_strnicmp(pCol->zCnName, "__hidden__", 10)==0 ){
|
||||
if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){
|
||||
pCol->colFlags |= COLFLAG_HIDDEN;
|
||||
if( pTab ) pTab->tabFlags |= TF_HasHidden;
|
||||
}else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){
|
||||
@@ -1469,7 +1373,7 @@ void sqlite3AddReturning(Parse *pParse, ExprList *pList){
|
||||
** first to get things going. Then this routine is called for each
|
||||
** column.
|
||||
*/
|
||||
void sqlite3AddColumn(Parse *pParse, Token sName, Token sType){
|
||||
void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){
|
||||
Table *p;
|
||||
int i;
|
||||
char *z;
|
||||
@@ -1477,96 +1381,55 @@ void sqlite3AddColumn(Parse *pParse, Token sName, Token sType){
|
||||
Column *pCol;
|
||||
sqlite3 *db = pParse->db;
|
||||
u8 hName;
|
||||
Column *aNew;
|
||||
u8 eType = COLTYPE_CUSTOM;
|
||||
u8 szEst = 1;
|
||||
char affinity = SQLITE_AFF_BLOB;
|
||||
|
||||
if( (p = pParse->pNewTable)==0 ) return;
|
||||
if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){
|
||||
sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName);
|
||||
return;
|
||||
}
|
||||
if( !IN_RENAME_OBJECT ) sqlite3DequoteToken(&sName);
|
||||
|
||||
/* Because keywords GENERATE ALWAYS can be converted into indentifiers
|
||||
** by the parser, we can sometimes end up with a typename that ends
|
||||
** with "generated always". Check for this case and omit the surplus
|
||||
** text. */
|
||||
if( sType.n>=16
|
||||
&& sqlite3_strnicmp(sType.z+(sType.n-6),"always",6)==0
|
||||
){
|
||||
sType.n -= 6;
|
||||
while( ALWAYS(sType.n>0) && sqlite3Isspace(sType.z[sType.n-1]) ) sType.n--;
|
||||
if( sType.n>=9
|
||||
&& sqlite3_strnicmp(sType.z+(sType.n-9),"generated",9)==0
|
||||
){
|
||||
sType.n -= 9;
|
||||
while( sType.n>0 && sqlite3Isspace(sType.z[sType.n-1]) ) sType.n--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for standard typenames. For standard typenames we will
|
||||
** set the Column.eType field rather than storing the typename after
|
||||
** the column name, in order to save space. */
|
||||
if( sType.n>=3 ){
|
||||
sqlite3DequoteToken(&sType);
|
||||
for(i=0; i<SQLITE_N_STDTYPE; i++){
|
||||
if( sType.n==sqlite3StdTypeLen[i]
|
||||
&& sqlite3_strnicmp(sType.z, sqlite3StdType[i], sType.n)==0
|
||||
){
|
||||
sType.n = 0;
|
||||
eType = i+1;
|
||||
affinity = sqlite3StdTypeAffinity[i];
|
||||
if( affinity<=SQLITE_AFF_TEXT ) szEst = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
z = sqlite3DbMallocRaw(db, sName.n + 1 + sType.n + (sType.n>0) );
|
||||
z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2);
|
||||
if( z==0 ) return;
|
||||
if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, &sName);
|
||||
memcpy(z, sName.z, sName.n);
|
||||
z[sName.n] = 0;
|
||||
if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, pName);
|
||||
memcpy(z, pName->z, pName->n);
|
||||
z[pName->n] = 0;
|
||||
sqlite3Dequote(z);
|
||||
hName = sqlite3StrIHash(z);
|
||||
for(i=0; i<p->nCol; i++){
|
||||
if( p->aCol[i].hName==hName && sqlite3StrICmp(z, p->aCol[i].zCnName)==0 ){
|
||||
if( p->aCol[i].hName==hName && sqlite3StrICmp(z, p->aCol[i].zName)==0 ){
|
||||
sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);
|
||||
sqlite3DbFree(db, z);
|
||||
return;
|
||||
}
|
||||
}
|
||||
aNew = sqlite3DbRealloc(db,p->aCol,(p->nCol+1)*sizeof(p->aCol[0]));
|
||||
if( aNew==0 ){
|
||||
sqlite3DbFree(db, z);
|
||||
return;
|
||||
if( (p->nCol & 0x7)==0 ){
|
||||
Column *aNew;
|
||||
aNew = sqlite3DbRealloc(db,p->aCol,(p->nCol+8)*sizeof(p->aCol[0]));
|
||||
if( aNew==0 ){
|
||||
sqlite3DbFree(db, z);
|
||||
return;
|
||||
}
|
||||
p->aCol = aNew;
|
||||
}
|
||||
p->aCol = aNew;
|
||||
pCol = &p->aCol[p->nCol];
|
||||
memset(pCol, 0, sizeof(p->aCol[0]));
|
||||
pCol->zCnName = z;
|
||||
pCol->zName = z;
|
||||
pCol->hName = hName;
|
||||
sqlite3ColumnPropertiesFromName(p, pCol);
|
||||
|
||||
if( sType.n==0 ){
|
||||
if( pType->n==0 ){
|
||||
/* If there is no type specified, columns have the default affinity
|
||||
** 'BLOB' with a default size of 4 bytes. */
|
||||
pCol->affinity = affinity;
|
||||
pCol->eCType = eType;
|
||||
pCol->szEst = szEst;
|
||||
pCol->affinity = SQLITE_AFF_BLOB;
|
||||
pCol->szEst = 1;
|
||||
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
|
||||
if( affinity==SQLITE_AFF_BLOB ){
|
||||
if( 4>=sqlite3GlobalConfig.szSorterRef ){
|
||||
pCol->colFlags |= COLFLAG_SORTERREF;
|
||||
}
|
||||
if( 4>=sqlite3GlobalConfig.szSorterRef ){
|
||||
pCol->colFlags |= COLFLAG_SORTERREF;
|
||||
}
|
||||
#endif
|
||||
}else{
|
||||
zType = z + sqlite3Strlen30(z) + 1;
|
||||
memcpy(zType, sType.z, sType.n);
|
||||
zType[sType.n] = 0;
|
||||
memcpy(zType, pType->z, pType->n);
|
||||
zType[pType->n] = 0;
|
||||
sqlite3Dequote(zType);
|
||||
pCol->affinity = sqlite3AffinityType(zType, pCol);
|
||||
pCol->colFlags |= COLFLAG_HASTYPE;
|
||||
@@ -1721,7 +1584,7 @@ void sqlite3AddDefaultValue(
|
||||
pCol = &(p->aCol[p->nCol-1]);
|
||||
if( !sqlite3ExprIsConstantOrFunction(pExpr, isInit) ){
|
||||
sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant",
|
||||
pCol->zCnName);
|
||||
pCol->zName);
|
||||
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
|
||||
}else if( pCol->colFlags & COLFLAG_GENERATED ){
|
||||
testcase( pCol->colFlags & COLFLAG_VIRTUAL );
|
||||
@@ -1732,15 +1595,15 @@ void sqlite3AddDefaultValue(
|
||||
/* A copy of pExpr is used instead of the original, as pExpr contains
|
||||
** tokens that point to volatile memory.
|
||||
*/
|
||||
Expr x, *pDfltExpr;
|
||||
Expr x;
|
||||
sqlite3ExprDelete(db, pCol->pDflt);
|
||||
memset(&x, 0, sizeof(x));
|
||||
x.op = TK_SPAN;
|
||||
x.u.zToken = sqlite3DbSpanDup(db, zStart, zEnd);
|
||||
x.pLeft = pExpr;
|
||||
x.flags = EP_Skip;
|
||||
pDfltExpr = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE);
|
||||
pCol->pDflt = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE);
|
||||
sqlite3DbFree(db, x.u.zToken);
|
||||
sqlite3ColumnSetExpr(pParse, p, pCol, pDfltExpr);
|
||||
}
|
||||
}
|
||||
if( IN_RENAME_OBJECT ){
|
||||
@@ -1838,7 +1701,7 @@ void sqlite3AddPrimaryKey(
|
||||
if( pCExpr->op==TK_ID ){
|
||||
const char *zCName = pCExpr->u.zToken;
|
||||
for(iCol=0; iCol<pTab->nCol; iCol++){
|
||||
if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zCnName)==0 ){
|
||||
if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){
|
||||
pCol = &pTab->aCol[iCol];
|
||||
makeColumnPartOfPrimaryKey(pParse, pCol);
|
||||
break;
|
||||
@@ -1849,7 +1712,7 @@ void sqlite3AddPrimaryKey(
|
||||
}
|
||||
if( nTerm==1
|
||||
&& pCol
|
||||
&& pCol->eCType==COLTYPE_INTEGER
|
||||
&& sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0
|
||||
&& sortOrder!=SQLITE_SO_DESC
|
||||
){
|
||||
if( IN_RENAME_OBJECT && pList ){
|
||||
@@ -1929,7 +1792,8 @@ void sqlite3AddCollateType(Parse *pParse, Token *pToken){
|
||||
|
||||
if( sqlite3LocateCollSeq(pParse, zColl) ){
|
||||
Index *pIdx;
|
||||
sqlite3ColumnSetColl(db, &p->aCol[i], zColl);
|
||||
sqlite3DbFree(db, p->aCol[i].zColl);
|
||||
p->aCol[i].zColl = zColl;
|
||||
|
||||
/* If the column is declared as "<name> PRIMARY KEY COLLATE <type>",
|
||||
** then an index may have been created on this column before the
|
||||
@@ -1938,11 +1802,12 @@ void sqlite3AddCollateType(Parse *pParse, Token *pToken){
|
||||
for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
|
||||
assert( pIdx->nKeyCol==1 );
|
||||
if( pIdx->aiColumn[0]==i ){
|
||||
pIdx->azColl[0] = sqlite3ColumnColl(&p->aCol[i]);
|
||||
pIdx->azColl[0] = p->aCol[i].zColl;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
sqlite3DbFree(db, zColl);
|
||||
}
|
||||
sqlite3DbFree(db, zColl);
|
||||
}
|
||||
|
||||
/* Change the most recently parsed column to be a GENERATED ALWAYS AS
|
||||
@@ -1962,7 +1827,7 @@ void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){
|
||||
sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns");
|
||||
goto generated_done;
|
||||
}
|
||||
if( pCol->iDflt>0 ) goto generated_error;
|
||||
if( pCol->pDflt ) goto generated_error;
|
||||
if( pType ){
|
||||
if( pType->n==7 && sqlite3StrNICmp("virtual",pType->z,7)==0 ){
|
||||
/* no-op */
|
||||
@@ -1980,13 +1845,13 @@ void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){
|
||||
if( pCol->colFlags & COLFLAG_PRIMKEY ){
|
||||
makeColumnPartOfPrimaryKey(pParse, pCol); /* For the error message */
|
||||
}
|
||||
sqlite3ColumnSetExpr(pParse, pTab, pCol, pExpr);
|
||||
pCol->pDflt = pExpr;
|
||||
pExpr = 0;
|
||||
goto generated_done;
|
||||
|
||||
generated_error:
|
||||
sqlite3ErrorMsg(pParse, "error in generated column \"%s\"",
|
||||
pCol->zCnName);
|
||||
pCol->zName);
|
||||
generated_done:
|
||||
sqlite3ExprDelete(pParse->db, pExpr);
|
||||
#else
|
||||
@@ -2088,7 +1953,7 @@ static char *createTableStmt(sqlite3 *db, Table *p){
|
||||
Column *pCol;
|
||||
n = 0;
|
||||
for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){
|
||||
n += identLength(pCol->zCnName) + 5;
|
||||
n += identLength(pCol->zName) + 5;
|
||||
}
|
||||
n += identLength(p->zName);
|
||||
if( n<50 ){
|
||||
@@ -2124,7 +1989,7 @@ static char *createTableStmt(sqlite3 *db, Table *p){
|
||||
sqlite3_snprintf(n-k, &zStmt[k], zSep);
|
||||
k += sqlite3Strlen30(&zStmt[k]);
|
||||
zSep = zSep2;
|
||||
identPut(zStmt, &k, pCol->zCnName);
|
||||
identPut(zStmt, &k, pCol->zName);
|
||||
assert( pCol->affinity-SQLITE_AFF_BLOB >= 0 );
|
||||
assert( pCol->affinity-SQLITE_AFF_BLOB < ArraySize(azType) );
|
||||
testcase( pCol->affinity==SQLITE_AFF_BLOB );
|
||||
@@ -2321,9 +2186,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
|
||||
*/
|
||||
if( !db->init.imposterTable ){
|
||||
for(i=0; i<pTab->nCol; i++){
|
||||
if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0
|
||||
&& (pTab->aCol[i].notNull==OE_None)
|
||||
){
|
||||
if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){
|
||||
pTab->aCol[i].notNull = OE_Abort;
|
||||
}
|
||||
}
|
||||
@@ -2345,7 +2208,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
|
||||
if( pTab->iPKey>=0 ){
|
||||
ExprList *pList;
|
||||
Token ipkToken;
|
||||
sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zCnName);
|
||||
sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);
|
||||
pList = sqlite3ExprListAppend(pParse, 0,
|
||||
sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
|
||||
if( pList==0 ){
|
||||
@@ -2475,7 +2338,7 @@ int sqlite3IsShadowTableOf(sqlite3 *db, Table *pTab, const char *zName){
|
||||
nName = sqlite3Strlen30(pTab->zName);
|
||||
if( sqlite3_strnicmp(zName, pTab->zName, nName)!=0 ) return 0;
|
||||
if( zName[nName]!='_' ) return 0;
|
||||
pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->u.vtab.azArg[0]);
|
||||
pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]);
|
||||
if( pMod==0 ) return 0;
|
||||
if( pMod->pModule->iVersion<3 ) return 0;
|
||||
if( pMod->pModule->xShadowName==0 ) return 0;
|
||||
@@ -2556,7 +2419,7 @@ void sqlite3EndTable(
|
||||
Parse *pParse, /* Parse context */
|
||||
Token *pCons, /* The ',' token after the last column defn. */
|
||||
Token *pEnd, /* The ')' before options in the CREATE TABLE */
|
||||
u32 tabOpts, /* Extra table options. Usually 0. */
|
||||
u8 tabOpts, /* Extra table options. Usually 0. */
|
||||
Select *pSelect /* Select from a "CREATE ... AS SELECT" */
|
||||
){
|
||||
Table *p; /* The new table */
|
||||
@@ -2592,37 +2455,6 @@ void sqlite3EndTable(
|
||||
if( p->tnum==1 ) p->tabFlags |= TF_Readonly;
|
||||
}
|
||||
|
||||
/* Special processing for tables that include the STRICT keyword:
|
||||
**
|
||||
** * Do not allow custom column datatypes. Every column must have
|
||||
** a datatype that is one of INT, INTEGER, REAL, TEXT, or BLOB.
|
||||
**
|
||||
** * If a PRIMARY KEY is defined, other than the INTEGER PRIMARY KEY,
|
||||
** then all columns of the PRIMARY KEY must have a NOT NULL
|
||||
** constraint.
|
||||
*/
|
||||
if( tabOpts & TF_Strict ){
|
||||
int ii;
|
||||
p->tabFlags |= TF_Strict;
|
||||
for(ii=0; ii<p->nCol; ii++){
|
||||
Column *pCol = &p->aCol[ii];
|
||||
if( pCol->eCType==COLTYPE_CUSTOM ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"unknown datatype for %s.%s: \"%s\"",
|
||||
p->zName, pCol->zCnName, sqlite3ColumnType(pCol, "")
|
||||
);
|
||||
return;
|
||||
}
|
||||
if( (pCol->colFlags & COLFLAG_PRIMKEY)!=0
|
||||
&& p->iPKey!=ii
|
||||
&& pCol->notNull == OE_None
|
||||
){
|
||||
pCol->notNull = OE_Abort;
|
||||
p->tabFlags |= TF_HasNotNull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert( (p->tabFlags & TF_HasPrimaryKey)==0
|
||||
|| p->iPKey>=0 || sqlite3PrimaryKeyIndex(p)!=0 );
|
||||
assert( (p->tabFlags & TF_HasPrimaryKey)!=0
|
||||
@@ -2667,7 +2499,7 @@ void sqlite3EndTable(
|
||||
for(ii=0; ii<p->nCol; ii++){
|
||||
u32 colFlags = p->aCol[ii].colFlags;
|
||||
if( (colFlags & COLFLAG_GENERATED)!=0 ){
|
||||
Expr *pX = sqlite3ColumnExpr(p, &p->aCol[ii]);
|
||||
Expr *pX = p->aCol[ii].pDflt;
|
||||
testcase( colFlags & COLFLAG_VIRTUAL );
|
||||
testcase( colFlags & COLFLAG_STORED );
|
||||
if( sqlite3ResolveSelfReference(pParse, p, NC_GenCol, pX, 0) ){
|
||||
@@ -2677,8 +2509,8 @@ void sqlite3EndTable(
|
||||
** tree that have been allocated from lookaside memory, which is
|
||||
** illegal in a schema and will lead to errors or heap corruption
|
||||
** when the database connection closes. */
|
||||
sqlite3ColumnSetExpr(pParse, p, &p->aCol[ii],
|
||||
sqlite3ExprAlloc(db, TK_NULL, 0, 0));
|
||||
sqlite3ExprDelete(db, pX);
|
||||
p->aCol[ii].pDflt = sqlite3ExprAlloc(db, TK_NULL, 0, 0);
|
||||
}
|
||||
}else{
|
||||
nNG++;
|
||||
@@ -2718,7 +2550,7 @@ void sqlite3EndTable(
|
||||
/*
|
||||
** Initialize zType for the new view or table.
|
||||
*/
|
||||
if( IsOrdinaryTable(p) ){
|
||||
if( p->pSelect==0 ){
|
||||
/* A regular table */
|
||||
zType = "table";
|
||||
zType2 = "TABLE";
|
||||
@@ -2868,12 +2700,12 @@ void sqlite3EndTable(
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_ALTERTABLE
|
||||
if( !pSelect && IsOrdinaryTable(p) ){
|
||||
if( !pSelect && !p->pSelect ){
|
||||
assert( pCons && pEnd );
|
||||
if( pCons->z==0 ){
|
||||
pCons = pEnd;
|
||||
}
|
||||
p->u.tab.addColOffset = 13 + (int)(pCons->z - pParse->sNameToken.z);
|
||||
p->addColOffset = 13 + (int)(pCons->z - pParse->sNameToken.z);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2930,13 +2762,12 @@ void sqlite3CreateView(
|
||||
*/
|
||||
pSelect->selFlags |= SF_View;
|
||||
if( IN_RENAME_OBJECT ){
|
||||
p->u.view.pSelect = pSelect;
|
||||
p->pSelect = pSelect;
|
||||
pSelect = 0;
|
||||
}else{
|
||||
p->u.view.pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
|
||||
p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
|
||||
}
|
||||
p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);
|
||||
p->eTabType = TABTYP_VIEW;
|
||||
if( db->mallocFailed ) goto create_view_fail;
|
||||
|
||||
/* Locate the end of the CREATE VIEW statement. Make sEnd point to
|
||||
@@ -3033,8 +2864,8 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
|
||||
** to be permanent. So the computation is done on a copy of the SELECT
|
||||
** statement that defines the view.
|
||||
*/
|
||||
assert( IsView(pTable) );
|
||||
pSel = sqlite3SelectDup(db, pTable->u.view.pSelect, 0);
|
||||
assert( pTable->pSelect );
|
||||
pSel = sqlite3SelectDup(db, pTable->pSelect, 0);
|
||||
if( pSel ){
|
||||
u8 eParseMode = pParse->eParseMode;
|
||||
pParse->eParseMode = PARSE_MODE_NORMAL;
|
||||
@@ -3093,6 +2924,8 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
|
||||
pTable->pSchema->schemaFlags |= DB_UnresetViews;
|
||||
if( db->mallocFailed ){
|
||||
sqlite3DeleteColumnNames(db, pTable);
|
||||
pTable->aCol = 0;
|
||||
pTable->nCol = 0;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_VIEW */
|
||||
return nErr;
|
||||
@@ -3109,8 +2942,10 @@ static void sqliteViewResetAll(sqlite3 *db, int idx){
|
||||
if( !DbHasProperty(db, idx, DB_UnresetViews) ) return;
|
||||
for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){
|
||||
Table *pTab = sqliteHashData(i);
|
||||
if( IsView(pTab) ){
|
||||
if( pTab->pSelect ){
|
||||
sqlite3DeleteColumnNames(db, pTab);
|
||||
pTab->aCol = 0;
|
||||
pTab->nCol = 0;
|
||||
}
|
||||
}
|
||||
DbClearProperty(db, idx, DB_UnresetViews);
|
||||
@@ -3451,11 +3286,11 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){
|
||||
/* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used
|
||||
** on a table.
|
||||
*/
|
||||
if( isView && !IsView(pTab) ){
|
||||
if( isView && pTab->pSelect==0 ){
|
||||
sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab->zName);
|
||||
goto exit_drop_table;
|
||||
}
|
||||
if( !isView && IsView(pTab) ){
|
||||
if( !isView && pTab->pSelect ){
|
||||
sqlite3ErrorMsg(pParse, "use DROP VIEW to delete view %s", pTab->zName);
|
||||
goto exit_drop_table;
|
||||
}
|
||||
@@ -3519,7 +3354,7 @@ void sqlite3CreateForeignKey(
|
||||
if( pToCol && pToCol->nExpr!=1 ){
|
||||
sqlite3ErrorMsg(pParse, "foreign key on %s"
|
||||
" should reference only one column of table %T",
|
||||
p->aCol[iCol].zCnName, pTo);
|
||||
p->aCol[iCol].zName, pTo);
|
||||
goto fk_end;
|
||||
}
|
||||
nCol = 1;
|
||||
@@ -3542,7 +3377,7 @@ void sqlite3CreateForeignKey(
|
||||
goto fk_end;
|
||||
}
|
||||
pFKey->pFrom = p;
|
||||
pFKey->pNextFrom = p->u.tab.pFKey;
|
||||
pFKey->pNextFrom = p->pFKey;
|
||||
z = (char*)&pFKey->aCol[nCol];
|
||||
pFKey->zTo = z;
|
||||
if( IN_RENAME_OBJECT ){
|
||||
@@ -3559,7 +3394,7 @@ void sqlite3CreateForeignKey(
|
||||
for(i=0; i<nCol; i++){
|
||||
int j;
|
||||
for(j=0; j<p->nCol; j++){
|
||||
if( sqlite3StrICmp(p->aCol[j].zCnName, pFromCol->a[i].zEName)==0 ){
|
||||
if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zEName)==0 ){
|
||||
pFKey->aCol[i].iFrom = j;
|
||||
break;
|
||||
}
|
||||
@@ -3607,8 +3442,7 @@ void sqlite3CreateForeignKey(
|
||||
|
||||
/* Link the foreign key to the table as the last step.
|
||||
*/
|
||||
assert( !IsVirtual(p) );
|
||||
p->u.tab.pFKey = pFKey;
|
||||
p->pFKey = pFKey;
|
||||
pFKey = 0;
|
||||
|
||||
fk_end:
|
||||
@@ -3629,9 +3463,7 @@ void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){
|
||||
#ifndef SQLITE_OMIT_FOREIGN_KEY
|
||||
Table *pTab;
|
||||
FKey *pFKey;
|
||||
if( (pTab = pParse->pNewTable)==0 ) return;
|
||||
if( NEVER(IsVirtual(pTab)) ) return;
|
||||
if( (pFKey = pTab->u.tab.pFKey)==0 ) return;
|
||||
if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;
|
||||
assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */
|
||||
pFKey->isDeferred = (u8)isDeferred;
|
||||
#endif
|
||||
@@ -3923,7 +3755,7 @@ void sqlite3CreateIndex(
|
||||
goto exit_create_index;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_VIEW
|
||||
if( IsView(pTab) ){
|
||||
if( pTab->pSelect ){
|
||||
sqlite3ErrorMsg(pParse, "views may not be indexed");
|
||||
goto exit_create_index;
|
||||
}
|
||||
@@ -4014,7 +3846,7 @@ void sqlite3CreateIndex(
|
||||
Token prevCol;
|
||||
Column *pCol = &pTab->aCol[pTab->nCol-1];
|
||||
pCol->colFlags |= COLFLAG_UNIQUE;
|
||||
sqlite3TokenInit(&prevCol, pCol->zCnName);
|
||||
sqlite3TokenInit(&prevCol, pCol->zName);
|
||||
pList = sqlite3ExprListAppend(pParse, 0,
|
||||
sqlite3ExprAlloc(db, TK_ID, &prevCol, 0));
|
||||
if( pList==0 ) goto exit_create_index;
|
||||
@@ -4135,7 +3967,7 @@ void sqlite3CreateIndex(
|
||||
zExtra += nColl;
|
||||
nExtra -= nColl;
|
||||
}else if( j>=0 ){
|
||||
zColl = sqlite3ColumnColl(&pTab->aCol[j]);
|
||||
zColl = pTab->aCol[j].zColl;
|
||||
}
|
||||
if( !zColl ) zColl = sqlite3StrBINARY;
|
||||
if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){
|
||||
@@ -5227,7 +5059,7 @@ void sqlite3UniqueConstraint(
|
||||
for(j=0; j<pIdx->nKeyCol; j++){
|
||||
char *zCol;
|
||||
assert( pIdx->aiColumn[j]>=0 );
|
||||
zCol = pTab->aCol[pIdx->aiColumn[j]].zCnName;
|
||||
zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
|
||||
if( j ) sqlite3_str_append(&errMsg, ", ", 2);
|
||||
sqlite3_str_appendall(&errMsg, pTab->zName);
|
||||
sqlite3_str_append(&errMsg, ".", 1);
|
||||
@@ -5254,7 +5086,7 @@ void sqlite3RowidConstraint(
|
||||
int rc;
|
||||
if( pTab->iPKey>=0 ){
|
||||
zMsg = sqlite3MPrintf(pParse->db, "%s.%s", pTab->zName,
|
||||
pTab->aCol[pTab->iPKey].zCnName);
|
||||
pTab->aCol[pTab->iPKey].zName);
|
||||
rc = SQLITE_CONSTRAINT_PRIMARYKEY;
|
||||
}else{
|
||||
zMsg = sqlite3MPrintf(pParse->db, "%s.rowid", pTab->zName);
|
||||
|
||||
+6
-6
@@ -84,7 +84,7 @@ int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
|
||||
return 1;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_VIEW
|
||||
if( !viewOk && IsView(pTab) ){
|
||||
if( !viewOk && pTab->pSelect ){
|
||||
sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName);
|
||||
return 1;
|
||||
}
|
||||
@@ -188,13 +188,13 @@ Expr *sqlite3LimitWhere(
|
||||
}else{
|
||||
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
|
||||
if( pPk->nKeyCol==1 ){
|
||||
const char *zName = pTab->aCol[pPk->aiColumn[0]].zCnName;
|
||||
const char *zName = pTab->aCol[pPk->aiColumn[0]].zName;
|
||||
pLhs = sqlite3Expr(db, TK_ID, zName);
|
||||
pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, zName));
|
||||
}else{
|
||||
int i;
|
||||
for(i=0; i<pPk->nKeyCol; i++){
|
||||
Expr *p = sqlite3Expr(db, TK_ID, pTab->aCol[pPk->aiColumn[i]].zCnName);
|
||||
Expr *p = sqlite3Expr(db, TK_ID, pTab->aCol[pPk->aiColumn[i]].zName);
|
||||
pEList = sqlite3ExprListAppend(pParse, pEList, p);
|
||||
}
|
||||
pLhs = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
|
||||
@@ -301,7 +301,7 @@ void sqlite3DeleteFrom(
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_TRIGGER
|
||||
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
|
||||
isView = IsView(pTab);
|
||||
isView = pTab->pSelect!=0;
|
||||
#else
|
||||
# define pTrigger 0
|
||||
# define isView 0
|
||||
@@ -551,7 +551,7 @@ void sqlite3DeleteFrom(
|
||||
if( eOnePass!=ONEPASS_OFF ){
|
||||
assert( nKey==nPk ); /* OP_Found will use an unpacked key */
|
||||
if( !IsVirtual(pTab) && aToOpen[iDataCur-iTabCur] ){
|
||||
assert( pPk!=0 || IsView(pTab) );
|
||||
assert( pPk!=0 || pTab->pSelect!=0 );
|
||||
sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, addrBypass, iKey, nKey);
|
||||
VdbeCoverage(v);
|
||||
}
|
||||
@@ -785,7 +785,7 @@ void sqlite3GenerateRowDelete(
|
||||
** the update-hook is not invoked for rows removed by REPLACE, but the
|
||||
** pre-update-hook is.
|
||||
*/
|
||||
if( !IsView(pTab) ){
|
||||
if( pTab->pSelect==0 ){
|
||||
u8 p5 = 0;
|
||||
sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek);
|
||||
sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0));
|
||||
|
||||
+12
-15
@@ -173,7 +173,7 @@ CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr){
|
||||
** a TK_COLUMN but was previously evaluated and cached in a register */
|
||||
int j = p->iColumn;
|
||||
if( j>=0 ){
|
||||
const char *zColl = sqlite3ColumnColl(&p->y.pTab->aCol[j]);
|
||||
const char *zColl = p->y.pTab->aCol[j].zColl;
|
||||
pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);
|
||||
}
|
||||
break;
|
||||
@@ -2513,7 +2513,7 @@ static Select *isCandidateForInOpt(Expr *pX){
|
||||
if( pSrc->a[0].pSelect ) return 0; /* FROM is not a subquery or view */
|
||||
pTab = pSrc->a[0].pTab;
|
||||
assert( pTab!=0 );
|
||||
assert( !IsView(pTab) ); /* FROM clause is not a view */
|
||||
assert( pTab->pSelect==0 ); /* FROM clause is not a view */
|
||||
if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */
|
||||
pEList = p->pEList;
|
||||
assert( pEList!=0 );
|
||||
@@ -3643,10 +3643,9 @@ void sqlite3ExprCodeLoadIndexColumn(
|
||||
** and store the result in register regOut
|
||||
*/
|
||||
void sqlite3ExprCodeGeneratedColumn(
|
||||
Parse *pParse, /* Parsing context */
|
||||
Table *pTab, /* Table containing the generated column */
|
||||
Column *pCol, /* The generated column */
|
||||
int regOut /* Put the result in this register */
|
||||
Parse *pParse,
|
||||
Column *pCol,
|
||||
int regOut
|
||||
){
|
||||
int iAddr;
|
||||
Vdbe *v = pParse->pVdbe;
|
||||
@@ -3657,7 +3656,7 @@ void sqlite3ExprCodeGeneratedColumn(
|
||||
}else{
|
||||
iAddr = 0;
|
||||
}
|
||||
sqlite3ExprCodeCopy(pParse, sqlite3ColumnExpr(pTab,pCol), regOut);
|
||||
sqlite3ExprCodeCopy(pParse, pCol->pDflt, regOut);
|
||||
if( pCol->affinity>=SQLITE_AFF_TEXT ){
|
||||
sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1);
|
||||
}
|
||||
@@ -3693,13 +3692,12 @@ void sqlite3ExprCodeGetColumnOfTable(
|
||||
}else if( (pCol = &pTab->aCol[iCol])->colFlags & COLFLAG_VIRTUAL ){
|
||||
Parse *pParse = sqlite3VdbeParser(v);
|
||||
if( pCol->colFlags & COLFLAG_BUSY ){
|
||||
sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"",
|
||||
pCol->zCnName);
|
||||
sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pCol->zName);
|
||||
}else{
|
||||
int savedSelfTab = pParse->iSelfTab;
|
||||
pCol->colFlags |= COLFLAG_BUSY;
|
||||
pParse->iSelfTab = iTabCur+1;
|
||||
sqlite3ExprCodeGeneratedColumn(pParse, pTab, pCol, regOut);
|
||||
sqlite3ExprCodeGeneratedColumn(pParse, pCol, regOut);
|
||||
pParse->iSelfTab = savedSelfTab;
|
||||
pCol->colFlags &= ~COLFLAG_BUSY;
|
||||
}
|
||||
@@ -3967,8 +3965,7 @@ expr_code_doover:
|
||||
if( pCol->iColumn<0 ){
|
||||
VdbeComment((v,"%s.rowid",pTab->zName));
|
||||
}else{
|
||||
VdbeComment((v,"%s.%s",
|
||||
pTab->zName, pTab->aCol[pCol->iColumn].zCnName));
|
||||
VdbeComment((v,"%s.%s",pTab->zName,pTab->aCol[pCol->iColumn].zName));
|
||||
if( pTab->aCol[pCol->iColumn].affinity==SQLITE_AFF_REAL ){
|
||||
sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
|
||||
}
|
||||
@@ -4029,12 +4026,12 @@ expr_code_doover:
|
||||
if( pCol->colFlags & COLFLAG_GENERATED ){
|
||||
if( pCol->colFlags & COLFLAG_BUSY ){
|
||||
sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"",
|
||||
pCol->zCnName);
|
||||
pCol->zName);
|
||||
return 0;
|
||||
}
|
||||
pCol->colFlags |= COLFLAG_BUSY;
|
||||
if( pCol->colFlags & COLFLAG_NOTAVAIL ){
|
||||
sqlite3ExprCodeGeneratedColumn(pParse, pTab, pCol, iSrc);
|
||||
sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc);
|
||||
}
|
||||
pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL);
|
||||
return iSrc;
|
||||
@@ -4512,7 +4509,7 @@ expr_code_doover:
|
||||
sqlite3VdbeAddOp2(v, OP_Param, p1, target);
|
||||
VdbeComment((v, "r[%d]=%s.%s", target,
|
||||
(pExpr->iTable ? "new" : "old"),
|
||||
(pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[iCol].zCnName)
|
||||
(pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[iCol].zName)
|
||||
));
|
||||
|
||||
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||
|
||||
+21
-26
@@ -215,9 +215,7 @@ int sqlite3FkLocateIndex(
|
||||
*/
|
||||
if( pParent->iPKey>=0 ){
|
||||
if( !zKey ) return 0;
|
||||
if( !sqlite3StrICmp(pParent->aCol[pParent->iPKey].zCnName, zKey) ){
|
||||
return 0;
|
||||
}
|
||||
if( !sqlite3StrICmp(pParent->aCol[pParent->iPKey].zName, zKey) ) return 0;
|
||||
}
|
||||
}else if( paiCol ){
|
||||
assert( nCol>1 );
|
||||
@@ -259,11 +257,11 @@ int sqlite3FkLocateIndex(
|
||||
/* If the index uses a collation sequence that is different from
|
||||
** the default collation sequence for the column, this index is
|
||||
** unusable. Bail out early in this case. */
|
||||
zDfltColl = sqlite3ColumnColl(&pParent->aCol[iCol]);
|
||||
zDfltColl = pParent->aCol[iCol].zColl;
|
||||
if( !zDfltColl ) zDfltColl = sqlite3StrBINARY;
|
||||
if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;
|
||||
|
||||
zIdxCol = pParent->aCol[iCol].zCnName;
|
||||
zIdxCol = pParent->aCol[iCol].zName;
|
||||
for(j=0; j<nCol; j++){
|
||||
if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){
|
||||
if( aiCol ) aiCol[i] = pFKey->aCol[j].iFrom;
|
||||
@@ -487,7 +485,7 @@ static Expr *exprTableRegister(
|
||||
pCol = &pTab->aCol[iCol];
|
||||
pExpr->iTable = regBase + sqlite3TableColumnToStorage(pTab,iCol) + 1;
|
||||
pExpr->affExpr = pCol->affinity;
|
||||
zColl = sqlite3ColumnColl(pCol);
|
||||
zColl = pCol->zColl;
|
||||
if( zColl==0 ) zColl = db->pDfltColl->zName;
|
||||
pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);
|
||||
}else{
|
||||
@@ -596,7 +594,7 @@ static void fkScanChildren(
|
||||
pLeft = exprTableRegister(pParse, pTab, regData, iCol);
|
||||
iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;
|
||||
assert( iCol>=0 );
|
||||
zCol = pFKey->pFrom->aCol[iCol].zCnName;
|
||||
zCol = pFKey->pFrom->aCol[iCol].zName;
|
||||
pRight = sqlite3Expr(db, TK_ID, zCol);
|
||||
pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight);
|
||||
pWhere = sqlite3ExprAnd(pParse, pWhere, pEq);
|
||||
@@ -631,7 +629,7 @@ static void fkScanChildren(
|
||||
i16 iCol = pIdx->aiColumn[i];
|
||||
assert( iCol>=0 );
|
||||
pLeft = exprTableRegister(pParse, pTab, regData, iCol);
|
||||
pRight = sqlite3Expr(db, TK_ID, pTab->aCol[iCol].zCnName);
|
||||
pRight = sqlite3Expr(db, TK_ID, pTab->aCol[iCol].zName);
|
||||
pEq = sqlite3PExpr(pParse, TK_IS, pLeft, pRight);
|
||||
pAll = sqlite3ExprAnd(pParse, pAll, pEq);
|
||||
}
|
||||
@@ -725,8 +723,7 @@ void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
|
||||
Vdbe *v = sqlite3GetVdbe(pParse);
|
||||
|
||||
assert( v ); /* VDBE has already been allocated */
|
||||
assert( !IsView(pTab) ); /* Not a view */
|
||||
assert( !IsVirtual(pTab) );
|
||||
assert( pTab->pSelect==0 ); /* Not a view */
|
||||
if( sqlite3FkReferences(pTab)==0 ){
|
||||
/* Search for a deferred foreign key constraint for which this table
|
||||
** is the child table. If one cannot be found, return without
|
||||
@@ -734,7 +731,7 @@ void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
|
||||
** the entire DELETE if there are no outstanding deferred constraints
|
||||
** when this statement is run. */
|
||||
FKey *p;
|
||||
for(p=pTab->u.tab.pFKey; p; p=p->pNextFrom){
|
||||
for(p=pTab->pFKey; p; p=p->pNextFrom){
|
||||
if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;
|
||||
}
|
||||
if( !p ) return;
|
||||
@@ -823,7 +820,7 @@ static int fkParentIsModified(
|
||||
if( aChange[iKey]>=0 || (iKey==pTab->iPKey && bChngRowid) ){
|
||||
Column *pCol = &pTab->aCol[iKey];
|
||||
if( zKey ){
|
||||
if( 0==sqlite3StrICmp(pCol->zCnName, zKey) ) return 1;
|
||||
if( 0==sqlite3StrICmp(pCol->zName, zKey) ) return 1;
|
||||
}else if( pCol->colFlags & COLFLAG_PRIMKEY ){
|
||||
return 1;
|
||||
}
|
||||
@@ -896,8 +893,7 @@ void sqlite3FkCheck(
|
||||
|
||||
/* Loop through all the foreign key constraints for which pTab is the
|
||||
** child table (the table that the foreign key definition is part of). */
|
||||
assert( !IsVirtual(pTab) );
|
||||
for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
Table *pTo; /* Parent table of foreign key pFKey */
|
||||
Index *pIdx = 0; /* Index on key columns in pTo */
|
||||
int *aiFree = 0;
|
||||
@@ -964,7 +960,7 @@ void sqlite3FkCheck(
|
||||
** values read from the parent table are NULL. */
|
||||
if( db->xAuth ){
|
||||
int rcauth;
|
||||
char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zCnName;
|
||||
char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;
|
||||
rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb);
|
||||
bIgnore = (rcauth==SQLITE_IGNORE);
|
||||
}
|
||||
@@ -1082,8 +1078,7 @@ u32 sqlite3FkOldmask(
|
||||
if( pParse->db->flags&SQLITE_ForeignKeys ){
|
||||
FKey *p;
|
||||
int i;
|
||||
assert( !IsVirtual(pTab) );
|
||||
for(p=pTab->u.tab.pFKey; p; p=p->pNextFrom){
|
||||
for(p=pTab->pFKey; p; p=p->pNextFrom){
|
||||
for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom);
|
||||
}
|
||||
for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
|
||||
@@ -1133,19 +1128,19 @@ int sqlite3FkRequired(
|
||||
){
|
||||
int eRet = 1; /* Value to return if bHaveFK is true */
|
||||
int bHaveFK = 0; /* If FK processing is required */
|
||||
if( pParse->db->flags&SQLITE_ForeignKeys && !IsVirtual(pTab) ){
|
||||
if( pParse->db->flags&SQLITE_ForeignKeys ){
|
||||
if( !aChange ){
|
||||
/* A DELETE operation. Foreign key processing is required if the
|
||||
** table in question is either the child or parent table for any
|
||||
** foreign key constraint. */
|
||||
bHaveFK = (sqlite3FkReferences(pTab) || pTab->u.tab.pFKey);
|
||||
bHaveFK = (sqlite3FkReferences(pTab) || pTab->pFKey);
|
||||
}else{
|
||||
/* This is an UPDATE. Foreign key processing is only required if the
|
||||
** operation modifies one or more child or parent key columns. */
|
||||
FKey *p;
|
||||
|
||||
/* Check if any child key columns are being modified. */
|
||||
for(p=pTab->u.tab.pFKey; p; p=p->pNextFrom){
|
||||
for(p=pTab->pFKey; p; p=p->pNextFrom){
|
||||
if( fkChildIsModified(pTab, p, aChange, chngRowid) ){
|
||||
if( 0==sqlite3_stricmp(pTab->zName, p->zTo) ) eRet = 2;
|
||||
bHaveFK = 1;
|
||||
@@ -1238,8 +1233,8 @@ static Trigger *fkActionTrigger(
|
||||
assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) );
|
||||
assert( pIdx==0 || pIdx->aiColumn[i]>=0 );
|
||||
sqlite3TokenInit(&tToCol,
|
||||
pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zCnName);
|
||||
sqlite3TokenInit(&tFromCol, pFKey->pFrom->aCol[iFromCol].zCnName);
|
||||
pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zName);
|
||||
sqlite3TokenInit(&tFromCol, pFKey->pFrom->aCol[iFromCol].zName);
|
||||
|
||||
/* Create the expression "OLD.zToCol = zFromCol". It is important
|
||||
** that the "OLD.zToCol" term is on the LHS of the = operator, so
|
||||
@@ -1284,7 +1279,7 @@ static Trigger *fkActionTrigger(
|
||||
testcase( pCol->colFlags & COLFLAG_STORED );
|
||||
pDflt = 0;
|
||||
}else{
|
||||
pDflt = sqlite3ColumnExpr(pFKey->pFrom, pCol);
|
||||
pDflt = pCol->pDflt;
|
||||
}
|
||||
if( pDflt ){
|
||||
pNew = sqlite3ExprDup(db, pDflt, 0);
|
||||
@@ -1421,9 +1416,9 @@ void sqlite3FkDelete(sqlite3 *db, Table *pTab){
|
||||
FKey *pFKey; /* Iterator variable */
|
||||
FKey *pNext; /* Copy of pFKey->pNextFrom */
|
||||
|
||||
assert( !IsVirtual(pTab) );
|
||||
for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pNext){
|
||||
assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );
|
||||
assert( db==0 || IsVirtual(pTab)
|
||||
|| sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );
|
||||
for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){
|
||||
|
||||
/* Remove the FK from the fkeyHash hash table. */
|
||||
if( !db || db->pnBytesFreed==0 ){
|
||||
|
||||
@@ -347,42 +347,3 @@ const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
|
||||
** Name of the default collating sequence
|
||||
*/
|
||||
const char sqlite3StrBINARY[] = "BINARY";
|
||||
|
||||
/*
|
||||
** Standard typenames. These names must match the COLTYPE_* definitions.
|
||||
** Adjust the SQLITE_N_STDTYPE value if adding or removing entries.
|
||||
**
|
||||
** sqlite3StdType[] The actual names of the datatypes.
|
||||
**
|
||||
** sqlite3StdTypeLen[] The length (in bytes) of each entry
|
||||
** in sqlite3StdType[].
|
||||
**
|
||||
** sqlite3StdTypeAffinity[] The affinity associated with each entry
|
||||
** in sqlite3StdType[].
|
||||
**
|
||||
** sqlite3StdTypeMap[] The type value (as returned from
|
||||
** sqlite3_column_type() or sqlite3_value_type())
|
||||
** for each entry in sqlite3StdType[].
|
||||
*/
|
||||
const unsigned char sqlite3StdTypeLen[] = { 4, 3, 7, 4, 4 };
|
||||
const char sqlite3StdTypeAffinity[] = {
|
||||
SQLITE_AFF_BLOB,
|
||||
SQLITE_AFF_INTEGER,
|
||||
SQLITE_AFF_INTEGER,
|
||||
SQLITE_AFF_REAL,
|
||||
SQLITE_AFF_TEXT
|
||||
};
|
||||
const char sqlite3StdTypeMap[] = {
|
||||
SQLITE_BLOB,
|
||||
SQLITE_INTEGER,
|
||||
SQLITE_INTEGER,
|
||||
SQLITE_FLOAT,
|
||||
SQLITE_TEXT
|
||||
};
|
||||
const char *sqlite3StdType[] = {
|
||||
"BLOB",
|
||||
"INT",
|
||||
"INTEGER",
|
||||
"REAL",
|
||||
"TEXT"
|
||||
};
|
||||
|
||||
+45
-97
@@ -110,68 +110,28 @@ const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){
|
||||
}
|
||||
|
||||
/*
|
||||
** Make changes to the evolving bytecode to do affinity transformations
|
||||
** of values that are about to be gathered into a row for table pTab.
|
||||
**
|
||||
** For ordinary (legacy, non-strict) tables:
|
||||
** -----------------------------------------
|
||||
**
|
||||
** Compute the affinity string for table pTab, if it has not already been
|
||||
** computed. As an optimization, omit trailing SQLITE_AFF_BLOB affinities.
|
||||
**
|
||||
** If the affinity string is empty (because it was all SQLITE_AFF_BLOB entries
|
||||
** which were then optimized out) then this routine becomes a no-op.
|
||||
**
|
||||
** Otherwise if iReg>0 then code an OP_Affinity opcode that will set the
|
||||
** affinities for register iReg and following. Or if iReg==0,
|
||||
** If the affinity exists (if it is not entirely SQLITE_AFF_BLOB values) and
|
||||
** if iReg>0 then code an OP_Affinity opcode that will set the affinities
|
||||
** for register iReg and following. Or if affinities exists and iReg==0,
|
||||
** then just set the P4 operand of the previous opcode (which should be
|
||||
** an OP_MakeRecord) to the affinity string.
|
||||
**
|
||||
** A column affinity string has one character per column:
|
||||
**
|
||||
** Character Column affinity
|
||||
** --------- ---------------
|
||||
** 'A' BLOB
|
||||
** 'B' TEXT
|
||||
** 'C' NUMERIC
|
||||
** 'D' INTEGER
|
||||
** 'E' REAL
|
||||
**
|
||||
** For STRICT tables:
|
||||
** ------------------
|
||||
**
|
||||
** Generate an appropropriate OP_TypeCheck opcode that will verify the
|
||||
** datatypes against the column definitions in pTab. If iReg==0, that
|
||||
** means an OP_MakeRecord opcode has already been generated and should be
|
||||
** the last opcode generated. The new OP_TypeCheck needs to be inserted
|
||||
** before the OP_MakeRecord. The new OP_TypeCheck should use the same
|
||||
** register set as the OP_MakeRecord. If iReg>0 then register iReg is
|
||||
** the first of a series of registers that will form the new record.
|
||||
** Apply the type checking to that array of registers.
|
||||
** Character Column affinity
|
||||
** ------------------------------
|
||||
** 'A' BLOB
|
||||
** 'B' TEXT
|
||||
** 'C' NUMERIC
|
||||
** 'D' INTEGER
|
||||
** 'E' REAL
|
||||
*/
|
||||
void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){
|
||||
int i, j;
|
||||
char *zColAff;
|
||||
if( pTab->tabFlags & TF_Strict ){
|
||||
if( iReg==0 ){
|
||||
/* Move the previous opcode (which should be OP_MakeRecord) forward
|
||||
** by one slot and insert a new OP_TypeCheck where the current
|
||||
** OP_MakeRecord is found */
|
||||
VdbeOp *pPrev;
|
||||
sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
|
||||
pPrev = sqlite3VdbeGetOp(v, -1);
|
||||
assert( pPrev!=0 );
|
||||
assert( pPrev->opcode==OP_MakeRecord || sqlite3VdbeDb(v)->mallocFailed );
|
||||
pPrev->opcode = OP_TypeCheck;
|
||||
sqlite3VdbeAddOp3(v, OP_MakeRecord, pPrev->p1, pPrev->p2, pPrev->p3);
|
||||
}else{
|
||||
/* Insert an isolated OP_Typecheck */
|
||||
sqlite3VdbeAddOp2(v, OP_TypeCheck, iReg, pTab->nNVCol);
|
||||
sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
zColAff = pTab->zColAff;
|
||||
char *zColAff = pTab->zColAff;
|
||||
if( zColAff==0 ){
|
||||
sqlite3 *db = sqlite3VdbeDb(v);
|
||||
zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1);
|
||||
@@ -197,8 +157,6 @@ void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){
|
||||
if( iReg ){
|
||||
sqlite3VdbeAddOp4(v, OP_Affinity, iReg, i, 0, zColAff, i);
|
||||
}else{
|
||||
assert( sqlite3VdbeGetOp(v, -1)->opcode==OP_MakeRecord
|
||||
|| sqlite3VdbeDb(v)->mallocFailed );
|
||||
sqlite3VdbeChangeP4(v, -1, zColAff, i);
|
||||
}
|
||||
}
|
||||
@@ -335,7 +293,7 @@ void sqlite3ComputeGeneratedColumns(
|
||||
int x;
|
||||
pCol->colFlags |= COLFLAG_BUSY;
|
||||
w.eCode = 0;
|
||||
sqlite3WalkExpr(&w, sqlite3ColumnExpr(pTab, pCol));
|
||||
sqlite3WalkExpr(&w, pCol->pDflt);
|
||||
pCol->colFlags &= ~COLFLAG_BUSY;
|
||||
if( w.eCode & COLFLAG_NOTAVAIL ){
|
||||
pRedo = pCol;
|
||||
@@ -344,13 +302,13 @@ void sqlite3ComputeGeneratedColumns(
|
||||
eProgress = 1;
|
||||
assert( pCol->colFlags & COLFLAG_GENERATED );
|
||||
x = sqlite3TableColumnToStorage(pTab, i) + iRegStore;
|
||||
sqlite3ExprCodeGeneratedColumn(pParse, pTab, pCol, x);
|
||||
sqlite3ExprCodeGeneratedColumn(pParse, pCol, x);
|
||||
pCol->colFlags &= ~COLFLAG_NOTAVAIL;
|
||||
}
|
||||
}
|
||||
}while( pRedo && eProgress );
|
||||
if( pRedo ){
|
||||
sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pRedo->zCnName);
|
||||
sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pRedo->zName);
|
||||
}
|
||||
pParse->iSelfTab = 0;
|
||||
}
|
||||
@@ -745,7 +703,7 @@ void sqlite3Insert(
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_TRIGGER
|
||||
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_INSERT, 0, &tmask);
|
||||
isView = IsView(pTab);
|
||||
isView = pTab->pSelect!=0;
|
||||
#else
|
||||
# define pTrigger 0
|
||||
# define tmask 0
|
||||
@@ -836,7 +794,7 @@ void sqlite3Insert(
|
||||
}
|
||||
for(i=0; i<pColumn->nId; i++){
|
||||
for(j=0; j<pTab->nCol; j++){
|
||||
if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zCnName)==0 ){
|
||||
if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){
|
||||
pColumn->a[i].idx = j;
|
||||
if( i!=j ) bIdListInOrder = 0;
|
||||
if( j==pTab->iPKey ){
|
||||
@@ -846,7 +804,7 @@ void sqlite3Insert(
|
||||
if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"cannot INSERT into generated column \"%s\"",
|
||||
pTab->aCol[j].zCnName);
|
||||
pTab->aCol[j].zName);
|
||||
goto insert_cleanup;
|
||||
}
|
||||
#endif
|
||||
@@ -1031,7 +989,7 @@ void sqlite3Insert(
|
||||
pTab->zName);
|
||||
goto insert_cleanup;
|
||||
}
|
||||
if( IsView(pTab) ){
|
||||
if( pTab->pSelect ){
|
||||
sqlite3ErrorMsg(pParse, "cannot UPSERT a view");
|
||||
goto insert_cleanup;
|
||||
}
|
||||
@@ -1130,9 +1088,7 @@ void sqlite3Insert(
|
||||
}else if( pColumn==0 ){
|
||||
/* Hidden columns that are not explicitly named in the INSERT
|
||||
** get there default value */
|
||||
sqlite3ExprCodeFactorable(pParse,
|
||||
sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
|
||||
iRegStore);
|
||||
sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1141,17 +1097,13 @@ void sqlite3Insert(
|
||||
if( j>=pColumn->nId ){
|
||||
/* A column not named in the insert column list gets its
|
||||
** default value */
|
||||
sqlite3ExprCodeFactorable(pParse,
|
||||
sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
|
||||
iRegStore);
|
||||
sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
|
||||
continue;
|
||||
}
|
||||
k = j;
|
||||
}else if( nColumn==0 ){
|
||||
/* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */
|
||||
sqlite3ExprCodeFactorable(pParse,
|
||||
sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
|
||||
iRegStore);
|
||||
sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);
|
||||
continue;
|
||||
}else{
|
||||
k = i - nHidden;
|
||||
@@ -1666,7 +1618,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
db = pParse->db;
|
||||
v = pParse->pVdbe;
|
||||
assert( v!=0 );
|
||||
assert( !IsView(pTab) ); /* This table is not a VIEW */
|
||||
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
|
||||
nCol = pTab->nCol;
|
||||
|
||||
/* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for
|
||||
@@ -1717,7 +1669,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
}
|
||||
if( onError==OE_Replace ){
|
||||
if( b2ndPass /* REPLACE becomes ABORT on the 2nd pass */
|
||||
|| pCol->iDflt==0 /* REPLACE is ABORT if no DEFAULT value */
|
||||
|| pCol->pDflt==0 /* REPLACE is ABORT if no DEFAULT value */
|
||||
){
|
||||
testcase( pCol->colFlags & COLFLAG_VIRTUAL );
|
||||
testcase( pCol->colFlags & COLFLAG_STORED );
|
||||
@@ -1739,8 +1691,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
VdbeCoverage(v);
|
||||
assert( (pCol->colFlags & COLFLAG_GENERATED)==0 );
|
||||
nSeenReplace++;
|
||||
sqlite3ExprCodeCopy(pParse,
|
||||
sqlite3ColumnExpr(pTab, pCol), iReg);
|
||||
sqlite3ExprCodeCopy(pParse, pCol->pDflt, iReg);
|
||||
sqlite3VdbeJumpHere(v, addr1);
|
||||
break;
|
||||
}
|
||||
@@ -1750,7 +1701,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
case OE_Rollback:
|
||||
case OE_Fail: {
|
||||
char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName,
|
||||
pCol->zCnName);
|
||||
pCol->zName);
|
||||
sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL,
|
||||
onError, iReg);
|
||||
sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);
|
||||
@@ -2168,7 +2119,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
testcase( sqlite3TableColumnToStorage(pTab, iField)!=iField );
|
||||
x = sqlite3TableColumnToStorage(pTab, iField) + regNewData + 1;
|
||||
sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i);
|
||||
VdbeComment((v, "%s", pTab->aCol[iField].zCnName));
|
||||
VdbeComment((v, "%s", pTab->aCol[iField].zName));
|
||||
}
|
||||
}
|
||||
sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
|
||||
@@ -2227,7 +2178,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
&& ( 0==(db->flags&SQLITE_RecTriggers) || /* Condition 4 */
|
||||
0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0))
|
||||
&& ( 0==(db->flags&SQLITE_ForeignKeys) || /* Condition 5 */
|
||||
(0==pTab->u.tab.pFKey && 0==sqlite3FkReferences(pTab)))
|
||||
(0==pTab->pFKey && 0==sqlite3FkReferences(pTab)))
|
||||
){
|
||||
sqlite3VdbeResolveLabel(v, addrUniqueOk);
|
||||
continue;
|
||||
@@ -2262,7 +2213,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
x = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
|
||||
sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i);
|
||||
VdbeComment((v, "%s.%s", pTab->zName,
|
||||
pTab->aCol[pPk->aiColumn[i]].zCnName));
|
||||
pTab->aCol[pPk->aiColumn[i]].zName));
|
||||
}
|
||||
}
|
||||
if( isUpdate ){
|
||||
@@ -2461,7 +2412,7 @@ void sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){
|
||||
if( pTab->pSchema->file_format<2 ) return;
|
||||
|
||||
for(i=pTab->nCol-1; i>0; i--){
|
||||
if( pTab->aCol[i].iDflt!=0 ) break;
|
||||
if( pTab->aCol[i].pDflt!=0 ) break;
|
||||
if( pTab->aCol[i].colFlags & COLFLAG_PRIMKEY ) break;
|
||||
}
|
||||
sqlite3VdbeChangeP5(v, i+1);
|
||||
@@ -2526,7 +2477,7 @@ void sqlite3CompleteInsertion(
|
||||
|
||||
v = pParse->pVdbe;
|
||||
assert( v!=0 );
|
||||
assert( !IsView(pTab) ); /* This table is not a VIEW */
|
||||
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
|
||||
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
|
||||
/* All REPLACE indexes are at the end of the list */
|
||||
assert( pIdx->onError!=OE_Replace
|
||||
@@ -2828,8 +2779,13 @@ static int xferOptimization(
|
||||
if( HasRowid(pDest)!=HasRowid(pSrc) ){
|
||||
return 0; /* source and destination must both be WITHOUT ROWID or not */
|
||||
}
|
||||
if( !IsOrdinaryTable(pSrc) ){
|
||||
return 0; /* tab2 may not be a view or virtual table */
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
if( IsVirtual(pSrc) ){
|
||||
return 0; /* tab2 must not be a virtual table */
|
||||
}
|
||||
#endif
|
||||
if( pSrc->pSelect ){
|
||||
return 0; /* tab2 may not be a view */
|
||||
}
|
||||
if( pDest->nCol!=pSrc->nCol ){
|
||||
return 0; /* Number of columns must be the same in tab1 and tab2 */
|
||||
@@ -2837,9 +2793,6 @@ static int xferOptimization(
|
||||
if( pDest->iPKey!=pSrc->iPKey ){
|
||||
return 0; /* Both tables must have the same INTEGER PRIMARY KEY */
|
||||
}
|
||||
if( (pDest->tabFlags & TF_Strict)!=0 && (pSrc->tabFlags & TF_Strict)==0 ){
|
||||
return 0; /* Cannot feed from a non-strict into a strict table */
|
||||
}
|
||||
for(i=0; i<pDest->nCol; i++){
|
||||
Column *pDestCol = &pDest->aCol[i];
|
||||
Column *pSrcCol = &pSrc->aCol[i];
|
||||
@@ -2876,9 +2829,7 @@ static int xferOptimization(
|
||||
** This requirement could be relaxed for VIRTUAL columns, I suppose.
|
||||
*/
|
||||
if( (pDestCol->colFlags & COLFLAG_GENERATED)!=0 ){
|
||||
if( sqlite3ExprCompare(0,
|
||||
sqlite3ColumnExpr(pSrc, pSrcCol),
|
||||
sqlite3ColumnExpr(pDest, pDestCol), -1)!=0 ){
|
||||
if( sqlite3ExprCompare(0, pSrcCol->pDflt, pDestCol->pDflt, -1)!=0 ){
|
||||
testcase( pDestCol->colFlags & COLFLAG_VIRTUAL );
|
||||
testcase( pDestCol->colFlags & COLFLAG_STORED );
|
||||
return 0; /* Different generator expressions */
|
||||
@@ -2888,8 +2839,7 @@ static int xferOptimization(
|
||||
if( pDestCol->affinity!=pSrcCol->affinity ){
|
||||
return 0; /* Affinity must be the same on all columns */
|
||||
}
|
||||
if( sqlite3_stricmp(sqlite3ColumnColl(pDestCol),
|
||||
sqlite3ColumnColl(pSrcCol))!=0 ){
|
||||
if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){
|
||||
return 0; /* Collating sequence must be the same on all columns */
|
||||
}
|
||||
if( pDestCol->notNull && !pSrcCol->notNull ){
|
||||
@@ -2897,13 +2847,11 @@ static int xferOptimization(
|
||||
}
|
||||
/* Default values for second and subsequent columns need to match. */
|
||||
if( (pDestCol->colFlags & COLFLAG_GENERATED)==0 && i>0 ){
|
||||
Expr *pDestExpr = sqlite3ColumnExpr(pDest, pDestCol);
|
||||
Expr *pSrcExpr = sqlite3ColumnExpr(pSrc, pSrcCol);
|
||||
assert( pDestExpr==0 || pDestExpr->op==TK_SPAN );
|
||||
assert( pSrcExpr==0 || pSrcExpr->op==TK_SPAN );
|
||||
if( (pDestExpr==0)!=(pSrcExpr==0)
|
||||
|| (pDestExpr!=0 && strcmp(pDestExpr->u.zToken,
|
||||
pSrcExpr->u.zToken)!=0)
|
||||
assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN );
|
||||
assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN );
|
||||
if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0)
|
||||
|| (pDestCol->pDflt && strcmp(pDestCol->pDflt->u.zToken,
|
||||
pSrcCol->pDflt->u.zToken)!=0)
|
||||
){
|
||||
return 0; /* Default values must be the same for all columns */
|
||||
}
|
||||
@@ -2940,7 +2888,7 @@ static int xferOptimization(
|
||||
** the extra complication to make this rule less restrictive is probably
|
||||
** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
|
||||
*/
|
||||
if( (db->flags & SQLITE_ForeignKeys)!=0 && pDest->u.tab.pFKey!=0 ){
|
||||
if( (db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
+11
-18
@@ -1242,7 +1242,7 @@ static int sqlite3Close(sqlite3 *db, int forceZombie){
|
||||
|
||||
/* Convert the connection into a zombie and then close it.
|
||||
*/
|
||||
db->eOpenState = SQLITE_STATE_ZOMBIE;
|
||||
db->magic = SQLITE_MAGIC_ZOMBIE;
|
||||
sqlite3LeaveMutexAndCloseZombie(db);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
@@ -1306,7 +1306,7 @@ void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){
|
||||
** or if the connection has not yet been closed by sqlite3_close_v2(),
|
||||
** then just leave the mutex and return.
|
||||
*/
|
||||
if( db->eOpenState!=SQLITE_STATE_ZOMBIE || connectionIsBusy(db) ){
|
||||
if( db->magic!=SQLITE_MAGIC_ZOMBIE || connectionIsBusy(db) ){
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
return;
|
||||
}
|
||||
@@ -1392,7 +1392,7 @@ void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){
|
||||
sqlite3_free(db->auth.zAuthPW);
|
||||
#endif
|
||||
|
||||
db->eOpenState = SQLITE_STATE_ERROR;
|
||||
db->magic = SQLITE_MAGIC_ERROR;
|
||||
|
||||
/* The temp-database schema is allocated differently from the other schema
|
||||
** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()).
|
||||
@@ -1402,7 +1402,7 @@ void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){
|
||||
*/
|
||||
sqlite3DbFree(db, db->aDb[1].pSchema);
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
db->eOpenState = SQLITE_STATE_CLOSED;
|
||||
db->magic = SQLITE_MAGIC_CLOSED;
|
||||
sqlite3_mutex_free(db->mutex);
|
||||
assert( sqlite3LookasideUsed(db,0)==0 );
|
||||
if( db->lookaside.bMalloced ){
|
||||
@@ -1790,7 +1790,7 @@ int sqlite3_busy_timeout(sqlite3 *db, int ms){
|
||||
*/
|
||||
void sqlite3_interrupt(sqlite3 *db){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( !sqlite3SafetyCheckOk(db) && (db==0 || db->eOpenState!=SQLITE_STATE_ZOMBIE) ){
|
||||
if( !sqlite3SafetyCheckOk(db) && (db==0 || db->magic!=SQLITE_MAGIC_ZOMBIE) ){
|
||||
(void)SQLITE_MISUSE_BKPT;
|
||||
return;
|
||||
}
|
||||
@@ -3193,7 +3193,7 @@ static int openDatabase(
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
db->errMask = 0xff;
|
||||
db->nDb = 2;
|
||||
db->eOpenState = SQLITE_STATE_BUSY;
|
||||
db->magic = SQLITE_MAGIC_BUSY;
|
||||
db->aDb = db->aDbStatic;
|
||||
db->lookaside.bDisable = 1;
|
||||
db->lookaside.sz = 0;
|
||||
@@ -3205,14 +3205,7 @@ static int openDatabase(
|
||||
db->nextAutovac = -1;
|
||||
db->szMmap = sqlite3GlobalConfig.szMmap;
|
||||
db->nextPagesize = 0;
|
||||
#ifdef SQLITE_ENABLE_SORTER_MMAP
|
||||
/* Beginning with version 3.37.0, using the VFS xFetch() API to memory-map
|
||||
** the temporary files used to do external sorts (see code in vdbesort.c)
|
||||
** is disabled. It can still be used either by defining
|
||||
** SQLITE_ENABLE_SORTER_MMAP at compile time or by using the
|
||||
** SQLITE_TESTCTRL_SORTER_MMAP test-control at runtime. */
|
||||
db->nMaxSorterMmap = 0x7FFFFFFF;
|
||||
#endif
|
||||
db->flags |= SQLITE_ShortColNames
|
||||
| SQLITE_EnableTrigger
|
||||
| SQLITE_EnableView
|
||||
@@ -3360,7 +3353,7 @@ static int openDatabase(
|
||||
db->aDb[1].zDbSName = "temp";
|
||||
db->aDb[1].safety_level = PAGER_SYNCHRONOUS_OFF;
|
||||
|
||||
db->eOpenState = SQLITE_STATE_OPEN;
|
||||
db->magic = SQLITE_MAGIC_OPEN;
|
||||
if( db->mallocFailed ){
|
||||
goto opendb_out;
|
||||
}
|
||||
@@ -3427,7 +3420,7 @@ opendb_out:
|
||||
sqlite3_close(db);
|
||||
db = 0;
|
||||
}else if( rc!=SQLITE_OK ){
|
||||
db->eOpenState = SQLITE_STATE_SICK;
|
||||
db->magic = SQLITE_MAGIC_SICK;
|
||||
}
|
||||
*ppDb = db;
|
||||
#ifdef SQLITE_ENABLE_SQLLOG
|
||||
@@ -3738,7 +3731,7 @@ int sqlite3_table_column_metadata(
|
||||
|
||||
/* Locate the table in question */
|
||||
pTab = sqlite3FindTable(db, zTableName, zDbName);
|
||||
if( !pTab || IsView(pTab) ){
|
||||
if( !pTab || pTab->pSelect ){
|
||||
pTab = 0;
|
||||
goto error_out;
|
||||
}
|
||||
@@ -3749,7 +3742,7 @@ int sqlite3_table_column_metadata(
|
||||
}else{
|
||||
for(iCol=0; iCol<pTab->nCol; iCol++){
|
||||
pCol = &pTab->aCol[iCol];
|
||||
if( 0==sqlite3StrICmp(pCol->zCnName, zColumnName) ){
|
||||
if( 0==sqlite3StrICmp(pCol->zName, zColumnName) ){
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3776,7 +3769,7 @@ int sqlite3_table_column_metadata(
|
||||
*/
|
||||
if( pCol ){
|
||||
zDataType = sqlite3ColumnType(pCol,0);
|
||||
zCollSeq = sqlite3ColumnColl(pCol);
|
||||
zCollSeq = pCol->zColl;
|
||||
notnull = pCol->notNull!=0;
|
||||
primarykey = (pCol->colFlags & COLFLAG_PRIMKEY)!=0;
|
||||
autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0;
|
||||
|
||||
+210
-28
@@ -272,6 +272,7 @@ struct winFile {
|
||||
winShm *pShm; /* Instance of shared memory on this file */
|
||||
#endif
|
||||
const char *zPath; /* Full pathname of this file */
|
||||
unsigned iBusyTimeout; /* Wait this many millisec on locks */
|
||||
int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */
|
||||
#if SQLITE_OS_WINCE
|
||||
LPWSTR zDeleteOnClose; /* Name of file to delete when closing */
|
||||
@@ -1126,7 +1127,7 @@ static struct win_syscall {
|
||||
{ "InterlockedCompareExchange", (SYSCALL)InterlockedCompareExchange, 0 },
|
||||
|
||||
#define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG \
|
||||
SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[76].pCurrent)
|
||||
SQLITE_WIN32_VOLATILE*,LONG,LONG))aSyscall[76].pCurrent)
|
||||
#endif /* defined(InterlockedCompareExchange) */
|
||||
|
||||
#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
|
||||
@@ -1155,6 +1156,23 @@ static struct win_syscall {
|
||||
#define osFlushViewOfFile \
|
||||
((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent)
|
||||
|
||||
#if !SQLITE_OS_WINRT
|
||||
{ "GetFileInformationByHandle", (SYSCALL)GetFileInformationByHandle, 0 },
|
||||
#else
|
||||
{ "GetFileInformationByHandle", (SYSCALL)0, 0 },
|
||||
#endif
|
||||
|
||||
#define osGetFileInformationByHandle ((BOOL(WINAPI*)(HANDLE, \
|
||||
LPBY_HANDLE_FILE_INFORMATION))aSyscall[80].pCurrent)
|
||||
|
||||
#if !SQLITE_OS_WINRT
|
||||
{ "SleepEx", (SYSCALL)SleepEx, 0 },
|
||||
#else
|
||||
{ "SleepEx", (SYSCALL)0, 0 },
|
||||
#endif
|
||||
|
||||
#define osSleepEx ((VOID(WINAPI*)(DWORD,BOOL))aSyscall[81].pCurrent)
|
||||
|
||||
}; /* End of the overrideable system calls */
|
||||
|
||||
/*
|
||||
@@ -1379,18 +1397,25 @@ void sqlite3_win32_write_debug(const char *zBuf, int nBuf){
|
||||
static HANDLE sleepObj = NULL;
|
||||
#endif
|
||||
|
||||
void sqlite3_win32_sleep(DWORD milliseconds){
|
||||
void sqlite3Win32Sleep(DWORD milliseconds, BOOL alertable){
|
||||
#if SQLITE_OS_WINRT
|
||||
if ( sleepObj==NULL ){
|
||||
sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,
|
||||
SYNCHRONIZE);
|
||||
}
|
||||
assert( sleepObj!=NULL );
|
||||
osWaitForSingleObjectEx(sleepObj, milliseconds, FALSE);
|
||||
osWaitForSingleObjectEx(sleepObj, milliseconds, alertable);
|
||||
#else
|
||||
osSleep(milliseconds);
|
||||
if( alertable ){
|
||||
osSleepEx(milliseconds, alertable);
|
||||
}else{
|
||||
osSleep(milliseconds);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void sqlite3_win32_sleep(DWORD milliseconds){
|
||||
sqlite3Win32Sleep(milliseconds, FALSE);
|
||||
}
|
||||
|
||||
#if SQLITE_MAX_WORKER_THREADS>0 && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \
|
||||
SQLITE_THREADSAFE>0
|
||||
@@ -2154,13 +2179,13 @@ static int winRetryIoerr(int *pnRetry, DWORD *pError){
|
||||
return 0;
|
||||
}
|
||||
if( winIoerrCanRetry1(e) ){
|
||||
sqlite3_win32_sleep(winIoerrRetryDelay*(1+*pnRetry));
|
||||
sqlite3Win32Sleep(winIoerrRetryDelay*(1+*pnRetry), TRUE);
|
||||
++*pnRetry;
|
||||
return 1;
|
||||
}
|
||||
#if defined(winIoerrCanRetry2)
|
||||
else if( winIoerrCanRetry2(e) ){
|
||||
sqlite3_win32_sleep(winIoerrRetryDelay*(1+*pnRetry));
|
||||
sqlite3Win32Sleep(winIoerrRetryDelay*(1+*pnRetry), TRUE);
|
||||
++*pnRetry;
|
||||
return 1;
|
||||
}
|
||||
@@ -2503,9 +2528,13 @@ static BOOL winceUnlockFile(
|
||||
|
||||
/*
|
||||
** Lock a file region.
|
||||
**
|
||||
** If the pFile->iBusyTimeout value is non-zero and the lock cannot be
|
||||
** acquired immediately, then try to block for up to iBusyTimeout milliseconds
|
||||
** waiting on the conflicting lock to appear.
|
||||
*/
|
||||
static BOOL winLockFile(
|
||||
LPHANDLE phFile,
|
||||
winFile *pFile,
|
||||
DWORD flags,
|
||||
DWORD offsetLow,
|
||||
DWORD offsetHigh,
|
||||
@@ -2517,17 +2546,31 @@ static BOOL winLockFile(
|
||||
** NOTE: Windows CE is handled differently here due its lack of the Win32
|
||||
** API LockFile.
|
||||
*/
|
||||
return winceLockFile(phFile, offsetLow, offsetHigh,
|
||||
return winceLockFile(&pFile->h, offsetLow, offsetHigh,
|
||||
numBytesLow, numBytesHigh);
|
||||
#else
|
||||
if( osIsNT() ){
|
||||
BOOL bResult;
|
||||
OVERLAPPED ovlp;
|
||||
memset(&ovlp, 0, sizeof(OVERLAPPED));
|
||||
ovlp.Offset = offsetLow;
|
||||
ovlp.OffsetHigh = offsetHigh;
|
||||
return osLockFileEx(*phFile, flags, 0, numBytesLow, numBytesHigh, &ovlp);
|
||||
bResult = osLockFileEx(pFile->h, flags, 0, numBytesLow,
|
||||
numBytesHigh, &ovlp);
|
||||
if( !bResult && pFile->iBusyTimeout>0 ){
|
||||
unsigned iDelay = (unsigned)winIoerrRetryDelay;
|
||||
if( iDelay>0 ){
|
||||
u64 iTotalDelay = 0;
|
||||
do{
|
||||
sqlite3Win32Sleep(iDelay, TRUE); iTotalDelay += iDelay;
|
||||
bResult = osLockFileEx(pFile->h, flags, 0, numBytesLow,
|
||||
numBytesHigh, &ovlp);
|
||||
}while( !bResult && iTotalDelay<pFile->iBusyTimeout );
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
}else{
|
||||
return osLockFile(*phFile, offsetLow, offsetHigh, numBytesLow,
|
||||
return osLockFile(pFile->h, offsetLow, offsetHigh, numBytesLow,
|
||||
numBytesHigh);
|
||||
}
|
||||
#endif
|
||||
@@ -2673,7 +2716,7 @@ static int winClose(sqlite3_file *id){
|
||||
do{
|
||||
rc = osCloseHandle(pFile->h);
|
||||
/* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
|
||||
}while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );
|
||||
}while( rc==0 && ++cnt<MX_CLOSE_ATTEMPT && (sqlite3Win32Sleep(100,TRUE), 1) );
|
||||
#if SQLITE_OS_WINCE
|
||||
#define WINCE_DELETION_ATTEMPTS 3
|
||||
{
|
||||
@@ -2689,7 +2732,7 @@ static int winClose(sqlite3_file *id){
|
||||
&& osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff
|
||||
&& cnt++ < WINCE_DELETION_ATTEMPTS
|
||||
){
|
||||
sqlite3_win32_sleep(100); /* Wait a little before trying again */
|
||||
sqlite3Win32Sleep(100, TRUE); /* Wait a little before trying again */
|
||||
}
|
||||
sqlite3_free(pFile->zDeleteOnClose);
|
||||
}
|
||||
@@ -3162,7 +3205,7 @@ static int winGetReadLock(winFile *pFile){
|
||||
*/
|
||||
res = winceLockFile(&pFile->h, SHARED_FIRST, 0, 1, 0);
|
||||
#else
|
||||
res = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS, SHARED_FIRST, 0,
|
||||
res = winLockFile(pFile, SQLITE_LOCKFILEEX_FLAGS, SHARED_FIRST, 0,
|
||||
SHARED_SIZE, 0);
|
||||
#endif
|
||||
}
|
||||
@@ -3171,7 +3214,7 @@ static int winGetReadLock(winFile *pFile){
|
||||
int lk;
|
||||
sqlite3_randomness(sizeof(lk), &lk);
|
||||
pFile->sharedLockByte = (short)((lk & 0x7fffffff)%(SHARED_SIZE - 1));
|
||||
res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS,
|
||||
res = winLockFile(pFile, SQLITE_LOCKFILE_FLAGS,
|
||||
SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);
|
||||
}
|
||||
#endif
|
||||
@@ -3275,7 +3318,7 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||
|| (locktype==EXCLUSIVE_LOCK && pFile->locktype<=RESERVED_LOCK)
|
||||
){
|
||||
int cnt = 3;
|
||||
while( cnt-->0 && (res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS,
|
||||
while( cnt-->0 && (res = winLockFile(pFile, SQLITE_LOCKFILE_FLAGS,
|
||||
PENDING_BYTE, 0, 1, 0))==0 ){
|
||||
/* Try 3 times to get the pending lock. This is needed to work
|
||||
** around problems caused by indexing and/or anti-virus software on
|
||||
@@ -3293,7 +3336,7 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||
pFile->h, cnt, sqlite3ErrName(rc)));
|
||||
return rc;
|
||||
}
|
||||
if( cnt ) sqlite3_win32_sleep(1);
|
||||
if( cnt ) sqlite3Win32Sleep(1, TRUE);
|
||||
}
|
||||
gotPendingLock = res;
|
||||
if( !res ){
|
||||
@@ -3317,7 +3360,7 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||
*/
|
||||
if( locktype==RESERVED_LOCK && res ){
|
||||
assert( pFile->locktype==SHARED_LOCK );
|
||||
res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, RESERVED_BYTE, 0, 1, 0);
|
||||
res = winLockFile(pFile, SQLITE_LOCKFILE_FLAGS, RESERVED_BYTE, 0, 1, 0);
|
||||
if( res ){
|
||||
newLocktype = RESERVED_LOCK;
|
||||
}else{
|
||||
@@ -3337,7 +3380,7 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||
if( locktype==EXCLUSIVE_LOCK && res ){
|
||||
assert( pFile->locktype>=SHARED_LOCK );
|
||||
res = winUnlockReadLock(pFile);
|
||||
res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, SHARED_FIRST, 0,
|
||||
res = winLockFile(pFile, SQLITE_LOCKFILE_FLAGS, SHARED_FIRST, 0,
|
||||
SHARED_SIZE, 0);
|
||||
if( res ){
|
||||
newLocktype = EXCLUSIVE_LOCK;
|
||||
@@ -3388,7 +3431,7 @@ static int winCheckReservedLock(sqlite3_file *id, int *pResOut){
|
||||
res = 1;
|
||||
OSTRACE(("TEST-WR-LOCK file=%p, result=%d (local)\n", pFile->h, res));
|
||||
}else{
|
||||
res = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS,RESERVED_BYTE,0,1,0);
|
||||
res = winLockFile(pFile, SQLITE_LOCKFILEEX_FLAGS,RESERVED_BYTE,0,1,0);
|
||||
if( res ){
|
||||
winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);
|
||||
}
|
||||
@@ -3527,6 +3570,12 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
|
||||
OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
|
||||
return SQLITE_OK;
|
||||
}
|
||||
case SQLITE_FCNTL_LOCK_TIMEOUT: {
|
||||
int iOld = pFile->iBusyTimeout;
|
||||
pFile->iBusyTimeout = *(int*)pArg;
|
||||
*(int*)pArg = iOld;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
case SQLITE_FCNTL_SIZE_HINT: {
|
||||
if( pFile->szChunk>0 ){
|
||||
sqlite3_int64 oldSz;
|
||||
@@ -3804,7 +3853,7 @@ static int winShmSystemLock(
|
||||
/* Initialize the locking parameters */
|
||||
DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
|
||||
if( lockType == WINSHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
|
||||
rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);
|
||||
rc = winLockFile(&pFile->hFile, dwFlags, ofst, 0, nByte, 0);
|
||||
}
|
||||
|
||||
if( rc!= 0 ){
|
||||
@@ -3824,6 +3873,135 @@ static int winShmSystemLock(
|
||||
/* Forward references to VFS methods */
|
||||
static int winOpen(sqlite3_vfs*,const char*,sqlite3_file*,int,int*);
|
||||
static int winDelete(sqlite3_vfs *,const char*,int);
|
||||
static int winFullPathname(sqlite3_vfs *,const char *,int,char *);
|
||||
static void *winConvertFromUtf8Filename(const char *);
|
||||
|
||||
#if !SQLITE_OS_WINRT
|
||||
/*
|
||||
** This function attempts to query the metadata information for the
|
||||
** specified file. Upon success, SQLITE_OK is returned; otherwise,
|
||||
** an appropriate error code is returned.
|
||||
*/
|
||||
|
||||
static int winGetFileInfo(
|
||||
const char *zFilename,
|
||||
winFile *pFile,
|
||||
LPBY_HANDLE_FILE_INFORMATION pFileInfo
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
HANDLE hFile = NULL;
|
||||
int lastError = 0;
|
||||
void *zConverted = winConvertFromUtf8Filename(zFilename);
|
||||
if( zConverted==0 ){
|
||||
lastError = osGetLastError();
|
||||
if( pFile ) pFile->lastErrno = lastError;
|
||||
return winLogError(SQLITE_IOERR_NOMEM, lastError,
|
||||
"winGetFileInfo1", zFilename);
|
||||
}
|
||||
if( osIsNT() ){
|
||||
hFile = osCreateFileW(
|
||||
(LPCWSTR)zConverted, GENERIC_READ,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL
|
||||
);
|
||||
#ifdef SQLITE_WIN32_HAS_ANSI
|
||||
}else{
|
||||
hFile = osCreateFileA(
|
||||
(LPCSTR)zConverted, GENERIC_READ,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL
|
||||
);
|
||||
#endif
|
||||
}
|
||||
sqlite3_free(zConverted);
|
||||
if( hFile==INVALID_HANDLE_VALUE ){
|
||||
lastError = osGetLastError();
|
||||
if( pFile ) pFile->lastErrno = lastError;
|
||||
return winLogError(SQLITE_CANTOPEN, lastError,
|
||||
"winGetFileInfo2", zFilename);
|
||||
}
|
||||
if( !osGetFileInformationByHandle(hFile, pFileInfo) ){
|
||||
lastError = osGetLastError();
|
||||
if( pFile ) pFile->lastErrno = lastError;
|
||||
rc = winLogError(SQLITE_IOERR_FSTAT, lastError,
|
||||
"winGetFileInfo3", zFilename);
|
||||
}
|
||||
osCloseHandle(hFile);
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Returns non-zero if both of the specified file names refer to the same
|
||||
** underlying file. On some sub-platforms, this function may return zero
|
||||
** even when both file names refer to the same underlying file; however,
|
||||
** it will never return non-zero unless both file names refer to the same
|
||||
** underlying file.
|
||||
*/
|
||||
|
||||
static int winIsSameFile(
|
||||
sqlite3_vfs *pVfs,
|
||||
winFile *pFile,
|
||||
const char *zFilename1,
|
||||
const char *zFilename2,
|
||||
BOOL *pbSame
|
||||
){
|
||||
*pbSame = 0; /* initially, assume not the same file */
|
||||
|
||||
#if !SQLITE_OS_WINRT
|
||||
{
|
||||
BY_HANDLE_FILE_INFORMATION info1;
|
||||
BY_HANDLE_FILE_INFORMATION info2;
|
||||
|
||||
if( !winGetFileInfo(zFilename1, pFile, &info1)
|
||||
|| !winGetFileInfo(zFilename2, pFile, &info2) ){
|
||||
/* wrong file system type? ok, use fallback. */
|
||||
goto fallback;
|
||||
}
|
||||
if( info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber
|
||||
&& info1.nFileIndexHigh == info2.nFileIndexHigh
|
||||
&& info1.nFileIndexLow == info2.nFileIndexLow ){
|
||||
OSTRACE(("SAME pid=%lu, pFile=%p, name1=%s, name2=%s, "
|
||||
"YES (ID), rc=SQLITE_OK\n", osGetCurrentProcessId(),
|
||||
pFile, zFilename1, zFilename2));
|
||||
*pbSame = 1;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
fallback:
|
||||
{
|
||||
int rc = SQLITE_OK;
|
||||
int nFull = pVfs->mxPathname+1;
|
||||
char *zFull1 = NULL;
|
||||
char *zFull2 = NULL;
|
||||
|
||||
zFull1 = sqlite3MallocZero( nFull );
|
||||
if( zFull1==0 ){
|
||||
rc = SQLITE_IOERR_NOMEM_BKPT;
|
||||
goto done;
|
||||
}
|
||||
zFull2 = sqlite3MallocZero( nFull );
|
||||
if( zFull2==0 ){
|
||||
rc = SQLITE_IOERR_NOMEM_BKPT;
|
||||
goto done;
|
||||
}
|
||||
rc = winFullPathname(pVfs, zFilename1, nFull, zFull1);
|
||||
if( rc!=SQLITE_OK ) goto done;
|
||||
rc = winFullPathname(pVfs, zFilename2, nFull, zFull2);
|
||||
if( rc!=SQLITE_OK ) goto done;
|
||||
*pbSame = sqlite3StrICmp(zFull1, zFull2)==0;
|
||||
done:
|
||||
if( zFull2 ) sqlite3_free(zFull2);
|
||||
if( zFull1 ) sqlite3_free(zFull1);
|
||||
OSTRACE(("SAME pid=%lu, pFile=%p, name1=%s, name2=%s, "
|
||||
"%s (NAME), rc=%s\n", osGetCurrentProcessId(),
|
||||
pFile, zFilename1, zFilename2, *pbSame?"YES":"NO",
|
||||
sqlite3ErrName(rc)));
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Purge the winShmNodeList list of all entries with winShmNode.nRef==0.
|
||||
@@ -3940,10 +4118,13 @@ static int winOpenSharedMemory(winFile *pDbFd){
|
||||
*/
|
||||
winShmEnterMutex();
|
||||
for(pShmNode = winShmNodeList; pShmNode; pShmNode=pShmNode->pNext){
|
||||
/* TBD need to come up with better match here. Perhaps
|
||||
** use FILE_ID_BOTH_DIR_INFO Structure.
|
||||
*/
|
||||
if( sqlite3StrICmp(pShmNode->zFilename, pNew->zFilename)==0 ) break;
|
||||
BOOL bSame;
|
||||
rc = winIsSameFile(
|
||||
pDbFd->pVfs, pDbFd, pShmNode->zFilename, pNew->zFilename,
|
||||
&bSame
|
||||
);
|
||||
if( rc!=SQLITE_OK ) goto shm_open_err;
|
||||
if( bSame ) break;
|
||||
}
|
||||
if( pShmNode ){
|
||||
sqlite3_free(pNew);
|
||||
@@ -4085,6 +4266,7 @@ static int winShmLock(
|
||||
mask = (u16)((1U<<(ofst+n)) - (1U<<ofst));
|
||||
assert( n>1 || mask==(1<<ofst) );
|
||||
sqlite3_mutex_enter(pShmNode->mutex);
|
||||
pShmNode->hFile.iBusyTimeout = pDbFd->iBusyTimeout;
|
||||
if( flags & SQLITE_SHM_UNLOCK ){
|
||||
u16 allMask = 0; /* Mask of locks held by siblings */
|
||||
|
||||
@@ -4990,7 +5172,7 @@ static int winOpen(
|
||||
int flags, /* Open mode flags */
|
||||
int *pOutFlags /* Status return flags */
|
||||
){
|
||||
HANDLE h;
|
||||
HANDLE h = INVALID_HANDLE_VALUE;
|
||||
DWORD lastErrno = 0;
|
||||
DWORD dwDesiredAccess;
|
||||
DWORD dwShareMode;
|
||||
@@ -5277,7 +5459,7 @@ static int winOpen(
|
||||
pFile->ctrlFlags |= WINFILE_RDONLY;
|
||||
}
|
||||
if( (flags & SQLITE_OPEN_MAIN_DB)
|
||||
&& sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE)
|
||||
&& sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE)
|
||||
){
|
||||
pFile->ctrlFlags |= WINFILE_PSOW;
|
||||
}
|
||||
@@ -5884,7 +6066,7 @@ static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
|
||||
** Sleep for a little while. Return the amount of time slept.
|
||||
*/
|
||||
static int winSleep(sqlite3_vfs *pVfs, int microsec){
|
||||
sqlite3_win32_sleep((microsec+999)/1000);
|
||||
sqlite3Win32Sleep((microsec+999)/1000, FALSE);
|
||||
UNUSED_PARAMETER(pVfs);
|
||||
return ((microsec+999)/1000)*1000;
|
||||
}
|
||||
@@ -6105,7 +6287,7 @@ int sqlite3_os_init(void){
|
||||
|
||||
/* Double-check that the aSyscall[] array has been constructed
|
||||
** correctly. See ticket [bb3a86e890c8e96ab] */
|
||||
assert( ArraySize(aSyscall)==80 );
|
||||
assert( ArraySize(aSyscall)==82 );
|
||||
|
||||
/* get memory map allocation granularity */
|
||||
memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
|
||||
|
||||
+5
-16
@@ -196,19 +196,16 @@ ifnotexists(A) ::= IF NOT EXISTS. {A = 1;}
|
||||
temp(A) ::= TEMP. {A = pParse->db->init.busy==0;}
|
||||
%endif SQLITE_OMIT_TEMPDB
|
||||
temp(A) ::= . {A = 0;}
|
||||
create_table_args ::= LP columnlist conslist_opt(X) RP(E) table_option_set(F). {
|
||||
create_table_args ::= LP columnlist conslist_opt(X) RP(E) table_options(F). {
|
||||
sqlite3EndTable(pParse,&X,&E,F,0);
|
||||
}
|
||||
create_table_args ::= AS select(S). {
|
||||
sqlite3EndTable(pParse,0,0,0,S);
|
||||
sqlite3SelectDelete(pParse->db, S);
|
||||
}
|
||||
%type table_option_set {u32}
|
||||
%type table_option {u32}
|
||||
table_option_set(A) ::= . {A = 0;}
|
||||
table_option_set(A) ::= table_option(A).
|
||||
table_option_set(A) ::= table_option_set(X) COMMA table_option(Y). {A = X|Y;}
|
||||
table_option(A) ::= WITHOUT nm(X). {
|
||||
%type table_options {int}
|
||||
table_options(A) ::= . {A = 0;}
|
||||
table_options(A) ::= WITHOUT nm(X). {
|
||||
if( X.n==5 && sqlite3_strnicmp(X.z,"rowid",5)==0 ){
|
||||
A = TF_WithoutRowid | TF_NoVisibleRowid;
|
||||
}else{
|
||||
@@ -216,17 +213,9 @@ table_option(A) ::= WITHOUT nm(X). {
|
||||
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", X.n, X.z);
|
||||
}
|
||||
}
|
||||
table_option(A) ::= nm(X). {
|
||||
if( X.n==6 && sqlite3_strnicmp(X.z,"strict",6)==0 ){
|
||||
A = TF_Strict;
|
||||
}else{
|
||||
A = 0;
|
||||
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", X.n, X.z);
|
||||
}
|
||||
}
|
||||
columnlist ::= columnlist COMMA columnname carglist.
|
||||
columnlist ::= columnname carglist.
|
||||
columnname(A) ::= nm(A) typetoken(Y). {sqlite3AddColumn(pParse,A,Y);}
|
||||
columnname(A) ::= nm(A) typetoken(Y). {sqlite3AddColumn(pParse,&A,&Y);}
|
||||
|
||||
// Declare some tokens early in order to influence their values, to
|
||||
// improve performance and reduce the executable size. The goal here is
|
||||
|
||||
+3
-9
@@ -817,18 +817,12 @@ static sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){
|
||||
*/
|
||||
static void pcache1Cachesize(sqlite3_pcache *p, int nMax){
|
||||
PCache1 *pCache = (PCache1 *)p;
|
||||
u32 n;
|
||||
assert( nMax>=0 );
|
||||
if( pCache->bPurgeable ){
|
||||
PGroup *pGroup = pCache->pGroup;
|
||||
pcache1EnterMutex(pGroup);
|
||||
n = (u32)nMax;
|
||||
if( n > 0x7fff0000 - pGroup->nMaxPage + pCache->nMax ){
|
||||
n = 0x7fff0000 - pGroup->nMaxPage + pCache->nMax;
|
||||
}
|
||||
pGroup->nMaxPage += (n - pCache->nMax);
|
||||
pGroup->nMaxPage += (nMax - pCache->nMax);
|
||||
pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
|
||||
pCache->nMax = n;
|
||||
pCache->nMax = nMax;
|
||||
pCache->n90pct = pCache->nMax*9/10;
|
||||
pcache1EnforceMaxPage(pCache);
|
||||
pcache1LeaveMutex(pGroup);
|
||||
@@ -844,7 +838,7 @@ static void pcache1Shrink(sqlite3_pcache *p){
|
||||
PCache1 *pCache = (PCache1*)p;
|
||||
if( pCache->bPurgeable ){
|
||||
PGroup *pGroup = pCache->pGroup;
|
||||
unsigned int savedMaxPage;
|
||||
int savedMaxPage;
|
||||
pcache1EnterMutex(pGroup);
|
||||
savedMaxPage = pGroup->nMaxPage;
|
||||
pGroup->nMaxPage = 0;
|
||||
|
||||
+19
-48
@@ -1177,16 +1177,13 @@ void sqlite3Pragma(
|
||||
}else{
|
||||
for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
|
||||
}
|
||||
assert( sqlite3ColumnExpr(pTab,pCol)==0
|
||||
|| sqlite3ColumnExpr(pTab,pCol)->op==TK_SPAN
|
||||
|| isHidden>=2 );
|
||||
assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN || isHidden>=2 );
|
||||
sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issisii" : "issisi",
|
||||
i-nHidden,
|
||||
pCol->zCnName,
|
||||
pCol->zName,
|
||||
sqlite3ColumnType(pCol,""),
|
||||
pCol->notNull ? 1 : 0,
|
||||
isHidden>=2 || sqlite3ColumnExpr(pTab,pCol)==0 ? 0 :
|
||||
sqlite3ColumnExpr(pTab,pCol)->u.zToken,
|
||||
pCol->pDflt && isHidden<2 ? pCol->pDflt->u.zToken : 0,
|
||||
k,
|
||||
isHidden);
|
||||
}
|
||||
@@ -1253,7 +1250,7 @@ void sqlite3Pragma(
|
||||
for(i=0; i<mx; i++){
|
||||
i16 cnum = pIdx->aiColumn[i];
|
||||
sqlite3VdbeMultiLoad(v, 1, "iisX", i, cnum,
|
||||
cnum<0 ? 0 : pTab->aCol[cnum].zCnName);
|
||||
cnum<0 ? 0 : pTab->aCol[cnum].zName);
|
||||
if( pPragma->iArg ){
|
||||
sqlite3VdbeMultiLoad(v, 4, "isiX",
|
||||
pIdx->aSortOrder[i],
|
||||
@@ -1360,8 +1357,8 @@ void sqlite3Pragma(
|
||||
FKey *pFK;
|
||||
Table *pTab;
|
||||
pTab = sqlite3FindTable(db, zRight, zDb);
|
||||
if( pTab && !IsVirtual(pTab) ){
|
||||
pFK = pTab->u.tab.pFKey;
|
||||
if( pTab ){
|
||||
pFK = pTab->pFKey;
|
||||
if( pFK ){
|
||||
int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
int i = 0;
|
||||
@@ -1374,7 +1371,7 @@ void sqlite3Pragma(
|
||||
i,
|
||||
j,
|
||||
pFK->zTo,
|
||||
pTab->aCol[pFK->aCol[j].iFrom].zCnName,
|
||||
pTab->aCol[pFK->aCol[j].iFrom].zName,
|
||||
pFK->aCol[j].zCol,
|
||||
actionName(pFK->aAction[1]), /* ON UPDATE */
|
||||
actionName(pFK->aAction[0]), /* ON DELETE */
|
||||
@@ -1420,7 +1417,7 @@ void sqlite3Pragma(
|
||||
pTab = (Table*)sqliteHashData(k);
|
||||
k = sqliteHashNext(k);
|
||||
}
|
||||
if( pTab==0 || IsVirtual(pTab) || pTab->u.tab.pFKey==0 ) continue;
|
||||
if( pTab==0 || pTab->pFKey==0 ) continue;
|
||||
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
zDb = db->aDb[iDb].zDbSName;
|
||||
sqlite3CodeVerifySchema(pParse, iDb);
|
||||
@@ -1428,8 +1425,7 @@ void sqlite3Pragma(
|
||||
if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
|
||||
sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
|
||||
sqlite3VdbeLoadString(v, regResult, pTab->zName);
|
||||
assert( !IsVirtual(pTab) );
|
||||
for(i=1, pFK=pTab->u.tab.pFKey; pFK; i++, pFK=pFK->pNextFrom){
|
||||
for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
|
||||
pParent = sqlite3FindTable(db, pFK->zTo, zDb);
|
||||
if( pParent==0 ) continue;
|
||||
pIdx = 0;
|
||||
@@ -1451,8 +1447,7 @@ void sqlite3Pragma(
|
||||
if( pFK ) break;
|
||||
if( pParse->nTab<i ) pParse->nTab = i;
|
||||
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); VdbeCoverage(v);
|
||||
assert( !IsVirtual(pTab) );
|
||||
for(i=1, pFK=pTab->u.tab.pFKey; pFK; i++, pFK=pFK->pNextFrom){
|
||||
for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
|
||||
pParent = sqlite3FindTable(db, pFK->zTo, zDb);
|
||||
pIdx = 0;
|
||||
aiCols = 0;
|
||||
@@ -1653,7 +1648,6 @@ void sqlite3Pragma(
|
||||
int loopTop;
|
||||
int iDataCur, iIdxCur;
|
||||
int r1 = -1;
|
||||
int bStrict;
|
||||
|
||||
if( pTab->tnum<1 ) continue; /* Skip VIEWs or VIRTUAL TABLEs */
|
||||
if( pObjTab && pObjTab!=pTab ) continue;
|
||||
@@ -1675,46 +1669,23 @@ void sqlite3Pragma(
|
||||
/* Sanity check on record header decoding */
|
||||
sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nNVCol-1,3);
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
|
||||
VdbeComment((v, "(right-most column)"));
|
||||
}
|
||||
/* Verify that all NOT NULL columns really are NOT NULL. At the
|
||||
** same time verify the type of the content of STRICT tables */
|
||||
bStrict = (pTab->tabFlags & TF_Strict)!=0;
|
||||
/* Verify that all NOT NULL columns really are NOT NULL */
|
||||
for(j=0; j<pTab->nCol; j++){
|
||||
char *zErr;
|
||||
Column *pCol = pTab->aCol + j;
|
||||
int doError, jmp2;
|
||||
int jmp2;
|
||||
if( j==pTab->iPKey ) continue;
|
||||
if( pCol->notNull==0 && !bStrict ) continue;
|
||||
doError = bStrict ? sqlite3VdbeMakeLabel(pParse) : 0;
|
||||
if( pTab->aCol[j].notNull==0 ) continue;
|
||||
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);
|
||||
if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
|
||||
}
|
||||
if( pCol->notNull ){
|
||||
jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);
|
||||
zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
|
||||
pCol->zCnName);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
|
||||
if( bStrict ){
|
||||
sqlite3VdbeGoto(v, doError);
|
||||
}else{
|
||||
integrityCheckResultRow(v);
|
||||
}
|
||||
sqlite3VdbeJumpHere(v, jmp2);
|
||||
}
|
||||
if( pTab->tabFlags & TF_Strict ){
|
||||
jmp2 = sqlite3VdbeAddOp3(v, OP_IsNullOrType, 3, 0,
|
||||
sqlite3StdTypeMap[pCol->eCType-1]);
|
||||
VdbeCoverage(v);
|
||||
zErr = sqlite3MPrintf(db, "non-%s value in %s.%s",
|
||||
sqlite3StdType[pCol->eCType-1],
|
||||
pTab->zName, pTab->aCol[j].zCnName);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
|
||||
sqlite3VdbeResolveLabel(v, doError);
|
||||
integrityCheckResultRow(v);
|
||||
sqlite3VdbeJumpHere(v, jmp2);
|
||||
}
|
||||
jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);
|
||||
zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
|
||||
pTab->aCol[j].zName);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
|
||||
integrityCheckResultRow(v);
|
||||
sqlite3VdbeJumpHere(v, jmp2);
|
||||
}
|
||||
/* Verify CHECK constraints */
|
||||
if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
|
||||
|
||||
+2
-6
@@ -333,9 +333,7 @@ static int lookupName(
|
||||
}
|
||||
hCol = sqlite3StrIHash(zCol);
|
||||
for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
|
||||
if( pCol->hName==hCol
|
||||
&& sqlite3StrICmp(pCol->zCnName, zCol)==0
|
||||
){
|
||||
if( pCol->hName==hCol && sqlite3StrICmp(pCol->zName, zCol)==0 ){
|
||||
/* If there has been exactly one prior match and this match
|
||||
** is for the right-hand table of a NATURAL JOIN or is in a
|
||||
** USING clause, then skip this match.
|
||||
@@ -412,9 +410,7 @@ static int lookupName(
|
||||
pSchema = pTab->pSchema;
|
||||
cntTab++;
|
||||
for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){
|
||||
if( pCol->hName==hCol
|
||||
&& sqlite3StrICmp(pCol->zCnName, zCol)==0
|
||||
){
|
||||
if( pCol->hName==hCol && sqlite3StrICmp(pCol->zName, zCol)==0 ){
|
||||
if( iCol==pTab->iPKey ){
|
||||
iCol = -1;
|
||||
}
|
||||
|
||||
+29
-33
@@ -271,7 +271,7 @@ int sqlite3ColumnIndex(Table *pTab, const char *zCol){
|
||||
u8 h = sqlite3StrIHash(zCol);
|
||||
Column *pCol;
|
||||
for(pCol=pTab->aCol, i=0; i<pTab->nCol; pCol++, i++){
|
||||
if( pCol->hName==h && sqlite3StrICmp(pCol->zCnName, zCol)==0 ) return i;
|
||||
if( pCol->hName==h && sqlite3StrICmp(pCol->zName, zCol)==0 ) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -470,7 +470,7 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){
|
||||
int iLeftCol; /* Matching column in the left table */
|
||||
|
||||
if( IsHiddenColumn(&pRightTab->aCol[j]) ) continue;
|
||||
zName = pRightTab->aCol[j].zCnName;
|
||||
zName = pRightTab->aCol[j].zName;
|
||||
if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol, 1) ){
|
||||
addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j,
|
||||
isOuter, &p->pWhere);
|
||||
@@ -1837,7 +1837,7 @@ static const char *columnTypeImpl(
|
||||
zType = "INTEGER";
|
||||
zOrigCol = "rowid";
|
||||
}else{
|
||||
zOrigCol = pTab->aCol[iCol].zCnName;
|
||||
zOrigCol = pTab->aCol[iCol].zName;
|
||||
zType = sqlite3ColumnType(&pTab->aCol[iCol],0);
|
||||
}
|
||||
zOrigTab = pTab->zName;
|
||||
@@ -2009,7 +2009,7 @@ void sqlite3GenerateColumnNames(
|
||||
if( iCol<0 ){
|
||||
zCol = "rowid";
|
||||
}else{
|
||||
zCol = pTab->aCol[iCol].zCnName;
|
||||
zCol = pTab->aCol[iCol].zName;
|
||||
}
|
||||
if( fullName ){
|
||||
char *zName = 0;
|
||||
@@ -2094,7 +2094,7 @@ int sqlite3ColumnsFromExprList(
|
||||
/* For columns use the column name name */
|
||||
int iCol = pColExpr->iColumn;
|
||||
if( iCol<0 ) iCol = pTab->iPKey;
|
||||
zName = iCol>=0 ? pTab->aCol[iCol].zCnName : "rowid";
|
||||
zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid";
|
||||
}else if( pColExpr->op==TK_ID ){
|
||||
assert( !ExprHasProperty(pColExpr, EP_IntValue) );
|
||||
zName = pColExpr->u.zToken;
|
||||
@@ -2122,7 +2122,7 @@ int sqlite3ColumnsFromExprList(
|
||||
zName = sqlite3MPrintf(db, "%.*z:%u", nName, zName, ++cnt);
|
||||
if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt);
|
||||
}
|
||||
pCol->zCnName = zName;
|
||||
pCol->zName = zName;
|
||||
pCol->hName = sqlite3StrIHash(zName);
|
||||
sqlite3ColumnPropertiesFromName(0, pCol);
|
||||
if( zName && sqlite3HashInsert(&ht, zName, pCol)==pCol ){
|
||||
@@ -2132,7 +2132,7 @@ int sqlite3ColumnsFromExprList(
|
||||
sqlite3HashClear(&ht);
|
||||
if( db->mallocFailed ){
|
||||
for(j=0; j<i; j++){
|
||||
sqlite3DbFree(db, aCol[j].zCnName);
|
||||
sqlite3DbFree(db, aCol[j].zName);
|
||||
}
|
||||
sqlite3DbFree(db, aCol);
|
||||
*paCol = 0;
|
||||
@@ -2184,18 +2184,17 @@ void sqlite3SelectAddColumnTypeAndCollation(
|
||||
pCol->affinity = sqlite3ExprAffinity(p);
|
||||
if( zType ){
|
||||
m = sqlite3Strlen30(zType);
|
||||
n = sqlite3Strlen30(pCol->zCnName);
|
||||
pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2);
|
||||
if( pCol->zCnName ){
|
||||
memcpy(&pCol->zCnName[n+1], zType, m+1);
|
||||
n = sqlite3Strlen30(pCol->zName);
|
||||
pCol->zName = sqlite3DbReallocOrFree(db, pCol->zName, n+m+2);
|
||||
if( pCol->zName ){
|
||||
memcpy(&pCol->zName[n+1], zType, m+1);
|
||||
pCol->colFlags |= COLFLAG_HASTYPE;
|
||||
}
|
||||
}
|
||||
if( pCol->affinity<=SQLITE_AFF_NONE ) pCol->affinity = aff;
|
||||
pColl = sqlite3ExprCollSeq(pParse, p);
|
||||
if( pColl && (pCol->colFlags & COLFLAG_HASCOLL)==0 ){
|
||||
assert( pTab->pIndex==0 );
|
||||
sqlite3ColumnSetColl(db, pCol, pColl->zName);
|
||||
if( pColl && pCol->zColl==0 ){
|
||||
pCol->zColl = sqlite3DbStrDup(db, pColl->zName);
|
||||
}
|
||||
}
|
||||
pTab->szTabRow = 1; /* Any non-zero value works */
|
||||
@@ -4934,7 +4933,7 @@ static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
|
||||
}
|
||||
pTab = p->pSrc->a[0].pTab;
|
||||
pExpr = p->pEList->a[0].pExpr;
|
||||
assert( pTab && !IsView(pTab) && pExpr );
|
||||
assert( pTab && !pTab->pSelect && pExpr );
|
||||
|
||||
if( IsVirtual(pTab) ) return 0;
|
||||
if( pExpr->op!=TK_AGG_FUNCTION ) return 0;
|
||||
@@ -5479,31 +5478,30 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
return WRC_Abort;
|
||||
}
|
||||
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
|
||||
if( !IsOrdinaryTable(pTab) ){
|
||||
if( IsVirtual(pTab) || pTab->pSelect ){
|
||||
i16 nCol;
|
||||
u8 eCodeOrig = pWalker->eCode;
|
||||
if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;
|
||||
assert( pFrom->pSelect==0 );
|
||||
if( IsView(pTab) ){
|
||||
if( (db->flags & SQLITE_EnableView)==0
|
||||
&& pTab->pSchema!=db->aDb[1].pSchema
|
||||
){
|
||||
sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited",
|
||||
pTab->zName);
|
||||
}
|
||||
pFrom->pSelect = sqlite3SelectDup(db, pTab->u.view.pSelect, 0);
|
||||
}else
|
||||
if( pTab->pSelect
|
||||
&& (db->flags & SQLITE_EnableView)==0
|
||||
&& pTab->pSchema!=db->aDb[1].pSchema
|
||||
){
|
||||
sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited",
|
||||
pTab->zName);
|
||||
}
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
if( ALWAYS(IsVirtual(pTab))
|
||||
assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 );
|
||||
if( IsVirtual(pTab)
|
||||
&& pFrom->fg.fromDDL
|
||||
&& ALWAYS(pTab->u.vtab.p!=0)
|
||||
&& pTab->u.vtab.p->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0)
|
||||
&& ALWAYS(pTab->pVTable!=0)
|
||||
&& pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0)
|
||||
){
|
||||
sqlite3ErrorMsg(pParse, "unsafe use of virtual table \"%s\"",
|
||||
pTab->zName);
|
||||
}
|
||||
assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 );
|
||||
#endif
|
||||
pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);
|
||||
nCol = pTab->nCol;
|
||||
pTab->nCol = -1;
|
||||
pWalker->eCode = 1; /* Turn on Select.selId renumbering */
|
||||
@@ -5603,7 +5601,7 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
zSchemaName = iDb>=0 ? db->aDb[iDb].zDbSName : "*";
|
||||
}
|
||||
for(j=0; j<pTab->nCol; j++){
|
||||
char *zName = pTab->aCol[j].zCnName;
|
||||
char *zName = pTab->aCol[j].zName;
|
||||
char *zColname; /* The computed column name */
|
||||
char *zToFree; /* Malloced string that needs to be freed */
|
||||
Token sColname; /* Computed column name as a token */
|
||||
@@ -6583,8 +6581,7 @@ int sqlite3Select(
|
||||
** inside the subquery. This can help the subquery to run more efficiently.
|
||||
*/
|
||||
if( OptimizationEnabled(db, SQLITE_PushDown)
|
||||
&& (pItem->fg.isCte==0
|
||||
|| (pItem->u2.pCteUse->eM10d!=M10d_Yes && pItem->u2.pCteUse->nUse<2))
|
||||
&& (pItem->fg.isCte==0 || pItem->u2.pCteUse->eM10d!=M10d_Yes)
|
||||
&& pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor,
|
||||
(pItem->fg.jointype & JT_OUTER)!=0)
|
||||
){
|
||||
@@ -6645,7 +6642,6 @@ int sqlite3Select(
|
||||
sqlite3VdbeAddOp2(v, OP_Gosub, pCteUse->regRtn, pCteUse->addrM9e);
|
||||
if( pItem->iCursor!=pCteUse->iCur ){
|
||||
sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pCteUse->iCur);
|
||||
VdbeComment((v, "%!S", pItem));
|
||||
}
|
||||
pSub->nSelectRow = pCteUse->nRowEst;
|
||||
}else if( (pPrior = isSelfJoinView(pTabList, pItem))!=0 ){
|
||||
|
||||
@@ -11140,14 +11140,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
if( n<0 ) n = 0;
|
||||
sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, n);
|
||||
if( sz*n==0 ) data.shellFlgs &= ~SHFLG_Lookaside;
|
||||
}else if( strcmp(z,"-threadsafe")==0 ){
|
||||
int n;
|
||||
n = (int)integerValue(cmdline_option_value(argc,argv,++i));
|
||||
switch( n ){
|
||||
case 0: sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); break;
|
||||
case 2: sqlite3_config(SQLITE_CONFIG_MULTITHREAD); break;
|
||||
default: sqlite3_config(SQLITE_CONFIG_SERIALIZED); break;
|
||||
}
|
||||
#ifdef SQLITE_ENABLE_VFSTRACE
|
||||
}else if( strcmp(z,"-vfstrace")==0 ){
|
||||
extern int vfstrace_register(
|
||||
@@ -11360,8 +11352,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
i+=2;
|
||||
}else if( strcmp(z,"-lookaside")==0 ){
|
||||
i+=2;
|
||||
}else if( strcmp(z,"-threadsafe")==0 ){
|
||||
i+=2;
|
||||
}else if( strcmp(z,"-mmap")==0 ){
|
||||
i++;
|
||||
}else if( strcmp(z,"-memtrace")==0 ){
|
||||
|
||||
@@ -561,7 +561,6 @@ int sqlite3_exec(
|
||||
#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
|
||||
#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
|
||||
#define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8))
|
||||
#define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12<<8))
|
||||
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
|
||||
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
|
||||
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
|
||||
|
||||
+54
-105
@@ -861,7 +861,6 @@ typedef INT16_TYPE LogEst;
|
||||
# define SQLITE_PTRSIZE __SIZEOF_POINTER__
|
||||
# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \
|
||||
defined(_M_ARM) || defined(__arm__) || defined(__x86) || \
|
||||
(defined(__APPLE__) && defined(__POWERPC__)) || \
|
||||
(defined(__TOS_AIX__) && !defined(__64BIT__))
|
||||
# define SQLITE_PTRSIZE 4
|
||||
# else
|
||||
@@ -1533,8 +1532,8 @@ struct sqlite3 {
|
||||
u8 mTrace; /* zero or more SQLITE_TRACE flags */
|
||||
u8 noSharedCache; /* True if no shared-cache backends */
|
||||
u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
|
||||
u8 eOpenState; /* Current condition of the connection */
|
||||
int nextPagesize; /* Pagesize after VACUUM if >0 */
|
||||
u32 magic; /* Magic number for detect library misuse */
|
||||
i64 nChange; /* Value returned by sqlite3_changes() */
|
||||
i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
|
||||
int aLimit[SQLITE_N_LIMIT]; /* Limits */
|
||||
@@ -1761,16 +1760,17 @@ struct sqlite3 {
|
||||
*/
|
||||
#define ConstFactorOk(P) ((P)->okConstFactor)
|
||||
|
||||
/* Possible values for the sqlite3.eOpenState field.
|
||||
** The numbers are randomly selected such that a minimum of three bits must
|
||||
** change to convert any number to another or to zero
|
||||
/*
|
||||
** Possible values for the sqlite.magic field.
|
||||
** The numbers are obtained at random and have no special meaning, other
|
||||
** than being distinct from one another.
|
||||
*/
|
||||
#define SQLITE_STATE_OPEN 0x76 /* Database is open */
|
||||
#define SQLITE_STATE_CLOSED 0xce /* Database is closed */
|
||||
#define SQLITE_STATE_SICK 0xba /* Error and awaiting close */
|
||||
#define SQLITE_STATE_BUSY 0x6d /* Database currently in use */
|
||||
#define SQLITE_STATE_ERROR 0xd5 /* An SQLITE_MISUSE error occurred */
|
||||
#define SQLITE_STATE_ZOMBIE 0xa7 /* Close with last statement close */
|
||||
#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */
|
||||
#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */
|
||||
#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */
|
||||
#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */
|
||||
#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */
|
||||
#define SQLITE_MAGIC_ZOMBIE 0x64cffc7f /* Close with last statement close */
|
||||
|
||||
/*
|
||||
** Each SQL function is defined by an instance of the following
|
||||
@@ -2027,41 +2027,18 @@ struct Module {
|
||||
** or equal to the table column index. It is
|
||||
** equal if and only if there are no VIRTUAL
|
||||
** columns to the left.
|
||||
**
|
||||
** Notes on zCnName:
|
||||
** The zCnName field stores the name of the column, the datatype of the
|
||||
** column, and the collating sequence for the column, in that order, all in
|
||||
** a single allocation. Each string is 0x00 terminated. The datatype
|
||||
** is only included if the COLFLAG_HASTYPE bit of colFlags is set and the
|
||||
** collating sequence name is only included if the COLFLAG_HASCOLL bit is
|
||||
** set.
|
||||
*/
|
||||
struct Column {
|
||||
char *zCnName; /* Name of this column */
|
||||
unsigned notNull :4; /* An OE_ code for handling a NOT NULL constraint */
|
||||
unsigned eCType :4; /* One of the standard types */
|
||||
char affinity; /* One of the SQLITE_AFF_... values */
|
||||
u8 szEst; /* Est size of value in this column. sizeof(INT)==1 */
|
||||
u8 hName; /* Column name hash for faster lookup */
|
||||
u16 iDflt; /* 1-based index of DEFAULT. 0 means "none" */
|
||||
u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */
|
||||
char *zName; /* Name of this column, \000, then the type */
|
||||
Expr *pDflt; /* Default value or GENERATED ALWAYS AS value */
|
||||
char *zColl; /* Collating sequence. If NULL, use the default */
|
||||
u8 notNull; /* An OE_ code for handling a NOT NULL constraint */
|
||||
char affinity; /* One of the SQLITE_AFF_... values */
|
||||
u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */
|
||||
u8 hName; /* Column name hash for faster lookup */
|
||||
u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */
|
||||
};
|
||||
|
||||
/* Allowed values for Column.eCType.
|
||||
**
|
||||
** Values must match entries in the global constant arrays
|
||||
** sqlite3StdTypeLen[] and sqlite3StdType[]. Each value is one more
|
||||
** than the offset into these arrays for the corresponding name.
|
||||
** Adjust the SQLITE_N_STDTYPE value if adding or removing entries.
|
||||
*/
|
||||
#define COLTYPE_CUSTOM 0 /* Type appended to zName */
|
||||
#define COLTYPE_BLOB 1
|
||||
#define COLTYPE_INT 2
|
||||
#define COLTYPE_INTEGER 3
|
||||
#define COLTYPE_REAL 4
|
||||
#define COLTYPE_TEXT 5
|
||||
#define SQLITE_N_STDTYPE 5 /* Number of standard types */
|
||||
|
||||
/* Allowed values for Column.colFlags.
|
||||
**
|
||||
** Constraints:
|
||||
@@ -2078,7 +2055,6 @@ struct Column {
|
||||
#define COLFLAG_STORED 0x0040 /* GENERATED ALWAYS AS ... STORED */
|
||||
#define COLFLAG_NOTAVAIL 0x0080 /* STORED column not yet calculated */
|
||||
#define COLFLAG_BUSY 0x0100 /* Blocks recursion on GENERATED columns */
|
||||
#define COLFLAG_HASCOLL 0x0200 /* Has collating sequence name in zCnName */
|
||||
#define COLFLAG_GENERATED 0x0060 /* Combo: _STORED, _VIRTUAL */
|
||||
#define COLFLAG_NOINSERT 0x0062 /* Combo: _HIDDEN, _STORED, _VIRTUAL */
|
||||
|
||||
@@ -2208,13 +2184,15 @@ struct VTable {
|
||||
#define SQLITE_VTABRISK_High 2
|
||||
|
||||
/*
|
||||
** The schema for each SQL table, virtual table, and view is represented
|
||||
** in memory by an instance of the following structure.
|
||||
** The schema for each SQL table and view is represented in memory
|
||||
** by an instance of the following structure.
|
||||
*/
|
||||
struct Table {
|
||||
char *zName; /* Name of the table or view */
|
||||
Column *aCol; /* Information about each column */
|
||||
Index *pIndex; /* List of SQL indexes on this table. */
|
||||
Select *pSelect; /* NULL for tables. Points to definition if a view. */
|
||||
FKey *pFKey; /* Linked list of all foreign keys in this table */
|
||||
char *zColAff; /* String defining the affinity of each column */
|
||||
ExprList *pCheck; /* All CHECK constraints */
|
||||
/* ... also used as column name list in a VIEW */
|
||||
@@ -2230,24 +2208,15 @@ struct Table {
|
||||
LogEst costMult; /* Cost multiplier for using this table */
|
||||
#endif
|
||||
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
|
||||
u8 eTabType; /* 0: normal, 1: virtual, 2: view */
|
||||
union {
|
||||
struct { /* Used by ordinary tables: */
|
||||
int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
|
||||
FKey *pFKey; /* Linked list of all foreign keys in this table */
|
||||
ExprList *pDfltList; /* DEFAULT clauses on various columns.
|
||||
** Or the AS clause for generated columns. */
|
||||
} tab;
|
||||
struct { /* Used by views: */
|
||||
Select *pSelect; /* View definition */
|
||||
} view;
|
||||
struct { /* Used by virtual tables only: */
|
||||
int nArg; /* Number of arguments to the module */
|
||||
char **azArg; /* 0: module 1: schema 2: vtab name 3...: args */
|
||||
VTable *p; /* List of VTable objects. */
|
||||
} vtab;
|
||||
} u;
|
||||
Trigger *pTrigger; /* List of triggers on this object */
|
||||
#ifndef SQLITE_OMIT_ALTERTABLE
|
||||
int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
|
||||
#endif
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
int nModuleArg; /* Number of arguments to the module */
|
||||
char **azModuleArg; /* 0: module 1: schema 2: vtab name 3...: args */
|
||||
VTable *pVTable; /* List of VTable objects. */
|
||||
#endif
|
||||
Trigger *pTrigger; /* List of triggers stored in pSchema */
|
||||
Schema *pSchema; /* Schema that contains this table */
|
||||
};
|
||||
|
||||
@@ -2266,35 +2235,24 @@ struct Table {
|
||||
** TF_HasStored == COLFLAG_STORED
|
||||
** TF_HasHidden == COLFLAG_HIDDEN
|
||||
*/
|
||||
#define TF_Readonly 0x00000001 /* Read-only system table */
|
||||
#define TF_HasHidden 0x00000002 /* Has one or more hidden columns */
|
||||
#define TF_HasPrimaryKey 0x00000004 /* Table has a primary key */
|
||||
#define TF_Autoincrement 0x00000008 /* Integer primary key is autoincrement */
|
||||
#define TF_HasStat1 0x00000010 /* nRowLogEst set from sqlite_stat1 */
|
||||
#define TF_HasVirtual 0x00000020 /* Has one or more VIRTUAL columns */
|
||||
#define TF_HasStored 0x00000040 /* Has one or more STORED columns */
|
||||
#define TF_HasGenerated 0x00000060 /* Combo: HasVirtual + HasStored */
|
||||
#define TF_WithoutRowid 0x00000080 /* No rowid. PRIMARY KEY is the key */
|
||||
#define TF_StatsUsed 0x00000100 /* Query planner decisions affected by
|
||||
#define TF_Readonly 0x0001 /* Read-only system table */
|
||||
#define TF_HasHidden 0x0002 /* Has one or more hidden columns */
|
||||
#define TF_HasPrimaryKey 0x0004 /* Table has a primary key */
|
||||
#define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */
|
||||
#define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */
|
||||
#define TF_HasVirtual 0x0020 /* Has one or more VIRTUAL columns */
|
||||
#define TF_HasStored 0x0040 /* Has one or more STORED columns */
|
||||
#define TF_HasGenerated 0x0060 /* Combo: HasVirtual + HasStored */
|
||||
#define TF_WithoutRowid 0x0080 /* No rowid. PRIMARY KEY is the key */
|
||||
#define TF_StatsUsed 0x0100 /* Query planner decisions affected by
|
||||
** Index.aiRowLogEst[] values */
|
||||
#define TF_NoVisibleRowid 0x00000200 /* No user-visible "rowid" column */
|
||||
#define TF_OOOHidden 0x00000400 /* Out-of-Order hidden columns */
|
||||
#define TF_HasNotNull 0x00000800 /* Contains NOT NULL constraints */
|
||||
#define TF_Shadow 0x00001000 /* True for a shadow table */
|
||||
#define TF_HasStat4 0x00002000 /* STAT4 info available for this table */
|
||||
#define TF_Ephemeral 0x00004000 /* An ephemeral table */
|
||||
#define TF_Eponymous 0x00008000 /* An eponymous virtual table */
|
||||
#define TF_Strict 0x00010000 /* STRICT mode */
|
||||
|
||||
/*
|
||||
** Allowed values for Table.eTabType
|
||||
*/
|
||||
#define TABTYP_NORM 0 /* Ordinary table */
|
||||
#define TABTYP_VTAB 1 /* Virtual table */
|
||||
#define TABTYP_VIEW 2 /* A view */
|
||||
|
||||
#define IsView(X) ((X)->eTabType==TABTYP_VIEW)
|
||||
#define IsOrdinaryTable(X) ((X)->eTabType==TABTYP_NORM)
|
||||
#define TF_NoVisibleRowid 0x0200 /* No user-visible "rowid" column */
|
||||
#define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */
|
||||
#define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */
|
||||
#define TF_Shadow 0x1000 /* True for a shadow table */
|
||||
#define TF_HasStat4 0x2000 /* STAT4 info available for this table */
|
||||
#define TF_Ephemeral 0x4000 /* An ephemeral table */
|
||||
#define TF_Eponymous 0x8000 /* An eponymous virtual table */
|
||||
|
||||
/*
|
||||
** Test to see whether or not a table is a virtual table. This is
|
||||
@@ -2302,9 +2260,9 @@ struct Table {
|
||||
** table support is omitted from the build.
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
# define IsVirtual(X) ((X)->eTabType==TABTYP_VTAB)
|
||||
# define IsVirtual(X) ((X)->nModuleArg)
|
||||
# define ExprIsVtab(X) \
|
||||
((X)->op==TK_COLUMN && (X)->y.pTab!=0 && (X)->y.pTab->eTabType==TABTYP_VTAB)
|
||||
((X)->op==TK_COLUMN && (X)->y.pTab!=0 && (X)->y.pTab->nModuleArg)
|
||||
#else
|
||||
# define IsVirtual(X) 0
|
||||
# define ExprIsVtab(X) 0
|
||||
@@ -4358,7 +4316,6 @@ void sqlite3ErrorMsg(Parse*, const char*, ...);
|
||||
int sqlite3ErrorToParser(sqlite3*,int);
|
||||
void sqlite3Dequote(char*);
|
||||
void sqlite3DequoteExpr(Expr*);
|
||||
void sqlite3DequoteToken(Token*);
|
||||
void sqlite3TokenInit(Token*,char*);
|
||||
int sqlite3KeywordCode(const unsigned char*, int);
|
||||
int sqlite3RunParser(Parse*, const char*, char **);
|
||||
@@ -4404,10 +4361,6 @@ void sqlite3ResetAllSchemasOfConnection(sqlite3*);
|
||||
void sqlite3ResetOneSchema(sqlite3*,int);
|
||||
void sqlite3CollapseDatabaseArray(sqlite3*);
|
||||
void sqlite3CommitInternalChanges(sqlite3*);
|
||||
void sqlite3ColumnSetExpr(Parse*,Table*,Column*,Expr*);
|
||||
Expr *sqlite3ColumnExpr(Table*,Column*);
|
||||
void sqlite3ColumnSetColl(sqlite3*,Column*,const char*zColl);
|
||||
const char *sqlite3ColumnColl(Column*);
|
||||
void sqlite3DeleteColumnNames(sqlite3*,Table*);
|
||||
void sqlite3GenerateColumnNames(Parse *pParse, Select *pSelect);
|
||||
int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
|
||||
@@ -4429,14 +4382,14 @@ void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
|
||||
#else
|
||||
# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */
|
||||
#endif
|
||||
void sqlite3AddColumn(Parse*,Token,Token);
|
||||
void sqlite3AddColumn(Parse*,Token*,Token*);
|
||||
void sqlite3AddNotNull(Parse*, int);
|
||||
void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
|
||||
void sqlite3AddCheckConstraint(Parse*, Expr*, const char*, const char*);
|
||||
void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
|
||||
void sqlite3AddCollateType(Parse*, Token*);
|
||||
void sqlite3AddGenerated(Parse*,Expr*,Token*);
|
||||
void sqlite3EndTable(Parse*,Token*,Token*,u32,Select*);
|
||||
void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
|
||||
void sqlite3AddReturning(Parse*,ExprList*);
|
||||
int sqlite3ParseUri(const char*,const char*,unsigned int*,
|
||||
sqlite3_vfs**,char**,char **);
|
||||
@@ -4546,7 +4499,7 @@ void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
|
||||
void sqlite3ExprCodeMove(Parse*, int, int, int);
|
||||
void sqlite3ExprCode(Parse*, Expr*, int);
|
||||
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
|
||||
void sqlite3ExprCodeGeneratedColumn(Parse*, Table*, Column*, int);
|
||||
void sqlite3ExprCodeGeneratedColumn(Parse*, Column*, int);
|
||||
#endif
|
||||
void sqlite3ExprCodeCopy(Parse*, Expr*, int);
|
||||
void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
|
||||
@@ -4839,10 +4792,6 @@ void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
|
||||
#ifndef SQLITE_AMALGAMATION
|
||||
extern const unsigned char sqlite3OpcodeProperty[];
|
||||
extern const char sqlite3StrBINARY[];
|
||||
extern const unsigned char sqlite3StdTypeLen[];
|
||||
extern const char sqlite3StdTypeAffinity[];
|
||||
extern const char sqlite3StdTypeMap[];
|
||||
extern const char *sqlite3StdType[];
|
||||
extern const unsigned char sqlite3UpperToLower[];
|
||||
extern const unsigned char *sqlite3aLTb;
|
||||
extern const unsigned char *sqlite3aEQb;
|
||||
|
||||
+32
@@ -5348,6 +5348,37 @@ static int SQLITE_TCLAPI test_stmt_int(
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite_set_magic DB MAGIC-NUMBER
|
||||
**
|
||||
** Set the db->magic value. This is used to test error recovery logic.
|
||||
*/
|
||||
static int SQLITE_TCLAPI sqlite_set_magic(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int argc,
|
||||
char **argv
|
||||
){
|
||||
sqlite3 *db;
|
||||
if( argc!=3 ){
|
||||
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
|
||||
" DB MAGIC", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
|
||||
if( strcmp(argv[2], "SQLITE_MAGIC_OPEN")==0 ){
|
||||
db->magic = SQLITE_MAGIC_OPEN;
|
||||
}else if( strcmp(argv[2], "SQLITE_MAGIC_CLOSED")==0 ){
|
||||
db->magic = SQLITE_MAGIC_CLOSED;
|
||||
}else if( strcmp(argv[2], "SQLITE_MAGIC_BUSY")==0 ){
|
||||
db->magic = SQLITE_MAGIC_BUSY;
|
||||
}else if( strcmp(argv[2], "SQLITE_MAGIC_ERROR")==0 ){
|
||||
db->magic = SQLITE_MAGIC_ERROR;
|
||||
}else if( Tcl_GetInt(interp, argv[2], (int*)&db->magic) ){
|
||||
return TCL_ERROR;
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite3_interrupt DB
|
||||
@@ -8288,6 +8319,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
||||
{ "breakpoint", (Tcl_CmdProc*)test_breakpoint },
|
||||
{ "sqlite3_key", (Tcl_CmdProc*)test_key },
|
||||
{ "sqlite3_rekey", (Tcl_CmdProc*)test_rekey },
|
||||
{ "sqlite_set_magic", (Tcl_CmdProc*)sqlite_set_magic },
|
||||
{ "sqlite3_interrupt", (Tcl_CmdProc*)test_interrupt },
|
||||
{ "sqlite_delete_function", (Tcl_CmdProc*)delete_function },
|
||||
{ "sqlite_delete_collation", (Tcl_CmdProc*)delete_collation },
|
||||
|
||||
+4
-4
@@ -219,12 +219,12 @@ void sqlite3BeginTrigger(
|
||||
/* INSTEAD of triggers are only for views and views only support INSTEAD
|
||||
** of triggers.
|
||||
*/
|
||||
if( IsView(pTab) && tr_tm!=TK_INSTEAD ){
|
||||
if( pTab->pSelect && tr_tm!=TK_INSTEAD ){
|
||||
sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S",
|
||||
(tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName->a);
|
||||
goto trigger_orphan_error;
|
||||
}
|
||||
if( !IsView(pTab) && tr_tm==TK_INSTEAD ){
|
||||
if( !pTab->pSelect && tr_tm==TK_INSTEAD ){
|
||||
sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF"
|
||||
" trigger on table: %S", pTableName->a);
|
||||
goto trigger_orphan_error;
|
||||
@@ -877,11 +877,11 @@ static ExprList *sqlite3ExpandReturning(
|
||||
for(jj=0; jj<pTab->nCol; jj++){
|
||||
Expr *pNewExpr;
|
||||
if( IsHiddenColumn(pTab->aCol+jj) ) continue;
|
||||
pNewExpr = sqlite3Expr(db, TK_ID, pTab->aCol[jj].zCnName);
|
||||
pNewExpr = sqlite3Expr(db, TK_ID, pTab->aCol[jj].zName);
|
||||
pNew = sqlite3ExprListAppend(pParse, pNew, pNewExpr);
|
||||
if( !db->mallocFailed ){
|
||||
struct ExprList_item *pItem = &pNew->a[pNew->nExpr-1];
|
||||
pItem->zEName = sqlite3DbStrDup(db, pTab->aCol[jj].zCnName);
|
||||
pItem->zEName = sqlite3DbStrDup(db, pTab->aCol[jj].zName);
|
||||
pItem->eEName = ENAME_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-16
@@ -60,14 +60,13 @@ static void updateVirtualTable(
|
||||
*/
|
||||
void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){
|
||||
assert( pTab!=0 );
|
||||
if( !IsView(pTab) ){
|
||||
if( !pTab->pSelect ){
|
||||
sqlite3_value *pValue = 0;
|
||||
u8 enc = ENC(sqlite3VdbeDb(v));
|
||||
Column *pCol = &pTab->aCol[i];
|
||||
VdbeComment((v, "%s.%s", pTab->zName, pCol->zCnName));
|
||||
VdbeComment((v, "%s.%s", pTab->zName, pCol->zName));
|
||||
assert( i<pTab->nCol );
|
||||
sqlite3ValueFromExpr(sqlite3VdbeDb(v),
|
||||
sqlite3ColumnExpr(pTab,pCol), enc,
|
||||
sqlite3ValueFromExpr(sqlite3VdbeDb(v), pCol->pDflt, enc,
|
||||
pCol->affinity, &pValue);
|
||||
if( pValue ){
|
||||
sqlite3VdbeAppendP4(v, pValue, P4_MEM);
|
||||
@@ -237,7 +236,7 @@ static void updateFromSelect(
|
||||
pList = sqlite3ExprListAppend(pParse, pList, pNew);
|
||||
}
|
||||
eDest = IsVirtual(pTab) ? SRT_Table : SRT_Upfrom;
|
||||
}else if( IsView(pTab) ){
|
||||
}else if( pTab->pSelect ){
|
||||
for(i=0; i<pTab->nCol; i++){
|
||||
pList = sqlite3ExprListAppend(pParse, pList, exprRowColumn(pParse, i));
|
||||
}
|
||||
@@ -362,7 +361,7 @@ void sqlite3Update(
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_TRIGGER
|
||||
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, &tmask);
|
||||
isView = IsView(pTab);
|
||||
isView = pTab->pSelect!=0;
|
||||
assert( pTrigger || tmask==0 );
|
||||
#else
|
||||
# define pTrigger 0
|
||||
@@ -451,16 +450,13 @@ void sqlite3Update(
|
||||
*/
|
||||
chngRowid = chngPk = 0;
|
||||
for(i=0; i<pChanges->nExpr; i++){
|
||||
u8 hCol = sqlite3StrIHash(pChanges->a[i].zEName);
|
||||
/* If this is an UPDATE with a FROM clause, do not resolve expressions
|
||||
** here. The call to sqlite3Select() below will do that. */
|
||||
if( nChangeFrom==0 && sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){
|
||||
goto update_cleanup;
|
||||
}
|
||||
for(j=0; j<pTab->nCol; j++){
|
||||
if( pTab->aCol[j].hName==hCol
|
||||
&& sqlite3StrICmp(pTab->aCol[j].zCnName, pChanges->a[i].zEName)==0
|
||||
){
|
||||
if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zEName)==0 ){
|
||||
if( j==pTab->iPKey ){
|
||||
chngRowid = 1;
|
||||
pRowidExpr = pChanges->a[i].pExpr;
|
||||
@@ -474,7 +470,7 @@ void sqlite3Update(
|
||||
testcase( pTab->aCol[j].colFlags & COLFLAG_STORED );
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"cannot UPDATE generated column \"%s\"",
|
||||
pTab->aCol[j].zCnName);
|
||||
pTab->aCol[j].zName);
|
||||
goto update_cleanup;
|
||||
}
|
||||
#endif
|
||||
@@ -498,7 +494,7 @@ void sqlite3Update(
|
||||
{
|
||||
int rc;
|
||||
rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,
|
||||
j<0 ? "ROWID" : pTab->aCol[j].zCnName,
|
||||
j<0 ? "ROWID" : pTab->aCol[j].zName,
|
||||
db->aDb[iDb].zDbSName);
|
||||
if( rc==SQLITE_DENY ){
|
||||
goto update_cleanup;
|
||||
@@ -530,10 +526,8 @@ void sqlite3Update(
|
||||
for(i=0; i<pTab->nCol; i++){
|
||||
if( aXRef[i]>=0 ) continue;
|
||||
if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 ) continue;
|
||||
if( sqlite3ExprReferencesUpdatedColumn(
|
||||
sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
|
||||
aXRef, chngRowid)
|
||||
){
|
||||
if( sqlite3ExprReferencesUpdatedColumn(pTab->aCol[i].pDflt,
|
||||
aXRef, chngRowid) ){
|
||||
aXRef[i] = 99999;
|
||||
bProgress = 1;
|
||||
}
|
||||
|
||||
+1
-1
@@ -287,7 +287,7 @@ void sqlite3UpsertDoUpdate(
|
||||
k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
|
||||
sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i);
|
||||
VdbeComment((v, "%s.%s", pIdx->zName,
|
||||
pTab->aCol[pPk->aiColumn[i]].zCnName));
|
||||
pTab->aCol[pPk->aiColumn[i]].zName));
|
||||
}
|
||||
sqlite3VdbeVerifyAbortable(v, OE_Abort);
|
||||
i = sqlite3VdbeAddOp4Int(v, OP_Found, iDataCur, 0, iPk, nPk);
|
||||
|
||||
+10
-38
@@ -89,14 +89,8 @@ int sqlite3Strlen30(const char *z){
|
||||
** the column name if and only if the COLFLAG_HASTYPE flag is set.
|
||||
*/
|
||||
char *sqlite3ColumnType(Column *pCol, char *zDflt){
|
||||
if( pCol->colFlags & COLFLAG_HASTYPE ){
|
||||
return pCol->zCnName + strlen(pCol->zCnName) + 1;
|
||||
}else if( pCol->eCType ){
|
||||
assert( pCol->eCType<=SQLITE_N_STDTYPE );
|
||||
return (char*)sqlite3StdType[pCol->eCType-1];
|
||||
}else{
|
||||
return zDflt;
|
||||
}
|
||||
if( (pCol->colFlags & COLFLAG_HASTYPE)==0 ) return zDflt;
|
||||
return pCol->zName + strlen(pCol->zName) + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -272,28 +266,6 @@ void sqlite3DequoteExpr(Expr *p){
|
||||
sqlite3Dequote(p->u.zToken);
|
||||
}
|
||||
|
||||
/*
|
||||
** If the input token p is quoted, try to adjust the token to remove
|
||||
** the quotes. This is not always possible:
|
||||
**
|
||||
** "abc" -> abc
|
||||
** "ab""cd" -> (not possible because of the interior "")
|
||||
**
|
||||
** Remove the quotes if possible. This is a optimization. The overall
|
||||
** system should still return the correct answer even if this routine
|
||||
** is always a no-op.
|
||||
*/
|
||||
void sqlite3DequoteToken(Token *p){
|
||||
unsigned int i;
|
||||
if( p->n<2 ) return;
|
||||
if( !sqlite3Isquote(p->z[0]) ) return;
|
||||
for(i=1; i<p->n-1; i++){
|
||||
if( sqlite3Isquote(p->z[i]) ) return;
|
||||
}
|
||||
p->n -= 2;
|
||||
p->z++;
|
||||
}
|
||||
|
||||
/*
|
||||
** Generate a Token object from a string
|
||||
*/
|
||||
@@ -1399,13 +1371,13 @@ static void logBadConnection(const char *zType){
|
||||
** used as an argument to sqlite3_errmsg() or sqlite3_close().
|
||||
*/
|
||||
int sqlite3SafetyCheckOk(sqlite3 *db){
|
||||
u8 eOpenState;
|
||||
u32 magic;
|
||||
if( db==0 ){
|
||||
logBadConnection("NULL");
|
||||
return 0;
|
||||
}
|
||||
eOpenState = db->eOpenState;
|
||||
if( eOpenState!=SQLITE_STATE_OPEN ){
|
||||
magic = db->magic;
|
||||
if( magic!=SQLITE_MAGIC_OPEN ){
|
||||
if( sqlite3SafetyCheckSickOrOk(db) ){
|
||||
testcase( sqlite3GlobalConfig.xLog!=0 );
|
||||
logBadConnection("unopened");
|
||||
@@ -1416,11 +1388,11 @@ int sqlite3SafetyCheckOk(sqlite3 *db){
|
||||
}
|
||||
}
|
||||
int sqlite3SafetyCheckSickOrOk(sqlite3 *db){
|
||||
u8 eOpenState;
|
||||
eOpenState = db->eOpenState;
|
||||
if( eOpenState!=SQLITE_STATE_SICK &&
|
||||
eOpenState!=SQLITE_STATE_OPEN &&
|
||||
eOpenState!=SQLITE_STATE_BUSY ){
|
||||
u32 magic;
|
||||
magic = db->magic;
|
||||
if( magic!=SQLITE_MAGIC_SICK &&
|
||||
magic!=SQLITE_MAGIC_OPEN &&
|
||||
magic!=SQLITE_MAGIC_BUSY ){
|
||||
testcase( sqlite3GlobalConfig.xLog!=0 );
|
||||
logBadConnection("invalid");
|
||||
return 0;
|
||||
|
||||
+2
-123
@@ -671,19 +671,6 @@ static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the symbolic name for the data type of a pMem
|
||||
*/
|
||||
static const char *vdbeMemTypeName(Mem *pMem){
|
||||
static const char *azTypes[] = {
|
||||
/* SQLITE_INTEGER */ "INT",
|
||||
/* SQLITE_FLOAT */ "REAL",
|
||||
/* SQLITE_TEXT */ "TEXT",
|
||||
/* SQLITE_BLOB */ "BLOB",
|
||||
/* SQLITE_NULL */ "NULL"
|
||||
};
|
||||
return azTypes[sqlite3_value_type(pMem)-1];
|
||||
}
|
||||
|
||||
/*
|
||||
** Execute as much of a VDBE program as we can.
|
||||
@@ -2515,22 +2502,6 @@ case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: IsNullOrType P1 P2 P3 * *
|
||||
** Synopsis: if typeof(r[P1]) IN (P3,5) goto P2
|
||||
**
|
||||
** Jump to P2 if the value in register P1 is NULL or has a datatype P3.
|
||||
** P3 is an integer which should be one of SQLITE_INTEGER, SQLITE_FLOAT,
|
||||
** SQLITE_BLOB, SQLITE_NULL, or SQLITE_TEXT.
|
||||
*/
|
||||
case OP_IsNullOrType: { /* jump, in1 */
|
||||
int doTheJump;
|
||||
pIn1 = &aMem[pOp->p1];
|
||||
doTheJump = (pIn1->flags & MEM_Null)!=0 || sqlite3_value_type(pIn1)==pOp->p3;
|
||||
VdbeBranchTaken( doTheJump, 2);
|
||||
if( doTheJump ) goto jump_to_p2;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: ZeroOrNull P1 P2 P3 * *
|
||||
** Synopsis: r[P2] = 0 OR NULL
|
||||
**
|
||||
@@ -2899,97 +2870,6 @@ op_column_corrupt:
|
||||
}
|
||||
}
|
||||
|
||||
/* Opcode: TypeCheck P1 P2 * P4 *
|
||||
** Synopsis: typecheck(r[P1@P2])
|
||||
**
|
||||
** Apply affinities to the range of P2 registers beginning with P1.
|
||||
** Take the affinities from the Table object in P4. If any value
|
||||
** cannot be coerced into the correct type, then raise an error.
|
||||
**
|
||||
** This opcode is similar to OP_Affinity except that this opcode
|
||||
** forces the register type to the Table column type. This is used
|
||||
** to implement "strict affinity".
|
||||
**
|
||||
** Preconditions:
|
||||
**
|
||||
** <ul>
|
||||
** <li> P2 should be the number of non-virtual columns in the
|
||||
** table of P4.
|
||||
** <li> Table P4 should be a STRICT table.
|
||||
** </ul>
|
||||
**
|
||||
** If any precondition is false, an assertion fault occurs.
|
||||
*/
|
||||
case OP_TypeCheck: {
|
||||
Table *pTab;
|
||||
Column *aCol;
|
||||
int i;
|
||||
|
||||
assert( pOp->p4type==P4_TABLE );
|
||||
pTab = pOp->p4.pTab;
|
||||
assert( pTab->tabFlags & TF_Strict );
|
||||
assert( pTab->nNVCol==pOp->p2 );
|
||||
aCol = pTab->aCol;
|
||||
pIn1 = &aMem[pOp->p1];
|
||||
for(i=0; i<pTab->nCol; i++){
|
||||
if( aCol[i].colFlags & COLFLAG_VIRTUAL ) continue;
|
||||
assert( pIn1 < &aMem[pOp->p1+pOp->p2] );
|
||||
applyAffinity(pIn1, aCol[i].affinity, encoding);
|
||||
if( (pIn1->flags & MEM_Null)==0 ){
|
||||
switch( aCol[i].eCType ){
|
||||
case COLTYPE_BLOB: {
|
||||
if( (pIn1->flags & MEM_Blob)==0 ) goto vdbe_type_error;
|
||||
break;
|
||||
}
|
||||
case COLTYPE_INTEGER:
|
||||
case COLTYPE_INT: {
|
||||
if( (pIn1->flags & MEM_Int)==0 ) goto vdbe_type_error;
|
||||
break;
|
||||
}
|
||||
case COLTYPE_TEXT: {
|
||||
if( (pIn1->flags & MEM_Str)==0 ) goto vdbe_type_error;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
assert( aCol[i].eCType==COLTYPE_REAL );
|
||||
if( pIn1->flags & MEM_Int ){
|
||||
/* When applying REAL affinity, if the result is still an MEM_Int
|
||||
** that will fit in 6 bytes, then change the type to MEM_IntReal
|
||||
** so that we keep the high-resolution integer value but know that
|
||||
** the type really wants to be REAL. */
|
||||
testcase( pIn1->u.i==140737488355328LL );
|
||||
testcase( pIn1->u.i==140737488355327LL );
|
||||
testcase( pIn1->u.i==-140737488355328LL );
|
||||
testcase( pIn1->u.i==-140737488355329LL );
|
||||
if( pIn1->u.i<=140737488355327LL && pIn1->u.i>=-140737488355328LL){
|
||||
pIn1->flags |= MEM_IntReal;
|
||||
pIn1->flags &= ~MEM_Int;
|
||||
}else{
|
||||
pIn1->u.r = (double)pIn1->u.i;
|
||||
pIn1->flags |= MEM_Real;
|
||||
pIn1->flags &= ~MEM_Int;
|
||||
}
|
||||
}else if( (pIn1->flags & MEM_Real)==0 ){
|
||||
goto vdbe_type_error;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
REGISTER_TRACE((int)(pIn1-aMem), pIn1);
|
||||
pIn1++;
|
||||
}
|
||||
assert( pIn1 == &aMem[pOp->p1+pOp->p2] );
|
||||
break;
|
||||
|
||||
vdbe_type_error:
|
||||
sqlite3VdbeError(p, "cannot store %s value in %s column %s.%s",
|
||||
vdbeMemTypeName(pIn1), sqlite3StdType[aCol[i].eCType-1],
|
||||
pTab->zName, aCol[i].zCnName);
|
||||
rc = SQLITE_CONSTRAINT_DATATYPE;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
|
||||
/* Opcode: Affinity P1 P2 * P4 *
|
||||
** Synopsis: affinity(r[P1@P2])
|
||||
**
|
||||
@@ -6040,8 +5920,7 @@ case OP_SorterInsert: { /* in2 */
|
||||
** an UPDATE or DELETE statement and the index entry to be updated
|
||||
** or deleted is not found. For some uses of IdxDelete
|
||||
** (example: the EXCEPT operator) it does not matter that no matching
|
||||
** entry is found. For those cases, P5 is zero. Also, do not raise
|
||||
** this (self-correcting and non-critical) error if in writable_schema mode.
|
||||
** entry is found. For those cases, P5 is zero.
|
||||
*/
|
||||
case OP_IdxDelete: {
|
||||
VdbeCursor *pC;
|
||||
@@ -6067,7 +5946,7 @@ case OP_IdxDelete: {
|
||||
if( res==0 ){
|
||||
rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
}else if( pOp->p5 && !sqlite3WritableSchema(db) ){
|
||||
}else if( pOp->p5 ){
|
||||
rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption");
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
|
||||
+4
-4
@@ -1660,7 +1660,7 @@ char *sqlite3VdbeDisplayP4(sqlite3 *db, Op *pOp){
|
||||
case P4_COLLSEQ: {
|
||||
static const char *const encnames[] = {"?", "8", "16LE", "16BE"};
|
||||
CollSeq *pColl = pOp->p4.pColl;
|
||||
assert( pColl->enc<4 );
|
||||
assert( pColl->enc>=0 && pColl->enc<4 );
|
||||
sqlite3_str_appendf(&x, "%.18s-%s", pColl->zName,
|
||||
encnames[pColl->enc]);
|
||||
break;
|
||||
@@ -3005,9 +3005,9 @@ int sqlite3VdbeCheckFk(Vdbe *p, int deferred){
|
||||
** has made changes and is in autocommit mode, then commit those
|
||||
** changes. If a rollback is needed, then do the rollback.
|
||||
**
|
||||
** This routine is the only way to move the sqlite3eOpenState of a VM from
|
||||
** SQLITE_STATE_RUN to SQLITE_STATE_HALT. It is harmless to
|
||||
** call this on a VM that is in the SQLITE_STATE_HALT state.
|
||||
** This routine is the only way to move the state of a VM from
|
||||
** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT. It is harmless to
|
||||
** call this on a VM that is in the SQLITE_MAGIC_HALT state.
|
||||
**
|
||||
** Return an error code. If the commit could not complete because of
|
||||
** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it
|
||||
|
||||
+3
-4
@@ -167,7 +167,7 @@ int sqlite3_blob_open(
|
||||
sqlite3ErrorMsg(&sParse, "cannot open table without rowid: %s", zTable);
|
||||
}
|
||||
#ifndef SQLITE_OMIT_VIEW
|
||||
if( pTab && IsView(pTab) ){
|
||||
if( pTab && pTab->pSelect ){
|
||||
pTab = 0;
|
||||
sqlite3ErrorMsg(&sParse, "cannot open view: %s", zTable);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ int sqlite3_blob_open(
|
||||
|
||||
/* Now search pTab for the exact column. */
|
||||
for(iCol=0; iCol<pTab->nCol; iCol++) {
|
||||
if( sqlite3StrICmp(pTab->aCol[iCol].zCnName, zColumn)==0 ){
|
||||
if( sqlite3StrICmp(pTab->aCol[iCol].zName, zColumn)==0 ){
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -212,8 +212,7 @@ int sqlite3_blob_open(
|
||||
** key columns must be indexed. The check below will pick up this
|
||||
** case. */
|
||||
FKey *pFKey;
|
||||
assert( !IsVirtual(pTab) );
|
||||
for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
int j;
|
||||
for(j=0; j<pFKey->nCol; j++){
|
||||
if( pFKey->aCol[j].iFrom==iCol ){
|
||||
|
||||
+40
-43
@@ -192,7 +192,7 @@ void sqlite3VtabLock(VTable *pVTab){
|
||||
VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){
|
||||
VTable *pVtab;
|
||||
assert( IsVirtual(pTab) );
|
||||
for(pVtab=pTab->u.vtab.p; pVtab && pVtab->db!=db; pVtab=pVtab->pNext);
|
||||
for(pVtab=pTab->pVTable; pVtab && pVtab->db!=db; pVtab=pVtab->pNext);
|
||||
return pVtab;
|
||||
}
|
||||
|
||||
@@ -205,8 +205,7 @@ void sqlite3VtabUnlock(VTable *pVTab){
|
||||
|
||||
assert( db );
|
||||
assert( pVTab->nRef>0 );
|
||||
assert( db->eOpenState==SQLITE_STATE_OPEN
|
||||
|| db->eOpenState==SQLITE_STATE_ZOMBIE );
|
||||
assert( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ZOMBIE );
|
||||
|
||||
pVTab->nRef--;
|
||||
if( pVTab->nRef==0 ){
|
||||
@@ -221,21 +220,21 @@ void sqlite3VtabUnlock(VTable *pVTab){
|
||||
|
||||
/*
|
||||
** Table p is a virtual table. This function moves all elements in the
|
||||
** p->u.vtab.p list to the sqlite3.pDisconnect lists of their associated
|
||||
** p->pVTable list to the sqlite3.pDisconnect lists of their associated
|
||||
** database connections to be disconnected at the next opportunity.
|
||||
** Except, if argument db is not NULL, then the entry associated with
|
||||
** connection db is left in the p->u.vtab.p list.
|
||||
** connection db is left in the p->pVTable list.
|
||||
*/
|
||||
static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){
|
||||
VTable *pRet = 0;
|
||||
VTable *pVTable = p->u.vtab.p;
|
||||
p->u.vtab.p = 0;
|
||||
VTable *pVTable = p->pVTable;
|
||||
p->pVTable = 0;
|
||||
|
||||
/* Assert that the mutex (if any) associated with the BtShared database
|
||||
** that contains table p is held by the caller. See header comments
|
||||
** above function sqlite3VtabUnlockList() for an explanation of why
|
||||
** this makes it safe to access the sqlite3.pDisconnect list of any
|
||||
** database connection that may have an entry in the p->u.vtab.p list.
|
||||
** database connection that may have an entry in the p->pVTable list.
|
||||
*/
|
||||
assert( db==0 || sqlite3SchemaMutexHeld(db, 0, p->pSchema) );
|
||||
|
||||
@@ -245,7 +244,7 @@ static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){
|
||||
assert( db2 );
|
||||
if( db2==db ){
|
||||
pRet = pVTable;
|
||||
p->u.vtab.p = pRet;
|
||||
p->pVTable = pRet;
|
||||
pRet->pNext = 0;
|
||||
}else{
|
||||
pVTable->pNext = db2->pDisconnect;
|
||||
@@ -273,7 +272,7 @@ void sqlite3VtabDisconnect(sqlite3 *db, Table *p){
|
||||
assert( sqlite3BtreeHoldsAllMutexes(db) );
|
||||
assert( sqlite3_mutex_held(db->mutex) );
|
||||
|
||||
for(ppVTab=&p->u.vtab.p; *ppVTab; ppVTab=&(*ppVTab)->pNext){
|
||||
for(ppVTab=&p->pVTable; *ppVTab; ppVTab=&(*ppVTab)->pNext){
|
||||
if( (*ppVTab)->db==db ){
|
||||
VTable *pVTab = *ppVTab;
|
||||
*ppVTab = pVTab->pNext;
|
||||
@@ -337,36 +336,36 @@ void sqlite3VtabUnlockList(sqlite3 *db){
|
||||
*/
|
||||
void sqlite3VtabClear(sqlite3 *db, Table *p){
|
||||
if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p);
|
||||
if( p->u.vtab.azArg ){
|
||||
if( p->azModuleArg ){
|
||||
int i;
|
||||
for(i=0; i<p->u.vtab.nArg; i++){
|
||||
if( i!=1 ) sqlite3DbFree(db, p->u.vtab.azArg[i]);
|
||||
for(i=0; i<p->nModuleArg; i++){
|
||||
if( i!=1 ) sqlite3DbFree(db, p->azModuleArg[i]);
|
||||
}
|
||||
sqlite3DbFree(db, p->u.vtab.azArg);
|
||||
sqlite3DbFree(db, p->azModuleArg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Add a new module argument to pTable->u.vtab.azArg[].
|
||||
** Add a new module argument to pTable->azModuleArg[].
|
||||
** The string is not copied - the pointer is stored. The
|
||||
** string will be freed automatically when the table is
|
||||
** deleted.
|
||||
*/
|
||||
static void addModuleArgument(Parse *pParse, Table *pTable, char *zArg){
|
||||
sqlite3_int64 nBytes = sizeof(char *)*(2+pTable->u.vtab.nArg);
|
||||
sqlite3_int64 nBytes = sizeof(char *)*(2+pTable->nModuleArg);
|
||||
char **azModuleArg;
|
||||
sqlite3 *db = pParse->db;
|
||||
if( pTable->u.vtab.nArg+3>=db->aLimit[SQLITE_LIMIT_COLUMN] ){
|
||||
if( pTable->nModuleArg+3>=db->aLimit[SQLITE_LIMIT_COLUMN] ){
|
||||
sqlite3ErrorMsg(pParse, "too many columns on %s", pTable->zName);
|
||||
}
|
||||
azModuleArg = sqlite3DbRealloc(db, pTable->u.vtab.azArg, nBytes);
|
||||
azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes);
|
||||
if( azModuleArg==0 ){
|
||||
sqlite3DbFree(db, zArg);
|
||||
}else{
|
||||
int i = pTable->u.vtab.nArg++;
|
||||
int i = pTable->nModuleArg++;
|
||||
azModuleArg[i] = zArg;
|
||||
azModuleArg[i+1] = 0;
|
||||
pTable->u.vtab.azArg = azModuleArg;
|
||||
pTable->azModuleArg = azModuleArg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,11 +388,10 @@ void sqlite3VtabBeginParse(
|
||||
pTable = pParse->pNewTable;
|
||||
if( pTable==0 ) return;
|
||||
assert( 0==pTable->pIndex );
|
||||
pTable->eTabType = TABTYP_VTAB;
|
||||
|
||||
db = pParse->db;
|
||||
|
||||
assert( pTable->u.vtab.nArg==0 );
|
||||
assert( pTable->nModuleArg==0 );
|
||||
addModuleArgument(pParse, pTable, sqlite3NameFromToken(db, pModuleName));
|
||||
addModuleArgument(pParse, pTable, 0);
|
||||
addModuleArgument(pParse, pTable, sqlite3DbStrDup(db, pTable->zName));
|
||||
@@ -410,11 +408,11 @@ void sqlite3VtabBeginParse(
|
||||
** sqlite_schema table, has already been made by sqlite3StartTable().
|
||||
** The second call, to obtain permission to create the table, is made now.
|
||||
*/
|
||||
if( pTable->u.vtab.azArg ){
|
||||
if( pTable->azModuleArg ){
|
||||
int iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
|
||||
assert( iDb>=0 ); /* The database the table is being created in */
|
||||
sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName,
|
||||
pTable->u.vtab.azArg[0], pParse->db->aDb[iDb].zDbSName);
|
||||
pTable->azModuleArg[0], pParse->db->aDb[iDb].zDbSName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -444,7 +442,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
|
||||
if( pTab==0 ) return;
|
||||
addArgumentToVtab(pParse);
|
||||
pParse->sArg.z = 0;
|
||||
if( pTab->u.vtab.nArg<1 ) return;
|
||||
if( pTab->nModuleArg<1 ) return;
|
||||
|
||||
/* If the CREATE VIRTUAL TABLE statement is being entered for the
|
||||
** first time (in other words if the virtual table is actually being
|
||||
@@ -559,8 +557,8 @@ static int vtabCallConstructor(
|
||||
VtabCtx sCtx;
|
||||
VTable *pVTable;
|
||||
int rc;
|
||||
const char *const*azArg = (const char *const*)pTab->u.vtab.azArg;
|
||||
int nArg = pTab->u.vtab.nArg;
|
||||
const char *const*azArg = (const char *const*)pTab->azModuleArg;
|
||||
int nArg = pTab->nModuleArg;
|
||||
char *zErr = 0;
|
||||
char *zModuleName;
|
||||
int iDb;
|
||||
@@ -592,7 +590,7 @@ static int vtabCallConstructor(
|
||||
pVTable->eVtabRisk = SQLITE_VTABRISK_Normal;
|
||||
|
||||
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
pTab->u.vtab.azArg[1] = db->aDb[iDb].zDbSName;
|
||||
pTab->azModuleArg[1] = db->aDb[iDb].zDbSName;
|
||||
|
||||
/* Invoke the virtual table constructor */
|
||||
assert( &db->pVtabCtx );
|
||||
@@ -631,12 +629,12 @@ static int vtabCallConstructor(
|
||||
int iCol;
|
||||
u16 oooHidden = 0;
|
||||
/* If everything went according to plan, link the new VTable structure
|
||||
** into the linked list headed by pTab->u.vtab.p. Then loop through the
|
||||
** into the linked list headed by pTab->pVTable. Then loop through the
|
||||
** columns of the table to see if any of them contain the token "hidden".
|
||||
** If so, set the Column COLFLAG_HIDDEN flag and remove the token from
|
||||
** the type string. */
|
||||
pVTable->pNext = pTab->u.vtab.p;
|
||||
pTab->u.vtab.p = pVTable;
|
||||
pVTable->pNext = pTab->pVTable;
|
||||
pTab->pVTable = pVTable;
|
||||
|
||||
for(iCol=0; iCol<pTab->nCol; iCol++){
|
||||
char *zType = sqlite3ColumnType(&pTab->aCol[iCol], "");
|
||||
@@ -694,11 +692,11 @@ int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
|
||||
}
|
||||
|
||||
/* Locate the required virtual table module */
|
||||
zMod = pTab->u.vtab.azArg[0];
|
||||
zMod = pTab->azModuleArg[0];
|
||||
pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);
|
||||
|
||||
if( !pMod ){
|
||||
const char *zModule = pTab->u.vtab.azArg[0];
|
||||
const char *zModule = pTab->azModuleArg[0];
|
||||
sqlite3ErrorMsg(pParse, "no such module: %s", zModule);
|
||||
rc = SQLITE_ERROR;
|
||||
}else{
|
||||
@@ -761,10 +759,10 @@ int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
|
||||
const char *zMod;
|
||||
|
||||
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);
|
||||
assert( pTab && IsVirtual(pTab) && !pTab->u.vtab.p );
|
||||
assert( pTab && IsVirtual(pTab) && !pTab->pVTable );
|
||||
|
||||
/* Locate the required virtual table module */
|
||||
zMod = pTab->u.vtab.azArg[0];
|
||||
zMod = pTab->azModuleArg[0];
|
||||
pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);
|
||||
|
||||
/* If the module has been registered and includes a Create method,
|
||||
@@ -824,13 +822,13 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
|
||||
if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr)
|
||||
&& sParse.pNewTable
|
||||
&& !db->mallocFailed
|
||||
&& IsOrdinaryTable(sParse.pNewTable)
|
||||
&& !sParse.pNewTable->pSelect
|
||||
&& !IsVirtual(sParse.pNewTable)
|
||||
){
|
||||
if( !pTab->aCol ){
|
||||
Table *pNew = sParse.pNewTable;
|
||||
Index *pIdx;
|
||||
pTab->aCol = pNew->aCol;
|
||||
sqlite3ExprListDelete(db, pNew->u.tab.pDfltList);
|
||||
pTab->nNVCol = pTab->nCol = pNew->nCol;
|
||||
pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid);
|
||||
pNew->nCol = 0;
|
||||
@@ -885,10 +883,10 @@ int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
|
||||
Table *pTab;
|
||||
|
||||
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);
|
||||
if( pTab!=0 && ALWAYS(pTab->u.vtab.p!=0) ){
|
||||
if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){
|
||||
VTable *p;
|
||||
int (*xDestroy)(sqlite3_vtab *);
|
||||
for(p=pTab->u.vtab.p; p; p=p->pNext){
|
||||
for(p=pTab->pVTable; p; p=p->pNext){
|
||||
assert( p->pVtab );
|
||||
if( p->pVtab->nRef>0 ){
|
||||
return SQLITE_LOCKED;
|
||||
@@ -902,9 +900,9 @@ int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
|
||||
rc = xDestroy(p->pVtab);
|
||||
/* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */
|
||||
if( rc==SQLITE_OK ){
|
||||
assert( pTab->u.vtab.p==p && p->pNext==0 );
|
||||
assert( pTab->pVTable==p && p->pNext==0 );
|
||||
p->pVtab = 0;
|
||||
pTab->u.vtab.p = 0;
|
||||
pTab->pVTable = 0;
|
||||
sqlite3VtabUnlock(p);
|
||||
}
|
||||
sqlite3DeleteTable(db, pTab);
|
||||
@@ -1221,9 +1219,8 @@ int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){
|
||||
}
|
||||
pMod->pEpoTab = pTab;
|
||||
pTab->nTabRef = 1;
|
||||
pTab->eTabType = TABTYP_VTAB;
|
||||
pTab->pSchema = db->aDb[0].pSchema;
|
||||
assert( pTab->u.vtab.nArg==0 );
|
||||
assert( pTab->nModuleArg==0 );
|
||||
pTab->iPKey = -1;
|
||||
pTab->tabFlags |= TF_Eponymous;
|
||||
addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName));
|
||||
|
||||
@@ -161,10 +161,7 @@
|
||||
** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and
|
||||
** HASHTABLE_NPAGE are selected so that together the wal-index header and
|
||||
** first index block are the same size as all other index blocks in the
|
||||
** wal-index. The values are:
|
||||
**
|
||||
** HASHTABLE_NPAGE 4096
|
||||
** HASHTABLE_NPAGE_ONE 4062
|
||||
** wal-index.
|
||||
**
|
||||
** Each index block contains two sections, a page-mapping that contains the
|
||||
** database page number associated with each wal frame, and a hash-table
|
||||
@@ -400,70 +397,6 @@ struct WalCkptInfo {
|
||||
};
|
||||
#define READMARK_NOT_USED 0xffffffff
|
||||
|
||||
/*
|
||||
** This is a schematic view of the complete 136-byte header of the
|
||||
** wal-index file (also known as the -shm file):
|
||||
**
|
||||
** +-----------------------------+
|
||||
** 0: | iVersion | \
|
||||
** +-----------------------------+ |
|
||||
** 4: | (unused padding) | |
|
||||
** +-----------------------------+ |
|
||||
** 8: | iChange | |
|
||||
** +-------+-------+-------------+ |
|
||||
** 12: | bInit | bBig | szPage | |
|
||||
** +-------+-------+-------------+ |
|
||||
** 16: | mxFrame | | First copy of the
|
||||
** +-----------------------------+ | WalIndexHdr object
|
||||
** 20: | nPage | |
|
||||
** +-----------------------------+ |
|
||||
** 24: | aFrameCksum | |
|
||||
** | | |
|
||||
** +-----------------------------+ |
|
||||
** 32: | aSalt | |
|
||||
** | | |
|
||||
** +-----------------------------+ |
|
||||
** 40: | aCksum | |
|
||||
** | | /
|
||||
** +-----------------------------+
|
||||
** 48: | iVersion | \
|
||||
** +-----------------------------+ |
|
||||
** 52: | (unused padding) | |
|
||||
** +-----------------------------+ |
|
||||
** 56: | iChange | |
|
||||
** +-------+-------+-------------+ |
|
||||
** 60: | bInit | bBig | szPage | |
|
||||
** +-------+-------+-------------+ | Second copy of the
|
||||
** 64: | mxFrame | | WalIndexHdr
|
||||
** +-----------------------------+ |
|
||||
** 68: | nPage | |
|
||||
** +-----------------------------+ |
|
||||
** 72: | aFrameCksum | |
|
||||
** | | |
|
||||
** +-----------------------------+ |
|
||||
** 80: | aSalt | |
|
||||
** | | |
|
||||
** +-----------------------------+ |
|
||||
** 88: | aCksum | |
|
||||
** | | /
|
||||
** +-----------------------------+
|
||||
** 96: | nBackfill |
|
||||
** +-----------------------------+
|
||||
** 100: | 5 read marks |
|
||||
** | |
|
||||
** | |
|
||||
** | |
|
||||
** | |
|
||||
** +-------+-------+------+------+
|
||||
** 120: | Write | Ckpt | Rcvr | Rd0 | \
|
||||
** +-------+-------+------+------+ ) 8 lock bytes
|
||||
** | Read1 | Read2 | Rd3 | Rd4 | /
|
||||
** +-------+-------+------+------+
|
||||
** 128: | nBackfillAttempted |
|
||||
** +-----------------------------+
|
||||
** 132: | (unused padding) |
|
||||
** +-----------------------------+
|
||||
*/
|
||||
|
||||
/* A block of WALINDEX_LOCK_RESERVED bytes beginning at
|
||||
** WALINDEX_LOCK_OFFSET is reserved for locks. Since some systems
|
||||
@@ -1477,43 +1410,14 @@ int sqlite3WalOpen(
|
||||
assert( zWalName && zWalName[0] );
|
||||
assert( pDbFd );
|
||||
|
||||
/* Verify the values of various constants. Any changes to the values
|
||||
** of these constants would result in an incompatible on-disk format
|
||||
** for the -shm file. Any change that causes one of these asserts to
|
||||
** fail is a backward compatibility problem, even if the change otherwise
|
||||
** works.
|
||||
**
|
||||
** This table also serves as a helpful cross-reference when trying to
|
||||
** interpret hex dumps of the -shm file.
|
||||
*/
|
||||
assert( 48 == sizeof(WalIndexHdr) );
|
||||
assert( 40 == sizeof(WalCkptInfo) );
|
||||
assert( 120 == WALINDEX_LOCK_OFFSET );
|
||||
assert( 136 == WALINDEX_HDR_SIZE );
|
||||
assert( 4096 == HASHTABLE_NPAGE );
|
||||
assert( 4062 == HASHTABLE_NPAGE_ONE );
|
||||
assert( 8192 == HASHTABLE_NSLOT );
|
||||
assert( 383 == HASHTABLE_HASH_1 );
|
||||
assert( 32768 == WALINDEX_PGSZ );
|
||||
assert( 8 == SQLITE_SHM_NLOCK );
|
||||
assert( 5 == WAL_NREADER );
|
||||
assert( 24 == WAL_FRAME_HDRSIZE );
|
||||
assert( 32 == WAL_HDRSIZE );
|
||||
assert( 120 == WALINDEX_LOCK_OFFSET + WAL_WRITE_LOCK );
|
||||
assert( 121 == WALINDEX_LOCK_OFFSET + WAL_CKPT_LOCK );
|
||||
assert( 122 == WALINDEX_LOCK_OFFSET + WAL_RECOVER_LOCK );
|
||||
assert( 123 == WALINDEX_LOCK_OFFSET + WAL_READ_LOCK(0) );
|
||||
assert( 124 == WALINDEX_LOCK_OFFSET + WAL_READ_LOCK(1) );
|
||||
assert( 125 == WALINDEX_LOCK_OFFSET + WAL_READ_LOCK(2) );
|
||||
assert( 126 == WALINDEX_LOCK_OFFSET + WAL_READ_LOCK(3) );
|
||||
assert( 127 == WALINDEX_LOCK_OFFSET + WAL_READ_LOCK(4) );
|
||||
|
||||
/* In the amalgamation, the os_unix.c and os_win.c source files come before
|
||||
** this source file. Verify that the #defines of the locking byte offsets
|
||||
** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value.
|
||||
** For that matter, if the lock offset ever changes from its initial design
|
||||
** value of 120, we need to know that so there is an assert() to check it.
|
||||
*/
|
||||
assert( 120==WALINDEX_LOCK_OFFSET );
|
||||
assert( 136==WALINDEX_HDR_SIZE );
|
||||
#ifdef WIN_SHM_BASE
|
||||
assert( WIN_SHM_BASE==WALINDEX_LOCK_OFFSET );
|
||||
#endif
|
||||
|
||||
+4
-4
@@ -805,7 +805,7 @@ static void constructAutomaticIndex(
|
||||
if( !sentWarning ){
|
||||
sqlite3_log(SQLITE_WARNING_AUTOINDEX,
|
||||
"automatic index on %s(%s)", pTable->zName,
|
||||
pTable->aCol[iCol].zCnName);
|
||||
pTable->aCol[iCol].zName);
|
||||
sentWarning = 1;
|
||||
}
|
||||
if( (idxCols & cMask)==0 ){
|
||||
@@ -3060,7 +3060,7 @@ static int whereLoopAddBtree(
|
||||
** those objects, since there is no opportunity to add schema
|
||||
** indexes on subqueries and views. */
|
||||
pNew->rSetup = rLogSize + rSize;
|
||||
if( !IsView(pTab) && (pTab->tabFlags & TF_Ephemeral)==0 ){
|
||||
if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){
|
||||
pNew->rSetup += 28;
|
||||
}else{
|
||||
pNew->rSetup -= 10;
|
||||
@@ -5211,7 +5211,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||
pTab = pTabItem->pTab;
|
||||
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
pLoop = pLevel->pWLoop;
|
||||
if( (pTab->tabFlags & TF_Ephemeral)!=0 || IsView(pTab) ){
|
||||
if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ){
|
||||
/* Do nothing */
|
||||
}else
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
@@ -5580,7 +5580,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
** created for the ONEPASS optimization.
|
||||
*/
|
||||
if( (pTab->tabFlags & TF_Ephemeral)==0
|
||||
&& !IsView(pTab)
|
||||
&& pTab->pSelect==0
|
||||
&& (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
|
||||
){
|
||||
int ws = pLoop->wsFlags;
|
||||
|
||||
+3
-4
@@ -29,7 +29,7 @@ static const char *explainIndexColumnName(Index *pIdx, int i){
|
||||
i = pIdx->aiColumn[i];
|
||||
if( i==XN_EXPR ) return "<expr>";
|
||||
if( i==XN_ROWID ) return "rowid";
|
||||
return pIdx->pTable->aCol[i].zCnName;
|
||||
return pIdx->pTable->aCol[i].zName;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1241,9 +1241,8 @@ static void whereIndexExprTrans(
|
||||
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
|
||||
}else if( iRef>=0
|
||||
&& (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0
|
||||
&& ((pTab->aCol[iRef].colFlags & COLFLAG_HASCOLL)==0
|
||||
|| sqlite3StrICmp(sqlite3ColumnColl(&pTab->aCol[iRef]),
|
||||
sqlite3StrBINARY)==0)
|
||||
&& (pTab->aCol[iRef].zColl==0
|
||||
|| sqlite3StrICmp(pTab->aCol[iRef].zColl, sqlite3StrBINARY)==0)
|
||||
){
|
||||
/* Check to see if there are direct references to generated columns
|
||||
** that are contained in the index. Pulling the generated column
|
||||
|
||||
+6
-6
@@ -64,13 +64,13 @@ do_test capi2-1.4 {
|
||||
} {t1 1}
|
||||
do_test capi2-1.5 {
|
||||
get_column_names $VM
|
||||
} {name rowid TEXT INTEGER}
|
||||
} {name rowid text INTEGER}
|
||||
do_test capi2-1.6 {
|
||||
sqlite3_step $VM
|
||||
} {SQLITE_DONE}
|
||||
do_test capi2-1.7 {
|
||||
list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM]
|
||||
} {2 {} {name rowid TEXT INTEGER}}
|
||||
} {2 {} {name rowid text INTEGER}}
|
||||
|
||||
# This used to be SQLITE_MISUSE. But now we automatically reset prepared
|
||||
# statements.
|
||||
@@ -91,7 +91,7 @@ ifcapable autoreset {
|
||||
do_test capi2-1.9 {
|
||||
sqlite3_reset $VM
|
||||
list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM]
|
||||
} {2 {} {name rowid TEXT INTEGER}}
|
||||
} {2 {} {name rowid text INTEGER}}
|
||||
do_test capi2-1.10 {
|
||||
sqlite3_data_count $VM
|
||||
} {0}
|
||||
@@ -120,13 +120,13 @@ do_test capi2-2.2 {
|
||||
lappend r [sqlite3_column_count $VM] \
|
||||
[get_row_values $VM] \
|
||||
[get_column_names $VM]
|
||||
} {SQLITE_ROW 2 {t1 1} {name rowid TEXT INTEGER}}
|
||||
} {SQLITE_ROW 2 {t1 1} {name rowid text INTEGER}}
|
||||
do_test capi2-2.3 {
|
||||
set r [sqlite3_step $VM]
|
||||
lappend r [sqlite3_column_count $VM] \
|
||||
[get_row_values $VM] \
|
||||
[get_column_names $VM]
|
||||
} {SQLITE_DONE 2 {} {name rowid TEXT INTEGER}}
|
||||
} {SQLITE_DONE 2 {} {name rowid text INTEGER}}
|
||||
do_test capi2-2.4 {
|
||||
sqlite3_finalize $VM
|
||||
} {SQLITE_OK}
|
||||
@@ -141,7 +141,7 @@ do_test capi2-2.6 {
|
||||
lappend r [sqlite3_column_count $VM] \
|
||||
[get_row_values $VM] \
|
||||
[get_column_names $VM]
|
||||
} {SQLITE_DONE 2 {} {name rowid TEXT INTEGER}}
|
||||
} {SQLITE_DONE 2 {} {name rowid text INTEGER}}
|
||||
do_test capi2-2.7 {
|
||||
sqlite3_finalize $VM
|
||||
} {SQLITE_OK}
|
||||
|
||||
@@ -585,21 +585,5 @@ do_execsql_test gencol1-20.2 {
|
||||
SELECT * FROM tab;
|
||||
} {2001-01-01 0 0 5 {}}
|
||||
|
||||
# 2021-07-30 forum https://sqlite.org/forum/forumpost/ff3ffe09251c105b?t=h
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test gencol1-21.1 {
|
||||
CREATE TABLE t1(
|
||||
a integer primary key,
|
||||
b int generated always as (a+5),
|
||||
c text GENERATED ALWAYS as (printf('%08x',a)),
|
||||
d Generated
|
||||
Always
|
||||
AS ('xyzzy'),
|
||||
e int Always default(5)
|
||||
);
|
||||
INSERT INTO t1(a) VALUES(5);
|
||||
SELECT name, type FROM pragma_table_xinfo('t1');
|
||||
} {a INTEGER b INT c TEXT d {} e INT}
|
||||
|
||||
finish_test
|
||||
|
||||
+1
-1
@@ -815,7 +815,7 @@ do_test pragma-6.7 {
|
||||
ORDER BY cid}
|
||||
} [concat \
|
||||
{0 one INT 1 -1 0} \
|
||||
{1 two TEXT 0 {} 0} \
|
||||
{1 two text 0 {} 0} \
|
||||
{2 three {VARCHAR(45, 65)} 0 'abcde' 0} \
|
||||
{3 four REAL 0 X'abcdef' 0} \
|
||||
{4 five {} 0 CURRENT_TIME 0} \
|
||||
|
||||
@@ -149,7 +149,6 @@ array set ::Configs [strip_comments {
|
||||
-DSQLITE_ENABLE_RBU
|
||||
-DSQLITE_MAX_ATTACHED=125
|
||||
-DSQLITE_MAX_MMAP_SIZE=12884901888
|
||||
-DSQLITE_ENABLE_SORTER_MMAP=1
|
||||
-DLONGDOUBLE_TYPE=double
|
||||
--enable-session
|
||||
}
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
# 2021-08-18
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing STRICT tables.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix strict1
|
||||
|
||||
# STRICT tables have on a limited number of allowed datatypes.
|
||||
#
|
||||
do_catchsql_test strict1-1.1 {
|
||||
CREATE TABLE t1(a) STRICT;
|
||||
} {1 {unknown datatype for t1.a: ""}}
|
||||
do_catchsql_test strict1-1.2 {
|
||||
CREATE TABLE t1(a PRIMARY KEY) STRICT, WITHOUT ROWID;
|
||||
} {1 {unknown datatype for t1.a: ""}}
|
||||
do_catchsql_test strict1-1.3 {
|
||||
CREATE TABLE t1(a PRIMARY KEY) WITHOUT ROWID, STRICT;
|
||||
} {1 {unknown datatype for t1.a: ""}}
|
||||
do_catchsql_test strict1-1.4 {
|
||||
CREATE TABLE t1(a BANJO PRIMARY KEY) WITHOUT ROWID, STRICT;
|
||||
} {1 {unknown datatype for t1.a: "BANJO"}}
|
||||
do_catchsql_test strict1-1.5 {
|
||||
CREATE TABLE t1(a TEXT PRIMARY KEY, b INT, c INTEGER, d REAL, e BLOB, f DATE) strict;
|
||||
} {1 {unknown datatype for t1.f: "DATE"}}
|
||||
do_catchsql_test strict1-1.6 {
|
||||
CREATE TABLE t1(a TEXT PRIMARY KEY, b INT, c INTEGER, d REAL, e BLOB, f TEXT(50)) WITHOUT ROWID, STRICT;
|
||||
} {1 {unknown datatype for t1.f: "TEXT(50)"}}
|
||||
|
||||
do_execsql_test strict1-2.0 {
|
||||
CREATE TABLE t1(
|
||||
a INT,
|
||||
b INTEGER,
|
||||
c BLOB,
|
||||
d TEXT,
|
||||
e REAL
|
||||
) STRICT;
|
||||
} {}
|
||||
do_catchsql_test strict1-2.1 {
|
||||
INSERT INTO t1(a) VALUES('xyz');
|
||||
} {1 {cannot store TEXT value in INT column t1.a}}
|
||||
do_catchsql_test strict1-2.2 {
|
||||
INSERT INTO t1(b) VALUES('xyz');
|
||||
} {1 {cannot store TEXT value in INTEGER column t1.b}}
|
||||
do_catchsql_test strict1-2.3 {
|
||||
INSERT INTO t1(c) VALUES('xyz');
|
||||
} {1 {cannot store TEXT value in BLOB column t1.c}}
|
||||
do_catchsql_test strict1-2.4 {
|
||||
INSERT INTO t1(d) VALUES(x'3142536475');
|
||||
} {1 {cannot store BLOB value in TEXT column t1.d}}
|
||||
do_catchsql_test strict1-2.5 {
|
||||
INSERT INTO t1(e) VALUES('xyz');
|
||||
} {1 {cannot store TEXT value in REAL column t1.e}}
|
||||
|
||||
do_execsql_test strict1-3.1 {
|
||||
INSERT INTO t1(a, b) VALUES(1,2),('3','4'),(5.0, 6.0),(null,null);
|
||||
SELECT a, b, '|' FROM t1;
|
||||
} {1 2 | 3 4 | 5 6 | {} {} |}
|
||||
do_catchsql_test strict1-3.2 {
|
||||
INSERT INTO t1(a) VALUES(1.2);
|
||||
} {1 {cannot store REAL value in INT column t1.a}}
|
||||
do_catchsql_test strict1-3.3 {
|
||||
INSERT INTO t1(a) VALUES(x'313233');
|
||||
} {1 {cannot store BLOB value in INT column t1.a}}
|
||||
do_catchsql_test strict1-3.4 {
|
||||
INSERT INTO t1(b) VALUES(1.2);
|
||||
} {1 {cannot store REAL value in INTEGER column t1.b}}
|
||||
do_catchsql_test strict1-3.5 {
|
||||
INSERT INTO t1(b) VALUES(x'313233');
|
||||
} {1 {cannot store BLOB value in INTEGER column t1.b}}
|
||||
|
||||
do_execsql_test strict1-4.1 {
|
||||
DELETE FROM t1;
|
||||
INSERT INTO t1(c) VALUES(x'313233'), (NULL);
|
||||
SELECT typeof(c), c FROM t1;
|
||||
} {blob 123 null {}}
|
||||
do_catchsql_test strict1-4.2 {
|
||||
INSERT INTO t1(c) VALUES('456');
|
||||
} {1 {cannot store TEXT value in BLOB column t1.c}}
|
||||
|
||||
do_execsql_test strict1-5.1 {
|
||||
DELETE FROM t1;
|
||||
INSERT INTO t1(d) VALUES('xyz'),(4),(5.5),(NULL);
|
||||
SELECT typeof(d), d FROM t1;
|
||||
} {text xyz text 4 text 5.5 null {}}
|
||||
do_catchsql_test strict1-5.2 {
|
||||
INSERT INTO t1(d) VALUES(x'4567');
|
||||
} {1 {cannot store BLOB value in TEXT column t1.d}}
|
||||
|
||||
do_execsql_test strict1-6.1 {
|
||||
DELETE FROM t1;
|
||||
INSERT INTO t1(e) VALUES(1),(2.5),('3'),('4.5'),(6.0),(NULL);
|
||||
SELECT typeof(e), e FROM t1;
|
||||
} {real 1.0 real 2.5 real 3.0 real 4.5 real 6.0 null {}}
|
||||
do_catchsql_test strict1-6.2 {
|
||||
INSERT INTO t1(e) VALUES('xyz');
|
||||
} {1 {cannot store TEXT value in REAL column t1.e}}
|
||||
do_catchsql_test strict1-6.3 {
|
||||
INSERT INTO t1(e) VALUES(x'3456');
|
||||
} {1 {cannot store BLOB value in REAL column t1.e}}
|
||||
|
||||
finish_test
|
||||
@@ -1,143 +0,0 @@
|
||||
# 2021-08-19
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing STRICT tables.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix strict2
|
||||
|
||||
# PRAGMA integrity_check on a STRICT table should verify that
|
||||
# all of the values are of the correct type.
|
||||
#
|
||||
do_execsql_test strict2-1.1 {
|
||||
CREATE TABLE t1(
|
||||
a INT,
|
||||
b INTEGER,
|
||||
c TEXT,
|
||||
d REAL,
|
||||
e BLOB
|
||||
) STRICT;
|
||||
CREATE TABLE t1nn(
|
||||
a INT NOT NULL,
|
||||
b INTEGER NOT NULL,
|
||||
c TEXT NOT NULL,
|
||||
d REAL NOT NULL,
|
||||
e BLOB NOT NULL
|
||||
) STRICT;
|
||||
CREATE TABLE t2(a,b,c,d,e);
|
||||
INSERT INTO t1(a,b,c,d,e) VALUES(1,1,'one',1.0,x'b1'),(2,2,'two',2.25,x'b2b2b2');
|
||||
PRAGMA writable_schema=on;
|
||||
UPDATE sqlite_schema SET rootpage=(SELECT rootpage FROM sqlite_schema WHERE name='t1');
|
||||
} {}
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
do_execsql_test strict2-1.2 {
|
||||
PRAGMA quick_check('t1');
|
||||
} {ok}
|
||||
do_execsql_test strict2-1.3 {
|
||||
UPDATE t2 SET a=2.5 WHERE b=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-INT value in t1.a}}
|
||||
do_execsql_test strict2-1.4 {
|
||||
UPDATE t2 SET a='xyz' WHERE b=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-INT value in t1.a}}
|
||||
do_execsql_test strict2-1.5 {
|
||||
UPDATE t2 SET a=x'445566' WHERE b=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-INT value in t1.a}}
|
||||
do_execsql_test strict2-1.6 {
|
||||
UPDATE t2 SET a=2.5 WHERE b=2;
|
||||
PRAGMA quick_check('t1nn');
|
||||
} {{non-INT value in t1nn.a}}
|
||||
do_execsql_test strict2-1.7 {
|
||||
UPDATE t2 SET a='xyz' WHERE b=2;
|
||||
PRAGMA quick_check('t1nn');
|
||||
} {{non-INT value in t1nn.a}}
|
||||
do_execsql_test strict2-1.8 {
|
||||
UPDATE t2 SET a=x'445566' WHERE b=2;
|
||||
PRAGMA quick_check('t1nn');
|
||||
} {{non-INT value in t1nn.a}}
|
||||
|
||||
do_execsql_test strict2-1.13 {
|
||||
UPDATE t2 SET a=2 WHERE b=2;
|
||||
UPDATE t2 SET b=2.5 WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-INTEGER value in t1.b}}
|
||||
do_execsql_test strict2-1.14 {
|
||||
UPDATE t2 SET b='two' WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-INTEGER value in t1.b}}
|
||||
do_execsql_test strict2-1.15 {
|
||||
UPDATE t2 SET b=x'b0b1b2b3b4' WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-INTEGER value in t1.b}}
|
||||
do_execsql_test strict2-1.16 {
|
||||
UPDATE t2 SET b=NULL WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {ok}
|
||||
do_execsql_test strict2-1.17 {
|
||||
UPDATE t2 SET b=2.5 WHERE a=2;
|
||||
PRAGMA quick_check('t1nn');
|
||||
} {{non-INTEGER value in t1nn.b}}
|
||||
do_execsql_test strict2-1.18 {
|
||||
UPDATE t2 SET b=NULL WHERE a=2;
|
||||
PRAGMA quick_check('t1nn');
|
||||
} {{NULL value in t1nn.b}}
|
||||
|
||||
do_execsql_test strict2-1.23 {
|
||||
UPDATE t2 SET b=2 WHERE a=2;
|
||||
UPDATE t2 SET c=9 WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-TEXT value in t1.c}}
|
||||
do_execsql_test strict2-1.24 {
|
||||
UPDATE t2 SET c=9.5 WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-TEXT value in t1.c}}
|
||||
do_execsql_test strict2-1.25 {
|
||||
UPDATE t2 SET c=x'b0b1b2b3b4' WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-TEXT value in t1.c}}
|
||||
|
||||
do_execsql_test strict2-1.33 {
|
||||
UPDATE t2 SET c='two' WHERE a=2;
|
||||
UPDATE t2 SET d=9 WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {ok}
|
||||
do_execsql_test strict2-1.34 {
|
||||
UPDATE t2 SET d='nine' WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-REAL value in t1.d}}
|
||||
do_execsql_test strict2-1.35 {
|
||||
UPDATE t2 SET d=x'b0b1b2b3b4' WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-REAL value in t1.d}}
|
||||
|
||||
do_execsql_test strict2-1.43 {
|
||||
UPDATE t2 SET d=2.5 WHERE a=2;
|
||||
UPDATE t2 SET e=9 WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-BLOB value in t1.e}}
|
||||
do_execsql_test strict2-1.44 {
|
||||
UPDATE t2 SET e=9.5 WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-BLOB value in t1.e}}
|
||||
do_execsql_test strict2-1.45 {
|
||||
UPDATE t2 SET e='hello' WHERE a=2;
|
||||
PRAGMA quick_check('t1');
|
||||
} {{non-BLOB value in t1.e}}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
+1
-1
@@ -166,7 +166,7 @@ do_test tcl-2.1 {
|
||||
ifcapable schema_pragmas {
|
||||
do_test tcl-2.2 {
|
||||
execsql "PRAGMA table_info(t\u0123x)"
|
||||
} "0 a INT 0 {} 0 1 b\u1235 float 0 {} 0"
|
||||
} "0 a int 0 {} 0 1 b\u1235 float 0 {} 0"
|
||||
}
|
||||
do_test tcl-2.3 {
|
||||
execsql "INSERT INTO t\u0123x VALUES(1,2.3)"
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ proc analyse_parse {columns decltype_list} {
|
||||
|
||||
do_test vtabA-2.1 {
|
||||
analyse_parse {(a text, b integer hidden, c hidden)} {a b c}
|
||||
} {a TEXT integer {}}
|
||||
} {a text integer {}}
|
||||
|
||||
do_test vtabA-2.2 {
|
||||
analyse_parse {(a hidden , b integerhidden, c hidden1)} {a b c}
|
||||
|
||||
@@ -611,14 +611,4 @@ do_execsql_test 12.1 {
|
||||
SELECT quote(c) FROM v3;
|
||||
} {1 'hello' 4.25 NULL X'3C626C6F623E'}
|
||||
|
||||
# 2021-08-11 https://sqlite.org/forum/forumpost/d496c3d29bc93736
|
||||
reset_db
|
||||
do_execsql_test 13.1 {
|
||||
WITH
|
||||
t1(x) AS (SELECT 111),
|
||||
t2(y) AS (SELECT 222),
|
||||
t3(z) AS (SELECT * FROM t2 WHERE false UNION ALL SELECT * FROM t2)
|
||||
SELECT * FROM t1, t3;
|
||||
} {111 222}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -186,87 +186,6 @@ do_execsql_test without_rowid5-5.9 {
|
||||
SELECT count(*) FROM nnw;
|
||||
} {1}
|
||||
|
||||
# Ticket f2be158c57aaa8c6 (2021-08-18)
|
||||
# NOT NULL ON CONFLICT clauses work on WITHOUT ROWID tables now.
|
||||
#
|
||||
do_test without_rowid5-5.100 {
|
||||
db eval {
|
||||
DROP TABLE IF EXISTS t5;
|
||||
CREATE TABLE t5(
|
||||
a INT NOT NULL ON CONFLICT ROLLBACK,
|
||||
b TEXT,
|
||||
c TEXT,
|
||||
PRIMARY KEY(a,b)
|
||||
) WITHOUT ROWID;
|
||||
BEGIN;
|
||||
INSERT INTO t5(a,b,c) VALUES(1,2,3);
|
||||
}
|
||||
catch {db eval {INSERT INTO t5(a,b,c) VALUES(NULL,6,7);}}
|
||||
db eval {
|
||||
SELECT * FROM t5;
|
||||
}
|
||||
} {}
|
||||
do_test without_rowid5-5.101 {
|
||||
db eval {
|
||||
DROP TABLE IF EXISTS t5;
|
||||
CREATE TABLE t5(
|
||||
a INT NOT NULL ON CONFLICT ABORT,
|
||||
b TEXT,
|
||||
c TEXT,
|
||||
PRIMARY KEY(a,b)
|
||||
) WITHOUT ROWID;
|
||||
BEGIN;
|
||||
INSERT INTO t5(a,b,c) VALUES(1,2,3);
|
||||
}
|
||||
catch {db eval {INSERT INTO t5(a,b,c) VALUES(NULL,6,7);}}
|
||||
db eval {
|
||||
COMMIT;
|
||||
SELECT * FROM t5;
|
||||
}
|
||||
} {1 2 3}
|
||||
do_test without_rowid5-5.102 {
|
||||
db eval {
|
||||
DROP TABLE IF EXISTS t5;
|
||||
CREATE TABLE t5(
|
||||
a INT NOT NULL ON CONFLICT FAIL,
|
||||
b TEXT,
|
||||
c TEXT,
|
||||
PRIMARY KEY(a,b)
|
||||
) WITHOUT ROWID;
|
||||
}
|
||||
catch {db eval {INSERT INTO t5(a,b,c) VALUES(1,2,3),(NULL,4,5),(6,7,8);}}
|
||||
db eval {
|
||||
SELECT * FROM t5;
|
||||
}
|
||||
} {1 2 3}
|
||||
do_test without_rowid5-5.103 {
|
||||
db eval {
|
||||
DROP TABLE IF EXISTS t5;
|
||||
CREATE TABLE t5(
|
||||
a INT NOT NULL ON CONFLICT IGNORE,
|
||||
b TEXT,
|
||||
c TEXT,
|
||||
PRIMARY KEY(a,b)
|
||||
) WITHOUT ROWID;
|
||||
INSERT INTO t5(a,b,c) VALUES(1,2,3),(NULL,4,5),(6,7,8);
|
||||
SELECT * FROM t5;
|
||||
}
|
||||
} {1 2 3 6 7 8}
|
||||
do_test without_rowid5-5.104 {
|
||||
db eval {
|
||||
DROP TABLE IF EXISTS t5;
|
||||
CREATE TABLE t5(
|
||||
a INT NOT NULL ON CONFLICT REPLACE DEFAULT 3,
|
||||
b TEXT,
|
||||
c TEXT,
|
||||
PRIMARY KEY(a,b)
|
||||
) WITHOUT ROWID;
|
||||
INSERT INTO t5(a,b,c) VALUES(1,2,3),(NULL,4,5),(6,7,8);
|
||||
SELECT * FROM t5;
|
||||
}
|
||||
} {1 2 3 3 4 5 6 7 8}
|
||||
|
||||
|
||||
# EVIDENCE-OF: R-12643-30541 The incremental blob I/O mechanism does not
|
||||
# work for WITHOUT ROWID tables.
|
||||
#
|
||||
|
||||
+2
-2
@@ -981,14 +981,14 @@ void Parse(
|
||||
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
|
||||
yymajor = YYNOCODE;
|
||||
}else{
|
||||
while( yypParser->yytos > yypParser->yystack
|
||||
while( yypParser->yytos >= yypParser->yystack
|
||||
&& (yyact = yy_find_reduce_action(
|
||||
yypParser->yytos->stateno,
|
||||
YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE
|
||||
){
|
||||
yy_pop_parser_stack(yypParser);
|
||||
}
|
||||
if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){
|
||||
if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
|
||||
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
|
||||
yy_parse_failed(yypParser);
|
||||
#ifndef YYNOERRORRECOVERY
|
||||
|
||||
+1
-2
@@ -22,8 +22,7 @@ puts "const char *sqlite3OpcodeName(int i)\173"
|
||||
puts " static const char *const azName\[\] = \173"
|
||||
set mx 0
|
||||
|
||||
set in [open [lindex $argv 0]]
|
||||
fconfigure $in -translation binary
|
||||
set in [open [lindex $argv 0] rb]
|
||||
while {![eof $in]} {
|
||||
set line [gets $in]
|
||||
if {[regexp {^#define OP_} $line]} {
|
||||
|
||||
+2
-4
@@ -30,8 +30,7 @@ puts $out {/* DO NOT EDIT!
|
||||
** edit the src/shell.c.in" and/or some of the other files that are included
|
||||
** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script.
|
||||
*/}
|
||||
set in [open $topdir/src/shell.c.in]
|
||||
fconfigure $in -translation binary
|
||||
set in [open $topdir/src/shell.c.in rb]
|
||||
proc omit_redundant_typedefs {line} {
|
||||
global typedef_seen
|
||||
if {[regexp {^typedef .*;} $line]} {
|
||||
@@ -51,8 +50,7 @@ while {1} {
|
||||
set cfile [lindex $lx 1]
|
||||
puts $out "/************************* Begin $cfile ******************/"
|
||||
# puts $out "#line 1 \"$cfile\""
|
||||
set in2 [open $topdir/src/$cfile]
|
||||
fconfigure $in2 -translation binary
|
||||
set in2 [open $topdir/src/$cfile rb]
|
||||
while {![eof $in2]} {
|
||||
set lx [omit_redundant_typedefs [gets $in2]]
|
||||
if {[regexp {^#include "sqlite} $lx]} {
|
||||
|
||||
+3
-3
@@ -166,7 +166,6 @@ foreach hdr {
|
||||
set available_hdr($hdr) 1
|
||||
}
|
||||
set available_hdr(sqliteInt.h) 0
|
||||
set available_hdr(os_common.h) 0
|
||||
set available_hdr(sqlite3session.h) 0
|
||||
|
||||
# These headers should be copied into the amalgamation without modifying any
|
||||
@@ -224,7 +223,9 @@ proc copy_file {filename} {
|
||||
if {[regexp {^\s*#\s*include\s+["<]([^">]+)[">]} $line all hdr]} {
|
||||
if {[info exists available_hdr($hdr)]} {
|
||||
if {$available_hdr($hdr)} {
|
||||
set available_hdr($hdr) 0
|
||||
if {$hdr!="os_common.h" && $hdr!="hwtime.h"} {
|
||||
set available_hdr($hdr) 0
|
||||
}
|
||||
section_comment "Include $hdr in the middle of $tail"
|
||||
copy_file $srcdir/$hdr
|
||||
section_comment "Continuing where we left off in $tail"
|
||||
@@ -326,7 +327,6 @@ proc copy_file {filename} {
|
||||
#
|
||||
foreach file {
|
||||
sqliteInt.h
|
||||
os_common.h
|
||||
ctime.c
|
||||
|
||||
global.c
|
||||
|
||||
+9
-10
@@ -117,7 +117,7 @@ static void out_of_memory(void){
|
||||
** Space to hold the content is obtained from malloc() and needs to be
|
||||
** freed by the caller.
|
||||
*/
|
||||
static unsigned char *getContent(i64 ofst, int nByte){
|
||||
static unsigned char *getContent(int ofst, int nByte){
|
||||
unsigned char *aData;
|
||||
aData = malloc(nByte);
|
||||
if( aData==0 ) out_of_memory();
|
||||
@@ -204,10 +204,10 @@ static void print_decode_line(
|
||||
** Print an entire page of content as hex
|
||||
*/
|
||||
static void print_frame(int iFrame){
|
||||
i64 iStart;
|
||||
int iStart;
|
||||
unsigned char *aData;
|
||||
iStart = 32 + (i64)(iFrame-1)*(pagesize+24);
|
||||
fprintf(stdout, "Frame %d: (offsets 0x%llx..0x%llx)\n",
|
||||
iStart = 32 + (iFrame-1)*(pagesize+24);
|
||||
fprintf(stdout, "Frame %d: (offsets 0x%x..0x%x)\n",
|
||||
iFrame, iStart, iStart+pagesize+24);
|
||||
aData = getContent(iStart, pagesize+24);
|
||||
print_decode_line(aData, 0, 4, 0, "Page number");
|
||||
@@ -224,10 +224,10 @@ static void print_frame(int iFrame){
|
||||
** Summarize a single frame on a single line.
|
||||
*/
|
||||
static void print_oneline_frame(int iFrame, Cksum *pCksum){
|
||||
i64 iStart;
|
||||
int iStart;
|
||||
unsigned char *aData;
|
||||
unsigned int s0, s1;
|
||||
iStart = 32 + (i64)(iFrame-1)*(pagesize+24);
|
||||
iStart = 32 + (iFrame-1)*(pagesize+24);
|
||||
aData = getContent(iStart, 24);
|
||||
extendCksum(pCksum, aData, 8, 0);
|
||||
extendCksum(pCksum, getContent(iStart+24, pagesize), pagesize, 0);
|
||||
@@ -564,8 +564,7 @@ int main(int argc, char **argv){
|
||||
}else if( zLeft && zLeft[0]=='.' && zLeft[1]=='.' ){
|
||||
iEnd = strtol(&zLeft[2], 0, 0);
|
||||
}else if( zLeft && zLeft[0]=='b' ){
|
||||
i64 ofst;
|
||||
int nByte, hdrSize;
|
||||
int ofst, nByte, hdrSize;
|
||||
unsigned char *a;
|
||||
if( iStart==1 ){
|
||||
hdrSize = 100;
|
||||
@@ -573,10 +572,10 @@ int main(int argc, char **argv){
|
||||
nByte = pagesize-100;
|
||||
}else{
|
||||
hdrSize = 0;
|
||||
ofst = (i64)(iStart-1)*pagesize;
|
||||
ofst = (iStart-1)*pagesize;
|
||||
nByte = pagesize;
|
||||
}
|
||||
ofst = 32 + hdrSize + (i64)(iStart-1)*(pagesize+24) + 24;
|
||||
ofst = 32 + hdrSize + (iStart-1)*(pagesize+24) + 24;
|
||||
a = getContent(ofst, nByte);
|
||||
decode_btree_page(a, iStart, hdrSize, zLeft+1);
|
||||
free(a);
|
||||
|
||||
Reference in New Issue
Block a user