src/evsql_test.c
branchnew-evsql
changeset 47 8c6c459eacb7
parent 46 75cecfc4603b
equal deleted inserted replaced
46:75cecfc4603b 47:8c6c459eacb7
    85         WARNING("evsql_query_exec failed");
    85         WARNING("evsql_query_exec failed");
    86 
    86 
    87     INFO("[evsql_test.query_send] enqueued query, trans=%p: %p: %d", trans, query, query_id);
    87     INFO("[evsql_test.query_send] enqueued query, trans=%p: %p: %d", trans, query, query_id);
    88 }
    88 }
    89 
    89 
       
    90 void trans_commit (struct evsql_test_ctx *ctx) {
       
    91     if (evsql_trans_commit(ctx->trans))
       
    92         FATAL("evsql_trans_commit failed");
       
    93     
       
    94     INFO("[evsql_test.trans_commit] commiting transaction");
       
    95 }
       
    96 
    90 void trans_insert_result (struct evsql_result *res, void *arg) {
    97 void trans_insert_result (struct evsql_result *res, void *arg) {
    91     struct evsql_test_ctx *ctx = arg;
    98     struct evsql_test_ctx *ctx = arg;
    92     err_t err;
    99     err_t err;
    93     
   100     
    94     // the result info
   101     // the result info
   119     
   126     
   120     INFO("\t(done)");
   127     INFO("\t(done)");
   121 
   128 
   122     // done
   129     // done
   123     evsql_result_end(res);
   130     evsql_result_end(res);
       
   131 
       
   132     // commit the transaction
       
   133     trans_commit(ctx);
   124 }
   134 }
   125 
   135 
   126 void trans_insert (struct evsql_test_ctx *ctx) {
   136 void trans_insert (struct evsql_test_ctx *ctx) {
   127     struct evsql_query *query = NULL;
   137     struct evsql_query *query = NULL;
   128 
   138 
   184 }
   194 }
   185 
   195 
   186 void trans_error (struct evsql_trans *trans, void *arg) {
   196 void trans_error (struct evsql_trans *trans, void *arg) {
   187     struct evsql_test_ctx *ctx = arg;
   197     struct evsql_test_ctx *ctx = arg;
   188 
   198 
   189     FATAL("[evsql_test.trans_error] failure: %s", evsql_trans_error(trans));
   199     FATAL("[evsql_test.trans_error] failure: trans=%p: %s", ctx->trans, evsql_trans_error(trans));
   190 }
   200 }
   191 
   201 
   192 void trans_ready (struct evsql_trans *trans, void *arg) {
   202 void trans_ready (struct evsql_trans *trans, void *arg) {
   193     struct evsql_test_ctx *ctx = arg;
   203     struct evsql_test_ctx *ctx = arg;
   194 
   204 
   198 }
   208 }
   199 
   209 
   200 void trans_done (struct evsql_trans *trans, void *arg) {
   210 void trans_done (struct evsql_trans *trans, void *arg) {
   201     struct evsql_test_ctx *ctx = arg;
   211     struct evsql_test_ctx *ctx = arg;
   202 
   212 
   203     INFO("[evsql_test.trans_done] done");
   213     INFO("[evsql_test.trans_done] done: trans=%p", ctx->trans);
   204 }
   214 }
   205 
   215 
   206 void begin_transaction (struct evsql_test_ctx *ctx) {
   216 void begin_transaction (struct evsql_test_ctx *ctx) {
   207     assert((ctx->trans = evsql_trans(ctx->db, EVSQL_TRANS_DEFAULT, 
   217     assert((ctx->trans = evsql_trans(ctx->db, EVSQL_TRANS_DEFAULT, 
   208         &trans_error, &trans_ready, &trans_done,
   218         &trans_error, &trans_ready, &trans_done,