]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
In the name resolver when SQLITE_ALLOW_ROWID_IN_INDEX is enabled, if there
authordrh <>
Tue, 19 Mar 2024 16:34:32 +0000 (16:34 +0000)
committerdrh <>
Tue, 19 Mar 2024 16:34:32 +0000 (16:34 +0000)
are multiple views that might resolve to the "rowid" but only one real table,
then use that one real table and ignore the views.

FossilOrigin-Name: 8fcea4cdfc89dd78eca5e7f62aa31aff0e296f41e79349d3af1cc3a2bc4d77c6

manifest
manifest.uuid
src/ctime.c
src/resolve.c
test/unionall.test

index c5b4e813c0ac6f29a0b861a09aa909dc1d5dedba..98c9af5c57a13635a1bfefb02c695661c860233d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Update\stests\sto\swork\swith\sSQLITE_ALLOW_ROWID_IN_VIEW.
-D 2024-03-19T15:27:15.880
+C In\sthe\sname\sresolver\swhen\sSQLITE_ALLOW_ROWID_IN_INDEX\sis\senabled,\sif\sthere\nare\smultiple\sviews\sthat\smight\sresolve\sto\sthe\s"rowid"\sbut\sonly\sone\sreal\stable,\nthen\suse\sthat\sone\sreal\stable\sand\signore\sthe\sviews.
+D 2024-03-19T16:34:32.133
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -695,7 +695,7 @@ F src/btreeInt.h 98aadb6dcb77b012cab2574d6a728fad56b337fc946839b9898c4b4c969e30b
 F src/build.c 71445e2d1e2c78b120a20a46d80a29a9ea42370df430efda5bb6ef377e8016c8
 F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490
 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
-F src/ctime.c 64e4b1227b4ed123146f0aa2989131d1fbd9b927b11e80c9d58c6a68f9cd5ce3
+F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b
 F src/date.c 126ba2ab10aeb2e7ba6e089b5f07b747c0625b8287f78b60da346eda8d23c875
 F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782
 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43
@@ -748,7 +748,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7
 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c
 F src/printf.c 87b67bba3662a0523f39ae6b084a3907109702f717c654d6cecb838af5cd57f1
 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
-F src/resolve.c ef87e3bc7700bfe761a7bbee2ce6084f1766dc816dd82a3ae77c133eec898432
+F src/resolve.c f851f7cce8cca274f82242b09e2fab67a42fa52de21c8a25cbdb490b057004ac
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c ac3689a3f54f81e8b710ce772c5c49c13a152e4ac484c2429ad5264243e7de66
 F src/shell.c.in a2ccceb9a250613f8156b098736bd94424c422972a1c1ddda35604531ae1762e
@@ -1887,7 +1887,7 @@ F test/types.test bf816ce73c7dfcfe26b700c19f97ef4050d194ff
 F test/types2.test 1aeb81976841a91eef292723649b5c4fe3bc3cac
 F test/types3.test c9db8f9e80309edfa4252585cf16bcab7ed31f39eeb904d21e831199a3613fb0
 F test/unhex.test b7f1b806207cb77fa31c3e434fe92fba524464e3e9356809bfcc28f15af1a8b7
-F test/unionall.test 5b1c4186a661e4bf762875caf4c61d8fda3dd04a6fa9005187f6ba8900c2913f
+F test/unionall.test cdae0b1b47128991d0c26075e552cbb1c1fa0b62c4fa7ffa5575e65a5e9fe834
 F test/unionall2.test 71e8fa08d5699d50dc9f9dc0c9799c2e7a6bb7931a330d369307a4df7f157fa1
 F test/unionallfault.test 652bfbb630e6c43135965dc1e8f0a9a791da83aec885d626a632fe1909c56f73
 F test/unionvtab.test e1704ab1b4c1bb3ffc9da4681f8e85a0b909fd80b937984fc94b27415ac8e5a4
@@ -2180,8 +2180,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 0d711aaaa14472a82f8893e1b07d845073f3d018bd5b8093ec0b00ffbbc8cd5a
-R 9a00ab01baff88b608a562a16a741256
-U dan
-Z 3b22054791de9eb30bbf5d96e1597df1
+P 495b8c7b08b998ddfe2ad055703f058c768e7e94014952e5cd8a81c7c1515cb1
+R 8eb7d29f7ff85a3768eaeec1cf36e8a2
+U drh
+Z 689a4a1a83e57ca389a38b62f6fe8edf
 # Remove this line to create a well-formed Fossil manifest.
index 2d1f2cba9433e2025adfd012930aff6ae59277b0..0ad3f9c5669dd6705d34235658c02214ed654743 100644 (file)
@@ -1 +1 @@
-495b8c7b08b998ddfe2ad055703f058c768e7e94014952e5cd8a81c7c1515cb1
\ No newline at end of file
+8fcea4cdfc89dd78eca5e7f62aa31aff0e296f41e79349d3af1cc3a2bc4d77c6
\ No newline at end of file
index 0ffe2a5bdf1ee9e145dd121b1ec42908094d206e..cf761299fe5b059b9bd6162444824942b7e383c4 100644 (file)
@@ -65,9 +65,6 @@ static const char * const sqlite3azCompileOpt[] = {
   "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN),
 # endif
 #endif
-#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
-  "ALLOW_ROWID_IN_VIEW",
-#endif
 #ifdef SQLITE_ALLOW_URI_AUTHORITY
   "ALLOW_URI_AUTHORITY",
 #endif
index c2957a870a29e4708c484e7b2ea5be35830e36e3..29719361054ee9a5170adc944c4aa1c65caafb11 100644 (file)
@@ -469,8 +469,37 @@ static int lookupName(
           }
         }
         if( 0==cnt && VisibleRowid(pTab) ){
+          /* pTab is a potential ROWID match.  Keep track of it and match
+          ** the ROWID later if that seems appropriate.  (Search for "cntTab"
+          ** to find related code.)  Only allow a ROWID match if there is
+          ** a single ROWID match candidate.
+          */
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+          /* In SQLITE_ALLOW_ROWID_IN_VIEW mode, allow a ROWID match
+          ** if there is a single VIEW candidate or if there is a single
+          ** non-VIEW candidate plus multiple VIEW candidates.  In other
+          ** words non-VIEW candidate terms take precedence over VIEWs.
+          */
+          if( cntTab==0
+           || (cntTab==1
+               && ALWAYS(pMatch!=0)
+               && ALWAYS(pMatch->pTab!=0)
+               && (pMatch->pTab->tabFlags & TF_Ephemeral)!=0
+               && (pTab->tabFlags & TF_Ephemeral)==0)
+          ){
+            cntTab = 1;
+            pMatch = pItem;
+          }else{
+            cntTab++;
+          }
+#else
+          /* The (much more common) non-SQLITE_ALLOW_ROWID_IN_VIEW case is
+          ** simpler since we require exactly one candidate, which will
+          ** always be a non-VIEW
+          */
           cntTab++;
           pMatch = pItem;
+#endif
         }
       }
       if( pMatch ){
index 99cb48a259d50a8431076d3e2516574a37ff88e5..ae1a271bfcb3ef8285658507159bd7e5663cf747 100644 (file)
@@ -351,7 +351,7 @@ do_catchsql_test 5.30 {
   SELECT * FROM (t1 NATURAL JOIN pragma_table_xinfo('t1_a') NATURAL JOIN t3) t1
                 NATURAL JOIN t2 NATURAL JOIN t3
    WHERE rowid ISNULL>0 AND 0%y;
-} {1 {no such column: rowid}}
+} {/1 {no such column: [a-z]+}/}
 }
 
 reset_db