comparison src/c/urweb.c @ 2056:a9159911c3ba

New phase: Dbmodecheck
author Adam Chlipala <adam@chlipala.net>
date Sun, 17 Aug 2014 13:07:56 -0400
parents 4ad46302f659
children d77b0665ba7c ef766ef6e242
comparison
equal deleted inserted replaced
2055:7c2229aa22fc 2056:a9159911c3ba
439 439
440 cleanup *cleanup, *cleanup_front, *cleanup_back; 440 cleanup *cleanup, *cleanup_front, *cleanup_back;
441 441
442 const char *script_header; 442 const char *script_header;
443 443
444 int needs_push, needs_sig, could_write_db; 444 int needs_push, needs_sig, could_write_db, at_most_one_query;
445 445
446 size_t n_deltas, used_deltas; 446 size_t n_deltas, used_deltas;
447 delta *deltas; 447 delta *deltas;
448 448
449 client *client; 449 client *client;
518 518
519 ctx->script_header = ""; 519 ctx->script_header = "";
520 ctx->needs_push = 0; 520 ctx->needs_push = 0;
521 ctx->needs_sig = 0; 521 ctx->needs_sig = 0;
522 ctx->could_write_db = 1; 522 ctx->could_write_db = 1;
523 ctx->at_most_one_query = 0;
523 524
524 ctx->source_count = 0; 525 ctx->source_count = 0;
525 526
526 ctx->n_deltas = ctx->used_deltas = 0; 527 ctx->n_deltas = ctx->used_deltas = 0;
527 ctx->deltas = malloc(0); 528 ctx->deltas = malloc(0);
784 785
785 return r; 786 return r;
786 } 787 }
787 788
788 void uw_ensure_transaction(uw_context ctx) { 789 void uw_ensure_transaction(uw_context ctx) {
789 if (!ctx->transaction_started) { 790 if (!ctx->transaction_started && !ctx->at_most_one_query) {
790 if (ctx->app->db_begin(ctx, ctx->could_write_db)) 791 if (ctx->app->db_begin(ctx, ctx->could_write_db))
791 uw_error(ctx, BOUNDED_RETRY, "Error running SQL BEGIN"); 792 uw_error(ctx, BOUNDED_RETRY, "Error running SQL BEGIN");
792 ctx->transaction_started = 1; 793 ctx->transaction_started = 1;
793 } 794 }
794 } 795 }
1201 ctx->needs_sig = n; 1202 ctx->needs_sig = n;
1202 } 1203 }
1203 1204
1204 void uw_set_could_write_db(uw_context ctx, int n) { 1205 void uw_set_could_write_db(uw_context ctx, int n) {
1205 ctx->could_write_db = n; 1206 ctx->could_write_db = n;
1207 }
1208
1209 void uw_set_at_most_one_query(uw_context ctx, int n) {
1210 ctx->at_most_one_query = n;
1206 } 1211 }
1207 1212
1208 1213
1209 static void uw_buffer_check_ctx(uw_context ctx, const char *kind, uw_buffer *b, size_t extra, const char *desc) { 1214 static void uw_buffer_check_ctx(uw_context ctx, const char *kind, uw_buffer *b, size_t extra, const char *desc) {
1210 if (b->back - b->front < extra) { 1215 if (b->back - b->front < extra) {