If a term of an ORDER BY or GROUP BY contains an aggregate function or column,

then it is not an alias that needs to be resolved, so don't try to.  This fixes
a harmless assertion found by dbsqlfuzz.  This yet another problem that
orginated at check-in [6e6b3729e0549de0].

FossilOrigin-Name: d4ec2a5d2297cd9ead0a8768dcf003ea76c74d8d68d88c40f62363f484a4a4d3
This commit is contained in:
drh 2024-02-11 20:53:14 +00:00
parent ece3567aec
commit 3c5a810646
3 changed files with 9 additions and 7 deletions

View File

@ -1,5 +1,5 @@
C Improved\sAggInfo\stracing\sin\sdebug\sbuilds.\s\sNo\schanges\sto\sdeliverable\scode.
D 2024-02-11T18:53:48.466
C If\sa\sterm\sof\san\sORDER\sBY\sor\sGROUP\sBY\scontains\san\saggregate\sfunction\sor\scolumn,\nthen\sit\sis\snot\san\salias\sthat\sneeds\sto\sbe\sresolved,\sso\sdon't\stry\sto.\s\sThis\sfixes\na\sharmless\sassertion\sfound\sby\sdbsqlfuzz.\s\sThis\syet\sanother\sproblem\sthat\norginated\sat\scheck-in\s[6e6b3729e0549de0].
D 2024-02-11T20:53:14.723
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -737,7 +737,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7
F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c
F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640
F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
F src/resolve.c 0ed10ebb70d15dcf3f1882051931ccfaf9c3f4debe67dbd114047d9e2adb9523
F src/resolve.c d77c6160bc8f249c2196fdd3e75f66a1dd70e37aa25c39aedc7b1f93c42b7c6d
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c 43fabfc01bf87addd15e39f112f1e2ade15b19594835ab8a9e5bd50839d4e1b1
F src/shell.c.in c6cb773b7703d76677529de19d1c40584520701966422c33da3e9334498a7099
@ -2162,8 +2162,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 993a1a843177b19a9cb5598f57d1e05c01e1695f164faaa9ae22810ad4533eba
R b08d58139ab071fec772aaa3f5cfa8ae
P bb31f9c44794e02a46ed3edbcc96eb48c5870d3f82cb404586ded9a3efa7a859
R 420903d8a166efd58090018027845648
U drh
Z 8c006f746e6086c64fa306e943cc82cc
Z 77dfb496104764f5c2dcbb370d30ed43
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
bb31f9c44794e02a46ed3edbcc96eb48c5870d3f82cb404586ded9a3efa7a859
d4ec2a5d2297cd9ead0a8768dcf003ea76c74d8d68d88c40f62363f484a4a4d3

View File

@ -79,6 +79,8 @@ static void resolveAlias(
assert( iCol>=0 && iCol<pEList->nExpr );
pOrig = pEList->a[iCol].pExpr;
assert( pOrig!=0 );
assert( !ExprHasProperty(pExpr, EP_Reduced|EP_TokenOnly) );
if( pExpr->pAggInfo ) return;
db = pParse->db;
pDup = sqlite3ExprDup(db, pOrig, 0);
if( db->mallocFailed ){