Merge fixes from trunk.

FossilOrigin-Name: 002406df22995880d002be2e4cebb4d560283d4e0d7a4b5a34edcb110802b543
This commit is contained in:
drh 2020-01-03 15:22:54 +00:00
commit 9ee00200ef
13 changed files with 112 additions and 27 deletions

View File

@ -1,5 +1,5 @@
C Merge\senhancements\sfrom\strunk.
D 2020-01-02T23:50:50.904
C Merge\sfixes\sfrom\strunk.
D 2020-01-03T15:22:54.803
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -472,7 +472,7 @@ F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
F src/btree.c f191aa4d99597a1ad77cb15a9473f1183f2a12a7f1650a7705eaac9085e493bb
F src/btree.h 6111552f19ed7a40f029cf4b33badc6fef9880314fffd80a945f0b7f43ab7471
F src/btreeInt.h 6794084fad08c9750b45145743c0e3e5c27c94dee89f26dd8df7073314934fd2
F src/build.c 9b7153d93308783c801c5c36d9b4b3189ab4f00cd9ad6bf4d6c9750378a56be9
F src/build.c 67b1a8d3ac700747687dbdc49ded847a3c17fef450a8c919ac0399b44cbd4215
F src/callback.c 88615dfc0a82167b65b452b4b305dbf86be77200b3343c6ffc6d03e92a01d181
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 1b0724e66f95f33b160b1af85caaf9cceb325d22abf39bd24df4f54a73982251
@ -480,7 +480,7 @@ F src/date.c e1d8ac7102f3f283e63e13867acb0efa33861cf34f0faf4cdbaf9fa7a1eb7041
F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
F src/dbstat.c 6c407e549406c10fde9ac3987f6d734459205239ad370369bc5fcd683084a4fa
F src/delete.c a5c59b9c0251cf7682bc52af0d64f09b1aefc6781a63592c8f1136f7b73c66e4
F src/expr.c bef2f4c18a90fec59575dba1e32cc7d120af4120105bf503b843507f03f1d378
F src/expr.c 70af050710e92b16dac5498005e77a8fd799eda31cac19f641da5b0531cccb03
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 92a248ec0fa4ed8ab60c98d9b188ce173aaf218f32e7737ba77deb2a684f9847
F src/func.c 259496e4856bd0a3215d16804992f3339f3e8db29f129a5a7285c341488bbe9c
@ -526,14 +526,14 @@ F src/pragma.h ec3b31eac9b1df040f1cc8cb3d89bc06605c3b4cb3d76f833de8d6d6c3f77f04
F src/prepare.c 6049beb71385f017af6fc320d2c75a4e50b75e280c54232442b785fbb83df057
F src/printf.c 9be6945837c839ba57837b4bc3af349eba630920fa5532aa518816defe42a7d4
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c 241c32d6be93e72572f23e3dd1160036db377fa0707fcb04b69e4d1a034c5fe9
F src/resolve.c 3868d75d4bbf8e7d3c78b9cd9c8ec5b483d004cf671a35ee2f18e5ed907d4bde
F src/rowset.c d977b011993aaea002cab3e0bb2ce50cf346000dff94e944d547b989f4b1fe93
F src/select.c 8791103f21df458fdaba16c7d6452f92b00363f222f0f242661654f12455ea0a
F src/select.c 64bf450dc0f2b37be8d2be6ff7d25a70de37ef6fb64527c68f767fe9fe47bc55
F src/shell.c.in 69462c95793d69a16df93deabbd6d026f5f6ef6c87d9da54ed1477c03490d17b
F src/sqlite.h.in efaecabd038dc30282f243af087c4960e528d0df25a05f90f988435fec5ef779
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 72af51aa4e912e14cd495fb6e7fac65f0940db80ed950d90911aff292cc47ce2
F src/sqliteInt.h 03a952654df3b9a94fbe34a2cbeb73a3a613689fa2a61307a4709a68628ee16b
F src/sqliteInt.h a45a681d64b1f86e8baac511d81e7ac11825efb929081ae75601391a9e4e2e7d
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
F src/status.c 9ff2210207c6c3b4d9631a8241a7d45ab1b26a0e9c84cb07a9b5ce2de9a3b278
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
@ -593,7 +593,7 @@ F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
F src/tokenize.c 7b17f6e2f20f6cbcb0b215025a86b7457c38451fc7622f705e553d7a488c572d
F src/treeview.c 74d4fb2b6a2eaced4c0a6e22a9caf6e4a975577774456575065c5c921bdb3381
F src/treeview.c 2f712c821748dccced8977c33de83146e75a193afd17da3da8ad64e0225fee20
F src/trigger.c a40d50e88bd3355f1d2a73f0a3b2d6b42eae26ca4219001b82ef0d064439badc
F src/update.c 9ad19af96aff95dc02a923a99f97c1bc0b909009a29a2914b796f786b9ac0c60
F src/upsert.c 2920de71b20f04fe25eb00b655d086f0ba60ea133c59d7fa3325c49838818e78
@ -735,7 +735,7 @@ F test/chunksize.test 427d87791743486cbf0c3b8c625002f3255cb3a89c6eba655a98923b13
F test/close.test eccbad8ecd611d974cbf47278c3d4e5874faf02d811338d5d348af42d56d647c
F test/closure01.test 9905883f1b171a4638f98fc764879f154e214a306d3d8daf412a15e7f3a9b1e0
F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91
F test/collate1.test 4178fda6f4cd757b7a278e6b83805868fb1eb46edafb6e3d4bcc2419f8d93202
F test/collate1.test 532b4992f78e91dd80c2e3c7bd944fada8cbe3d6c0ded0b20f7182b4dfca0006
F test/collate2.test 9aaa410a00734e48bcb27f3872617d6f69b2a621
F test/collate3.test 89defc49983ddfbf0a0555aca8c0521a676f56a5
F test/collate4.test c953715fb498b87163e3e73dd94356bff1f317bd
@ -1199,7 +1199,7 @@ F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394
F test/optfuzz-db01.c a0c256905c8ac79f9a5de2f374a3d9f757bef0dca2a238dc7c10cc8a38031834
F test/optfuzz-db01.txt 21f6bdeadc701cf11528276e2a55c70bfcb846ba42df327f979bd9e7b6ce7041
F test/optfuzz.c 50e330304eb1992e15ddd11f3daaad9bcc0d9aaad09cb2bcc77f9515df2e88b1
F test/orderby1.test e4501f54721f804ca56922e253403ac6775f88e9f07569994ce99212b3ca5b10
F test/orderby1.test 6bf0ce45cbfb1cf4779dd418ac5e8cf66abfa04de2c1d2edf1e0e85f1520d8f3
F test/orderby2.test bc11009f7cd99d96b1b11e57b199b00633eb5b04
F test/orderby3.test 8619d06a3debdcd80a27c0fdea5c40b468854b99
F test/orderby4.test 4d39bfbaaa3ae64d026ca2ff166353d2edca4ba4
@ -1295,7 +1295,7 @@ F test/schema6.test e4bd1f23d368695eb9e7b51ef6e02ca0642ea2ab4a52579959826b5e7dce
F test/schemafault.test 1936bceca55ac82c5efbcc9fc91a1933e45c8d1e1d106b9a7e56c972a5a2a51e
F test/securedel.test 2f70b2449186a1921bd01ec9da407fbfa98c3a7a5521854c300c194b2ff09384
F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5
F test/select1.test 0aaefed5e770232effeba2d19b8dde01b639d617b844cb2492a75961e4119549
F test/select1.test 009a6d8eacd9684d046302b8d13b50846a87e39d6f08e92178aa13e95ea29a2d
F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56
F test/select3.test 3905450067c28766bc83ee397f6d87342de868baa60f2bcfd00f286dfbd62cb9
F test/select4.test 5389d9895968d1196c457d59b3ee6515d771d328
@ -1714,7 +1714,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 30f38038f2878a28befa66c288099e5da131ba673799d73d0864f08375d503e1
F test/window1.test b61afc46bad183e19dcd46119d908ee79aecfd5929e61d332dba4ce9c2c0b7b9
F test/window2.tcl 492c125fa550cda1dd3555768a2303b3effbeceee215293adf8871efc25f1476
F test/window2.test e466a88bd626d66edc3d352d7d7e1d5531e0079b549ba44efb029d1fbff9fd3c
F test/window3.tcl acea6e86a4324a210fd608d06741010ca83ded9fde438341cb978c49928faf03
@ -1733,7 +1733,7 @@ F test/windowB.test 7a983ea1cc1cf72be7f378e4b32f6cb2d73014c5cd8b25aaee825164cd42
F test/windowerr.tcl f5acd6fbc210d7b5546c0e879d157888455cd4a17a1d3f28f07c1c8a387019e0
F test/windowerr.test a8b752402109c15aa1c5efe1b93ccb0ce1ef84fa964ae1cd6684dd0b3cc1819b
F test/windowfault.test 8e3b69abe0eea9595ba3940afd9c63644e11966ed8815734b67f1479a8e9891a
F test/with1.test d32792084dcb5f6c047d77bb8a032822ef9fe050ade07d0aeffa37753a05e3c9
F test/with1.test 386d1c1763a9d369fd08ea03145869b6313ba263e1a102df5a275007000d1b47
F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab
F test/with3.test 7de8dff2891aca0f9453463e4a2d6eb995baf137827d5596116fee53e22a4e29
F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205
@ -1853,7 +1853,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 96a2db2612f2e47bbec0e374a242820c88f03c42ccbf8467abccaef41469bae2 51665bf0f975fb248964a4be205a4f3285d3f3f8cc697977d264efefbbe20dd8
R 8c7e397d4bcba49889cbfedd58b7bb0e
P 091403a6705f5f1352c76eacbfdca75fe0bab12ab9b156842641de07c38d3f66 536e9a9d1bd514056ecbc8172ed58f2656a86f791a15e526ae2e5f2c93687b6a
R 9513c96f193ce58d39e33f5bdd19fac1
U drh
Z 091b61bd8246d8cb46dad6a652b4937a
Z 07648178e3cddd9499b97db1756ee9dd

