Further improvements to the computation of affinity for compound subqueries:
make sure that the selected affinity is compatible with a literal values in arms to the left of the arm that is used to determine affinity. FossilOrigin-Name: bbdf22e3d989f42b963f1f2f219dfeac11db786f17ac27097ab72f72e7638a2a
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
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
|
||||
C Further\simprovements\sto\sthe\scomputation\sof\saffinity\sfor\scompound\ssubqueries:\nmake\ssure\sthat\sthe\sselected\saffinity\sis\scompatible\swith\sa\sliteral\svalues\sin\narms\sto\sthe\sleft\sof\sthe\sarm\sthat\sis\sused\sto\sdetermine\saffinity.
|
||||
D 2024-04-25T17:52:10.004
|
||||
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 f0f8f7fd601aff50c303205c6ac6da789d02a6e420ccb25d9aaaeccc7fa314d7
|
||||
F src/select.c 04178566d0188be7de471064ced8cec1d407920726cb49b609486282d78faf56
|
||||
F src/shell.c.in 0354ca51eee5fbf6af394a7ef9f5ef6823ef45b743db65431f6777e4d5be2199
|
||||
F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
@@ -1662,7 +1662,7 @@ F test/stmtvtab1.test 6873dfb24f8e79cbb5b799b95c2e4349060eb7a3b811982749a84b3594
|
||||
F test/strict1.test 4d2b492152b984fd7e8196d23eb88e2ccb0ef9e46ca2f96c2ce7147ceef9d168
|
||||
F test/strict2.test b22c7a98b5000aef937f1990776497f0e979b1a23bc4f63e2d53b00e59b20070
|
||||
F test/subjournal.test 8d4e2572c0ee9a15549f0d8e40863161295107e52f07a3e8012a2e1fdd093c49
|
||||
F test/subquery.test 312c5d26304b0e93a56ba2cb9d4480b8a1c8217e3b2b8f8be2bfb0b2458ac3a7
|
||||
F test/subquery.test 903abf41049f8404256f7be24b3151328304a5b25162e17ab0079460237382fc
|
||||
F test/subquery2.test 90cf944b9de8204569cf656028391e4af1ccc8c0cc02d4ef38ee3be8de1ffb12
|
||||
F test/subselect.test 0966aa8e720224dbd6a5e769a3ec2a723e332303
|
||||
F test/substr.test a673e3763e247e9b5e497a6cacbaf3da2bd8ec8921c0677145c109f2e633f36b
|
||||
@@ -2185,8 +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 779723ad792ca24dd07b7a1425303c76b44bb173e718a33c26c9f7644e9912cb
|
||||
R 365eec55f15f0f323e41980c307a2a9e
|
||||
P b8ec8511b1968bbc1472b3e2e21f0fef1d5becebeb31f9d13ee3ca9e13abb1e5
|
||||
R a7fab6239835ca1909d168c0371f9e50
|
||||
U drh
|
||||
Z 924642415660e94bafdaa96d702ef424
|
||||
Z 0a86570527084dd8d6c773960419770f
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
b8ec8511b1968bbc1472b3e2e21f0fef1d5becebeb31f9d13ee3ca9e13abb1e5
|
||||
bbdf22e3d989f42b963f1f2f219dfeac11db786f17ac27097ab72f72e7638a2a
|
||||
+4
-3
@@ -2336,21 +2336,22 @@ void sqlite3SubqueryColumnTypes(
|
||||
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
|
||||
const char *zType;
|
||||
i64 n;
|
||||
int m = 0;
|
||||
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 ){
|
||||
m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr);
|
||||
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 && pS2->pNext ){
|
||||
int m = 0;
|
||||
for(m=0, pS2=pS2->pNext; pS2; pS2=pS2->pNext){
|
||||
if( pCol->affinity>=SQLITE_AFF_TEXT && (pS2->pNext || pS2!=pSelect) ){
|
||||
for(pS2=pS2->pNext; pS2; pS2=pS2->pNext){
|
||||
m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr);
|
||||
}
|
||||
if( pCol->affinity==SQLITE_AFF_TEXT && (m&0x01)!=0 ){
|
||||
|
||||
@@ -651,5 +651,64 @@ do_eqp_test subquery-10.2 {
|
||||
# `--SEARCH t1 USING INDEX x12 (aa=?)
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 2024-04-25 Column affinities for columns of compound subqueries
|
||||
#
|
||||
reset_db
|
||||
sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
|
||||
do_execsql_test subquery-11.1 {
|
||||
CREATE TABLE t1(ix INT, rx REAL, bx BLOB, tx TEXT, ax);
|
||||
INSERT INTO t1 VALUES(1,1.0,x'31','x',NULL);
|
||||
WITH c(a) AS (SELECT 'y' UNION SELECT tx FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT tx FROM t1 UNION SELECT 'y') SELECT affinity(a) FROM c;
|
||||
} {text text text text}
|
||||
do_execsql_test subquery-11.2 {
|
||||
WITH c(a) AS (SELECT 2 UNION SELECT tx FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT tx FROM t1 UNION SELECT 2) SELECT affinity(a) FROM c;
|
||||
} {blob blob blob blob}
|
||||
do_execsql_test subquery-11.3 {
|
||||
WITH c(a) AS (SELECT 2.0 UNION SELECT tx FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT tx FROM t1 UNION SELECT 2.0) SELECT affinity(a) FROM c;
|
||||
} {blob blob blob blob}
|
||||
do_execsql_test subquery-11.4 {
|
||||
WITH c(a) AS (SELECT null UNION SELECT tx FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT tx FROM t1 UNION SELECT null) SELECT affinity(a) FROM c;
|
||||
} {text text text text}
|
||||
do_execsql_test subquery-11.5 {
|
||||
WITH c(a) AS (SELECT x'32' UNION SELECT tx FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT tx FROM t1 UNION SELECT x'32') SELECT affinity(a) FROM c;
|
||||
} {text text text text}
|
||||
do_execsql_test subquery-11.6 {
|
||||
WITH c(a) AS (SELECT 3 UNION SELECT ix FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT ix FROM t1 UNION SELECT 3) SELECT affinity(a) FROM c;
|
||||
} {integer integer integer integer}
|
||||
do_execsql_test subquery-11.7 {
|
||||
WITH c(a) AS (SELECT 3.0 UNION SELECT ix FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT ix FROM t1 UNION SELECT 3.0) SELECT affinity(a) FROM c;
|
||||
} {integer integer integer integer}
|
||||
do_execsql_test subquery-11.8 {
|
||||
WITH c(a) AS (SELECT '3' UNION SELECT ix FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT ix FROM t1 UNION SELECT '3') SELECT affinity(a) FROM c;
|
||||
} {blob blob blob blob}
|
||||
do_execsql_test subquery-11.10 {
|
||||
WITH c(a) AS (SELECT x'32' UNION SELECT ix FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT ix FROM t1 UNION SELECT x'32') SELECT affinity(a) FROM c;
|
||||
} {integer integer integer integer}
|
||||
do_execsql_test subquery-11.11 {
|
||||
WITH c(a) AS (SELECT 4 UNION SELECT rx FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT rx FROM t1 UNION SELECT 4) SELECT affinity(a) FROM c;
|
||||
} {real real real real}
|
||||
do_execsql_test subquery-11.12 {
|
||||
WITH c(a) AS (SELECT '4' UNION SELECT rx FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT rx FROM t1 UNION SELECT '4') SELECT affinity(a) FROM c;
|
||||
} {blob blob blob blob}
|
||||
do_execsql_test subquery-11.13 {
|
||||
WITH c(a) AS (SELECT null UNION SELECT rx FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT rx FROM t1 UNION SELECT null) SELECT affinity(a) FROM c;
|
||||
} {real real real real}
|
||||
do_execsql_test subquery-11.14 {
|
||||
WITH c(a) AS (SELECT x'b4' UNION SELECT rx FROM t1) SELECT affinity(a) FROM c;
|
||||
WITH c(a) AS (SELECT rx FROM t1 UNION SELECT x'b4') SELECT affinity(a) FROM c;
|
||||
} {real real real real}
|
||||
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user