/* Reads the next result row from the snapshot query, parses and processes it. * Blocks until a new row is available, if necessary. */ int snapshot_poll(client_context_t context) { int err = 0; PGresult *res = PQgetResult(context->sql_conn); /* null result indicates that there are no more rows */ if (!res) { check(err, exec_sql(context, "COMMIT")); PQfinish(context->sql_conn); context->sql_conn = NULL; // Invoke the commit callback with xid==0 to indicate end of snapshot commit_txn_cb on_commit = context->repl.frame_reader->on_commit_txn; void *cb_context = context->repl.frame_reader->cb_context; if (on_commit) { check(err, on_commit(cb_context, context->repl.start_lsn, 0)); } return 0; } ExecStatusType status = PQresultStatus(res); if (status != PGRES_SINGLE_TUPLE && status != PGRES_TUPLES_OK) { client_error(context, "While reading snapshot: %s: %s", PQresStatus(PQresultStatus(res)), PQresultErrorMessage(res)); PQclear(res); return EIO; } int tuples = PQntuples(res); for (int tuple = 0; tuple < tuples; tuple++) { check(err, snapshot_tuple(context, res, tuple)); } PQclear(res); return err; }
virtual void on_start(){ ease_assert( m_db.create(), "%d => %s", m_db.code(), m_db.msg().p() ); on_bool(); on_int8(); on_uint8(); on_int16(); on_uint16(); on_int32(); on_uint32(); on_int64(); on_uint64(); on_float(); on_double(); on_string(); on_rollback(); on_commit(); }