|
Lines 1-114
Link Here
|
| 1 |
--- src/dm_db.c.orig Tue Jan 6 14:51:55 2009 |
|
|
| 2 |
+++ src/dm_db.c Sun Jan 25 19:25:06 2009 |
| 3 |
@@ -312,8 +312,9 @@ |
| 4 |
TRACE(TRACE_DATABASE,"[%p] [%s]", c, query); |
| 5 |
TRY |
| 6 |
gettimeofday(&before, NULL); |
| 7 |
- result = Connection_execute(c, query); |
| 8 |
+ Connection_execute(c, query); |
| 9 |
gettimeofday(&after, NULL); |
| 10 |
+ result = TRUE; |
| 11 |
CATCH(SQLException) |
| 12 |
LOG_SQLERROR; |
| 13 |
TRACE(TRACE_ERR,"failed query [%s]", query); |
| 14 |
@@ -395,26 +396,51 @@ |
| 15 |
int db_stmt_set_str(S s, int index, const char *x) |
| 16 |
{ |
| 17 |
TRACE(TRACE_DATABASE,"[%p] %d:[%s]", s, index, x); |
| 18 |
- return PreparedStatement_setString(s, index, x); |
| 19 |
+ TRY |
| 20 |
+ PreparedStatement_setString(s, index, x); |
| 21 |
+ return TRUE; |
| 22 |
+ CATCH(SQLException) |
| 23 |
+ return FALSE; |
| 24 |
+ END_TRY; |
| 25 |
} |
| 26 |
int db_stmt_set_int(S s, int index, int x) |
| 27 |
{ |
| 28 |
TRACE(TRACE_DATABASE,"[%p] %d:[%d]", s, index, x); |
| 29 |
- return PreparedStatement_setInt(s, index, x); |
| 30 |
+ TRY |
| 31 |
+ PreparedStatement_setInt(s, index, x); |
| 32 |
+ return TRUE; |
| 33 |
+ CATCH(SQLException) |
| 34 |
+ return FALSE; |
| 35 |
+ END_TRY; |
| 36 |
} |
| 37 |
int db_stmt_set_u64(S s, int index, u64_t x) |
| 38 |
{ |
| 39 |
TRACE(TRACE_DATABASE,"[%p] %d:[%llu]", s, index, x); |
| 40 |
- return PreparedStatement_setLLong(s, index, (long long)x); |
| 41 |
+ TRY |
| 42 |
+ PreparedStatement_setLLong(s, index, (long long)x); |
| 43 |
+ return TRUE; |
| 44 |
+ CATCH(SQLException) |
| 45 |
+ return FALSE; |
| 46 |
+ END_TRY; |
| 47 |
} |
| 48 |
int db_stmt_set_blob(S s, int index, const void *x, int size) |
| 49 |
{ |
| 50 |
// TRACE(TRACE_DATABASE,"[%p] %d:[%s]", s, index, (const char *)x); |
| 51 |
- return PreparedStatement_setBlob(s, index, x, size); |
| 52 |
+ TRY |
| 53 |
+ PreparedStatement_setBlob(s, index, x, size); |
| 54 |
+ return TRUE; |
| 55 |
+ CATCH(SQLException) |
| 56 |
+ return FALSE; |
| 57 |
+ END_TRY; |
| 58 |
} |
| 59 |
gboolean db_stmt_exec(S s) |
| 60 |
{ |
| 61 |
- return PreparedStatement_execute(s); |
| 62 |
+ TRY |
| 63 |
+ PreparedStatement_execute(s); |
| 64 |
+ return TRUE; |
| 65 |
+ CATCH(SQLException) |
| 66 |
+ return FALSE; |
| 67 |
+ END_TRY; |
| 68 |
} |
| 69 |
R db_stmt_query(S s) |
| 70 |
{ |
| 71 |
@@ -474,28 +500,36 @@ |
| 72 |
int db_begin_transaction(C c) |
| 73 |
{ |
| 74 |
TRACE(TRACE_DATABASE,"BEGIN"); |
| 75 |
- if (! Connection_beginTransaction(c)) |
| 76 |
+ TRY |
| 77 |
+ Connection_beginTransaction(c); |
| 78 |
+ return DM_SUCCESS; |
| 79 |
+ CATCH(SQLException) |
| 80 |
return DM_EQUERY; |
| 81 |
- return DM_SUCCESS; |
| 82 |
+ END_TRY; |
| 83 |
} |
| 84 |
|
| 85 |
int db_commit_transaction(C c) |
| 86 |
{ |
| 87 |
TRACE(TRACE_DATABASE,"COMMIT"); |
| 88 |
- if (! Connection_commit(c)) { |
| 89 |
+ TRY |
| 90 |
+ Connection_commit(c); |
| 91 |
+ return DM_SUCCESS; |
| 92 |
+ CATCH(SQLException) |
| 93 |
db_rollback_transaction(c); |
| 94 |
return DM_EQUERY; |
| 95 |
- } |
| 96 |
- return DM_SUCCESS; |
| 97 |
+ END_TRY; |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
int db_rollback_transaction(C c) |
| 102 |
{ |
| 103 |
TRACE(TRACE_DATABASE,"ROLLBACK"); |
| 104 |
- if (! Connection_rollback(c)) |
| 105 |
+ TRY |
| 106 |
+ Connection_rollback(c); |
| 107 |
+ return DM_SUCCESS; |
| 108 |
+ CATCH(SQLException) |
| 109 |
return DM_EQUERY; |
| 110 |
- return DM_SUCCESS; |
| 111 |
+ END_TRY; |
| 112 |
} |
| 113 |
|
| 114 |
int db_savepoint(C UNUSED c, const char UNUSED *id) |