Changeset 1851
- Timestamp:
- 03/17/07 11:08:06 (21 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-0.2X/opensync/opensync/opensync_db.c
r1666 r1851 38 38 if (rc) { 39 39 osync_error_set(error, OSYNC_ERROR_GENERIC, "Cannot open database: %s", sqlite3_errmsg(db->db)); 40 goto error_ free;40 goto error_close; 41 41 } 42 42 sqlite3_trace(db->db, osync_db_trace, NULL); … … 45 45 return db; 46 46 47 error_free: 47 error_close: 48 osync_db_close(db); 49 //error_free: 48 50 g_free(db); 49 51 error: … … 57 59 58 60 int ret = sqlite3_close(db->db); 59 if (ret )61 if (ret != SQLITE_OK) 60 62 osync_trace(TRACE_INTERNAL, "Can't close database: %s", sqlite3_errmsg(db->db)); 61 63 … … 70 72 if (sqlite3_prepare(db->db, query, -1, &ppStmt, NULL) != SQLITE_OK) 71 73 osync_debug("OSDB", 3, "Unable prepare count! %s", sqlite3_errmsg(db->db)); 72 if (sqlite3_step(ppStmt) != SQLITE_OK) 74 ret = sqlite3_step(ppStmt); 75 if (ret != SQLITE_DONE && ret != SQLITE_ROW) 73 76 osync_debug("OSDB", 3, "Unable step count! %s", sqlite3_errmsg(db->db)); 77 if (ret == SQLITE_DONE) 78 osync_debug("OSDB", 3, "No row found!"); 74 79 ret = sqlite3_column_int64(ppStmt, 0); 75 80 sqlite3_finalize(ppStmt); … … 85 90 if (!(log_db = osync_db_open(filename, error))) { 86 91 osync_error_update(error, "Unable to load changelog: %s", osync_error_print(error)); 92 g_free(filename); 87 93 osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); 88 94 return NULL; … … 481 487 char *filename = g_strdup_printf ("%s/anchor.db", member->configdir); 482 488 if (!(sdb = osync_db_open(filename, error))) { 489 g_free(filename); 483 490 osync_error_update(error, "Unable to open anchor table: %s", (*error)->message); 484 491 return NULL; … … 503 510 if (sqlite3_prepare(sdb->db, query, -1, &ppStmt, NULL) != SQLITE_OK) 504 511 osync_debug("OSDB", 3, "Unable prepare anchor! %s", sqlite3_errmsg(sdb->db)); 505 sqlite3_step(ppStmt); 512 int ret = sqlite3_step(ppStmt); 513 if (ret != SQLITE_DONE && ret != SQLITE_ROW) 514 osync_debug("OSDB", 3, "Unable step count! %s", sqlite3_errmsg(sdb->db)); 515 if (ret == SQLITE_DONE) 516 osync_debug("OSDB", 3, "No row found!"); 506 517 *retanchor = g_strdup((gchar*)sqlite3_column_text(ppStmt, 0)); 507 518 sqlite3_finalize(ppStmt); … … 527 538 char *filename = g_strdup_printf ("%s/hash.db", member->configdir); 528 539 if (!(table->dbhandle = osync_db_open(filename, error))) { 540 g_free(filename); 529 541 osync_error_update(error, "Unable to open hashtable: %s", (*error)->message); 530 542 return FALSE;
