From 80a10f920274c73883b3c82676eb394845b96d75 Mon Sep 17 00:00:00 2001 From: Nikita Sivukhin Date: Sun, 29 Sep 2024 15:17:47 +0400 Subject: [PATCH] build bundles --- .../SQLite3MultipleCiphers/src/sqlite3.c | 32 ++++++++++++++----- libsql-ffi/bundled/src/sqlite3.c | 32 ++++++++++++++----- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c b/libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c index 69dd8e24a6..82db050d36 100644 --- a/libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c +++ b/libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c @@ -216033,6 +216033,7 @@ int vectorIndexSearch( char **pzErrMsg ) { int type, dims, k, rc; + double kDouble; const char *zIdxName; const char *zErrMsg; Vector *pVector = NULL; @@ -216063,17 +216064,32 @@ int vectorIndexSearch( rc = SQLITE_ERROR; goto out; } - if( sqlite3_value_type(argv[2]) != SQLITE_INTEGER ){ - *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be a non-negative integer"); - rc = SQLITE_ERROR; - goto out; - } - k = sqlite3_value_int(argv[2]); - if( k < 0 ){ - *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be a non-negative integer"); + if( sqlite3_value_type(argv[2]) == SQLITE_INTEGER ){ + k = sqlite3_value_int(argv[2]); + if( k < 0 ){ + *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be a non-negative integer, but negative value were provided"); + rc = SQLITE_ERROR; + goto out; + } + }else if( sqlite3_value_type(argv[2]) == SQLITE_FLOAT ) { + kDouble = sqlite3_value_double(argv[2]); + k = (int)kDouble; + if( (double)k != kDouble ){ + *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be an integer, but float value were provided"); + rc = SQLITE_ERROR; + goto out; + } + if( k < 0 ){ + *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be a non-negative integer, but negative value were provided"); + rc = SQLITE_ERROR; + goto out; + } + }else{ + *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be an integer, but unexpected type of value were provided"); rc = SQLITE_ERROR; goto out; } + if( sqlite3_value_type(argv[0]) != SQLITE_TEXT ){ *pzErrMsg = sqlite3_mprintf("vector index(search): first parameter (index) must be a string"); rc = SQLITE_ERROR; diff --git a/libsql-ffi/bundled/src/sqlite3.c b/libsql-ffi/bundled/src/sqlite3.c index 69dd8e24a6..82db050d36 100644 --- a/libsql-ffi/bundled/src/sqlite3.c +++ b/libsql-ffi/bundled/src/sqlite3.c @@ -216033,6 +216033,7 @@ int vectorIndexSearch( char **pzErrMsg ) { int type, dims, k, rc; + double kDouble; const char *zIdxName; const char *zErrMsg; Vector *pVector = NULL; @@ -216063,17 +216064,32 @@ int vectorIndexSearch( rc = SQLITE_ERROR; goto out; } - if( sqlite3_value_type(argv[2]) != SQLITE_INTEGER ){ - *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be a non-negative integer"); - rc = SQLITE_ERROR; - goto out; - } - k = sqlite3_value_int(argv[2]); - if( k < 0 ){ - *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be a non-negative integer"); + if( sqlite3_value_type(argv[2]) == SQLITE_INTEGER ){ + k = sqlite3_value_int(argv[2]); + if( k < 0 ){ + *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be a non-negative integer, but negative value were provided"); + rc = SQLITE_ERROR; + goto out; + } + }else if( sqlite3_value_type(argv[2]) == SQLITE_FLOAT ) { + kDouble = sqlite3_value_double(argv[2]); + k = (int)kDouble; + if( (double)k != kDouble ){ + *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be an integer, but float value were provided"); + rc = SQLITE_ERROR; + goto out; + } + if( k < 0 ){ + *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be a non-negative integer, but negative value were provided"); + rc = SQLITE_ERROR; + goto out; + } + }else{ + *pzErrMsg = sqlite3_mprintf("vector index(search): third parameter (k) must be an integer, but unexpected type of value were provided"); rc = SQLITE_ERROR; goto out; } + if( sqlite3_value_type(argv[0]) != SQLITE_TEXT ){ *pzErrMsg = sqlite3_mprintf("vector index(search): first parameter (index) must be a string"); rc = SQLITE_ERROR;