Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3c93f65

Browse files
committedNov 27, 2024·
libsql-sqlite3: Improve WAL API test
Make the test bit harder on the WAL API by generating more than one frame per transaction.
1 parent 98a5345 commit 3c93f65

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
 

‎libsql-sqlite3/src/test_walapi.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ static int cmp_data(sqlite3 *db1, sqlite3 *db2){
3030
sqlite3_stmt *stmt1, *stmt2;
3131
int rc;
3232

33-
rc = sqlite3_prepare_v2(db1, "SELECT * FROM users", -1, &stmt1, 0);
33+
rc = sqlite3_prepare_v2(db1, "SELECT HEX(x) FROM t", -1, &stmt1, 0);
3434
if( rc!=SQLITE_OK ){
3535
fprintf(stderr, "Can't prepare statement: %s\n", sqlite3_errmsg(db1));
3636
return 1;
3737
}
3838

39-
rc = sqlite3_prepare_v2(db2, "SELECT * FROM users", -1, &stmt2, 0);
39+
rc = sqlite3_prepare_v2(db2, "SELECT HEX(x) FROM t", -1, &stmt2, 0);
4040
if( rc!=SQLITE_OK ){
4141
fprintf(stderr, "Can't prepare statement: %s\n", sqlite3_errmsg(db2));
4242
return 1;
@@ -52,10 +52,10 @@ static int cmp_data(sqlite3 *db1, sqlite3 *db2){
5252
if( step1!=SQLITE_ROW ){
5353
break;
5454
}
55-
const unsigned char *name1 = sqlite3_column_text(stmt1, 1);
56-
const unsigned char *name2 = sqlite3_column_text(stmt2, 1);
57-
if( strcmp((const char *)name1, (const char *)name2)!=0 ){
58-
fprintf(stderr, "Data mismatch: %s != %s\n", name1, name2);
55+
const unsigned char *text1 = sqlite3_column_text(stmt1, 0);
56+
const unsigned char *text2 = sqlite3_column_text(stmt2, 0);
57+
if( strncmp((const char *)text1, (const char *)text2, 4096)!=0 ){
58+
fprintf(stderr, "Data mismatch\n");
5959
return 1;
6060
}
6161
}
@@ -98,10 +98,10 @@ static int sync_db(sqlite3 *db_primary, sqlite3 *db_backup){
9898
}
9999

100100
static void gen_data(sqlite3 *db){
101-
sqlite3_exec(db, "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)", 0, 0, 0);
102-
sqlite3_exec(db, "INSERT INTO users (id, name) VALUES (1, 'John Doe')", 0, 0, 0);
103-
sqlite3_exec(db, "INSERT INTO users (id, name) VALUES (2, 'Jane Doe')", 0, 0, 0);
104-
sqlite3_exec(db, "INSERT INTO users (id, name) VALUES (3, 'Jim Beam')", 0, 0, 0);
101+
sqlite3_exec(db, "CREATE TABLE t (x)", 0, 0, 0);
102+
sqlite3_exec(db, "INSERT INTO t VALUES (randomblob(4 * 1024))", 0, 0, 0);
103+
sqlite3_exec(db, "INSERT INTO t VALUES (randomblob(1 * 1024))", 0, 0, 0);
104+
sqlite3_exec(db, "INSERT INTO t VALUES (randomblob(1 * 1024))", 0, 0, 0);
105105
}
106106

107107
int open_db(const char *path, sqlite3 **db) {

0 commit comments

Comments
 (0)
Please sign in to comment.