Compare commits

...

7 Commits

Author SHA1 Message Date
drh 415ae35ee2 In the push-down optimization, do not substitute columns that have previously
been identified as being constant by the propagate-constants optimization.
Fix for ticket [51166be0159fd2ce].
Also, avoid factoring out constant expressions on the LHS of an IN(...)
operator, as the IN(...) operation may affect the affinity of these values.
Fix for [fd1bda016d1].

FossilOrigin-Name: 43612157f87f7365cdb6d77ca3f1e06efd64ce023fb6825bbd3895265cc10f51
2020-04-04 00:29:18 +00:00
mistachkin c40d2db7ec Restore an #if block inadvertently removed via check-in [9c77bfe41e].
FossilOrigin-Name: bf6bcfc16e621edc5385a2a3fc6ea8d907edfaa32b4019605b51cdf675decb29
2020-04-03 20:14:00 +00:00
drh 96b6e28400 Do not suppress errors when resolving references in an ORDER BY clause
belonging to a compound SELECT within a view or trigger within ALTER
TABLE. Fix for ticket [a10a14e9b4ba2].
Also, in the event of a semantic error in an aggregate query, early-out the
resetAccumulator() function to prevent problems due to incomplete or
incorrect initialization of the AggInfo object.
Fix for ticket [af4556bb5c285c08].

FossilOrigin-Name: b64674919f6736025b2066672a5cf5cb51a28bbac4c709b85a1a6163cc0d7971
2020-04-03 13:39:03 +00:00
drh 787224f2d0 Fix a case when a pointer might be used after being freed in the ALTER TABLE code. Fix for [4722bdab08cb1].
FossilOrigin-Name: 52f800fa93dd2b2d1e52fed74bff8a1c7e68699edc3fb0e74a40dc0544a3a51e
2020-04-03 13:29:42 +00:00
drh efd6135b21 Prevent the read-only expressions held in the schema from being passed down
into code generating subroutines where they might be changed.  Pass a copy
of the expression instead.

FossilOrigin-Name: 2b750b0f74e5a11621997267d419c567cd860dd8bc7306d58fe037200c0d7679
2020-03-10 19:23:48 +00:00
drh 4f71e7733d Backport the change that allows the filename passed into the xFullPathname to
be used as an argument to sqlite3_uri_parameter().

