21 #include "catalog/pg_type_d.h"
34 static const
char *const
progname = "libpq_pipeline";
41 #define pg_debug(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
47 "DROP TABLE IF EXISTS pq_pipeline_demo";
49 "CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer,"
52 "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1)";
54 "INSERT INTO pq_pipeline_demo(itemno,int8filler) VALUES ($1, $2)";
75 #define pg_fatal(...) pg_fatal_impl(__LINE__, __VA_ARGS__)
78 pg_fatal_impl(
int line, const
char *
fmt,...)
96 #define confirm_query_canceled(conn) confirm_query_canceled_impl(__LINE__, conn)
104 pg_fatal_impl(line,
"PQgetResult returned null: %s",
107 pg_fatal_impl(line,
"query did not fail when it was expected");
109 pg_fatal_impl(line,
"query failed with a different error than cancellation: %s",
124 char *
state,
char *event)
126 const Oid paramTypes[] = {INT4OID, TEXTOID};
127 const char *paramValues[2];
128 char *pidstr =
psprintf(
"%d", procpid);
132 paramValues[0] = pidstr;
142 "SELECT count(*) FROM pg_stat_activity WHERE "
143 "pid = $1 AND state = $2",
144 2, paramTypes, paramValues, NULL, NULL, 0);
147 "SELECT count(*) FROM pg_stat_activity WHERE "
148 "pid = $1 AND wait_event = $2",
149 2, paramTypes, paramValues, NULL, NULL, 0);
152 pg_fatal_impl(line,
"could not query pg_stat_activity: %s",
PQerrorMessage(monitorConn));
154 pg_fatal_impl(line,
"unexpected number of rows received: %d",
PQntuples(
res));
156 pg_fatal_impl(line,
"unexpected number of columns received: %d",
PQnfields(
res));
158 if (strcmp(
value,
"0") != 0)
172 #define send_cancellable_query(conn, monitorConn) \
173 send_cancellable_query_impl(__LINE__, conn, monitorConn)
177 const char *env_wait;
178 const Oid paramTypes[1] = {INT4OID};
187 env_wait = getenv(
"PG_TEST_TIMEOUT_DEFAULT");
188 if (env_wait == NULL)
192 &env_wait, NULL, NULL, 0) != 1)
210 const char **keywords;
218 keywords =
pg_malloc(
sizeof(
char *) * nopts);
219 vals =
pg_malloc(
sizeof(
char *) * nopts);
225 keywords[
i] = opt->keyword;
230 keywords[
i] = vals[
i] = NULL;
235 pg_fatal(
"Connection to database failed: %s",
252 fprintf(stderr,
"test cancellations... ");
267 if (!
PQcancel(cancel, errorbuf,
sizeof(errorbuf)))
268 pg_fatal(
"failed to run PQcancel: %s", errorbuf);
273 if (!
PQcancel(cancel, errorbuf,
sizeof(errorbuf)))
274 pg_fatal(
"failed to run PQcancel: %s", errorbuf);
309 FD_ZERO(&input_mask);
310 FD_ZERO(&output_mask);
315 FD_SET(sock, &input_mask);
319 FD_SET(sock, &output_mask);
333 if (
select(sock + 1, &input_mask, &output_mask, NULL, &tv) < 0)
366 FD_ZERO(&input_mask);
367 FD_ZERO(&output_mask);
372 FD_SET(sock, &input_mask);
376 FD_SET(sock, &output_mask);
390 if (
select(sock + 1, &input_mask, &output_mask, NULL, &tv) < 0)
413 fprintf(stderr,
"test error cases... ");
416 pg_fatal(
"Expected blocking connection mode");
419 pg_fatal(
"Unable to enter pipeline mode");
422 pg_fatal(
"Pipeline mode not activated properly");
427 pg_fatal(
"PQexec should fail in pipeline mode but succeeded");
429 "synchronous command execution functions are not allowed in pipeline mode\n") != 0)
430 pg_fatal(
"did not get expected error message; got: \"%s\"",
435 pg_fatal(
"PQsendQuery should fail in pipeline mode but succeeded");
437 "PQsendQuery not allowed in pipeline mode\n") != 0)
438 pg_fatal(
"did not get expected error message; got: \"%s\"",
443 pg_fatal(
"re-entering pipeline mode should be a no-op but failed");
446 pg_fatal(
"PQisBusy should return 0 when idle in pipeline mode, returned 1");
450 pg_fatal(
"couldn't exit idle empty pipeline mode");
453 pg_fatal(
"Pipeline mode not terminated properly");
457 pg_fatal(
"pipeline mode exit when not in pipeline mode should succeed but failed");
462 pg_fatal(
"PQexec should succeed after exiting pipeline mode but failed with: %s",
472 const char *dummy_params[1] = {
"1"};
473 Oid dummy_param_oids[1] = {INT4OID};
475 fprintf(stderr,
"multi pipeline... ");
486 dummy_params, NULL, NULL, 0) != 1)
494 dummy_params, NULL, NULL, 0) != 1)
503 dummy_params, NULL, NULL, 0) != 1)
515 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
519 pg_fatal(
"Unexpected result code %s from first pipeline item",
525 pg_fatal(
"PQgetResult returned something extra after first result");
528 pg_fatal(
"exiting pipeline mode after query but before sync succeeded incorrectly");
532 pg_fatal(
"PQgetResult returned null when sync result expected: %s",
536 pg_fatal(
"Unexpected result code %s instead of sync result, error: %s",
544 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
548 pg_fatal(
"Unexpected result code %s from second pipeline item",
554 pg_fatal(
"PQgetResult returned something extra after first result");
557 pg_fatal(
"exiting pipeline mode after query but before sync succeeded incorrectly");
561 pg_fatal(
"PQgetResult returned null when sync result expected: %s",
565 pg_fatal(
"Unexpected result code %s instead of sync result, error: %s",
573 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
577 pg_fatal(
"Unexpected result code %s from third pipeline item",
582 pg_fatal(
"Expected null result, got %s",
587 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
591 pg_fatal(
"Unexpected result code %s from second pipeline sync",
596 pg_fatal(
"Fell out of pipeline mode somehow");
600 pg_fatal(
"attempt to exit pipeline mode failed when it should've succeeded: %s",
604 pg_fatal(
"exiting pipeline mode didn't seem to work");
626 pg_fatal(
"could not enter pipeline mode");
627 for (
int i = 0;
i < numqueries;
i++)
633 0, NULL, NULL, NULL, NULL, 0) != 1)
640 FD_ZERO(&input_mask);
641 FD_SET(sock, &input_mask);
644 if (
select(sock + 1, &input_mask, NULL, NULL, &tv) < 0)
646 fprintf(stderr,
"select() failed: %m\n");
655 pg_fatal(
"failed to send flush request");
667 pg_fatal(
"got unexpected NULL result after %d results", results);
683 if (results == numqueries)
709 const char *dummy_params[1] = {
"1"};
710 Oid dummy_param_oids[1] = {INT4OID};
715 fprintf(stderr,
"aborted pipeline... ");
733 dummy_params[0] =
"1";
735 dummy_params, NULL, NULL, 0) != 1)
739 1, dummy_param_oids, dummy_params,
743 dummy_params[0] =
"2";
745 dummy_params, NULL, NULL, 0) != 1)
751 dummy_params[0] =
"3";
753 dummy_params, NULL, NULL, 0) != 1)
754 pg_fatal(
"dispatching second-pipeline insert failed: %s",
771 pg_fatal(
"Unexpected result status %s: %s",
778 pg_fatal(
"Expected null result, got %s",
786 pg_fatal(
"Unexpected result code -- expected PGRES_FATAL_ERROR, got %s",
792 pg_fatal(
"Expected null result, got %s",
803 pg_fatal(
"pipeline should be flagged as aborted but isn't");
810 pg_fatal(
"Unexpected result code -- expected PGRES_PIPELINE_ABORTED, got %s",
819 pg_fatal(
"pipeline should be flagged as aborted but isn't");
823 pg_fatal(
"Fell out of pipeline mode somehow");
835 pg_fatal(
"Unexpected result code from first pipeline sync\n"
836 "Expected PGRES_PIPELINE_SYNC, got %s",
841 pg_fatal(
"sync should've cleared the aborted flag but didn't");
845 pg_fatal(
"Fell out of pipeline mode somehow");
852 pg_fatal(
"Unexpected result code %s from first item in second pipeline",
864 pg_fatal(
"Unexpected result code %s from second pipeline sync",
869 pg_fatal(
"Expected null result, got %s: %s",
885 pg_fatal(
"expected error about multiple commands, got %s",
896 pg_fatal(
"did not get cannot-insert-multiple-commands error");
901 pg_fatal(
"Unexpected result code %s from pipeline sync",
907 0, NULL, NULL, NULL, NULL, 0) != 1)
924 pg_fatal(
"expected division-by-zero, got: %s (%s)",
927 printf(
"got expected division-by-zero\n");
936 pg_fatal(
"did not get division-by-zero error");
943 pg_fatal(
"Unexpected result code %s from third pipeline sync",
949 pg_fatal(
"Fell out of pipeline mode somehow");
953 pg_fatal(
"attempt to exit pipeline mode failed when it should've succeeded: %s",
957 pg_fatal(
"exiting pipeline mode didn't seem to work");
977 pg_fatal(
"Expected tuples, got %s: %s",
985 if (strcmp(
val,
"3") != 0)
986 pg_fatal(
"expected only insert with value 3, got %s",
val);
1010 Oid insert_param_oids[2] = {INT4OID, INT8OID};
1011 const char *insert_params[2];
1019 insert_params[0] = insert_param_0;
1020 insert_params[1] = insert_param_1;
1022 rows_to_send = rows_to_receive = n_rows;
1037 sql =
"BEGIN TRANSACTION";
1058 0, NULL, NULL, NULL, NULL, 0) != 1)
1090 FD_ZERO(&input_mask);
1091 FD_SET(sock, &input_mask);
1092 FD_ZERO(&output_mask);
1093 FD_SET(sock, &output_mask);
1095 if (
select(sock + 1, &input_mask, &output_mask, NULL, NULL) < 0)
1097 fprintf(stderr,
"select() failed: %m\n");
1105 if (FD_ISSET(sock, &input_mask))
1113 const char *cmdtag =
"";
1133 cmdtag =
"DROP TABLE";
1137 cmdtag =
"CREATE TABLE";
1148 if (rows_to_receive == 0)
1167 pg_fatal(
"%s reported status %s, expected %s\n"
1168 "Error message: \"%s\"",
1173 pg_fatal(
"%s expected command tag '%s', got '%s'",
1183 if (FD_ISSET(sock, &output_mask))
1194 2, insert_params, NULL, NULL, 0) == 1)
1196 pg_debug(
"sent row %d\n", rows_to_send);
1199 if (rows_to_send == 0)
1208 fprintf(stderr,
"WARNING: failed to send insert #%d: %s\n",
1215 0, NULL, NULL, NULL, NULL, 0) == 1)
1222 fprintf(stderr,
"WARNING: failed to send commit: %s\n",
1226 else if (send_step ==
BI_SYNC)
1235 fprintf(stderr,
"WARNING: pipeline sync failed: %s\n",
1244 pg_fatal(
"attempt to exit pipeline mode failed when it should've succeeded: %s",
1257 Oid param_oids[1] = {INT4OID};
1258 Oid expected_oids[4];
1261 fprintf(stderr,
"prepared... ");
1267 1, param_oids) != 1)
1269 expected_oids[0] = INT4OID;
1270 expected_oids[1] = TEXTOID;
1271 expected_oids[2] = NUMERICOID;
1272 expected_oids[3] = INTERVALOID;
1280 pg_fatal(
"PQgetResult returned null");
1290 pg_fatal(
"PQgetResult returned NULL");
1294 pg_fatal(
"expected %zu columns, got %d",
1299 if (typ != expected_oids[
i])
1300 pg_fatal(
"field %d: expected type %u, got %u",
1301 i, expected_oids[
i], typ);
1312 fprintf(stderr,
"closing statement..");
1320 pg_fatal(
"expected non-NULL result");
1347 fprintf(stderr,
"creating portal... ");
1349 PQexec(
conn,
"DECLARE cursor_one CURSOR FOR SELECT 1");
1357 pg_fatal(
"PQgetResult returned null");
1363 pg_fatal(
"portal: expected type %u, got %u",
1373 fprintf(stderr,
"closing portal... ");
1381 pg_fatal(
"expected non-NULL result");
1415 int *n_notices = (
int *)
arg;
1418 fprintf(stderr,
"NOTICE %d: %s", *n_notices, message);
1428 fprintf(stderr,
"\npipeline idle...\n");
1440 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
1443 pg_fatal(
"unexpected result code %s from first pipeline item",
1448 pg_fatal(
"did not receive terminating NULL");
1452 pg_fatal(
"exiting pipeline succeeded when it shouldn't");
1454 strlen(
"cannot exit pipeline mode")) != 0)
1455 pg_fatal(
"did not get expected error; got: %s",
1460 pg_fatal(
"unexpected result code %s from second pipeline item",
1465 pg_fatal(
"did not receive terminating NULL");
1470 pg_fatal(
"got %d notice(s)", n_notices);
1476 if (
PQsendQueryParams(
conn,
"SELECT pg_catalog.pg_advisory_unlock(1,1)", 0, NULL, NULL, NULL, NULL, 0) != 1)
1481 pg_fatal(
"unexpected NULL result received");
1493 const char *dummy_params[1] = {
"1"};
1494 Oid dummy_param_oids[1] = {INT4OID};
1496 fprintf(stderr,
"simple pipeline... ");
1507 pg_fatal(
"Expected blocking connection mode");
1513 1, dummy_param_oids, dummy_params,
1514 NULL, NULL, 0) != 1)
1518 pg_fatal(
"exiting pipeline mode with work in progress should fail, but succeeded");
1525 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
1529 pg_fatal(
"Unexpected result code %s from first pipeline item",
1536 pg_fatal(
"PQgetResult returned something extra after first query result.");
1543 pg_fatal(
"exiting pipeline mode after query but before sync succeeded incorrectly");
1547 pg_fatal(
"PQgetResult returned null when sync result PGRES_PIPELINE_SYNC expected: %s",
1551 pg_fatal(
"Unexpected result code %s instead of PGRES_PIPELINE_SYNC, error: %s",
1558 pg_fatal(
"PQgetResult returned something extra after pipeline end: %s",
1563 pg_fatal(
"Fell out of pipeline mode somehow");
1567 pg_fatal(
"attempt to exit pipeline mode failed when it should've succeeded: %s",
1571 pg_fatal(
"Exiting pipeline mode didn't seem to work");
1581 bool pipeline_ended =
false;
1584 pg_fatal(
"failed to enter pipeline mode: %s",
1588 for (
i = 0;
i < 3;
i++)
1595 "SELECT generate_series(42, $1)",
1598 (
const char **) param,
1602 pg_fatal(
"failed to send query: %s",
1609 for (
i = 0; !pipeline_ended;
i++)
1612 bool saw_ending_tuplesok;
1613 bool isSingleTuple =
false;
1619 pg_fatal(
"PQsetSingleRowMode() failed for i=%d",
i);
1623 saw_ending_tuplesok =
false;
1630 fprintf(stderr,
"end of pipeline reached\n");
1631 pipeline_ended =
true;
1634 pg_fatal(
"Expected three results, got %d",
i);
1642 pg_fatal(
"Expected PGRES_SINGLE_TUPLE for query %d, got %s",
1645 pg_fatal(
"Expected PGRES_TUPLES_OK for query %d, got %s",
1655 saw_ending_tuplesok =
true;
1659 fprintf(stderr,
"all tuples received in query %d\n",
i);
1661 pg_fatal(
"Expected to follow PGRES_SINGLE_TUPLE, but received PGRES_TUPLES_OK directly instead");
1666 isSingleTuple =
true;
1675 if (!pipeline_ended && !saw_ending_tuplesok)
1676 pg_fatal(
"didn't get expected terminating TUPLES_OK");
1685 0, NULL, NULL, NULL, NULL, 0) != 1)
1686 pg_fatal(
"failed to send query: %s",
1689 pg_fatal(
"failed to send flush request");
1691 pg_fatal(
"PQsetSingleRowMode() failed");
1696 pg_fatal(
"Expected PGRES_SINGLE_TUPLE, got %s",
1702 pg_fatal(
"Expected PGRES_TUPLES_OK, got %s",
1708 0, NULL, NULL, NULL, NULL, 0) != 1)
1709 pg_fatal(
"failed to send query: %s",
1712 pg_fatal(
"failed to send flush request");
1717 pg_fatal(
"Expected PGRES_TUPLES_OK, got %s",
1727 0, NULL, NULL, NULL, NULL, 0) != 1)
1728 pg_fatal(
"failed to send query: %s",
1731 pg_fatal(
"failed to send flush request");
1733 pg_fatal(
"PQsetChunkedRowsMode() failed");
1738 pg_fatal(
"Expected PGRES_TUPLES_CHUNK, got %s: %s",
1747 pg_fatal(
"Expected PGRES_TUPLES_CHUNK, got %s",
1755 pg_fatal(
"Expected PGRES_TUPLES_OK, got %s",
1780 "CREATE TABLE pq_pipeline_tst (id int)");
1782 pg_fatal(
"failed to create test table: %s",
1787 pg_fatal(
"failed to enter pipeline mode: %s",
1790 pg_fatal(
"could not send prepare on pipeline: %s",
1795 0, NULL, NULL, NULL, NULL, 0) != 1)
1796 pg_fatal(
"failed to send query: %s",
1800 0, NULL, NULL, NULL, NULL, 0) != 1)
1801 pg_fatal(
"failed to send query: %s",
1809 pg_fatal(
"failed to execute prepared: %s",
1814 "INSERT INTO pq_pipeline_tst VALUES (1)",
1815 0, NULL, NULL, NULL, NULL, 0) != 1)
1816 pg_fatal(
"failed to send query: %s",
1827 "INSERT INTO pq_pipeline_tst VALUES (2)",
1828 0, NULL, NULL, NULL, NULL, 0) != 1)
1829 pg_fatal(
"failed to send query: %s",
1840 pg_fatal(
"failed to execute prepared: %s",
1848 "INSERT INTO pq_pipeline_tst VALUES (3)",
1849 0, NULL, NULL, NULL, NULL, 0) != 1)
1850 pg_fatal(
"failed to send query: %s",
1860 expect_null =
false;
1861 for (
int i = 0;;
i++)
1868 printf(
"%d: got NULL result\n",
i);
1870 pg_fatal(
"did not expect NULL here");
1871 expect_null =
false;
1882 printf(
": command didn't run because pipeline aborted\n");
1896 pg_fatal(
"returned something extra after all the syncs: %s",
1909 pg_fatal(
"did not get expected tuple");
1925 Oid paramTypes[2] = {INT8OID, INT8OID};
1926 const char *paramValues[2];
1932 bool read_done =
false;
1933 bool write_done =
false;
1934 bool error_sent =
false;
1935 bool got_error =
false;
1941 fprintf(stderr,
"uniqviol ...");
1945 paramValues[0] = paramValue0;
1946 paramValues[1] = paramValue1;
1950 "create table ppln_uniqviol(id bigint primary key, idata bigint)");
1959 "insert into ppln_uniqviol values ($1, $2) returning id",
1965 pg_fatal(
"failed to enter pipeline mode");
1980 if (results >= numsent)
1989 if (new_error && got_error)
1991 got_error |= new_error;
1992 if (results++ >= numsent - 1)
2004 FD_SET(sock, &out_fds);
2007 FD_SET(sock, &in_fds);
2009 if (
select(sock + 1, &in_fds, write_done ? NULL : &out_fds, NULL, NULL) == -1)
2023 if (!write_done && FD_ISSET(sock, &out_fds))
2033 if (switched >= 1 && !error_sent && ctr % socketful >= socketful / 2)
2035 sprintf(paramValue0,
"%d", numsent / 2);
2042 sprintf(paramValue0,
"%d", ctr++);
2050 if (socketful != 0 && numsent % socketful == 42 && error_sent)
2053 pg_fatal(
"failed to send flush request");
2055 fprintf(stderr,
"\ndone writing\n");
2067 socketful = numsent;
2068 fprintf(stderr,
"\nswitch to reading\n");
2077 pg_fatal(
"did not get expected error");
2092 bool got_error =
false;
2121 fprintf(stderr,
"result %d/%d: pipeline aborted\n", results, numsent);
2143 fprintf(stderr,
"\nOptions:\n");
2144 fprintf(stderr,
" -t TRACEFILE generate a libpq trace to TRACEFILE\n");
2145 fprintf(stderr,
" -r NUMROWS use NUMROWS as the test size\n");
2152 printf(
"disallowed_in_pipeline\n");
2153 printf(
"multi_pipelines\n");
2155 printf(
"pipeline_abort\n");
2156 printf(
"pipeline_idle\n");
2157 printf(
"pipelined_insert\n");
2159 printf(
"simple_pipeline\n");
2168 const char *conninfo =
"";
2172 int numrows = 10000;
2176 while ((
c =
getopt(argc, argv,
"r:t:")) != -1)
2182 numrows = strtol(
optarg, NULL, 10);
2183 if (errno != 0 || numrows <= 0)
2185 fprintf(stderr,
"couldn't parse \"%s\" as a positive integer\n",
2207 if (strcmp(testname,
"tests") == 0)
2223 fprintf(stderr,
"Connection to database failed: %s\n",
2253 if (strcmp(testname,
"cancel") == 0)
2255 else if (strcmp(testname,
"disallowed_in_pipeline") == 0)
2257 else if (strcmp(testname,
"multi_pipelines") == 0)
2259 else if (strcmp(testname,
"nosync") == 0)
2261 else if (strcmp(testname,
"pipeline_abort") == 0)
2263 else if (strcmp(testname,
"pipeline_idle") == 0)
2265 else if (strcmp(testname,
"pipelined_insert") == 0)
2267 else if (strcmp(testname,
"prepared") == 0)
2269 else if (strcmp(testname,
"simple_pipeline") == 0)
2271 else if (strcmp(testname,
"singlerow") == 0)
2273 else if (strcmp(testname,
"transaction") == 0)
2275 else if (strcmp(testname,
"uniqviol") == 0)
2279 fprintf(stderr,
"\"%s\" is not a recognized test name\n", testname);
static PGcancel *volatile cancelConn
static void PGresult * res
PGcancel * PQgetCancel(PGconn *conn)
void PQcancelReset(PGcancelConn *cancelConn)
PGcancelConn * PQcancelCreate(PGconn *conn)
ConnStatusType PQcancelStatus(const PGcancelConn *cancelConn)
int PQcancelBlocking(PGcancelConn *cancelConn)
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
char * PQcancelErrorMessage(const PGcancelConn *cancelConn)
PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn)
void PQcancelFinish(PGcancelConn *cancelConn)
int PQrequestCancel(PGconn *conn)
void PQfreeCancel(PGcancel *cancel)
int PQcancelSocket(const PGcancelConn *cancelConn)
int PQcancelStart(PGcancelConn *cancelConn)
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
PQconninfoOption * PQconninfo(PGconn *conn)
char * PQerrorMessage(const PGconn *conn)
ConnStatusType PQstatus(const PGconn *conn)
void PQfinish(PGconn *conn)
PGconn * PQconnectdb(const char *conninfo)
int PQbackendPID(const PGconn *conn)
PGpipelineStatus PQpipelineStatus(const PGconn *conn)
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
int PQsocket(const PGconn *conn)
int PQsendQueryParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
int PQsetSingleRowMode(PGconn *conn)
int PQflush(PGconn *conn)
PGresult * PQprepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
Oid PQftype(const PGresult *res, int field_num)
int PQexitPipelineMode(PGconn *conn)
int PQsendClosePortal(PGconn *conn, const char *portal)
int PQenterPipelineMode(PGconn *conn)
PGresult * PQexecParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
ExecStatusType PQresultStatus(const PGresult *res)
PGresult * PQdescribePrepared(PGconn *conn, const char *stmt)
int PQsendClosePrepared(PGconn *conn, const char *stmt)
char * PQresultErrorMessage(const PGresult *res)
PGresult * PQclosePortal(PGconn *conn, const char *portal)
int PQsendPipelineSync(PGconn *conn)
int PQntuples(const PGresult *res)
PGresult * PQdescribePortal(PGconn *conn, const char *portal)
int PQsendDescribePrepared(PGconn *conn, const char *stmt)
PGresult * PQexec(PGconn *conn, const char *query)
int PQconsumeInput(PGconn *conn)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
char * PQcmdStatus(PGresult *res)
int PQsetnonblocking(PGconn *conn, int arg)
int PQsendPrepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
int PQsetChunkedRowsMode(PGconn *conn, int chunkSize)
int PQsendQuery(PGconn *conn, const char *query)
int PQpipelineSync(PGconn *conn)
char * PQresStatus(ExecStatusType status)
int PQsendDescribePortal(PGconn *conn, const char *portal)
PGresult * PQclosePrepared(PGconn *conn, const char *stmt)
int PQisBusy(PGconn *conn)
int PQsendQueryPrepared(PGconn *conn, const char *stmtName, int nParams, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
int PQsendFlushRequest(PGconn *conn)
char * PQresultErrorField(const PGresult *res, int fieldcode)
int PQisnonblocking(const PGconn *conn)
int PQnfields(const PGresult *res)
PGresult * PQgetResult(PGconn *conn)
void PQtrace(PGconn *conn, FILE *debug_port)
void PQsetTraceFlags(PGconn *conn, int flags)
char * pg_strdup(const char *in)
void * pg_malloc(size_t size)
#define PQTRACE_SUPPRESS_TIMESTAMPS
PostgresPollingStatusType
#define PQTRACE_REGRESS_MODE
static void usage(const char *progname)
static void const char * fmt
static void print_test_list(void)
static void const char pg_attribute_printf(2, 3)
static const char *const insert_sql2
static void confirm_query_canceled_impl(int line, PGconn *conn)
static void wait_for_connection_state(int line, PGconn *monitorConn, int procpid, char *state, char *event)
static void const char fflush(stdout)
static void exit_nicely(PGconn *conn)
int main(int argc, char **argv)
#define confirm_query_canceled(conn)
static void test_uniqviol(PGconn *conn)
static void send_cancellable_query_impl(int line, PGconn *conn, PGconn *monitorConn)
static void test_simple_pipeline(PGconn *conn)
static bool process_result(PGconn *conn, PGresult *res, int results, int numsent)
static void test_multi_pipelines(PGconn *conn)
vfprintf(stderr, fmt, args)
Assert(fmt[strlen(fmt) - 1] !='\n')
static void test_pipeline_idle(PGconn *conn)
static const char *const create_table_sql
static const char *const insert_sql
static void pg_attribute_noreturn() pg_fatal_impl(int line
static void test_nosync(PGconn *conn)
static PGconn * copy_connection(PGconn *conn)
static const char *const progname
static void test_pipeline_abort(PGconn *conn)
static const char *const drop_table_sql
#define send_cancellable_query(conn, monitorConn)
static void notice_processor(void *arg, const char *message)
static void test_transaction(PGconn *conn)
static void test_prepared(PGconn *conn)
static void test_cancel(PGconn *conn)
static void test_singlerowmode(PGconn *conn)
fprintf(stderr, "\n%s:%d: ", progname, line)
static void test_disallowed_in_pipeline(PGconn *conn)
static void test_pipelined_insert(PGconn *conn, int n_rows)
void pfree(void *pointer)
static AmcheckOptions opts
int getopt(int nargc, char *const *nargv, const char *ostr)
PGDLLIMPORT char * optarg
char * psprintf(const char *fmt,...)
void pg_usleep(long microsec)
#define select(n, r, w, e, timeout)