View File

@ -1 +1 @@
091403a6705f5f1352c76eacbfdca75fe0bab12ab9b156842641de07c38d3f66
002406df22995880d002be2e4cebb4d560283d4e0d7a4b5a34edcb110802b543

View File

@ -2638,7 +2638,7 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
&pTable->nCol, &pTable->aCol);
if( db->mallocFailed==0
&& ALWAYS(pParse->nErr==0)
&& pParse->nErr==0
&& pTable->nCol==pSel->pEList->nExpr
){
sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel,

View File

@ -1848,19 +1848,34 @@ int sqlite3SelectWalkFail(Walker *pWalker, Select *NotUsed){
return WRC_Abort;
}
/*
** Check the input string to see if it is "true" or "false" (in any case).
**
** If the string is.... Return
** "true" EP_IsTrue
** "false" EP_IsFalse
** anything else 0
*/
u32 sqlite3IsTrueOrFalse(const char *zIn){
if( sqlite3StrICmp(zIn, "true")==0 ) return EP_IsTrue;
if( sqlite3StrICmp(zIn, "false")==0 ) return EP_IsFalse;
return 0;
}
/*
** If the input expression is an ID with the name "true" or "false"
** then convert it into an TK_TRUEFALSE term. Return non-zero if
** the conversion happened, and zero if the expression is unaltered.
*/
int sqlite3ExprIdToTrueFalse(Expr *pExpr){
u32 v;
assert( pExpr->op==TK_ID || pExpr->op==TK_STRING );
if( !ExprHasProperty(pExpr, EP_Quoted)
&& (sqlite3StrICmp(pExpr->u.zToken, "true")==0
|| sqlite3StrICmp(pExpr->u.zToken, "false")==0)
&& (v = sqlite3IsTrueOrFalse(pExpr->u.zToken))!=0
){
pExpr->op = TK_TRUEFALSE;
ExprSetProperty(pExpr, pExpr->u.zToken[4]==0 ? EP_IsTrue : EP_IsFalse);
ExprSetProperty(pExpr, v);
return 1;
}
return 0;
@ -3605,6 +3620,9 @@ static int exprCodeInlineFunction(
VdbeCoverage(v);
sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
}
if( sqlite3VdbeGetOp(v, -1)->opcode==OP_Copy ){
sqlite3VdbeChangeP5(v, 1); /* Tag trailing OP_Copy as not mergable */
}
sqlite3VdbeResolveLabel(v, endCoalesce);
break;
}
@ -4592,6 +4610,7 @@ int sqlite3ExprCodeExprList(
&& (pOp=sqlite3VdbeGetOp(v, -1))->opcode==OP_Copy
&& pOp->p1+pOp->p3+1==inReg
&& pOp->p2+pOp->p3+1==target+i
&& pOp->p5==0 /* The do-not-merge flag must be clear */
){
pOp->p3++;
}else{

View File

@ -453,8 +453,7 @@ static int lookupName(
for(j=0; j<pEList->nExpr; j++){
char *zAs = pEList->a[j].zEName;
if( pEList->a[j].eEName==ENAME_NAME
&& ALWAYS(zAs!=0)
&& sqlite3StrICmp(zAs, zCol)==0
&& sqlite3_stricmp(zAs, zCol)==0
){
Expr *pOrig;
assert( pExpr->pLeft==0 && pExpr->pRight==0 );
@ -1133,10 +1132,8 @@ static int resolveAsName(
if( pE->op==TK_ID ){
char *zCol = pE->u.zToken;
for(i=0; i<pEList->nExpr; i++){
char *zAs = pEList->a[i].zEName;
if( pEList->a[i].eEName==ENAME_NAME
&& ALWAYS(zAs!=0)
&& sqlite3StrICmp(zAs, zCol)==0
&& sqlite3_stricmp(pEList->a[i].zEName, zCol)==0
){
return i+1;
}

View File

@ -202,6 +202,7 @@ void sqlite3SelectReset(Parse *pParse, Select *p){
memset(&p->iLimit, 0, sizeof(Select) - offsetof(Select,iLimit));
p->pEList = sqlite3ExprListAppend(pParse, 0,
sqlite3ExprAlloc(pParse->db,TK_NULL,0,0));
p->pSrc = sqlite3DbMallocZero(pParse->db, sizeof(SrcList));
}
}
@ -2003,7 +2004,7 @@ int sqlite3ColumnsFromExprList(
zName = pEList->a[i].zEName;
}
}
if( zName ){
if( zName && !sqlite3IsTrueOrFalse(zName) ){
zName = sqlite3DbStrDup(db, zName);
}else{
zName = sqlite3MPrintf(db,"column%d",i+1);

View File

@ -4260,6 +4260,7 @@ void sqlite3EndTransaction(Parse*,int);
void sqlite3Savepoint(Parse*, int, Token*);
void sqlite3CloseSavepoints(sqlite3 *);
void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
u32 sqlite3IsTrueOrFalse(const char*);
int sqlite3ExprIdToTrueFalse(Expr*);
int sqlite3ExprTruthValue(const Expr*);
int sqlite3ExprIsConstant(Expr*);

View File

@ -730,6 +730,7 @@ void sqlite3TreeViewBareExprList(
int j = pList->a[i].u.x.iOrderByCol;
char *zName = pList->a[i].zEName;
int moreToFollow = i<pList->nExpr - 1;
if( pList->a[i].eEName!=ENAME_NAME ) zName = 0;
if( j || zName ){
sqlite3TreeViewPush(pView, moreToFollow);
moreToFollow = 0;

View File

@ -436,4 +436,16 @@ do_faultsim_test 9.1 -faults oom* -body {
faultsim_test_result {0 {}}
}
# 2020-01-03 dbsqlfuzz find
#
reset_db
do_catchsql_test 10.0 {
CREATE TABLE t1(a INTEGER PRIMARY KEY,b);
INSERT INTO t1 VALUES(0,NULL);
CREATE TABLE t2(x UNIQUE);
CREATE VIEW v1a(z,y) AS SELECT x COLLATE x FROM t2;
SELECT a,b,z,y,'' FROM t1 JOIN v1a ON b IS NOT FALSE;
} {1 {no such collation sequence: x}}
finish_test

View File

@ -558,5 +558,9 @@ do_execsql_test 10.0 {
SELECT b, rowid, '^' FROM t10 ORDER BY b, a LIMIT 4;
} {2 1 ^ 4 3 ^ 4 4 ^ 7 5 ^}
do_catchsql_test 11.0 {
VALUES(2) EXCEPT SELECT '' ORDER BY abc
} {1 {1st ORDER BY term does not match any column in the result set}}
finish_test

View File

@ -1197,5 +1197,8 @@ do_execsql_test select-20.10 {
WHERE ((SELECT t1.a FROM t1 AS x GROUP BY b) AND b=0)
OR a = 10;
} {10 Y}
do_execsql_test select-20.20 {
SELECT ifnull(a, max((SELECT 123))), count(a) FROM t1 ;
} {10 1}
finish_test

View File

@ -1554,4 +1554,27 @@ do_execsql_test 46.4 {
OR ((SELECT sum(a)OVER(ORDER BY a)) AND a<=10)
} 10
#-------------------------------------------------------------------------
reset_db
do_execsql_test 47.0 {
CREATE TABLE t1(
a,
e,
f,
g UNIQUE,
h UNIQUE
);
}
do_execsql_test 47.1 {
CREATE VIEW t2(k) AS
SELECT e FROM t1 WHERE g = 'abc' OR h BETWEEN 10 AND f;
}
do_catchsql_test 47.2 {
SELECT 234 FROM t2
WHERE k=1
OR (SELECT k FROM t2 WHERE (SELECT sum(a) OVER() FROM t1 GROUP BY 1));
} {1 {misuse of window function sum()}}
finish_test

View File

@ -1140,4 +1140,28 @@ do_execsql_test 24.2 {
3 1 1 3
}
# 2020-01-02 chromium ticket 1033461
# Do not allow the generated name of a CTE be "true" or "false" as
# such a label might be later confused for the boolean literals of
# the same name, causing inconsistencies in the abstract syntax
# tree. This problem first arose in version 3.23.0 when SQLite
# began recognizing "true" and "false" as boolean literals, but also
# had to continue to recognize "true" and "false" as identifiers for
# backwards compatibility.
#
reset_db
do_execsql_test 25.1 {
CREATE TABLE dual(dummy);
INSERT INTO dual(dummy) VALUES('X');
WITH cte1 AS (
SELECT TRUE, (
WITH cte2 AS (SELECT avg(DISTINCT TRUE) FROM dual)
SELECT 2571 FROM cte2
) AS subquery1
FROM dual
GROUP BY 1
)
SELECT (SELECT 1324 FROM cte1) FROM cte1;
} {1324}
finish_test