Conversation
There was a problem hiding this comment.
Pull request overview
Updates the vendored SQLite headers/extensions in CSQLite to align with SQLite 3.52.0, including new public APIs and extension behaviors exposed through this package.
Changes:
- Bumps SQLite version macros/metadata and updates
sqlite3_api_routines/extension macros for 3.52.0. - Adds support for new SQLite 3.52.0 APIs/config options (e.g.,
SQLITE_DBCONFIG_FP_DIGITS,sqlite3_str_free,sqlite3_str_truncate,sqlite3_carray_bind_v2). - Extends bundled extensions: decimal now supports a 2-argument rounding mode; ieee754 adds int<->double bit-pattern conversion functions.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/CSQLite/include/sqlite3ext.h | Adds 3.52.0 extension API routine pointers/macros. |
| Sources/CSQLite/include/sqlite3.h | Updates version metadata and public API/docs for 3.52.0 features. |
| Sources/CSQLite/include/csqlite_shims.h | Declares new shim for SQLITE_DBCONFIG_FP_DIGITS. |
| Sources/CSQLite/csqlite_shims.c | Implements shim for SQLITE_DBCONFIG_FP_DIGITS. |
| Sources/CSQLite/ieee754.c | Adds new SQL functions for int/double bit-pattern conversions; tweaks INT64_MIN handling. |
| Sources/CSQLite/decimal.c | Adds rounding to N significant digits and registers 2-arg decimal/decimal_exp. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ** inside [sqlite3_str] object X back to zero bytes in length. | ||
| ** | ||
| ** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string | ||
| ** under construction to be N bytes are less. This routine is a no-op if |
There was a problem hiding this comment.
Grammar: "to be N bytes are less" should be "to be N bytes or less" in this documentation for sqlite3_str_truncate.
| ** under construction to be N bytes are less. This routine is a no-op if | |
| ** under construction to be N bytes or less. This routine is a no-op if |
| UNUSED_PARAMETER(argc); | ||
| if( sqlite3_value_type(argv[0])==SQLITE_FLOAT ){ | ||
| double r = sqlite3_value_double(argv[0]); | ||
| sqlite3_uint64 v; |
There was a problem hiding this comment.
ieee754func_to_int stores the copied bit-pattern in a sqlite3_uint64 and then passes it to sqlite3_result_int64. If the high bit is set, converting an out-of-range unsigned 64-bit value to signed 64-bit is implementation-defined and may not preserve the intended bit pattern across platforms/compilers. To guarantee a bitwise reinterpretation, copy into a sqlite3_int64 (or use an explicit memcpy into a signed variable) before returning it.
| sqlite3_uint64 v; | |
| sqlite3_int64 v; |
| ** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE], | ||
| ** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that | ||
| ** the result text is both UTF-8 and zero-terminated. In other words, | ||
| ** SQLITE_UTF8_ZT means that the Z array holds at least N+1 byes and that |
There was a problem hiding this comment.
Typo: "byes" should be "bytes" in this documentation ("N+1 bytes").
| ** SQLITE_UTF8_ZT means that the Z array holds at least N+1 byes and that | |
| ** SQLITE_UTF8_ZT means that the Z array holds at least N+1 bytes and that |
| if( N>0 ) decimal_round(p, N); | ||
| }else{ | ||
| N = 0; | ||
| } |
There was a problem hiding this comment.
decimalFunc calls decimal_round(p, N) before checking whether decimal_new(...) returned NULL. decimal_new can legitimately return NULL (e.g., SQLITE_NULL input, invalid blob length, NaN/Infinity, OOM), which makes this a NULL dereference crash when argc==2 and N>0. Move the rounding call behind the if (p) check (and ideally also skip rounding for p->isNull/p->oom).
| if( N>0 ) decimal_round(p, N); | |
| }else{ | |
| N = 0; | |
| } | |
| }else{ | |
| N = 0; | |
| } | |
| if( p && N>0 && !p->isNull && !p->oom ){ | |
| decimal_round(p, N); | |
| } |
| { "decimal", 1, 0, decimalFunc }, | ||
| { "decimal", 2, 0, decimalFunc }, | ||
| { "decimal_exp", 1, 1, decimalFunc }, | ||
| { "decimal_exp", 2, 1, decimalFunc }, |
There was a problem hiding this comment.
New 2-argument overloads for decimal/decimal_exp (significant-digits rounding) are introduced here, but the existing Swift extension tests only cover the 1-argument behavior. Please add tests that exercise rounding (e.g., decimal('1.2345', 3) and decimal_exp(..., N)) including edge cases like N<=0 and NULL input.
| { "ieee754_to_int", 1, 0, ieee754func_to_int }, | ||
| { "ieee754_from_int", 1, 0, ieee754func_from_int }, |
There was a problem hiding this comment.
New SQL functions ieee754_to_int/ieee754_from_int are registered here, but the existing Swift extension tests only cover ieee754(...). Please add coverage that validates round-trip behavior and bit-pattern preservation (including NaN payloads / sign-bit cases if applicable).
| ** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used | ||
| ** for special purposes. | ||
| ** [sqlite3_prepare_v3()] has an extra | ||
| ** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is some times |
There was a problem hiding this comment.
Typo/grammar: "some times" should be "sometimes" in this API doc string.
| ** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is some times | |
| ** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is sometimes |
| ** | ||
| ** See also: [sqlite3_stmt_scanstatus_reset()] | ||
| ** See also: [sqlite3_stmt_scanstatus_reset()] and the | ||
| ** [nexec and ncycle] columnes of the [bytecode virtual table]. |
There was a problem hiding this comment.
Typo: "columnes" should be "columns" in this documentation.
| ** [nexec and ncycle] columnes of the [bytecode virtual table]. | |
| ** [nexec and ncycle] columns of the [bytecode virtual table]. |
| ** is invoked even if the call to sqlite3_carray_bind() fails. If the X | ||
| ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes | ||
| ** that the data static and the destructor is never invoked. If the X | ||
| ** parameter is the special-case value [SQLITE_TRANSIENT], then | ||
| ** sqlite3_carray_bind_v2() makes its own private copy of the data prior | ||
| ** to returning and never invokes the destructor X. | ||
| ** | ||
| ** The sqlite3_carray_bind() function works the same as sqlite_carray_bind_v2() | ||
| ** with a D parameter set to P. In other words, | ||
| ** sqlite3_carray_bind(S,I,P,N,F,X) is same as | ||
| ** sqlite3_carray_bind(S,I,P,N,F,X,P). |
There was a problem hiding this comment.
The documentation examples here refer to sqlite_carray_bind_v2() (missing the 3) and then show a 7-argument call as sqlite3_carray_bind(...,P), but the 7-argument API is sqlite3_carray_bind_v2(...). This mismatch is confusing for API consumers; please correct the function names in the prose/examples to match the actual exported symbols/signatures below.
| ** is invoked even if the call to sqlite3_carray_bind() fails. If the X | |
| ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes | |
| ** that the data static and the destructor is never invoked. If the X | |
| ** parameter is the special-case value [SQLITE_TRANSIENT], then | |
| ** sqlite3_carray_bind_v2() makes its own private copy of the data prior | |
| ** to returning and never invokes the destructor X. | |
| ** | |
| ** The sqlite3_carray_bind() function works the same as sqlite_carray_bind_v2() | |
| ** with a D parameter set to P. In other words, | |
| ** sqlite3_carray_bind(S,I,P,N,F,X) is same as | |
| ** sqlite3_carray_bind(S,I,P,N,F,X,P). | |
| ** is invoked even if the call to sqlite3_carray_bind_v2() fails. If the X | |
| ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes | |
| ** that the data static and the destructor is never invoked. If the X | |
| ** parameter is the special-case value [SQLITE_TRANSIENT], then | |
| ** sqlite3_carray_bind_v2() makes its own private copy of the data prior | |
| ** to returning and never invokes the destructor X. | |
| ** | |
| ** The sqlite3_carray_bind() function works the same as sqlite3_carray_bind_v2() | |
| ** with a D parameter set to P. In other words, | |
| ** sqlite3_carray_bind(S,I,P,N,F,X) is same as | |
| ** sqlite3_carray_bind_v2(S,I,P,N,F,X,P). |
No description provided.