switch to BWU1

This commit is contained in:
vms 2021-04-22 19:48:39 +03:00
parent 107372813c
commit f23126d37e
8 changed files with 380 additions and 390 deletions

View File

@ -26,7 +26,7 @@ EXPORT_FUNCS = \
--export=sqlite3_column_name_,$\
--export=sqlite3_step,$\
--export=sqlite3_reset,$\
--export=sqlite3_bind_blob_,$\
--export=sqlite3_bind_blob,$\
--export=sqlite3_bind_double,$\
--export=sqlite3_bind_int64,$\
--export=sqlite3_bind_text,$\
@ -34,7 +34,6 @@ EXPORT_FUNCS = \
--export=sqlite3_column_count,$\
--export=sqlite3_column_double,$\
--export=sqlite3_column_int64,$\
--export=sqlite3_column_text_,$\
--export=sqlite3_column_blob_,$\
--export=sqlite3_column_bytes,$\
--export=sqlite3_finalize

View File

@ -1,4 +1,4 @@
(@interface it_version "0.19.0")
(@interface it_version "0.20.0")
;; Types
(@interface type (func

View File

@ -28,6 +28,7 @@
** argument to xCallback(). If xCallback=NULL then no callback
** is invoked, even for queries.
*/
#ifndef __sqlite_unmodified_upstream
void sqlite3_exec_(
sqlite3 *db, /* The database on which the SQL executes */
char *zSql, /* The SQL to be executed */
@ -40,21 +41,20 @@ void sqlite3_exec_(
char *pzErrMsg = 0;
const int ret_code = sqlite3_exec(db, zSql, xCallback, pArg, &pzErrMsg);
// free the string passed from the IT side
free(zSql);
int *result = malloc(3*8);
result[0] = ret_code;
result[1] = 0;
result[2] = (int) pzErrMsg;
result[3] = 0;
result[4] = strlen(pzErrMsg);
result[5] = 0;
unsigned char *result = (unsigned char*)malloc(3*4);
write_le_int(result, 0, (unsigned int)ret_code);
write_le_int(result, 4, (unsigned int)pzErrMsg);
write_le_int(result, 8, (unsigned int)strlen(pzErrMsg));
// errmsg should be managed by user
add_object_to_release((void *) pzErrMsg);
add_object_to_release((void *) result);
set_result_ptr((void *) result);
}
#endif
int sqlite3_exec(
sqlite3 *db, /* The database on which the SQL executes */

File diff suppressed because it is too large Load Diff

View File

@ -783,6 +783,7 @@ int sqlite3_prepare(
return rc;
}
#ifndef __sqlite_unmodified_upstream
void sqlite3_prepare_v2_(
sqlite3 *db, /* Database handle. */
const char *zSql, /* UTF-8 encoded SQL statement. */
@ -792,17 +793,20 @@ void sqlite3_prepare_v2_(
const char *pzTail = NULL;
const int ret_code = sqlite3_prepare_v2(db, zSql, nBytes, &ppStmt, &pzTail);
// free the string passed from the IT side
free((void *) zSql);
int *result = (int *)malloc(3*8);
result[0] = ret_code;
result[2] = (int)ppStmt;
result[4] = (int)pzTail;
result[5] = strlen(pzTail);
unsigned char *result = (unsigned char*)malloc(4 * 4);
write_le_int(result, 0, (unsigned int)ret_code);
write_le_int(result, 4, (unsigned int)ppStmt);
write_le_int(result, 8, (unsigned int)pzTail);
write_le_int(result, 12, (unsigned int)strlen(pzTail));
add_object_to_release((void *) result);
set_result_ptr((void *) result);
}
#endif
int sqlite3_prepare_v2(
sqlite3 *db, /* Database handle. */

View File

@ -4908,13 +4908,14 @@ void sqlite3VectorErrorMsg(Parse*, Expr*);
const char **sqlite3CompileOptions(int *pnOpt);
#endif
#ifndef __sqlite_unmodified_upstram
#ifndef __sqlite_unmodified_upstream
void add_object_to_release(void *object);
void set_result_ptr(void *ptr);
void set_result_size(int size);
char *handle_input_string(char *str, int len);
void write_le_int(unsigned char *array, unsigned int offset, unsigned int value);
#endif
#endif /* SQLITEINT_H */

View File

@ -1255,6 +1255,7 @@ static const void *columnName(
** Return the name of the Nth column of the result set returned by SQL
** statement pStmt.
*/
#ifndef __sqlite_unmodified_upstream
void sqlite3_column_name_(sqlite3_stmt *pStmt, int N) __EXPORT_NAME(sqlite3_column_name) {
const char *result = sqlite3_column_name(pStmt, N);
@ -1262,6 +1263,7 @@ void sqlite3_column_name_(sqlite3_stmt *pStmt, int N) __EXPORT_NAME(sqlite3_colu
set_result_ptr((void *)result);
set_result_size(strlen(result));
}
#endif
const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
return columnName(pStmt, N, 0, COLNAME_NAME);
@ -1435,31 +1437,6 @@ static int bindText(
/*
** Bind a blob value to an SQL statement variable.
*/
int sqlite3_bind_blob_(
sqlite3_stmt *pStmt,
int i,
char *zData,
int nData,
void (*xDel)(void*)
) __EXPORT_NAME(sqlite3_bind_blob) {
const int copied_nData = nData / 8;
char *copied_zData = malloc(copied_nData);
if (copied_zData == 0) {
return -1;
}
for (int char_id = 0; char_id < copied_nData; ++char_id) {
copied_zData[char_id] = zData[char_id * 8];
}
free(zData);
const int result = sqlite3_bind_blob(pStmt, i, copied_zData, copied_nData, 0);
return result;
}
int sqlite3_bind_blob(
sqlite3_stmt *pStmt,
int i,

View File

@ -54,6 +54,13 @@ char *handle_input_string(char *str, int len) {
return str;
}
void write_le_int(unsigned char *array, unsigned int offset, unsigned int value) {
array[offset] = value & 0xff;
array[offset + 1] = (value >> 8) & 0xff;
array[offset + 2] = (value >> 16) & 0xff;
array[offset + 3] = (value >> 24) & 0xff;
}
int main() {
// the main purpose of this empty main is to initialize WASI subsystem
return 0;