Add a test-control to disable the skip-scan optimization.
FossilOrigin-Name: 650a3fe03d61068e06f3097878a777ca8ed713a769444cdb3f8be7d1e19a0b83
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 4071be1..f84cd78 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -1583,6 +1583,7 @@
/* TH3 expects the Stat34 ^^^^^^ value to be 0x0800. Don't change it */
#define SQLITE_PushDown 0x1000 /* The push-down optimization */
#define SQLITE_SimplifyJoin 0x2000 /* Convert LEFT JOIN to JOIN */
+#define SQLITE_SkipScan 0x4000 /* Skip-scans */
#define SQLITE_AllOpts 0xffff /* All optimizations */
/*
diff --git a/src/test1.c b/src/test1.c
index b62c310..1276505 100644
--- a/src/test1.c
+++ b/src/test1.c
@@ -6954,6 +6954,7 @@
{ "omit-noop-join", SQLITE_OmitNoopJoin },
{ "stat3", SQLITE_Stat34 },
{ "stat4", SQLITE_Stat34 },
+ { "skip-scan", SQLITE_SkipScan },
};
if( objc!=4 ){
diff --git a/src/where.c b/src/where.c
index f83c429..aa7567f 100644
--- a/src/where.c
+++ b/src/where.c
@@ -2672,6 +2672,7 @@
if( saved_nEq==saved_nSkip
&& saved_nEq+1<pProbe->nKeyCol
&& pProbe->noSkipScan==0
+ && OptimizationEnabled(db, SQLITE_SkipScan)
&& pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
&& (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
){