FossilOrigin-Name: 9c77bfe41e1b786dbe649bffddc2500202884de1a19bbbee63831ba583ce0878
2020-02-27 12:33:33 +00:00
dan b6b86f6ebf Fix a 4 byte OOB read in test_multiplex.c.
FossilOrigin-Name: 6279f69f0fe3c7bb7b2eddd5ca51e28f003044ed0a3629260991a3aa8e521850
2020-02-06 11:02:30 +00:00
16 changed files with 228 additions and 50 deletions
+21 -22
View File
@@ -1,5 +1,5 @@
C Fix\sa\sproblem\sin\ssqlite3CodecQueryParameters()\sthat\swas\sintroduced\sby\sthe\nquery\sparameter\sencoding\schanges\sfor\sthe\s3.31.1\srelease.
D 2020-02-01T13:30:39.095
C In\sthe\spush-down\soptimization,\sdo\snot\ssubstitute\scolumns\sthat\shave\spreviously\nbeen\sidentified\sas\sbeing\sconstant\sby\sthe\spropagate-constants\soptimization.\nFix\sfor\sticket\s[51166be0159fd2ce].\nAlso,\savoid\sfactoring\sout\sconstant\sexpressions\son\sthe\sLHS\sof\san\sIN(...)\noperator,\sas\sthe\sIN(...)\soperation\smay\saffect\sthe\saffinity\sof\sthese\svalues.\nFix\sfor\s[fd1bda016d1].
D 2020-04-04T00:29:18.875
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -465,9 +465,9 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
F src/alter.c f48a4423c8f198d7f1ae4940f74b606707d05384ac79fb219be8e3323af2a2de
F src/alter.c ac9d737cace62b5cd88bff5310e53e299bc0919f08b5934a2bd0f8e8e65d770e
F src/analyze.c b3ceec3fc052df8a96ca8a8c858d455dc5029ba681b4be98bb5c5a9162cfa58c
F src/attach.c df0ead9091042c68964856ecc08dba55d5403ad5f3ca865d9d396d71528c511a
F src/attach.c 9fd451d7b9ac5b2138e60f858e99b07bdfb9bf6c6132d0dcbb078a4519de12d0
F src/auth.c a3d5bfdba83d25abed1013a8c7a5f204e2e29b0c25242a56bc02bb0c07bf1e06
F src/backup.c f70077d40c08b7787bfe934e4d1da8030cb0cc57d46b345fba2294b7d1be23ab
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
@@ -483,7 +483,7 @@ F src/date.c 6c408fdd2e9ddf6e8431aba76315a2d061bea2cec8fbb75e25d7c1ba08274712
F src/dbpage.c 8a01e865bf8bc6d7b1844b4314443a6436c07c3efe1d488ed89e81719047833a
F src/dbstat.c 0f55297469d4244ab7df395849e1af98eb5e95816af7c661e7d2d8402dea23da
F src/delete.c a5c59b9c0251cf7682bc52af0d64f09b1aefc6781a63592c8f1136f7b73c66e4
F src/expr.c 003c59158b33d7f3b198122cb0d1e13c06517cc3932e56b42283eb0e96696d66
F src/expr.c 7eec20f912d0bb72d6fb6765114c5f653482b374ce9f0544e893503ef0bf2cd1
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 92a248ec0fa4ed8ab60c98d9b188ce173aaf218f32e7737ba77deb2a684f9847
F src/func.c 108577cebe8a50c86d849a93b99493a54e348dd0b846f00d13b52ca973d5baf4
@@ -492,10 +492,10 @@ 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 2fe4d7f67078a68650f16e4efe73207899e21702e6b9d2e8ad1894c76dcad352
F src/insert.c 465ee38d9d0180cb2df79dfa4d14ebae44ee9c34b13a0bb208bf3629486e3d86
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 8cd803f1747c03a50b32fe87ebfb5851998d0cdafefe02737daa95e0616b42bb
F src/main.c a82239262ef4d926fc00824e1ab4fdb958496d6efe9ee8ebd3e37d6005deccc4
F src/main.c aad9966a6fc1fdabfbe4750f725987dc346e086539036280ba1498757b4ece8b
F src/malloc.c eaa4dc9602ce28b077f7de2eb275db2be270c5cc56d7fec5466301bd9b80e2f5
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
@@ -529,14 +529,14 @@ F src/pragma.h 9f86a3a3a0099e651189521c8ad03768df598974e7bbdc21c7f9bb6125592fbd
F src/prepare.c 6049beb71385f017af6fc320d2c75a4e50b75e280c54232442b785fbb83df057
F src/printf.c 9be6945837c839ba57837b4bc3af349eba630920fa5532aa518816defe42a7d4
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c f0781c9e180028b279bc4ff079ad54f4727223d470c8d2343643fcaf79b67740
F src/resolve.c 534927e6f425ce83db0699a80bc00e1b5e7262968b35e0ae43c5097865ac2c5c
F src/rowset.c d977b011993aaea002cab3e0bb2ce50cf346000dff94e944d547b989f4b1fe93
F src/select.c 3f7aecf64b08b018b89e4fe16ea621cc9a0e3f3801e9e5638cfe1a6035fa1581
F src/select.c ac24b7ddd0e984a58352e0f9cd3d32a3b8a89338ac616e86711b6e774d69794b
F src/shell.c.in c2e20c43a44fb5588a6c27ce60589538fbf4794fd7686f5b2598eca22eaae1fa
F src/sqlite.h.in 75d0304247a2154122d6d06f12219c1e29291d72304f0eeef4c1ec6b1409b443
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 27951f294f29cd875c6027f2707d644ef99f469bd97514568b5a8581a114db8c
F src/sqliteInt.h 7a29ba700a51eeb925731749a570cf3859f6a58ed94797ecf47508875b0ba279
F src/sqliteInt.h 32d0ab6d0a3e7d8e5dbc6d4d81a7fbfe3adbdc3567c7c9630585a37b6861e967
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
F src/status.c 9ff2210207c6c3b4d9631a8241a7d45ab1b26a0e9c84cb07a9b5ce2de9a3b278
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
@@ -570,7 +570,7 @@ F src/test_journal.c a0b9709b2f12b1ec819eea8a1176f283bca6d688a6d4a502bd6fd79786f
F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd
F src/test_malloc.c dec0aa821b230773aeb3dd11d652c1193f7cedb18a20b25659bc672288115242
F src/test_md5.c 7268e1e8c399d4a5e181b64ac20e1e6f3bc4dd9fc87abac02db145a3d951fa8c
F src/test_multiplex.c e054459f7633f3ff8ce1245da724f9a8be189e4e
F src/test_multiplex.c e5fac104a0eebf935e6732cda6abce79ea0b4b10949518d5dac7b0293173a40f
F src/test_multiplex.h 5436d03f2d0501d04f3ed50a75819e190495b635
F src/test_mutex.c 7f4337ba23ee6b1d2ec81c189653608cb069926a
F src/test_onefile.c f31e52e891c5fef6709b9fcef54ce660648a34172423a9cbdf4cbce3ba0049f4
@@ -639,7 +639,7 @@ F test/altercol.test 1d6a6fe698b81e626baea4881f5717f9bc53d7d07f1cd23ee7ad1b931f1
F test/alterlegacy.test 82022721ce0de29cedc9a7af63bc9fcc078b0ee000f8283b4b6ea9c3eab2f44b
F test/altermalloc.test 167a47de41b5c638f5f5c6efb59784002b196fff70f98d9b4ed3cd74a3fb80c9
F test/altermalloc2.test fa7b1c1139ea39b8dec407cf1feb032ca8e0076bd429574969b619175ad0174b
F test/altertab.test bd61e5b73d495ec4707133db91b07f09d57e339d988de5ec5a76d34a2198e8f2
F test/altertab.test 523ba6368e0da19f462f7c05563c569675736d946724cac1c4ae848f76783434
F test/altertab2.test b0d62f323ca5dab42b0bc028c52e310ebdd13e655e8fac070fe622bad7852c2b
F test/altertab3.test 155b8dc225ce484454a7fb4c8ba745680b6fa0fc3e08919cbbc19f9309d128ff
F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f
@@ -792,7 +792,7 @@ F test/crash8.test 64366e459c28dd62edfb7ad87253a409c7533b92d16fcc479a6a8131bdcc3
F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/createtab.test 85cdfdae5c3de331cd888d6c66e1aba575b47c2e3c3cc4a1d6f54140699f5165
F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c
F test/cse.test 00b3aea44b16828833c94fbe92475fd6977583fcb064ae0bc590986812b38d0c
F test/csv01.test c9c3af0d58c34e9ac970c5875a77939edb958762c8aafb95409e19a3f088b6cd
F test/ctime.test 78749e6c9a5f0010d67985be80788f841e3cd2da18114e2ed6010399a7d807f3
F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856
@@ -808,7 +808,7 @@ F test/dbfuzz2.c c2c9cb40082a77b7e95ffb8b2da1e93322efadfb1c8c1e0001c95a0af1e156c
F test/dbpage.test 650234ba683b9d82b899c6c51439819787e7609f17a0cc40e0080a7b6443bc38
F test/dbstatus.test 4a4221a883025ffd39696b3d1b3910b928fb097d77e671351acb35f3aed42759
F test/dbstatus2.test f5fe0afed3fa45e57cfa70d1147606c20d2ba23feac78e9a172f2fe8ab5b78ef
F test/default.test 3e46c421eebefd2787c2f96673efabf792d360f3a1d5073918cbe450ce672a62
F test/default.test 9687cfb16717e4b8238c191697c98be88c0b16e568dd5368cd9284154097ef50
F test/delete.test 31832b0c45ecb51a54348c68db173be462985901e6ed7f403d6d7a8f70ab4ef0
F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa
F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab
@@ -1301,7 +1301,7 @@ F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5
F test/select1.test 009a6d8eacd9684d046302b8d13b50846a87e39d6f08e92178aa13e95ea29a2d
F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56
F test/select3.test 3905450067c28766bc83ee397f6d87342de868baa60f2bcfd00f286dfbd62cb9
F test/select4.test 5389d9895968d1196c457d59b3ee6515d771d328
F test/select4.test e8a2502e3623f3058871030599a48abb35789d2244d5b380ecf3696873fdd4a4
F test/select5.test df9ec0d218cedceb4fe7b63262025b547b50a55e59148c6f40b60ca25f1d4546
F test/select6.test 319d45e414cdd321bf17cfacedaf19e3935ad64dac357c53f1492338c6e9b801
F test/select7.test f659f231489349e8c5734e610803d7654207318f
@@ -1718,7 +1718,7 @@ F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2
F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972
F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc
F test/window1.test cec56b9a0a2e7ca4bd63b30590c7b049dce9acfd87478e2597e13b67152bd821
F test/window1.test 4aa2a388e55fba03ad32f652e036884d457bb240f34843c267468cf4f78520db
F test/window2.tcl 492c125fa550cda1dd3555768a2303b3effbeceee215293adf8871efc25f1476
F test/window2.test e466a88bd626d66edc3d352d7d7e1d5531e0079b549ba44efb029d1fbff9fd3c
F test/window3.tcl acea6e86a4324a210fd608d06741010ca83ded9fde438341cb978c49928faf03
@@ -1857,10 +1857,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6
R 37dff97ea1827bf789931484e75996b9
T *branch * branch-3.31
T *sym-branch-3.31 *
T -sym-trunk *
P bf6bcfc16e621edc5385a2a3fc6ea8d907edfaa32b4019605b51cdf675decb29
Q +70c44811d12f540d4ec1c29dedbe999cf79b82e326a8712ae2fa0725d6bd8a65
Q +98d56b4a34fddcbaecd953a045ae0270b4d78c1edf34cc73522fb4e12743af80
R bbf71157386490a0eb7285ef1f3d9126
U drh
Z b11b538d7cc74f2de7b61f8de517a681
Z 2c10dcc8208eef311a37e32183f7ec52
+1 -1
View File
@@ -1 +1 @@
cc65ca541265bd7061ed8f5ec9a54f3c384c41019c5ea1c68dcaabeff3495839
43612157f87f7365cdb6d77ca3f1e06efd64ce023fb6825bbd3895265cc10f51
+17
View File
@@ -755,6 +755,21 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){
}
}
/*
** Unmap all tokens in the IdList object passed as the second argument.
*/
static void unmapColumnIdlistNames(
Parse *pParse,
IdList *pIdList
){
if( pIdList ){
int ii;
for(ii=0; ii<pIdList->nId; ii++){
sqlite3RenameTokenRemap(pParse, 0, (void*)pIdList->a[ii].zName);
}
}
}
/*
** Walker callback used by sqlite3RenameExprUnmap().
*/
@@ -776,6 +791,7 @@ static int renameUnmapSelectCb(Walker *pWalker, Select *p){
for(i=0; i<pSrc->nSrc; i++){
sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName);
if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort;
unmapColumnIdlistNames(pParse, pSrc->a[i].pUsing);
}
}
@@ -984,6 +1000,7 @@ static void renameColumnIdlistNames(
}
}
/*
** Parse the SQL statement zSql using Parse object (*p). The Parse object
** is initialized by this function before it is used.
+1 -2
View File
@@ -188,7 +188,6 @@ static void attachFunc(
rc = SQLITE_NOMEM_BKPT;
}
#ifdef SQLITE_HAS_CODEC
if( rc==SQLITE_OK ){
extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);
@@ -223,7 +222,7 @@ static void attachFunc(
}
}
#endif
sqlite3_free( zPath );
sqlite3FreeFilename( zPath );
/* If the file was opened successfully, read the schema for the new database.
** If this fails, or if opening the file failed, then close the file and
+11 -3
View File
@@ -2850,6 +2850,7 @@ void sqlite3CodeRhsOfIN(
/* Begin coding the subroutine */
ExprSetProperty(pExpr, EP_Subrtn);
assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
pExpr->y.sub.regReturn = ++pParse->nMem;
pExpr->y.sub.iAddr =
sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
@@ -3169,6 +3170,7 @@ static void sqlite3ExprCodeIN(
int destNotNull; /* Jump here if a comparison is not true in step 6 */
int addrTop; /* Top of the step-6 loop */
int iTab = 0; /* Index to use */
u8 okConstFactor = pParse->okConstFactor;
pLeft = pExpr->pLeft;
if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
@@ -3212,8 +3214,14 @@ static void sqlite3ExprCodeIN(
** so that the fields are in the same order as an existing index. The
** aiMap[] array contains a mapping from the original LHS field order to
** the field order that matches the RHS index.
*/
**
** Avoid factoring the LHS of the IN(...) expression out of the loop,
** even if it is constant, as OP_Affinity may be used on the register
** by code generated below. */
assert( pParse->okConstFactor==okConstFactor );
pParse->okConstFactor = 0;
rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy);
pParse->okConstFactor = okConstFactor;
for(i=0; i<nVector && aiMap[i]==i; i++){} /* Are LHS fields reordered? */
if( i==nVector ){
/* LHS fields are not reordered */
@@ -3496,7 +3504,7 @@ void sqlite3ExprCodeGeneratedColumn(
}else{
iAddr = 0;
}
sqlite3ExprCode(pParse, pCol->pDflt, regOut);
sqlite3ExprCodeCopy(pParse, pCol->pDflt, regOut);
if( pCol->affinity>=SQLITE_AFF_TEXT ){
sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1);
}
@@ -4595,7 +4603,7 @@ void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){
if( pParse->okConstFactor && sqlite3ExprIsConstantNotJoin(pExpr) ){
sqlite3ExprCodeAtInit(pParse, pExpr, target);
}else{
sqlite3ExprCode(pParse, pExpr, target);
sqlite3ExprCodeCopy(pParse, pExpr, target);
}
}
+7 -2
View File
@@ -1606,7 +1606,7 @@ void sqlite3GenerateConstraintChecks(
VdbeCoverage(v);
assert( (pCol->colFlags & COLFLAG_GENERATED)==0 );
nSeenReplace++;
sqlite3ExprCode(pParse, pCol->pDflt, iReg);
sqlite3ExprCodeCopy(pParse, pCol->pDflt, iReg);
sqlite3VdbeJumpHere(v, addr1);
break;
}
@@ -1661,6 +1661,7 @@ void sqlite3GenerateConstraintChecks(
onError = overrideError!=OE_Default ? overrideError : OE_Abort;
for(i=0; i<pCheck->nExpr; i++){
int allOk;
Expr *pCopy;
Expr *pExpr = pCheck->a[i].pExpr;
if( aiChng
&& !sqlite3ExprReferencesUpdatedColumn(pExpr, aiChng, pkChng)
@@ -1671,7 +1672,11 @@ void sqlite3GenerateConstraintChecks(
}
allOk = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeVerifyAbortable(v, onError);
sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
pCopy = sqlite3ExprDup(db, pExpr, 0);
if( !db->mallocFailed ){
sqlite3ExprIfTrue(pParse, pCopy, allOk, SQLITE_JUMPIFNULL);
}
sqlite3ExprDelete(db, pCopy);
if( onError==OE_Ignore ){
sqlite3VdbeGoto(v, ignoreDest);
}else{
+24 -11
View File
@@ -2750,9 +2750,11 @@ int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
**
** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to
** the VFS that should be used to open the database file. *pzFile is set to
** point to a buffer containing the name of the file to open. It is the
** responsibility of the caller to eventually call sqlite3_free() to release
** this buffer.
** point to a buffer containing the name of the file to open. The value
** stored in *pzFile is a database name acceptable to sqlite3_uri_parameter()
** and is in the same format as names created using sqlite3_create_filename().
** The caller must invoke sqlite3FreeFilename() (not sqlite3_free()!) on
** the value returned in *pzFile to avoid a memory leak.
**
** If an error occurs, then an SQLite error code is returned and *pzErrMsg
** may be set to point to a buffer containing an English language error
@@ -2784,7 +2786,7 @@ int sqlite3ParseUri(
int eState; /* Parser state when parsing URI */
int iIn; /* Input character index */
int iOut = 0; /* Output character index */
u64 nByte = nUri+2; /* Bytes of space to allocate */
u64 nByte = nUri+8; /* Bytes of space to allocate */
/* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen
** method that there may be extra parameters following the file-name. */
@@ -2794,6 +2796,9 @@ int sqlite3ParseUri(
zFile = sqlite3_malloc64(nByte);
if( !zFile ) return SQLITE_NOMEM_BKPT;
memset(zFile, 0, 4); /* 4-byte of 0x00 is the start of DB name marker */
zFile += 4;
iIn = 5;
#ifdef SQLITE_ALLOW_URI_AUTHORITY
if( strncmp(zUri+5, "///", 3)==0 ){
@@ -2883,8 +2888,7 @@ int sqlite3ParseUri(
zFile[iOut++] = c;
}
if( eState==1 ) zFile[iOut++] = '\0';
zFile[iOut++] = '\0';
zFile[iOut++] = '\0';
memset(zFile+iOut, 0, 4); /* end-of-options + empty journal filenames */
/* Check if there were any options specified that should be interpreted
** here. Options that are interpreted here include "vfs" and those that
@@ -2964,13 +2968,14 @@ int sqlite3ParseUri(
}
}else{
zFile = sqlite3_malloc64(nUri+2);
zFile = sqlite3_malloc64(nUri+8);
if( !zFile ) return SQLITE_NOMEM_BKPT;
memset(zFile, 0, 4);
zFile += 4;
if( nUri ){
memcpy(zFile, zUri, nUri);
}
zFile[nUri] = '\0';
zFile[nUri+1] = '\0';
memset(zFile+nUri, 0, 4);
flags &= ~SQLITE_OPEN_URI;
}
@@ -2981,7 +2986,7 @@ int sqlite3ParseUri(
}
parse_uri_out:
if( rc!=SQLITE_OK ){
sqlite3_free(zFile);
sqlite3FreeFilename(zFile);
zFile = 0;
}
*pFlags = flags;
@@ -3426,7 +3431,7 @@ opendb_out:
#if defined(SQLITE_HAS_CODEC)
if( rc==SQLITE_OK ) sqlite3CodecQueryParameters(db, 0, zOpen);
#endif
sqlite3_free(zOpen);
sqlite3FreeFilename(zOpen);
return rc & 0xff;
}
@@ -4292,6 +4297,14 @@ const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){
return uriParameter(zFilename, zParam);
}
/*
** Free memory obtained from sqlite3ParseUri().
*/
void sqlite3FreeFilename(char *p){
if( p==0 ) return;
sqlite3_free(p - 4);
}
/*
** Return a pointer to the name of Nth query parameter of the filename.
*/
+1 -1
View File
@@ -1177,7 +1177,7 @@ static int resolveOrderByTermToExprList(
nc.nErr = 0;
db = pParse->db;
savedSuppErr = db->suppressErr;
db->suppressErr = 1;
if( IN_RENAME_OBJECT==0 ) db->suppressErr = 1;
rc = sqlite3ResolveExprNames(&nc, pE);
db->suppressErr = savedSuppErr;
if( rc ) return 0;
+5 -1
View File
@@ -3476,7 +3476,10 @@ static Expr *substExpr(
){
pExpr->iRightJoinTable = pSubst->iNewTable;
}
if( pExpr->op==TK_COLUMN && pExpr->iTable==pSubst->iTable ){
if( pExpr->op==TK_COLUMN
&& pExpr->iTable==pSubst->iTable
&& !ExprHasProperty(pExpr, EP_FixedCol)
){
if( pExpr->iColumn<0 ){
pExpr->op = TK_NULL;
}else{
@@ -5352,6 +5355,7 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
struct AggInfo_func *pFunc;
int nReg = pAggInfo->nFunc + pAggInfo->nColumn;
if( nReg==0 ) return;
if( pParse->nErr ) return;
#ifdef SQLITE_DEBUG
/* Verify that all AggInfo registers are within the range specified by
** AggInfo.mnReg..AggInfo.mxReg */
+14 -5
View File
@@ -2153,8 +2153,11 @@ struct Table {
*/
#ifndef SQLITE_OMIT_VIRTUALTABLE
# define IsVirtual(X) ((X)->nModuleArg)
# define ExprIsVtab(X) \
((X)->op==TK_COLUMN && (X)->y.pTab!=0 && (X)->y.pTab->nModuleArg)
#else
# define IsVirtual(X) 0
# define ExprIsVtab(X) 0
#endif
/*
@@ -2512,10 +2515,10 @@ struct AggInfo {
** it uses less memory in the Expr object, which is a big memory user
** in systems with lots of prepared statements. And few applications
** need more than about 10 or 20 variables. But some extreme users want
** to have prepared statements with over 32767 variables, and for them
** to have prepared statements with over 32766 variables, and for them
** the option is available (at compile-time).
*/
#if SQLITE_MAX_VARIABLE_NUMBER<=32767
#if SQLITE_MAX_VARIABLE_NUMBER<32767
typedef i16 ynVar;
#else
typedef int ynVar;
@@ -3834,13 +3837,16 @@ int sqlite3CantopenError(int);
#ifdef SQLITE_DEBUG
int sqlite3NomemError(int);
int sqlite3IoerrnomemError(int);
int sqlite3CorruptPgnoError(int,Pgno);
# define SQLITE_NOMEM_BKPT sqlite3NomemError(__LINE__)
# define SQLITE_IOERR_NOMEM_BKPT sqlite3IoerrnomemError(__LINE__)
# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptPgnoError(__LINE__,(P))
#else
# define SQLITE_NOMEM_BKPT SQLITE_NOMEM
# define SQLITE_IOERR_NOMEM_BKPT SQLITE_IOERR_NOMEM
#endif
#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_CORRUPT_PGNO)
int sqlite3CorruptPgnoError(int,Pgno);
# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptPgnoError(__LINE__,(P))
#else
# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptError(__LINE__)
#endif
@@ -3920,6 +3926,7 @@ void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64);
void *sqlite3DbRealloc(sqlite3 *, void *, u64);
void sqlite3DbFree(sqlite3*, void*);
void sqlite3DbFreeNN(sqlite3*, void*);
void sqlite3FreeFilename(char*);
int sqlite3MallocSize(void*);
int sqlite3DbMallocSize(sqlite3*, void*);
void *sqlite3PageMalloc(int);
@@ -4111,7 +4118,7 @@ void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
int sqlite3ParseUri(const char*,const char*,unsigned int*,
sqlite3_vfs**,char**,char **);
#ifdef SQLITE_HAS_CODEC
int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*);
int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*);
#else
# define sqlite3CodecQueryParameters(A,B,C) 0
#endif
@@ -4426,6 +4433,8 @@ int sqlite3VarintLen(u64 v);
*/
#define getVarint32(A,B) \
(u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))
#define getVarint32NR(A,B) \
B=(u32)*(A);if(B>=0x80)sqlite3GetVarint32((A),(u32*)&(B))
#define putVarint32(A,B) \
(u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\
sqlite3PutVarint((A),(B)))
+1 -1
View File
@@ -530,7 +530,7 @@ static int multiplexOpen(
pGroup->szChunk += 65536;
}
}
pGroup->flags = flags;
pGroup->flags = (flags & ~SQLITE_OPEN_URI);
rc = multiplexSubFilename(pGroup, 1);
if( rc==SQLITE_OK ){
pSubOpen = multiplexSubOpen(pGroup, 0, &rc, pOutFlags, 0);
+47 -1
View File
@@ -594,7 +594,6 @@ reset_db
do_execsql_test 18.1.0 {
CREATE TABLE t0 (c0 INTEGER, PRIMARY KEY(c0)) WITHOUT ROWID;
}
breakpoint
do_execsql_test 18.1.1 {
ALTER TABLE t0 RENAME COLUMN c0 TO c1;
}
@@ -613,4 +612,51 @@ do_execsql_test 18.2.2 {
SELECT sql FROM sqlite_master;
} {{CREATE TABLE t0 (c1 INTEGER, PRIMARY KEY(c1))}}
# 2020-02-23 ticket f50af3e8a565776b
reset_db
do_execsql_test 19.100 {
CREATE TABLE t1(x);
CREATE VIEW t2 AS SELECT 1 FROM t1, (t1 AS a0, t1);
ALTER TABLE t1 RENAME TO t3;
SELECT sql FROM sqlite_master;
} {{CREATE TABLE "t3"(x)} {CREATE VIEW t2 AS SELECT 1 FROM "t3", ("t3" AS a0, "t3")}}
do_execsql_test 19.110 {
INSERT INTO t3(x) VALUES(123);
SELECT * FROM t2;
} {1}
do_execsql_test 19.120 {
INSERT INTO t3(x) VALUES('xyz');
SELECT * FROM t2;
} {1 1 1 1 1 1 1 1}
# Ticket 4722bdab08cb14
reset_db
do_execsql_test 20.0 {
CREATE TABLE a(a);
CREATE VIEW b AS SELECT(SELECT *FROM c JOIN a USING(d, a, a, a) JOIN a) IN();
}
do_execsql_test 20.1 {
ALTER TABLE a RENAME a TO e;
} {}
reset_db
do_execsql_test 21.0 {
CREATE TABLE a(b);
CREATE VIEW c AS
SELECT NULL INTERSECT
SELECT NULL ORDER BY
likelihood(NULL, (d, (SELECT c)));
} {}
do_catchsql_test 21.1 {
SELECT likelihood(NULL, (d, (SELECT c)));
} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
do_catchsql_test 21.2 {
SELECT * FROM c;
} {1 {1st ORDER BY term does not match any column in the result set}}
do_catchsql_test 21.3 {
ALTER TABLE a RENAME TO e;
} {1 {error in view c: 1st ORDER BY term does not match any column in the result set}}
finish_test
+40
View File
@@ -18,6 +18,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix cse
do_test cse-1.1 {
execsql {
@@ -157,4 +158,43 @@ for {set i 1} {$i<100} {incr i} {
} $answer
}
#-------------------------------------------------------------------------
# Ticket fd1bda016d1a
#
reset_db
do_execsql_test 3.0 {
CREATE TABLE t1(a TEXT, b);
INSERT INTO t1 VALUES('hello', 0);
INSERT INTO t1 VALUES('world', 0);
CREATE TABLE t2(x TEXT);
INSERT INTO t2 VALUES('hello');
INSERT INTO t2 VALUES('world');
CREATE TABLE t3(y);
INSERT INTO t3 VALUES(1000);
} {}
do_execsql_test 3.1 {
SELECT 1000 = y FROM t3
} {1}
do_execsql_test 3.2 {
SELECT 1000 IN (SELECT x FROM t2), 1000 = y FROM t3
} {0 1}
do_execsql_test 3.3 {
SELECT 0 IN (SELECT a), (SELECT a LIMIT 0) FROM t1
} {0 {} 0 {}}
do_execsql_test 3.4 {
SELECT 0 IN (SELECT a) FROM t1 WHERE a = 'hello' OR (SELECT a LIMIT 0);
} {0}
do_execsql_test 3.5 {
CREATE TABLE v0(v1 VARCHAR0);
INSERT INTO v0 VALUES(2), (3);
SELECT 0 IN(SELECT v1) FROM v0 WHERE v1 = 2 OR(SELECT v1 LIMIT 0);
} {0}
finish_test
+9
View File
@@ -128,4 +128,13 @@ do_catchsql_test default-4.4 {
CREATE TABLE t2(a TEXT, b TEXT DEFAULT(98+coalesce(5,:xyz)));
} {1 {default value of column [b] is not constant}}
# 2020-03-09 out-of-bounds memory access discovered by "Eternal Sakura"
# and reported to chromium.
#
reset_db
do_catchsql_test default-5.1 {
CREATE TABLE t1 (a,b DEFAULT(random() NOTNULL IN (RAISE(IGNORE),2,3)));
INSERT INTO t1(a) VALUES(1);
} {1 {RAISE() may only be used within a trigger-program}}
finish_test
+19
View File
@@ -1005,6 +1005,25 @@ do_catchsql_test select4-17.3 {
ORDER BY +x;
} {1 {LIMIT clause should come after UNION not before}}
# 2020-04-03 ticket 51166be0159fd2ce from Yong Heng.
# Adverse interaction between the constant propagation and push-down
# optimizations.
#
reset_db
do_execsql_test select4-18.1 {
CREATE VIEW v0(v0) AS WITH v0 AS(SELECT 0 v0) SELECT(SELECT min(v0) OVER()) FROM v0 GROUP BY v0;
SELECT *FROM v0 v1 JOIN v0 USING(v0) WHERE datetime(v0) = (v0.v0)AND v0 = 10;
} {}
do_execsql_test select4-18.2 {
CREATE VIEW t1(aa) AS
WITH t2(bb) AS (SELECT 123)
SELECT (SELECT min(bb) OVER()) FROM t2 GROUP BY bb;
SELECT * FROM t1;
} {123}
do_execsql_test select4-18.3 {
SELECT * FROM t1 AS z1 JOIN t1 AS z2 USING(aa)
WHERE abs(z1.aa)=z2.aa AND z1.aa=123;
} {123}
finish_test
+10
View File
@@ -1594,4 +1594,14 @@ do_execsql_test 48.1 {
} {2 2 2}
# 2020-04-03 ticket af4556bb5c285c08
#
reset_db
do_catchsql_test 51.1 {
CREATE TABLE a(b, c);
SELECT c FROM a GROUP BY c
HAVING(SELECT(sum(b) OVER(ORDER BY b),
sum(b) OVER(PARTITION BY min(DISTINCT c), c ORDER BY b)));
} {1 {row value misused}}
finish_test