Merge recent trunk enchancements into the seekscan-improvements branch.

FossilOrigin-Name: d9e85fe80cdd3d798a583a5f99148235d0c3f39adfabbc661615893c387e6e45
This commit is contained in:
drh 2021-06-04 12:29:22 +00:00
commit 2540a7482a
12 changed files with 115 additions and 37 deletions

View File

@ -248,7 +248,7 @@ static int re_match(ReCompiled *pRe, const unsigned char *zIn, int nIn){
break;
}
case RE_OP_ANY: {
re_add_state(pNext, x+1);
if( c!=0 ) re_add_state(pNext, x+1);
break;
}
case RE_OP_WORD: {
@ -673,7 +673,7 @@ static const char *re_compile(ReCompiled **ppRe, const char *zIn, int noCase){
** regex engine over the string. Do not worry able trying to match
** unicode characters beyond plane 0 - those are very rare and this is
** just an optimization. */
if( pRe->aOp[0]==RE_OP_ANYSTAR ){
if( pRe->aOp[0]==RE_OP_ANYSTAR && !noCase ){
for(j=0, i=1; j<sizeof(pRe->zInit)-2 && pRe->aOp[i]==RE_OP_MATCH; i++){
unsigned x = pRe->aArg[i];
if( x<=127 ){
@ -719,7 +719,7 @@ static void re_sql_func(
if( pRe==0 ){
zPattern = (const char*)sqlite3_value_text(argv[0]);
if( zPattern==0 ) return;
zErr = re_compile(&pRe, zPattern, 0);
zErr = re_compile(&pRe, zPattern, sqlite3_user_data(context)!=0);
if( zErr ){
re_free(pRe);
sqlite3_result_error(context, zErr, -1);
@ -756,5 +756,11 @@ int sqlite3_regexp_init(
SQLITE_EXTENSION_INIT2(pApi);
rc = sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
0, re_sql_func, 0, 0);
if( rc==SQLITE_OK ){
/* The regexpi(PATTERN,STRING) function is a case-insensitive version
** of regexp(PATTERN,STRING). */
rc = sqlite3_create_function(db, "regexpi", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
(void*)db, re_sql_func, 0, 0);
}
return rc;
}

View File

@ -1,5 +1,5 @@
C Add\san\soptimization\scontrol\sbit\sto\sdisable\sthe\sOP_SeekScan\soptimization.
D 2021-06-02T19:28:07.128
C Merge\srecent\strunk\senchancements\sinto\sthe\sseekscan-improvements\sbranch.
D 2021-06-04T12:29:22.099
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -315,7 +315,7 @@ F ext/misc/noop.c 81efe4cad9ec740e64388b14281cb983e6e2c223fed43eb77ab3e34946e0c1
F ext/misc/normalize.c bd84355c118e297522aba74de34a4fd286fc775524e0499b14473918d09ea61f
F ext/misc/percentile.c b9086e223d583bdaf8cb73c98a6539d501a2fc4282654adbfea576453d82e691
F ext/misc/prefixes.c 0f4f8cff5aebc00a7e3ac4021fd59cfe1a8e17c800ceaf592859ecb9cbc38196
F ext/misc/regexp.c 246244c714267f303df76acf73dcf110cf2eaf076896aaaba8db6d6d21a129db
F ext/misc/regexp.c bc97bedcb504f6e885cc21f32e03302696c0498876ac10be0857dbeef534353f
F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c
F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c
F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946
@ -485,7 +485,7 @@ F src/auth.c 08954fdc4cc2da5264ba5b75cfd90b67a6fc7d1710a02ccf917c38eadec77853
F src/backup.c 3014889fa06e20e6adfa0d07b60097eec1f6e5b06671625f476a714d2356513d
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
F src/btree.c 51ba86095316fceb3e25bc61617d673d84627e79f4ace83f8722910f33eedef3
F src/btree.c 6b24d93490ea4450a6800eef046fedf29e5e5ba00efc896eef2da5bb2869ea2e
F src/btree.h 096cc53baa58be22b02c896d1cf933c38cfc6d65f9253c1367ece8cc88a24de5
F src/btreeInt.h 7bc15a24a02662409ebcd6aeaa1065522d14b7fda71573a2b0568b458f514ae0
F src/build.c d766f04ddd88822c2c10cf3c0dfb34b068c45f103f442222038b9eeff02312ca
@ -495,8 +495,8 @@ F src/ctime.c 3052b6b05ed9ef547a3dd66b8e01bfa9d582e78752ad6ed327da84652641e038
F src/date.c e0632f335952b32401482d099321bbf12716b29d6e72836b53ae49683ebae4bf
F src/dbpage.c 8a01e865bf8bc6d7b1844b4314443a6436c07c3efe1d488ed89e81719047833a
F src/dbstat.c 3aa79fc3aed7ce906e4ea6c10e85d657299e304f6049861fe300053ac57de36c
F src/delete.c 73f57a9a183532c344a3135cf8f2a5589376e39183e0b5f562d6b61b2af0f4d8
F src/expr.c 09f8ae1421d09802b4ac4b05c507761ecd142fa32cc0b1e33b9bd07fba10d34a
F src/delete.c 930e63df768dcb197242b1efa0ed9fcdcc9a7b7556c236ee01a9959b61cf527b
F src/expr.c f175b34cc0da572f899bb6591fd3510b17200702dce7d80226cd4e454f7cd83a
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c e9063648396c58778f77583a678342fe4a9bc82436bf23c5f9f444f2df0fdaa4
F src/func.c 88fd711754a7241cb9f8eb1391370fd0c0cea756b3358efa274c5d1efd59af93
@ -545,7 +545,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c 35630effd4d16d2373caa41bae40a3d71f853f3ad0cb4f572f2ed4b8c350c1e9
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c 2f4429e0b0ca031e360489c45dca5dfa06cd85480e12c0d1360b91e1c8e7f7a2
F src/shell.c.in 2a2b06d463933ee3a5bb0242d5d2200ca36769493fd6f4d939a0574113f3d6d8
F src/shell.c.in ab37c8869390a7624e594cb1459277319d16521d4644c42f4ee6a3866cf5f0cd
F src/sqlite.h.in 5c950066775ca9efdaa49077c05d38d0bef6418f3bd07d2dce0210f1d2f3c326
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 61b38c073d5e1e96a3d45271b257aef27d0d13da2bea5347692ae579475cd95e
@ -616,7 +616,7 @@ F src/upsert.c df8f1727d62b5987c4fd302cd4d7c0c84ae57cd65683c5a34a740dfe24039235
F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0
F src/util.c 41c7a72da1df47864faa378a1c720b38adb288c6838cb6be5594511b6287a048
F src/vacuum.c 492422c1463c076473bae1858799c7a0a5fe87a133d1223239447c422cd26286
F src/vdbe.c bcb074ce72ad18723ce01d21d389dac60069270a42fb5e832dc567ccc62b6a13
F src/vdbe.c a51f4947380b0561ef70730e1144bf3837216cfea61a59a498149d47eeb09943
F src/vdbe.h 25dabb25c7e157b84e59260cfb5b466c3ac103ede9f36f4db371332c47601abe
F src/vdbeInt.h 58980223a32495ad059d10581b83e133abdc77248b1bab85c080cab8a13bd819
F src/vdbeapi.c d9e99daf59fec928986838b3389a7337e82fec6b3b5de30206cb99fb4661b94e
@ -836,10 +836,10 @@ F test/dbstatus.test 4a4221a883025ffd39696b3d1b3910b928fb097d77e671351acb35f3aed
F test/dbstatus2.test f5fe0afed3fa45e57cfa70d1147606c20d2ba23feac78e9a172f2fe8ab5b78ef
F test/decimal.test fcf403fd5585f47342234e153c4a4338cd737b8e0884ac66fc484df47dbcf1a7
F test/default.test 9687cfb16717e4b8238c191697c98be88c0b16e568dd5368cd9284154097ef50
F test/delete.test 31832b0c45ecb51a54348c68db173be462985901e6ed7f403d6d7a8f70ab4ef0
F test/delete.test 438c14fdf2f2a520b63f892ea645896acf8832e2a2308578593d8e05274314b1
F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa
F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab
F test/delete4.test 6aa279f459f4aa792cc251435c3809415c1ecaf9f27dce91675e26f05b503db3
F test/delete4.test 51fafebe9503a40796d1aae1565c60524cada720e50eecac01b7fd0419d9ea0b
F test/delete_db.test 096d828493c7907f9ea11a7098ea6a0f73edba89406487d5d6cc2228dc4ab8b0
F test/descidx1.test edc8adee58d491b06c7157c50364eaf1c3605c9c19f8093cb1ea2b6184f3ac13
F test/descidx2.test a0ba347037ff3b811f4c6ceca5fd0f9d5d72e74e59f2d9de346a9d2f6ad78298
@ -1292,7 +1292,7 @@ F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df
F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736
F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8
F test/recover.test ccb8c2623902a92ebb76770edd075cb4f75a4760bb7afde38026572c6e79070d
F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8
F test/regexp1.test 0c3ff80f66b0eff80e623eb5db7a3dad512095c573d78ac23009785f6d8f51ce
F test/regexp2.test 40e894223b3d6672655481493f1be12012f2b33c
F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d
F test/releasetest.tcl 6f803ef0b896f8f3f4c26eb072c0399963a5987a509a64d45f5dfbc1ebae2951 x
@ -1307,7 +1307,7 @@ F test/round1.test 768018b04522ca420b1aba8a24bd76091d269f3bce3902af3ec6ebcee41ab
F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc
F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
F test/rowid.test bfbd7b97d9267660be3c8f28507c4ed7f205196b8877c0db42df347c2e8845e3
F test/rowvalue.test 466efbb7bb93ca9f95d89f69c7c140aa52cc57ac6dfa7efba09ea4a9ab3cd9f0
F test/rowvalue.test 37effea4dd83555ea969a9461dfcffb25e6731a5db7c388e232410999c100853
F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b
F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256
F test/rowvalue4.test 441e7e366ac6d939a3a95a574031c56ec2a854077a91d66eee5ff1d86cb5be58
@ -1918,7 +1918,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 a87f8ecd6db11ea40a15314b875fc78289c19ab2dec6f738b4bf37f4aafa7bbd
R 0673ef2c1144007e5dc9919859a8d932
P f674c41e5cbbb08ffc3cc00ab449229b672054c872e209337f12e7eacb531fe5 4a587c3492faa99490fd67ca1de9fceafcdc12d220f42817791923be258b73f1
R e31162f50a8fe0f7f09f83d8467f9ef2
U drh
Z e77ba6d1357c1434f617cbb216a877e4
Z f3a9a5e483214de7c18a55211d90eb86

View File

@ -1 +1 @@
f674c41e5cbbb08ffc3cc00ab449229b672054c872e209337f12e7eacb531fe5
d9e85fe80cdd3d798a583a5f99148235d0c3f39adfabbc661615893c387e6e45

View File

@ -9494,8 +9494,8 @@ static int clearDatabasePage(
if( !pPage->leaf ){
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
if( rc ) goto cleardatabasepage_out;
}else if( pnChange ){
assert( pPage->intKey || CORRUPT_DB );
}
if( pnChange ){
testcase( !pPage->intKey );
*pnChange += pPage->nCell;
}
@ -9520,9 +9520,8 @@ cleardatabasepage_out:
** read cursors on the table. Open write cursors are moved to the
** root of the table.
**
** If pnChange is not NULL, then table iTable must be an intkey table. The
** integer value pointed to by pnChange is incremented by the number of
** entries in the table.
** If pnChange is not NULL, then the integer value pointed to by pnChange
** is incremented by the number of entries in the table.
*/
int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
int rc;

View File

@ -428,6 +428,9 @@ void sqlite3DeleteFrom(
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
assert( pIdx->pSchema==pTab->pSchema );
sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
sqlite3VdbeChangeP3(v, -1, memCnt ? memCnt : -1);
}
}
}else
#endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */

View File

@ -6005,6 +6005,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
*/
struct AggInfo_func *pItem = pAggInfo->aFunc;
for(i=0; i<pAggInfo->nFunc; i++, pItem++){
if( pItem->pFExpr==pExpr ) break;
if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){
break;
}

View File

@ -1027,6 +1027,7 @@ INCLUDE ../ext/misc/uint.c
INCLUDE ../ext/misc/decimal.c
INCLUDE ../ext/misc/ieee754.c
INCLUDE ../ext/misc/series.c
INCLUDE ../ext/misc/regexp.c
#ifdef SQLITE_HAVE_ZLIB
INCLUDE ../ext/misc/zipfile.c
INCLUDE ../ext/misc/sqlar.c
@ -4615,6 +4616,7 @@ static void open_db(ShellState *p, int openFlags){
sqlite3_completion_init(p->db, 0, 0);
sqlite3_uint_init(p->db, 0, 0);
sqlite3_decimal_init(p->db, 0, 0);
sqlite3_regexp_init(p->db, 0, 0);
sqlite3_ieee_init(p->db, 0, 0);
sqlite3_series_init(p->db, 0, 0);
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)

View File

@ -6241,11 +6241,10 @@ case OP_Destroy: { /* out2 */
** P2==1 then the table to be clear is in the auxiliary database file
** that is used to store tables create using CREATE TEMPORARY TABLE.
**
** If the P3 value is non-zero, then the table referred to must be an
** intkey table (an SQL table, not an index). In this case the row change
** count is incremented by the number of rows in the table being cleared.
** If P3 is greater than zero, then the value stored in register P3 is
** also incremented by the number of rows in the table being cleared.
** If the P3 value is non-zero, then the row change count is incremented
** by the number of rows in the table being cleared. If P3 is greater
** than zero, then the value stored in register P3 is also incremented
** by the number of rows in the table being cleared.
**
** See also: Destroy
*/
@ -6256,9 +6255,7 @@ case OP_Clear: {
nChange = 0;
assert( p->readOnly==0 );
assert( DbMaskTest(p->btreeMask, pOp->p2) );
rc = sqlite3BtreeClearTable(
db->aDb[pOp->p2].pBt, (u32)pOp->p1, (pOp->p3 ? &nChange : 0)
);
rc = sqlite3BtreeClearTable(db->aDb[pOp->p2].pBt, (u32)pOp->p1, &nChange);
if( pOp->p3 ){
p->nChange += nChange;
if( pOp->p3>0 ){

View File

@ -100,7 +100,7 @@ do_test delete-5.2.1 {
} {200}
do_test delete-5.2.2 {
execsql {DELETE FROM table1}
} {200}
} {202}
do_test delete-5.2.3 {
execsql {BEGIN TRANSACTION}
for {set i 1} {$i<=200} {incr i} {

View File

@ -59,14 +59,22 @@ do_execsql_test 2.3 {
#-------------------------------------------------------------------------
#
reset_db
do_execsql_test 3.1 {
do_execsql_test 3.0.1 {
CREATE TABLE t1(a, b, PRIMARY KEY(a, b)) WITHOUT ROWID;
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(2, 4);
INSERT INTO t1 VALUES(1, 5);
DELETE FROM t1 WHERE a=1;
SELECT printf('(%d)',changes());
SELECT * FROM t1;
} {2 4}
} {(2) 2 4}
do_execsql_test 3.0.2 {
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
INSERT INTO t1(a,b) SELECT x, x+1 FROM c;
SELECT printf('(%d)',changes());
DELETE FROM t1;
SELECT printf('(%d)',changes());
} {(100) (101)}
#-------------------------------------------------------------------------
# DELETE statement that uses the OR optimization

View File

@ -28,18 +28,49 @@ do_test regexp1-1.1 {
}
} {1 3}
do_execsql_test regexp1-1.1.2 {
SELECT regexpi('abc','ABC');
} {1}
do_execsql_test regexp1-1.1.3 {
SELECT regexpi('ABC','ABC');
} {1}
do_execsql_test regexp1-1.1.4 {
SELECT regexpi('ABC','abc');
} {1}
do_execsql_test regexp1-1.1.5 {
SELECT regexpi('ABC.','ABC');
} {0}
do_execsql_test regexp1-1.2 {
SELECT x FROM t1 WHERE y REGEXP 'by|in' ORDER BY x;
} {1 2 3 4}
do_execsql_test regexp1-1.3 {
do_execsql_test regexp1-1.3.1 {
SELECT x FROM t1 WHERE y REGEXP 'by|Christ' ORDER BY x;
} {1 2 4}
do_execsql_test regexp1-1.3.2 {
SELECT x FROM t1 WHERE regexp('by|christ',y) ORDER BY x;
} {1 2}
do_execsql_test regexp1-1.3.3 {
SELECT x FROM t1 WHERE regexpi('by|christ',y) ORDER BY x;
} {1 2 4}
do_execsql_test regexp1-1.3.4 {
SELECT x FROM t1 WHERE regexpi('BY|CHRIST',y) ORDER BY x;
} {1 2 4}
do_execsql_test regexp1-1.4 {
SELECT x FROM t1 WHERE y REGEXP 'shal+ al+' ORDER BY x;
} {4}
do_execsql_test regexp1-1.5 {
do_execsql_test regexp1-1.5.1 {
SELECT x FROM t1 WHERE y REGEXP 'shall x*y*z*all' ORDER BY x;
} {4}
do_execsql_test regexp1-1.5.2 {
SELECT x FROM t1 WHERE regexp('shall x*y*z*all',y) ORDER BY x;
} {4}
do_execsql_test regexp1-1.5.3 {
SELECT x FROM t1 WHERE regexp('SHALL x*y*z*all',y) ORDER BY x;
} {}
do_execsql_test regexp1-1.5.4 {
SELECT x FROM t1 WHERE regexpi('SHALL x*y*z*all',y) ORDER BY x;
} {4}
do_execsql_test regexp1-1.6 {
SELECT x FROM t1 WHERE y REGEXP 'shallx?y? ?z?all' ORDER BY x;
} {4}

View File

@ -663,4 +663,35 @@ do_catchsql_test 29.1 {
SELECT (SELECT 1 WHERE ((SELECT 1 WHERE (2,(2,0)) IS (2,(20))),(2,0)) IS (2,(20))) WHERE (2,(2,0)) IS (2 IN(SELECT 1 WHERE (2,(2,2,0)) IS (2,(20))),(20));
} {1 {row value misused}}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 30.0 {
CREATE TABLE t1(x, y, z);
CREATE TABLE t2(a, b);
INSERT INTO t1 VALUES(1000, 2000, 3000);
INSERT INTO t2 VALUES(NULL, NULL);
}
do_execsql_test 30.1 {
UPDATE t2 SET (a,b)=(
SELECT max( t1.x ) OVER( PARTITION BY sum( (SELECT t1.y) ) ), 2
)
FROM t1;
} {}
do_execsql_test 30.2 {
SELECT * FROM t2
} {1000 2}
reset_db
do_execsql_test 30.3 {
CREATE TABLE t1(x INT PRIMARY KEY, y, z);
CREATE TABLE t2(a,b,c,d,e,PRIMARY KEY(a,b))WITHOUT ROWID;
UPDATE t2 SET (d,d,a)=(SELECT EXISTS(SELECT 1 IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT y FROM t1 UNION SELECT x ORDER BY 1)))INTERSECT SELECT EXISTS(SELECT 1 FROM t1 UNION SELECT x ORDER BY 1) ORDER BY 1) ORDERa)|9 AS blob, 2, 3) FROM t1 WHERE x<a;
}
finish_test