mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 22:46:04 +03:00
Fix several bugs in the journal query function.
This commit is contained in:
parent
cc5c87068e
commit
27fb5d9128
2 changed files with 25 additions and 5 deletions
|
@ -76,7 +76,7 @@ static int csync_journal_is_empty(CSYNC *ctx) {
|
|||
int rc = 0;
|
||||
|
||||
result = csync_journal_query(ctx, "SELECT COUNT(key) FROM metadata LIMIT 1 OFFSET 0;");
|
||||
if (result && result->count == 0) {
|
||||
if (result == NULL) {
|
||||
rc = 1;
|
||||
}
|
||||
c_strlist_destroy(result);
|
||||
|
@ -264,7 +264,6 @@ c_strlist_t *csync_journal_query(CSYNC *ctx, const char *statement) {
|
|||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Gave up waiting for lock to clear");
|
||||
}
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "sqlite3_compile error: %s - on query %s", sqlite3_errmsg(ctx->journal.db), statement);
|
||||
result = c_strlist_new(1);
|
||||
break;
|
||||
} else {
|
||||
busy_count = 0;
|
||||
|
@ -289,8 +288,14 @@ c_strlist_t *csync_journal_query(CSYNC *ctx, const char *statement) {
|
|||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "sqlite3_step: MISUSE!!");
|
||||
}
|
||||
|
||||
if (err == SQLITE_DONE || err == SQLITE_ERROR) {
|
||||
if (err == SQLITE_DONE) {
|
||||
if (result == NULL) {
|
||||
result = c_strlist_new(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (err == SQLITE_ERROR) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,20 @@ START_TEST (check_csync_journal_query_statement)
|
|||
c_strlist_destroy(result);
|
||||
|
||||
result = csync_journal_query(csync, "SELECT;");
|
||||
fail_unless(result != NULL, NULL);
|
||||
fail_unless(result == NULL, NULL);
|
||||
c_strlist_destroy(result);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (check_csync_journal_create_error)
|
||||
{
|
||||
c_strlist_t *result = NULL;
|
||||
result = csync_journal_query(csync, "CREATE TABLE test(key INTEGER, text VARCHAR(10));");
|
||||
fail_if(result == NULL, NULL);
|
||||
c_strlist_destroy(result);
|
||||
|
||||
result = csync_journal_query(csync, "CREATE TABLE test(key INTEGER, text VARCHAR(10));");
|
||||
fail_unless(result == NULL, NULL);
|
||||
c_strlist_destroy(result);
|
||||
}
|
||||
END_TEST
|
||||
|
@ -71,6 +84,7 @@ START_TEST (check_csync_journal_insert_statement)
|
|||
{
|
||||
c_strlist_t *result = NULL;
|
||||
result = csync_journal_query(csync, "CREATE TABLE test(key INTEGER, text VARCHAR(10));");
|
||||
fail_if(result == NULL, NULL);
|
||||
c_strlist_destroy(result);
|
||||
fail_unless(csync_journal_insert(csync, "INSERT;") == 0, NULL);
|
||||
fail_unless(csync_journal_insert(csync, "INSERT") == 0, NULL);
|
||||
|
@ -120,6 +134,7 @@ static Suite *csync_suite(void) {
|
|||
create_case(s, "check_csync_journal_check", check_csync_journal_check);
|
||||
create_case_fixture(s, "check_csync_journal_load", check_csync_journal_load, setup, teardown);
|
||||
create_case_fixture(s, "check_csync_journal_query_statement", check_csync_journal_query_statement, setup_init, teardown);
|
||||
create_case_fixture(s, "check_csync_journal_create_error", check_csync_journal_create_error, setup_init, teardown);
|
||||
create_case_fixture(s, "check_csync_journal_insert_statement", check_csync_journal_insert_statement, setup_init, teardown);
|
||||
create_case_fixture(s, "check_csync_journal_query_create_and_insert_table", check_csync_journal_query_create_and_insert_table, setup_init, teardown);
|
||||
create_case_fixture(s, "check_csync_journal_is_empty", check_csync_journal_is_empty, setup_init, teardown);
|
||||
|
|
Loading…
Reference in a new issue