Skip to content

Commit be88b13

Browse files
author
D. Richard Hipp
committed
Fix a harmless assertion fault resulting from [6e6b3729e0549de0] that was
discovered by dbsqlfuzz. Enhance .selecttrace output to show omitted ORDER BY clauses. New dbsqlfuzz test cases added.
1 parent d82218b commit be88b13

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/select.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6034,8 +6034,18 @@ int sqlite3Select(
60346034
pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard ||
60356035
pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_DistFifo );
60366036
/* All of these destinations are also able to ignore the ORDER BY clause */
6037-
sqlite3ExprListDelete(db, p->pOrderBy);
6038-
p->pOrderBy = 0;
6037+
if( p->pOrderBy ){
6038+
#if SELECTTRACE_ENABLED
6039+
SELECTTRACE(1,pParse,p, ("dropping superfluous ORDER BY:\n"));
6040+
if( sqlite3SelectTrace & 0x100 ){
6041+
sqlite3TreeViewExprList(0, p->pOrderBy, 0, "ORDERBY");
6042+
}
6043+
#endif
6044+
sqlite3ParserAddCleanup(pParse,
6045+
(void(*)(sqlite3*,void*))sqlite3ExprListDelete,
6046+
p->pOrderBy);
6047+
p->pOrderBy = 0;
6048+
}
60396049
p->selFlags &= ~SF_Distinct;
60406050
p->selFlags |= SF_NoopOrderBy;
60416051
}

test/fuzzdata8.db

20 KB
Binary file not shown.

0 commit comments

Comments
 (0)