19#define PREP_WAITING "isolationtester_waiting"
60#define STEP_NONBLOCK 0x1
97 while ((opt =
getopt(argc, argv,
"V")) != -1)
126 conninfo =
"dbname = postgres";
143 printf(
"Parsed test spec with %d sessions\n",
testspec->nsessions);
155 const char *sessionname;
158 sessionname =
"control connection";
160 sessionname =
testspec->sessions[
i - 1]->name;
194 "SELECT set_config('application_name',\n"
195 " current_setting('application_name') || '/' || $1,\n"
222 "SELECT pg_catalog.pg_isolation_test_session_is_blocked($1, '{");
316 fprintf(
stderr,
"undefined step \"%s\" specified in permutation\n",
323 pstep->step->used =
true;
336 for (k = 0; k <
pstep->nblockers; k++)
345 for (n = 0; n < p->
nsteps; n++)
357 fprintf(
stderr,
"undefined blocking step \"%s\" referenced in permutation step \"%s\"\n",
364 fprintf(
stderr,
"permutation step \"%s\" cannot block on its own session\n",
422 for (
i = 0;
i < nsteps;
i++)
510 const char *stepname = (
const char *)
a;
529 printf(
"\nstarting permutation:");
530 for (
i = 0;
i < nsteps;
i++)
572 for (
i = 0;
i < nsteps;
i++)
648 iconn->active_step->name,
657 oconn->active_step->name);
669 fprintf(stdout,
"failed to send query for step %s: %s\n",
678 for (
j = 0;
j <
pstep->nblockers;
j++)
703 fprintf(
stderr,
"failed to complete permutation due to mutually-blocking steps\n");
830 bool canceled =
false;
841 for (
i = 0;
i <
pstep->nblockers;
i++)
847 printf(
"step %s: %s <waiting ...>\n",
925 printf(
"step %s: %s <waiting ...>\n",
957 printf(
"isolationtester: canceling step %s after %d seconds\n",
995 printf(
"step %s: %s <waiting ...>\n",
1002 printf(
"step %s: <... completed>\n", step->
name);
1036 printf(
"unexpected result status: %s\n",
1065 printf(
"%s: NOTIFY \"%s\" with payload \"%s\" from %s\n",
1084 for (
i = 0;
i <
pstep->nblockers;
i++)
1097 if (
iconn->active_step &&
1098 iconn->active_step->step == blocker->
step)
1117 memset(&popt, 0,
sizeof(popt));
#define fprintf(file, fmt, msg)
PGcancelConn * PQcancelCreate(PGconn *conn)
int PQcancelBlocking(PGcancelConn *cancelConn)
void PQcancelFinish(PGcancelConn *cancelConn)
char * PQcancelErrorMessage(const PGcancelConn *cancelConn)
PGconn * PQconnectdb(const char *conninfo)
ConnStatusType PQstatus(const PGconn *conn)
void PQfinish(PGconn *conn)
int PQbackendPID(const PGconn *conn)
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
char * PQerrorMessage(const PGconn *conn)
int PQsocket(const PGconn *conn)
void PQfreemem(void *ptr)
PGresult * PQexecParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
PGresult * PQexecPrepared(PGconn *conn, const char *stmtName, int nParams, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
PGresult * PQprepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
int PQconsumeInput(PGconn *conn)
int PQsendQuery(PGconn *conn, const char *query)
char * PQresStatus(ExecStatusType status)
int PQisBusy(PGconn *conn)
PGresult * PQexec(PGconn *conn, const char *query)
PGnotify * PQnotifies(PGconn *conn)
void PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
void * pg_malloc(size_t size)
void * pg_malloc0(size_t size)
static void printResultSet(PGresult *res)
static int step_bsearch_cmp(const void *a, const void *b)
static IsoConnInfo * conns
static int step_qsort_cmp(const void *a, const void *b)
static void run_testspec(TestSpec *testspec)
static void run_named_permutations(TestSpec *testspec)
static int try_complete_steps(TestSpec *testspec, PermutationStep **waiting, int nwaiting, int flags)
static void run_all_permutations_recurse(TestSpec *testspec, int *piles, int nsteps, PermutationStep **steps)
static bool try_complete_step(TestSpec *testspec, PermutationStep *pstep, int flags)
static void run_all_permutations(TestSpec *testspec)
static void blackholeNoticeProcessor(void *arg, const char *message)
static void check_testspec(TestSpec *testspec)
static void run_permutation(TestSpec *testspec, int nsteps, PermutationStep **steps)
static void isotesterNoticeProcessor(void *arg, const char *message)
static int64 max_step_wait
static bool step_has_blocker(PermutationStep *pstep)
static void disconnect_atexit(void)
static bool any_new_notice
#define PQresultErrorMessage
#define PQresultErrorField
int getopt(int nargc, char *const *nargv, const char *ostr)
#define qsort(a, b, c, d)
#define PG_DIAG_MESSAGE_PRIMARY
void initPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
void termPQExpBuffer(PQExpBuffer str)
char * psprintf(const char *fmt,...)
PermutationStep * active_step
const char * backend_pid_str
PermutationStepBlockerType blocktype
static volatile sig_atomic_t waiting
#define select(n, r, w, e, timeout)
int gettimeofday(struct timeval *tp, void *tzp)