Skip to content

Commit 4c223c7

Browse files
committed
use lower bits only because with sqlite3_extended_result_codes on we will get more detailed error codes
1 parent f0d6611 commit 4c223c7

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214236,7 +214236,7 @@ int insertIndexParameters(sqlite3* db, const char *zDbSName, const char *zName,
214236214236
goto clear_and_exit;
214237214237
}
214238214238
rc = sqlite3_step(pStatement);
214239-
if( rc == SQLITE_CONSTRAINT ){
214239+
if( (rc&0xff) == SQLITE_CONSTRAINT ){
214240214240
rc = SQLITE_CONSTRAINT;
214241214241
}else if( rc != SQLITE_DONE ){
214242214242
rc = SQLITE_ERROR;
@@ -214544,7 +214544,10 @@ int vectorIndexCreate(Parse *pParse, const Index *pIdx, const char *zDbSName, co
214544214544
return CREATE_FAIL;
214545214545
}
214546214546
rc = insertIndexParameters(db, zDbSName, pIdx->zName, &idxParams);
214547-
if( rc == SQLITE_CONSTRAINT ){
214547+
214548+
// we must consider only lower bits because with sqlite3_extended_result_codes on
214549+
// we can recieve different subtypes of CONSTRAINT error
214550+
if( (rc&0xff) == SQLITE_CONSTRAINT ){
214548214551
// we are violating unique constraint here which means that someone inserted parameters in the table before us
214549214552
// taking aside corruption scenarios, this can be in case of loading dump (because tables and data are loaded before indices)
214550214553
// this case is valid and we must proceed with index creating but avoid index-refill step as it is already filled

libsql-ffi/bundled/bindings/bindgen.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ extern "C" {
2424
}
2525

2626
pub const __GNUC_VA_LIST: i32 = 1;
27-
pub const SQLITE_VERSION: &[u8; 7] = b"3.44.0\0";
28-
pub const SQLITE_VERSION_NUMBER: i32 = 3044000;
27+
pub const SQLITE_VERSION: &[u8; 7] = b"3.45.1\0";
28+
pub const SQLITE_VERSION_NUMBER: i32 = 3045001;
2929
pub const SQLITE_SOURCE_ID: &[u8; 85] =
30-
b"2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad8alt1\0";
30+
b"2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257ccalt1\0";
3131
pub const LIBSQL_VERSION: &[u8; 6] = b"0.2.3\0";
3232
pub const SQLITE_OK: i32 = 0;
3333
pub const SQLITE_ERROR: i32 = 1;
@@ -356,6 +356,7 @@ pub const SQLITE_DETERMINISTIC: i32 = 2048;
356356
pub const SQLITE_DIRECTONLY: i32 = 524288;
357357
pub const SQLITE_SUBTYPE: i32 = 1048576;
358358
pub const SQLITE_INNOCUOUS: i32 = 2097152;
359+
pub const SQLITE_RESULT_SUBTYPE: i32 = 16777216;
359360
pub const SQLITE_WIN32_DATA_DIRECTORY_TYPE: i32 = 1;
360361
pub const SQLITE_WIN32_TEMP_DIRECTORY_TYPE: i32 = 2;
361362
pub const SQLITE_TXN_NONE: i32 = 0;
@@ -408,6 +409,7 @@ pub const SQLITE_TESTCTRL_PENDING_BYTE: i32 = 11;
408409
pub const SQLITE_TESTCTRL_ASSERT: i32 = 12;
409410
pub const SQLITE_TESTCTRL_ALWAYS: i32 = 13;
410411
pub const SQLITE_TESTCTRL_RESERVE: i32 = 14;
412+
pub const SQLITE_TESTCTRL_JSON_SELFCHECK: i32 = 14;
411413
pub const SQLITE_TESTCTRL_OPTIMIZATIONS: i32 = 15;
412414
pub const SQLITE_TESTCTRL_ISKEYWORD: i32 = 16;
413415
pub const SQLITE_TESTCTRL_SCRATCHMALLOC: i32 = 17;
@@ -3133,6 +3135,24 @@ pub struct Fts5ExtensionApi {
31333135
piCol: *mut ::std::os::raw::c_int,
31343136
),
31353137
>,
3138+
pub xQueryToken: ::std::option::Option<
3139+
unsafe extern "C" fn(
3140+
arg1: *mut Fts5Context,
3141+
iPhrase: ::std::os::raw::c_int,
3142+
iToken: ::std::os::raw::c_int,
3143+
ppToken: *mut *const ::std::os::raw::c_char,
3144+
pnToken: *mut ::std::os::raw::c_int,
3145+
) -> ::std::os::raw::c_int,
3146+
>,
3147+
pub xInstToken: ::std::option::Option<
3148+
unsafe extern "C" fn(
3149+
arg1: *mut Fts5Context,
3150+
iIdx: ::std::os::raw::c_int,
3151+
iToken: ::std::os::raw::c_int,
3152+
arg2: *mut *const ::std::os::raw::c_char,
3153+
arg3: *mut ::std::os::raw::c_int,
3154+
) -> ::std::os::raw::c_int,
3155+
>,
31363156
}
31373157
#[repr(C)]
31383158
#[derive(Debug, Copy, Clone)]

libsql-ffi/bundled/src/sqlite3.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214236,7 +214236,7 @@ int insertIndexParameters(sqlite3* db, const char *zDbSName, const char *zName,
214236214236
goto clear_and_exit;
214237214237
}
214238214238
rc = sqlite3_step(pStatement);
214239-
if( rc == SQLITE_CONSTRAINT ){
214239+
if( (rc&0xff) == SQLITE_CONSTRAINT ){
214240214240
rc = SQLITE_CONSTRAINT;
214241214241
}else if( rc != SQLITE_DONE ){
214242214242
rc = SQLITE_ERROR;
@@ -214544,7 +214544,10 @@ int vectorIndexCreate(Parse *pParse, const Index *pIdx, const char *zDbSName, co
214544214544
return CREATE_FAIL;
214545214545
}
214546214546
rc = insertIndexParameters(db, zDbSName, pIdx->zName, &idxParams);
214547-
if( rc == SQLITE_CONSTRAINT ){
214547+
214548+
// we must consider only lower bits because with sqlite3_extended_result_codes on
214549+
// we can recieve different subtypes of CONSTRAINT error
214550+
if( (rc&0xff) == SQLITE_CONSTRAINT ){
214548214551
// we are violating unique constraint here which means that someone inserted parameters in the table before us
214549214552
// taking aside corruption scenarios, this can be in case of loading dump (because tables and data are loaded before indices)
214550214553
// this case is valid and we must proceed with index creating but avoid index-refill step as it is already filled

libsql-sqlite3/src/vectorIndex.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ int insertIndexParameters(sqlite3* db, const char *zDbSName, const char *zName,
629629
goto clear_and_exit;
630630
}
631631
rc = sqlite3_step(pStatement);
632-
if( rc == SQLITE_CONSTRAINT ){
632+
if( (rc&0xff) == SQLITE_CONSTRAINT ){
633633
rc = SQLITE_CONSTRAINT;
634634
}else if( rc != SQLITE_DONE ){
635635
rc = SQLITE_ERROR;
@@ -937,7 +937,10 @@ int vectorIndexCreate(Parse *pParse, const Index *pIdx, const char *zDbSName, co
937937
return CREATE_FAIL;
938938
}
939939
rc = insertIndexParameters(db, zDbSName, pIdx->zName, &idxParams);
940-
if( rc == SQLITE_CONSTRAINT ){
940+
941+
// we must consider only lower bits because with sqlite3_extended_result_codes on
942+
// we can recieve different subtypes of CONSTRAINT error
943+
if( (rc&0xff) == SQLITE_CONSTRAINT ){
941944
// we are violating unique constraint here which means that someone inserted parameters in the table before us
942945
// taking aside corruption scenarios, this can be in case of loading dump (because tables and data are loaded before indices)
943946
// this case is valid and we must proceed with index creating but avoid index-refill step as it is already filled

0 commit comments

Comments
 (0)