Esempio n. 1
0
static void snapshot_float(t_snapshot *x, t_float f)
{
    /* CHECKED nonzero/zero, CHECKED incompatible: int only (float ignored) */
    if (f != 0.)
	snapshot_start(x);
    else
	snapshot_stop(x);
}
Esempio n. 2
0
/* Connects to the Postgres server (using context->conninfo for server info and
 * context->app_name as client name), and checks whether replication slot
 * context->repl.slot_name already exists. If yes, sets up the context to start
 * receiving the stream of changes from that slot. If no, creates the slot, and
 * initiates the consistent snapshot. */
int db_client_start(client_context_t context) {
    int err = 0;
    bool slot_exists;

    check(err, client_connect(context));
    checkRepl(err, context, replication_stream_check(&context->repl));
    check(err, replication_slot_exists(context, &slot_exists));

    if (slot_exists) {
        PQfinish(context->sql_conn);
        context->sql_conn = NULL;
        context->taking_snapshot = false;

        checkRepl(err, context, replication_stream_start(&context->repl));
        return err;

    } else {
        context->taking_snapshot = true;
        checkRepl(err, context, replication_slot_create(&context->repl));
        check(err, snapshot_start(context));
        return err;
    }
}