From 1e157dd5faf65fc1b87fb6971b5d47ac47bbf5a9 Mon Sep 17 00:00:00 2001 From: xurui Date: Fri, 13 Sep 2024 21:09:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsqlite3=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xurui --- amalgamation/rename_exports.h | 2 +- amalgamation/sqlite3.c | 7 +++++-- amalgamation/sqlite3.h | 2 +- amalgamation_dev/rename_exports.h | 2 +- amalgamation_dev/sqlite3.c | 25 ++++++++++++++++--------- amalgamation_dev/sqlite3.h | 2 +- src/where.c | 5 ++++- 7 files changed, 29 insertions(+), 16 deletions(-) diff --git a/amalgamation/rename_exports.h b/amalgamation/rename_exports.h index 52274ef..36b6c9d 100644 --- a/amalgamation/rename_exports.h +++ b/amalgamation/rename_exports.h @@ -1,4 +1,4 @@ -// Copyright 2023 The Chromium Authors. All rights reserved. +// Copyright 2024 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/amalgamation/sqlite3.c b/amalgamation/sqlite3.c index 560ea7a..acb2dbe 100644 --- a/amalgamation/sqlite3.c +++ b/amalgamation/sqlite3.c @@ -454,7 +454,7 @@ extern "C" { */ #define SQLITE_VERSION "3.41.2" #define SQLITE_VERSION_NUMBER 3041002 -#define SQLITE_SOURCE_ID "2023-03-22 11:56:21 c5a8ed5442668c558f8330bc68beb9e9e6396526f364a63f7a6cb812639aff78" +#define SQLITE_SOURCE_ID "2023-03-22 11:56:21 c5a8ed5442668c558f8330bc68beb9e9e6396526f364a63f7a6cb812639aalt1" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -162770,7 +162770,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */ testcase( pOrderBy && pOrderBy->nExpr==BMS-1 ); - if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0; + if( pOrderBy && pOrderBy->nExpr>=BMS ){ + pOrderBy = 0; + wctrlFlags &= ~WHERE_WANT_DISTINCT; + } /* The number of tables in the FROM clause is limited by the number of ** bits in a Bitmask diff --git a/amalgamation/sqlite3.h b/amalgamation/sqlite3.h index e967249..c87819b 100644 --- a/amalgamation/sqlite3.h +++ b/amalgamation/sqlite3.h @@ -148,7 +148,7 @@ extern "C" { */ #define SQLITE_VERSION "3.41.2" #define SQLITE_VERSION_NUMBER 3041002 -#define SQLITE_SOURCE_ID "2023-03-22 11:56:21 c5a8ed5442668c558f8330bc68beb9e9e6396526f364a63f7a6cb812639aff78" +#define SQLITE_SOURCE_ID "2023-03-22 11:56:21 c5a8ed5442668c558f8330bc68beb9e9e6396526f364a63f7a6cb812639aalt1" /* ** CAPI3REF: Run-Time Library Version Numbers diff --git a/amalgamation_dev/rename_exports.h b/amalgamation_dev/rename_exports.h index 52274ef..36b6c9d 100644 --- a/amalgamation_dev/rename_exports.h +++ b/amalgamation_dev/rename_exports.h @@ -1,4 +1,4 @@ -// Copyright 2023 The Chromium Authors. All rights reserved. +// Copyright 2024 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/amalgamation_dev/sqlite3.c b/amalgamation_dev/sqlite3.c index 0819ea6..48ec733 100644 --- a/amalgamation_dev/sqlite3.c +++ b/amalgamation_dev/sqlite3.c @@ -454,7 +454,7 @@ extern "C" { */ #define SQLITE_VERSION "3.41.2" #define SQLITE_VERSION_NUMBER 3041002 -#define SQLITE_SOURCE_ID "2023-03-22 11:56:21 c5a8ed5442668c558f8330bc68beb9e9e6396526f364a63f7a6cb812639aff78" +#define SQLITE_SOURCE_ID "2023-03-22 11:56:21 c5a8ed5442668c558f8330bc68beb9e9e6396526f364a63f7a6cb812639aalt1" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -162783,7 +162783,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */ testcase( pOrderBy && pOrderBy->nExpr==BMS-1 ); - if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0; + if( pOrderBy && pOrderBy->nExpr>=BMS ){ + pOrderBy = 0; + wctrlFlags &= ~WHERE_WANT_DISTINCT; + } /* The number of tables in the FROM clause is limited by the number of ** bits in a Bitmask @@ -219195,15 +219198,19 @@ static int sessionReadRecord( } } if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ - sqlite3_int64 v = sessionGetI64(aVal); - if( eType==SQLITE_INTEGER ){ - sqlite3VdbeMemSetInt64(apOut[i], v); + if( (pIn->nData-pIn->iNext)<8 ){ + rc = SQLITE_CORRUPT_BKPT; }else{ - double d; - memcpy(&d, &v, 8); - sqlite3VdbeMemSetDouble(apOut[i], d); + sqlite3_int64 v = sessionGetI64(aVal); + if( eType==SQLITE_INTEGER ){ + sqlite3VdbeMemSetInt64(apOut[i], v); + }else{ + double d; + memcpy(&d, &v, 8); + sqlite3VdbeMemSetDouble(apOut[i], d); + } + pIn->iNext += 8; } - pIn->iNext += 8; } } } diff --git a/amalgamation_dev/sqlite3.h b/amalgamation_dev/sqlite3.h index e967249..c87819b 100644 --- a/amalgamation_dev/sqlite3.h +++ b/amalgamation_dev/sqlite3.h @@ -148,7 +148,7 @@ extern "C" { */ #define SQLITE_VERSION "3.41.2" #define SQLITE_VERSION_NUMBER 3041002 -#define SQLITE_SOURCE_ID "2023-03-22 11:56:21 c5a8ed5442668c558f8330bc68beb9e9e6396526f364a63f7a6cb812639aff78" +#define SQLITE_SOURCE_ID "2023-03-22 11:56:21 c5a8ed5442668c558f8330bc68beb9e9e6396526f364a63f7a6cb812639aalt1" /* ** CAPI3REF: Run-Time Library Version Numbers diff --git a/src/where.c b/src/where.c index 448c955..423fa37 100644 --- a/src/where.c +++ b/src/where.c @@ -5849,7 +5849,10 @@ WhereInfo *sqlite3WhereBegin( /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */ testcase( pOrderBy && pOrderBy->nExpr==BMS-1 ); - if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0; + if( pOrderBy && pOrderBy->nExpr>=BMS ){ + pOrderBy = 0; + wctrlFlags &= ~WHERE_WANT_DISTINCT; + } /* The number of tables in the FROM clause is limited by the number of ** bits in a Bitmask -- Gitee