From d3a4dbe4b84732a57393a1966bae5ab56460478e Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 26 Apr 2024 17:09:33 +0000 Subject: [PATCH] Further fixes and improvements to the generate_series() enhancements on this branch. FossilOrigin-Name: b7d9bd7ee2f4100608063fdf7648f290351465d393bc876a89704f643358853e --- ext/misc/series.c | 26 ++++++++++++++++++++------ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/ext/misc/series.c b/ext/misc/series.c index e355e5aab7..0dfed181f6 100644 --- a/ext/misc/series.c +++ b/ext/misc/series.c @@ -478,7 +478,9 @@ static int seriesBestIndex( ){ int i, j; /* Loop over constraints */ int idxNum = 0; /* The query plan bitmask */ +#ifndef ZERO_ARGUMENT_GENERATE_SERIES int bStartSeen = 0; /* EQ constraint seen on the START column */ +#endif int unusableMask = 0; /* Mask of unusable constraints */ int nArg = 0; /* Number of arguments that seriesFilter() expects */ int aIdx[5]; /* Constraints on start, stop, step, LIMIT, OFFSET */ @@ -495,11 +497,16 @@ static int seriesBestIndex( int iCol; /* 0 for start, 1 for stop, 2 for step */ int iMask; /* bitmask for those column */ int op = pConstraint->op; - if( op!=SQLITE_INDEX_CONSTRAINT_EQ ){ - if( op==SQLITE_INDEX_CONSTRAINT_LIMIT ){ + if( op>=SQLITE_INDEX_CONSTRAINT_LIMIT + && op<=SQLITE_INDEX_CONSTRAINT_OFFSET + ){ + if( pConstraint->usable==0 ){ + /* do nothing */ + }else if( op==SQLITE_INDEX_CONSTRAINT_LIMIT ){ aIdx[3] = i; idxNum |= 0x20; - }else if( op==SQLITE_INDEX_CONSTRAINT_OFFSET ){ + }else{ + assert( op==SQLITE_INDEX_CONSTRAINT_OFFSET ); aIdx[4] = i; idxNum |= 0x40; } @@ -509,11 +516,15 @@ static int seriesBestIndex( iCol = pConstraint->iColumn - SERIES_COLUMN_START; assert( iCol>=0 && iCol<=2 ); iMask = 1 << iCol; - if( iCol==0 ) bStartSeen = 1; +#ifndef ZERO_ARGUMENT_GENERATE_SERIES + if( iCol==0 && op==SQLITE_INDEX_CONSTRAINT_EQ ){ + bStartSeen = 1; + } +#endif if( pConstraint->usable==0 ){ unusableMask |= iMask; continue; - }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){ + }else if( op==SQLITE_INDEX_CONSTRAINT_EQ ){ idxNum |= iMask; aIdx[iCol] = i; } @@ -548,7 +559,7 @@ static int seriesBestIndex( ** this plan is unusable */ return SQLITE_CONSTRAINT; } - if( (idxNum & 3)==3 ){ + if( (idxNum & 0x03)==0x03 ){ /* Both start= and stop= boundaries are available. This is the ** the preferred case */ pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0)); @@ -561,6 +572,9 @@ static int seriesBestIndex( } pIdxInfo->orderByConsumed = 1; } + }else if( (idxNum & 0x21)==0x21 ){ + /* We have start= and LIMIT */ + pIdxInfo->estimatedRows = 2500; }else{ /* If either boundary is missing, we have to generate a huge span ** of numbers. Make this case very expensive so that the query diff --git a/manifest b/manifest index 6ebcff0402..8aa5658ec1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\shex\sflag\smasks\srather\sthan\sdecimals\sin\sext/misc/series.c. -D 2024-04-26T14:36:28.914 +C Further\sfixes\sand\simprovements\sto\sthe\sgenerate_series()\senhancements\son\nthis\sbranch. +D 2024-04-26T17:09:33.571 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -411,7 +411,7 @@ F ext/misc/regexp.c 4bdd0045912f81c84908bd535ec5ad3b1c8540b4287c70ab840709636240 F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 -F ext/misc/series.c ba7c22c607e24c42bd8e6f289e246abb997e6a11b76b1a385d6f4272eae1ac88 +F ext/misc/series.c d96e5aac21658c6b5d54f918ac140460ec7197734c1a4fba806950831a7b1e7a F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f08d F ext/misc/shathree.c 543af7ce71d391cd3a9ab6924a6a1124efc63211fd0f2e240dc4b56077ba88ac F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 @@ -2186,8 +2186,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 72c8ed9698dd2aadee7b84fd293e8306233f0fe5b5b5731687482444fdf461c7 -R e853dfcde05ddfe7b4221b55af72f1df +P a94e2cd02873c283d46bf6c21d0306ad454881d7882bb167d043cc79f79a2396 +R 321007e70e23799770941a10ae3004c2 U drh -Z 2da9867ae5f646560b353212baa0f0fb +Z 725229cc9017e5eea01f2ec07aa5dfdd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index bc24868c16..269ea1f24e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a94e2cd02873c283d46bf6c21d0306ad454881d7882bb167d043cc79f79a2396 \ No newline at end of file +b7d9bd7ee2f4100608063fdf7648f290351465d393bc876a89704f643358853e \ No newline at end of file -- 2.47.2