Do not convert an expression node that is already TK_REGISTER into a

new TK_REGISTER.  This is a follow-up to [663f5dd32d9db832] that fixes a
bug discovered by dbsqlfuzz.

FossilOrigin-Name: fcb669cfaa8a59ca710504d5aaa1936f65a6da8ff13473ad84458f97a6fd1f49
This commit is contained in:
drh 2024-06-28 17:14:00 +00:00
parent 105c20648e
commit 076bd5758b
4 changed files with 31 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Fix\san\sincorrect\stcl\scomment\sthat\sappeared\sin\smany\sfts5\stest\sfiles.
D 2024-06-24T18:06:15.031
C Do\snot\sconvert\san\sexpression\snode\sthat\sis\salready\sTK_REGISTER\sinto\sa\nnew\sTK_REGISTER.\s\sThis\sis\sa\sfollow-up\sto\s[663f5dd32d9db832]\sthat\sfixes\sa\nbug\sdiscovered\sby\sdbsqlfuzz.
D 2024-06-28T17:14:00.360
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -755,7 +755,7 @@ F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9
F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
F src/resolve.c 7e8d23ce7cdbfedf351a47e759f2722e8182ca10fd7580be43f4ce1f1a228145
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c d26ac0a13b4154cbd71a9a57ca024350cd73f0f6fcf0ca0cbb4537e2d5b3e257
F src/select.c a1c8fadd45d0843b14793db2af49809a5327db5cca9d87d507b57aa748ee6ee2
F src/shell.c.in 2ccbed6a9fd451399b0f378aafa323ad2286fa9de54ae0cd28f32907cd94d18d
F src/sqlite.h.in 6c884a87bbf8828562b49272025a1e66e3801a196a58b0bdec87edcd2c9c8fc1
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
@ -1074,7 +1074,7 @@ F test/descidx2.test a0ba347037ff3b811f4c6ceca5fd0f9d5d72e74e59f2d9de346a9d2f6ad
F test/descidx3.test 953c831df7ea219c73826dfbf2f6ee02d95040725aa88ccb4fa43d1a1999b926
F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e
F test/distinct.test 691c9e850b0d0b56b66e7e235453198cb4cf0760e324b7403d3c5abbeab0a014
F test/distinct2.test 931a242fccaa05f17232e23acc9b2debe42901d90db723ddca038f7758951b5f
F test/distinct2.test 4d6316b6487a0aa5a90bee111575c957e2a5ba5a9be9156febe9533ce78876e8
F test/distinctagg.test 40d7169ae5846caaf62c6e307d2ca3c333daf9b6f7cde888956a339a97afe85f
F test/e_blobbytes.test 4c01dfe4f12087b92b20705a3fdfded45dc4ed16d5a211fed4e1d2786ba68a52
F test/e_blobclose.test 692fc02a058476c2222a63d97e3f3b2b809c1842e5525ded7f854d540ac2e075
@ -2195,8 +2195,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 56d265f956fe6433b625c6d732e55f387af3f643e705316f5a6f709d63731669
R 5ad9950c3d8fa87fe57068f06313a6c9
U dan
Z 3992b6a75558611778f9237da672a1e0
P d07085e2035b52a7edd27980523225e59c5bf851fb4a6de975f03e653b937c9c
R 6b4e371b1a6983b6d20bf6bb77f15e3d
U drh
Z 1da9b70811e2736c2416513d2f56f791
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
d07085e2035b52a7edd27980523225e59c5bf851fb4a6de975f03e653b937c9c
fcb669cfaa8a59ca710504d5aaa1936f65a6da8ff13473ad84458f97a6fd1f49

View File

@ -8336,7 +8336,10 @@ int sqlite3Select(
if( iOrderByCol ){
Expr *pX = p->pEList->a[iOrderByCol-1].pExpr;
Expr *pBase = sqlite3ExprSkipCollateAndLikely(pX);
if( ALWAYS(pBase!=0) && pBase->op!=TK_AGG_COLUMN ){
if( ALWAYS(pBase!=0)
&& pBase->op!=TK_AGG_COLUMN
&& pBase->op!=TK_REGISTER
){
sqlite3ExprToRegister(pX, iAMem+j);
}
}

View File

@ -362,4 +362,22 @@ do_execsql_test 5070 {
SELECT v4.e FROM t3 LEFT JOIN v4 ON true GROUP BY 1;
} NULL
# 2024-06-28 dbsqlfuzz 46343912848a603e32c6072cae792eb056bac897
# Do not call sqlite3ExprToRegister() on an expression that is already
# a register.
#
do_execsql_test 5080 {
CREATE TABLE dual(dummy TEXT);
INSERT INTO dual VALUES('X');
SELECT 11 = (
SELECT b
FROM (
SELECT a AS b
FROM dual
LEFT JOIN (SELECT 22 AS a FROM dual)
)
GROUP BY b, b
);
} 0
finish_test