Fix a case where an error in the ORDER BY clause of an aggregate function that is part of a trigger body might cause an assert() to fail in an ALTER TABLE command. dbsqlfuzz 899d9255555a07f1fe11a0bb51a2fe197b3150cd

FossilOrigin-Name: 953271f29e7bd6ba9b85f73250b1c22b08eef317f9ac3c7c3d92cbaa57d7efd5
This commit is contained in:
drh 2024-05-16 00:20:43 +00:00
commit c4439fb134
5 changed files with 36 additions and 17 deletions

View File

@ -1,5 +1,5 @@
C If\sthere\sis\sno\sdata\savailable\sfor\sa\sfield\sin\sa\scorrupted\srecord,\sbut\sthe\stype\sis\savailable,\shave\sthe\srecovery\sextension\ssubstitute\s0,\s0.0,\s''\sor\sX''\sinstead\sof\sa\sNULL\svalue.
D 2024-05-15T15:06:27.777
C Fix\sa\scase\swhere\san\serror\sin\sthe\sORDER\sBY\sclause\sof\san\saggregate\sfunction\sthat\sis\spart\sof\sa\strigger\sbody\smight\scause\san\sassert()\sto\sfail\sin\san\sALTER\sTABLE\scommand.\s\sdbsqlfuzz\s899d9255555a07f1fe11a0bb51a2fe197b3150cd
D 2024-05-16T00:20:43.867
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -752,9 +752,9 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7
F src/prepare.c d99931f45416652895e502328ca49fe782cfc4e1ebdcda13b3736d991ebf42ce
F src/printf.c 8b250972305e14b365561be5117ed0fd364e4fd58968776df1ce64c6280b90f9
F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
F src/resolve.c 8816212645e4e9bdf3cc2f2d298304f388d699f8fab47f3a5712ef5bbc5b6ccc
F src/resolve.c 6adf4bf10151bca046f3206ae8ff07dbf90b49de20bea49197f010276f5f494d
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c ce81687d769b174aa547b8216a34fabc9cafc05789b615494ab78dc2c1e799fa
F src/select.c 1a841c38974d45cf15a7611398479182b61ad4c187423c380741d8b1688fe607
F src/shell.c.in 8f2406e4e8d726452e48058d117f52e86b789f47435157b0418fb06c631349b6
F src/sqlite.h.in 32389e0d584551b300d0157881336162c14315a424cbf385c0d65eb7c2e31f7b
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
@ -870,7 +870,7 @@ F test/altermalloc2.test 17fb3724c4b004c469c27dc4ef181608aa644555fbd3f3236767584
F test/altermalloc3.test 8040e486368403f2fdd6fc3998258b499bd4cc2f3ddbb5f8f874cd436f076e81
F test/alterqf.test 8ec03d776de9c391daa0078ea8f838903bdcfb11dfae4ba3576b48436834ccba
F test/altertab.test 8a2712f9076da5012a002d0b5cc0a421398a5bf61c25bab41b77c427586a7a27
F test/altertab2.test 62597b6fd08feaba1b6bfe7d31dac6117c67e06dc9ce9c478a3abe75b5926de0
F test/altertab2.test fff90e3f01e8eb0e09282f538b8ec7cfeb035dbedbe570fe1983440f4613ad0e
F test/altertab3.test b331ae34e69594e19605e3297805202d6156fcc8f75379dfd972a2e51cae8721
F test/altertrig.test aacc980b657354fe2d3d4d3a004f07d04ccc1a93e5ef82d68a79088c274ddc6b
F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f
@ -2191,8 +2191,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 58d938c0e03c3c8d8796c537f89e69734ba6263d60ba37e345259cb6fdffbea5
R cd015e2f2734629b19947eb11f0220ff
U dan
Z be5ac0bdafce0ff1c422be3037819109
P 8eb326c24981647e2df90e4b9d75db52a552bd997bd821f5898c7ff3fb93a57d 3120c7c8a3565b8a3ca321129c09db96839c2f9af1777fc7a1668fef81973603
R 91267a6a1982f21ea275bc49553555c1
T +closed 3120c7c8a3565b8a3ca321129c09db96839c2f9af1777fc7a1668fef81973603
U drh
Z 697456db2f591cb2a06b3f31c7640456
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
8eb326c24981647e2df90e4b9d75db52a552bd997bd821f5898c7ff3fb93a57d
953271f29e7bd6ba9b85f73250b1c22b08eef317f9ac3c7c3d92cbaa57d7efd5

View File

@ -1281,11 +1281,9 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
#endif
}
}
#ifndef SQLITE_OMIT_WINDOWFUNC
else if( ExprHasProperty(pExpr, EP_WinFunc) ){
else if( ExprHasProperty(pExpr, EP_WinFunc) || pExpr->pLeft ){
is_agg = 1;
}
#endif
sqlite3WalkExprList(pWalker, pList);
if( is_agg ){
if( pExpr->pLeft ){

View File

@ -2324,8 +2324,7 @@ void sqlite3SubqueryColumnTypes(
NameContext sNC;
assert( pSelect!=0 );
testcase( (pSelect->selFlags & SF_Resolved)==0 );
assert( (pSelect->selFlags & SF_Resolved)!=0 || IN_RENAME_OBJECT );
assert( (pSelect->selFlags & SF_Resolved)!=0 );
assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 );
assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB );
if( db->mallocFailed || IN_RENAME_OBJECT ) return;
@ -6412,8 +6411,7 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){
if( p->selFlags & SF_HasTypeInfo ) return;
p->selFlags |= SF_HasTypeInfo;
pParse = pWalker->pParse;
testcase( (p->selFlags & SF_Resolved)==0 );
assert( (p->selFlags & SF_Resolved) || IN_RENAME_OBJECT );
assert( (p->selFlags & SF_Resolved) );
pTabList = p->pSrc;
for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
Table *pTab = pFrom->pTab;

View File

@ -360,4 +360,26 @@ do_catchsql_test 8.6 {
SELECT sql FROM sqlite_master WHERE name='i0';
} {1 {error in index i0: second argument to likelihood() must be a constant between 0.0 and 1.0}}
reset_db
do_execsql_test 9.0 {
CREATE TABLE t1(a,b,c,d);
CREATE TABLE t2(a,b,c,d,x);
CREATE TRIGGER AFTER INSERT ON t2 BEGIN
SELECT group_conct(
123 ORDER BY (
SELECT 1 FROM ( VALUES(a, 'b'), ('c') )
))
FROM t1;
END;
}
do_catchsql_test 9.1 {
ALTER TABLE t2 RENAME TO newname;
} {1 {error in trigger AFTER: all VALUES must have the same number of terms}}
finish_test