1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Merge the latest trunk enhancements into the reuse-schema branch.

FossilOrigin-Name: 271e0373a812d8da153a0e74adec2605d4d8b71e4f8f0ffee8707db501861487
This commit is contained in:
drh
2025-03-15 20:35:24 +00:00
55 changed files with 700 additions and 367 deletions

View File

@@ -88,6 +88,11 @@
#include "sqlite3recover.h"
#define ISSPACE(X) isspace((unsigned char)(X))
#define ISDIGIT(X) isdigit((unsigned char)(X))
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define FLEXARRAY
#else
# define FLEXARRAY 1
#endif
#ifdef __unix__
@@ -129,9 +134,12 @@ struct Blob {
int id; /* Id of this Blob */
int seq; /* Sequence number */
int sz; /* Size of this Blob in bytes */
unsigned char a[1]; /* Blob content. Extra space allocated as needed. */
unsigned char a[FLEXARRAY]; /* Blob content. Allocated as needed. */
};
/* Size in bytes of a Blob object sufficient to store N byte of content */
#define SZ_BLOB(N) (offsetof(Blob,a) + (((N)+7)&~7))
/*
** Maximum number of files in the in-memory virtual filesystem.
*/
@@ -512,13 +520,15 @@ static void blobListLoadFromDb(
int *pN, /* OUT: Write number of blobs loaded here */
Blob **ppList /* OUT: Write the head of the blob list here */
){
Blob head;
Blob *head;
Blob *p;
sqlite3_stmt *pStmt;
int n = 0;
int rc;
char *z2;
unsigned char tmp[SZ_BLOB(8)];
head = (Blob*)tmp;
if( firstId>0 ){
z2 = sqlite3_mprintf("%s WHERE rowid BETWEEN %d AND %d", zSql,
firstId, lastId);
@@ -528,11 +538,11 @@ static void blobListLoadFromDb(
rc = sqlite3_prepare_v2(db, z2, -1, &pStmt, 0);
sqlite3_free(z2);
if( rc ) fatalError("%s", sqlite3_errmsg(db));
head.pNext = 0;
p = &head;
head->pNext = 0;
p = head;
while( SQLITE_ROW==sqlite3_step(pStmt) ){
int sz = sqlite3_column_bytes(pStmt, 1);
Blob *pNew = safe_realloc(0, sizeof(*pNew)+sz );
Blob *pNew = safe_realloc(0, SZ_BLOB(sz+1));
pNew->id = sqlite3_column_int(pStmt, 0);
pNew->sz = sz;
pNew->seq = n++;
@@ -544,7 +554,7 @@ static void blobListLoadFromDb(
}
sqlite3_finalize(pStmt);
*pN = n;
*ppList = head.pNext;
*ppList = head->pNext;
}
/*

View File

@@ -47,6 +47,9 @@ proc recover_with_opts {opts} {
set sql [read $fd]
close $fd
# Remove the ".dbconfig defensive off" line
set sql [string map {".dbconfig defensive off" ""} $sql]
forcedelete test.db2
sqlite3 db2 test.db2
execsql $sql db2

View File

@@ -312,7 +312,7 @@ do_test shared-$av.4.1.3 {
} {2}
# Sanity check: Create a table in ./test.db via handle db, and test that handle
# db2 can "see" the new table immediately. A handle using a seperate pager
# db2 can "see" the new table immediately. A handle using a separate pager
# cache would have to reload the database schema before this were possible.
#
do_test shared-$av.4.2.1 {

View File

@@ -181,6 +181,19 @@ do_execsql_test tabfunc01-4.4 {
SELECT * FROM (generate_series(1,5,2)) AS x LIMIT 10;
} {1 3 5}
# 2025-03-13 forum post bf2dc8e909983511
#
do_execsql_test tabfunc01-5.1 {
SELECT value
FROM generate_series(60,73,6)
WHERE value=66;
} 66
do_execsql_test tabfunc01-5.2 {
SELECT value
FROM generate_series(73,60,-6)
WHERE value=67;
} 67
# The next series of tests is verifying that virtual table are able
# to optimize the IN operator, even on terms that are not marked "omit".
# When the generate_series virtual table is compiled for the testfixture,

View File

@@ -230,7 +230,7 @@ ifcapable schema_pragmas {
}
# do_malloc_test closes and deletes the usual db connections and files on
# each iteration. $::dbx is a seperate connection, and on Windows, will
# each iteration. $::dbx is a separate connection, and on Windows, will
# cause the file deletion of test.db to fail, so we move the close of $::dbx
# up to here before the do_malloc_test.
do_test tableapi-99.0 {

View File

@@ -1724,7 +1724,7 @@ proc ifcapable {expr code {else ""} {elsecode ""}} {
return -code $c $r
}
# This proc execs a seperate process that crashes midway through executing
# This proc execs a separate process that crashes midway through executing
# the SQL script $sql on database test.db.
#
# The crash occurs during a sync() of file $crashfile. When the crash

View File

@@ -315,6 +315,7 @@ testfixture_nb done {
db eval {
COMMIT
}
db close
}
after 500 {set ok 1}