Skip to content

Commit 8680b28

Browse files
committed
Various PostgreSQL fixes
1 parent 970bb21 commit 8680b28

File tree

2 files changed

+140
-288
lines changed

2 files changed

+140
-288
lines changed

src/cloudsync.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#define MAX(a, b) (((a)>(b))?(a):(b))
5858
#endif
5959

60-
#define DEBUG_DBERROR(_rc, _fn, _db) do {if (_rc != DBRES_OK) printf("Error in %s: %s\n", _fn, database_errmsg(_db));} while (0)
60+
#define DEBUG_DBERROR(_rc, _fn, _data) do {if (_rc != DBRES_OK) printf("Error in %s: %s\n", _fn, database_errmsg(_data));} while (0)
6161

6262
typedef enum {
6363
CLOUDSYNC_PK_INDEX_TBL = 0,
@@ -245,7 +245,7 @@ const char *cloudsync_algo_name (table_algo algo) {
245245
DBVM_VALUE dbvm_execute (dbvm_t *stmt, cloudsync_context *data) {
246246
int rc = databasevm_step(stmt);
247247
if (rc != DBRES_ROW && rc != DBRES_DONE) {
248-
if (data) DEBUG_DBERROR(rc, "stmt_execute", data->db);
248+
if (data) DEBUG_DBERROR(rc, "stmt_execute", data);
249249
databasevm_reset(stmt);
250250
return DBVM_VALUE_ERROR;
251251
}
@@ -293,7 +293,6 @@ int dbvm_count (dbvm_t *stmt, const char *value, size_t len, int type) {
293293
}
294294

295295
cleanup:
296-
//DEBUG_DBERROR(rc, "stmt_count", sqlite3_db_handle(stmt));
297296
databasevm_reset(stmt);
298297
return result;
299298
}
@@ -1798,7 +1797,7 @@ int local_update_sentinel (cloudsync_table_context *table, const char *pk, size_
17981797
if (rc == DBRES_DONE) rc = DBRES_OK;
17991798

18001799
cleanup:
1801-
DEBUG_DBERROR(rc, "local_update_sentinel", table->context->db);
1800+
DEBUG_DBERROR(rc, "local_update_sentinel", table->context);
18021801
databasevm_reset(vm);
18031802
return rc;
18041803
}
@@ -1826,7 +1825,7 @@ int local_mark_insert_sentinel_meta (cloudsync_table_context *table, const char
18261825
if (rc == DBRES_DONE) rc = DBRES_OK;
18271826

18281827
cleanup:
1829-
DEBUG_DBERROR(rc, "local_insert_sentinel", table->context->db);
1828+
DEBUG_DBERROR(rc, "local_insert_sentinel", table->context);
18301829
databasevm_reset(vm);
18311830
return rc;
18321831
}
@@ -1861,7 +1860,7 @@ int local_mark_insert_or_update_meta_impl (cloudsync_table_context *table, const
18611860
if (rc == DBRES_DONE) rc = DBRES_OK;
18621861

18631862
cleanup:
1864-
DEBUG_DBERROR(rc, "local_insert_or_update", table->context->db);
1863+
DEBUG_DBERROR(rc, "local_insert_or_update", table->context);
18651864
databasevm_reset(vm);
18661865
return rc;
18671866
}
@@ -1885,7 +1884,7 @@ int local_drop_meta (cloudsync_table_context *table, const char *pk, size_t pkle
18851884
if (rc == DBRES_DONE) rc = DBRES_OK;
18861885

18871886
cleanup:
1888-
DEBUG_DBERROR(rc, "local_drop_meta", table->context->db);
1887+
DEBUG_DBERROR(rc, "local_drop_meta", table->context);
18891888
databasevm_reset(vm);
18901889
return rc;
18911890
}
@@ -1930,7 +1929,7 @@ int local_update_move_meta (cloudsync_table_context *table, const char *pk, size
19301929
if (rc == DBRES_DONE) rc = DBRES_OK;
19311930

19321931
cleanup:
1933-
DEBUG_DBERROR(rc, "local_update_move_meta", table->context->db);
1932+
DEBUG_DBERROR(rc, "local_update_move_meta", table->context);
19341933
databasevm_reset(vm);
19351934
return rc;
19361935
}

0 commit comments

Comments
 (0)