blob: 6b041d9332bf458177b2f7bc6f44551f0d9977f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
From b816ca9994e03a8bc829b49452b8158a731e81a9 Mon Sep 17 00:00:00 2001
From: drh <>
Date: Thu, 16 Mar 2023 20:54:29 +0000
Subject: [PATCH] Correctly handle SELECT DISTINCT ... ORDER BY when all of the
result set terms are constant and there are more result set terms than ORDER
BY terms. Fix for these tickets: [c36cdb4afd504dc1], [4051a7f931d9ba24],
[d6fd512f50513ab7].
FossilOrigin-Name: 12ad822d9b827777526ca5ed5bf3e678d600294fc9b5c25482dfff2a021328a4
CVE: CVE-2025-7458
Upstream-Status: Backport [github.com/sqlite/sqlite/commit/b816ca9994e03a8bc829b49452b8158a731e81a9]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
sqlite3.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sqlite3.c b/sqlite3.c
index 19d0438..6d92184 100644
--- a/sqlite3.c
+++ b/sqlite3.c
@@ -156989,6 +156989,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
}
+ if( pWInfo->pSelect->pOrderBy
+ && pWInfo->nOBSat > pWInfo->pSelect->pOrderBy->nExpr ){
+ pWInfo->nOBSat = pWInfo->pSelect->pOrderBy->nExpr;
+ }
}else{
pWInfo->nOBSat = pFrom->isOrdered;
pWInfo->revMask = pFrom->revLoop;
|