From: drh <> Date: Thu, 25 Apr 2024 16:55:53 +0000 (+0000) Subject: Back out the previous change on this branch. In its place: Determine the X-Git-Tag: version-3.46.0~44^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=23afc2c4ec1abc95f61e75411926527e93ebb500;p=thirdparty%2Fsqlite.git Back out the previous change on this branch. In its place: Determine the affinity of a subquery by the left-most arm of the subquery that has an affinity other than NONE. In other words, scan from left to right looking for an arm of the compound subquery with an affinity of BLOB, TEXT, INTEGER, or REAL and pick the first one found. Or stay with NONE if no arm has a defined affinity. Test cases added. FossilOrigin-Name: b8ec8511b1968bbc1472b3e2e21f0fef1d5becebeb31f9d13ee3ca9e13abb1e5 --- diff --git a/manifest b/manifest index 14d0ac506e..91f3bc3d8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\sexperimental\sminor\stweak\sto\sthe\sway\saffinities\sare\scomputed\sfor\scompound\nsubqueries,\swhen\sthe\sactual\saffinity\sis\sambiguous. -D 2024-04-24T19:49:52.341 +C Back\sout\sthe\sprevious\schange\son\sthis\sbranch.\s\sIn\sits\splace:\s\sDetermine\sthe\naffinity\sof\sa\ssubquery\sby\sthe\sleft-most\sarm\sof\sthe\ssubquery\sthat\shas\san\naffinity\sother\sthan\sNONE.\s\sIn\sother\swords,\sscan\sfrom\sleft\sto\sright\slooking\nfor\san\sarm\sof\sthe\scompound\ssubquery\swith\san\saffinity\sof\sBLOB,\sTEXT,\sINTEGER,\nor\sREAL\sand\spick\sthe\sfirst\sone\sfound.\s\sOr\sstay\swith\sNONE\sif\sno\sarm\shas\sa\ndefined\saffinity.\s\sTest\scases\sadded. +D 2024-04-25T16:55:53.038 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -751,7 +751,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 647edf93729ba124c0a6048982af56c2fa4f841e69d626e4f3caa620f082bb15 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 39c5dc8b2fca3b1e52db1a9b469507bfc312d3e3a4bf10c58a7a716626c4bdff +F src/select.c f0f8f7fd601aff50c303205c6ac6da789d02a6e420ccb25d9aaaeccc7fa314d7 F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199 F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1929,7 +1929,7 @@ F test/values.test 52102ad9e5068b449429e40a976486a52246041f7cd79d086a2b170e77dec F test/valuesfault.test 2ef23ed965e3bd08e268cdc38a0d11653390ddbbe1e8e2e98d16f55edd30f6e8 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 -F test/view.test 9df7e00eb1f96a9d738a317137989a594541ce7b9ebea0506e39f89de0c1319a +F test/view.test 3c23d7a068e9e4a0c4e6907498042772adea725f0630c3d9638ffd4e5a08b92b F test/view2.test db32c8138b5b556f610b35dfddd38c5a58a292f07fda5281eedb0851b2672679 F test/view3.test ad8a8290ee2b55ff6ce66c9ef1ce3f1e47926273a3814e1c425293e128a95456 F test/vt02.c 5b44ac67b1a283fedecf2d6e2ceda61e7a157f01d44dcb4490dcb1e87d057060 @@ -2185,11 +2185,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 9ea6bcc8fdf6aadb756ec5bcaaa7af314167f8973bdd32fd23f83bd964f0c21e -R 069cab252330979e2eef5b88f83953a3 -T *branch * compound-subquery-affinity -T *sym-compound-subquery-affinity * -T -sym-trunk * +P 779723ad792ca24dd07b7a1425303c76b44bb173e718a33c26c9f7644e9912cb +R 365eec55f15f0f323e41980c307a2a9e U drh -Z 7c2ae6bcf3d76ce120ccc503dbc0842f +Z 924642415660e94bafdaa96d702ef424 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b78d32b4c4..208bda000a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -779723ad792ca24dd07b7a1425303c76b44bb173e718a33c26c9f7644e9912cb \ No newline at end of file +b8ec8511b1968bbc1472b3e2e21f0fef1d5becebeb31f9d13ee3ca9e13abb1e5 \ No newline at end of file diff --git a/src/select.c b/src/select.c index d391762039..785f9bc255 100644 --- a/src/select.c +++ b/src/select.c @@ -2336,17 +2336,21 @@ void sqlite3SubqueryColumnTypes( for(i=0, pCol=pTab->aCol; inCol; i++, pCol++){ const char *zType; i64 n; + Select *pS2 = pSelect; pTab->tabFlags |= (pCol->colFlags & COLFLAG_NOINSERT); p = a[i].pExpr; /* pCol->szEst = ... // Column size est for SELECT tables never used */ pCol->affinity = sqlite3ExprAffinity(p); + while( pCol->affinity<=SQLITE_AFF_NONE && pS2->pNext!=0 ){ + pS2 = pS2->pNext; + pCol->affinity = sqlite3ExprAffinity(pS2->pEList->a[i].pExpr); + } if( pCol->affinity<=SQLITE_AFF_NONE ){ pCol->affinity = aff; } - if( pCol->affinity>=SQLITE_AFF_TEXT && pSelect->pNext ){ + if( pCol->affinity>=SQLITE_AFF_TEXT && pS2->pNext ){ int m = 0; - Select *pS2; - for(m=0, pS2=pSelect->pNext; pS2; pS2=pS2->pNext){ + for(m=0, pS2=pS2->pNext; pS2; pS2=pS2->pNext){ m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr); } if( pCol->affinity==SQLITE_AFF_TEXT && (m&0x01)!=0 ){ @@ -6417,7 +6421,7 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ /* A sub-query in the FROM clause of a SELECT */ Select *pSel = pFrom->pSelect; if( pSel ){ - sqlite3SubqueryColumnTypes(pParse, pTab, pSel, SQLITE_AFF_BLOB); + sqlite3SubqueryColumnTypes(pParse, pTab, pSel, SQLITE_AFF_NONE); } } } diff --git a/test/view.test b/test/view.test index 612e0cc2e4..241742025c 100644 --- a/test/view.test +++ b/test/view.test @@ -737,16 +737,16 @@ do_execsql_test view-27.5 { do_execsql_test view-27.6 { SELECT c0