21#include "catalog/pg_type_d.h"
32static const
char *const
progname = "libpq_pipeline";
39#define pg_debug(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
45"DROP TABLE IF EXISTS pq_pipeline_demo";
47"CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer,"
50"INSERT INTO pq_pipeline_demo(itemno) VALUES ($1)";
52"INSERT INTO pq_pipeline_demo(itemno,int8filler) VALUES ($1, $2)";
73#define pg_fatal(...) pg_fatal_impl(__LINE__, __VA_ARGS__)
76pg_fatal_impl(
int line, const
char *
fmt,...)
94#define confirm_query_canceled(conn) confirm_query_canceled_impl(__LINE__, conn)
102 pg_fatal_impl(line,
"PQgetResult returned null: %s",
105 pg_fatal_impl(line,
"query did not fail when it was expected");
107 pg_fatal_impl(line,
"query failed with a different error than cancellation: %s",
122 char *
state,
char *event)
124 const Oid paramTypes[] = {INT4OID, TEXTOID};
125 const char *paramValues[2];
126 char *pidstr =
psprintf(
"%d", procpid);
130 paramValues[0] = pidstr;
140 "SELECT count(*) FROM pg_stat_activity WHERE "
141 "pid = $1 AND state = $2",
142 2, paramTypes, paramValues, NULL, NULL, 0);
145 "SELECT count(*) FROM pg_stat_activity WHERE "
146 "pid = $1 AND wait_event = $2",
147 2, paramTypes, paramValues, NULL, NULL, 0);
150 pg_fatal_impl(line,
"could not query pg_stat_activity: %s",
PQerrorMessage(monitorConn));
152 pg_fatal_impl(line,
"unexpected number of rows received: %d",
PQntuples(
res));
154 pg_fatal_impl(line,
"unexpected number of columns received: %d",
PQnfields(
res));
156 if (strcmp(
value,
"0") != 0)
170#define send_cancellable_query(conn, monitorConn) \
171 send_cancellable_query_impl(__LINE__, conn, monitorConn)
175 const char *env_wait;
176 const Oid paramTypes[1] = {INT4OID};
185 env_wait = getenv(
"PG_TEST_TIMEOUT_DEFAULT");
186 if (env_wait == NULL)
190 &env_wait, NULL, NULL, 0) != 1)
217 vals =
pg_malloc(
sizeof(
char *) * nopts);
233 pg_fatal(
"Connection to database failed: %s",
250 fprintf(stderr,
"test cancellations... ");
265 if (!
PQcancel(cancel, errorbuf,
sizeof(errorbuf)))
266 pg_fatal(
"failed to run PQcancel: %s", errorbuf);
271 if (!
PQcancel(cancel, errorbuf,
sizeof(errorbuf)))
272 pg_fatal(
"failed to run PQcancel: %s", errorbuf);
307 FD_ZERO(&input_mask);
308 FD_ZERO(&output_mask);
313 FD_SET(sock, &input_mask);
317 FD_SET(sock, &output_mask);
331 if (
select(sock + 1, &input_mask, &output_mask, NULL, &tv) < 0)
364 FD_ZERO(&input_mask);
365 FD_ZERO(&output_mask);
370 FD_SET(sock, &input_mask);
374 FD_SET(sock, &output_mask);
388 if (
select(sock + 1, &input_mask, &output_mask, NULL, &tv) < 0)
411 fprintf(stderr,
"test error cases... ");
414 pg_fatal(
"Expected blocking connection mode");
417 pg_fatal(
"Unable to enter pipeline mode");
420 pg_fatal(
"Pipeline mode not activated properly");
425 pg_fatal(
"PQexec should fail in pipeline mode but succeeded");
427 "synchronous command execution functions are not allowed in pipeline mode\n") != 0)
428 pg_fatal(
"did not get expected error message; got: \"%s\"",
433 pg_fatal(
"PQsendQuery should fail in pipeline mode but succeeded");
435 "PQsendQuery not allowed in pipeline mode\n") != 0)
436 pg_fatal(
"did not get expected error message; got: \"%s\"",
441 pg_fatal(
"re-entering pipeline mode should be a no-op but failed");
444 pg_fatal(
"PQisBusy should return 0 when idle in pipeline mode, returned 1");
448 pg_fatal(
"couldn't exit idle empty pipeline mode");
451 pg_fatal(
"Pipeline mode not terminated properly");
455 pg_fatal(
"pipeline mode exit when not in pipeline mode should succeed but failed");
460 pg_fatal(
"PQexec should succeed after exiting pipeline mode but failed with: %s",
470 const char *dummy_params[1] = {
"1"};
471 Oid dummy_param_oids[1] = {INT4OID};
473 fprintf(stderr,
"multi pipeline... ");
484 dummy_params, NULL, NULL, 0) != 1)
492 dummy_params, NULL, NULL, 0) != 1)
501 dummy_params, NULL, NULL, 0) != 1)
513 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
517 pg_fatal(
"Unexpected result code %s from first pipeline item",
523 pg_fatal(
"PQgetResult returned something extra after first result");
526 pg_fatal(
"exiting pipeline mode after query but before sync succeeded incorrectly");
530 pg_fatal(
"PQgetResult returned null when sync result expected: %s",
534 pg_fatal(
"Unexpected result code %s instead of sync result, error: %s",
542 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
546 pg_fatal(
"Unexpected result code %s from second pipeline item",
552 pg_fatal(
"PQgetResult returned something extra after first result");
555 pg_fatal(
"exiting pipeline mode after query but before sync succeeded incorrectly");
559 pg_fatal(
"PQgetResult returned null when sync result expected: %s",
563 pg_fatal(
"Unexpected result code %s instead of sync result, error: %s",
571 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
575 pg_fatal(
"Unexpected result code %s from third pipeline item",
580 pg_fatal(
"Expected null result, got %s",
585 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
589 pg_fatal(
"Unexpected result code %s from second pipeline sync",
594 pg_fatal(
"Fell out of pipeline mode somehow");
598 pg_fatal(
"attempt to exit pipeline mode failed when it should've succeeded: %s",
602 pg_fatal(
"exiting pipeline mode didn't seem to work");
624 pg_fatal(
"could not enter pipeline mode");
625 for (
int i = 0;
i < numqueries;
i++)
631 0, NULL, NULL, NULL, NULL, 0) != 1)
638 FD_ZERO(&input_mask);
639 FD_SET(sock, &input_mask);
642 if (
select(sock + 1, &input_mask, NULL, NULL, &tv) < 0)
644 fprintf(stderr,
"select() failed: %m\n");
653 pg_fatal(
"failed to send flush request");
665 pg_fatal(
"got unexpected NULL result after %d results", results);
681 if (results == numqueries)
707 const char *dummy_params[1] = {
"1"};
708 Oid dummy_param_oids[1] = {INT4OID};
713 fprintf(stderr,
"aborted pipeline... ");
731 dummy_params[0] =
"1";
733 dummy_params, NULL, NULL, 0) != 1)
737 1, dummy_param_oids, dummy_params,
741 dummy_params[0] =
"2";
743 dummy_params, NULL, NULL, 0) != 1)
749 dummy_params[0] =
"3";
751 dummy_params, NULL, NULL, 0) != 1)
752 pg_fatal(
"dispatching second-pipeline insert failed: %s",
769 pg_fatal(
"Unexpected result status %s: %s",
776 pg_fatal(
"Expected null result, got %s",
784 pg_fatal(
"Unexpected result code -- expected PGRES_FATAL_ERROR, got %s",
790 pg_fatal(
"Expected null result, got %s",
801 pg_fatal(
"pipeline should be flagged as aborted but isn't");
808 pg_fatal(
"Unexpected result code -- expected PGRES_PIPELINE_ABORTED, got %s",
817 pg_fatal(
"pipeline should be flagged as aborted but isn't");
821 pg_fatal(
"Fell out of pipeline mode somehow");
833 pg_fatal(
"Unexpected result code from first pipeline sync\n"
834 "Expected PGRES_PIPELINE_SYNC, got %s",
839 pg_fatal(
"sync should've cleared the aborted flag but didn't");
843 pg_fatal(
"Fell out of pipeline mode somehow");
850 pg_fatal(
"Unexpected result code %s from first item in second pipeline",
862 pg_fatal(
"Unexpected result code %s from second pipeline sync",
867 pg_fatal(
"Expected null result, got %s: %s",
883 pg_fatal(
"expected error about multiple commands, got %s",
894 pg_fatal(
"did not get cannot-insert-multiple-commands error");
899 pg_fatal(
"Unexpected result code %s from pipeline sync",
905 0, NULL, NULL, NULL, NULL, 0) != 1)
922 pg_fatal(
"expected division-by-zero, got: %s (%s)",
925 printf(
"got expected division-by-zero\n");
934 pg_fatal(
"did not get division-by-zero error");
941 pg_fatal(
"Unexpected result code %s from third pipeline sync",
947 pg_fatal(
"Fell out of pipeline mode somehow");
951 pg_fatal(
"attempt to exit pipeline mode failed when it should've succeeded: %s",
955 pg_fatal(
"exiting pipeline mode didn't seem to work");
975 pg_fatal(
"Expected tuples, got %s: %s",
983 if (strcmp(
val,
"3") != 0)
984 pg_fatal(
"expected only insert with value 3, got %s",
val);
1008 Oid insert_param_oids[2] = {INT4OID, INT8OID};
1009 const char *insert_params[2];
1017 insert_params[0] = insert_param_0;
1018 insert_params[1] = insert_param_1;
1020 rows_to_send = rows_to_receive = n_rows;
1035 sql =
"BEGIN TRANSACTION";
1056 0, NULL, NULL, NULL, NULL, 0) != 1)
1088 FD_ZERO(&input_mask);
1089 FD_SET(sock, &input_mask);
1090 FD_ZERO(&output_mask);
1091 FD_SET(sock, &output_mask);
1093 if (
select(sock + 1, &input_mask, &output_mask, NULL, NULL) < 0)
1095 fprintf(stderr,
"select() failed: %m\n");
1103 if (FD_ISSET(sock, &input_mask))
1111 const char *cmdtag =
"";
1131 cmdtag =
"DROP TABLE";
1135 cmdtag =
"CREATE TABLE";
1146 if (rows_to_receive == 0)
1165 pg_fatal(
"%s reported status %s, expected %s\n"
1166 "Error message: \"%s\"",
1171 pg_fatal(
"%s expected command tag '%s', got '%s'",
1181 if (FD_ISSET(sock, &output_mask))
1192 2, insert_params, NULL, NULL, 0) == 1)
1194 pg_debug(
"sent row %d\n", rows_to_send);
1197 if (rows_to_send == 0)
1206 fprintf(stderr,
"WARNING: failed to send insert #%d: %s\n",
1213 0, NULL, NULL, NULL, NULL, 0) == 1)
1220 fprintf(stderr,
"WARNING: failed to send commit: %s\n",
1224 else if (send_step ==
BI_SYNC)
1233 fprintf(stderr,
"WARNING: pipeline sync failed: %s\n",
1242 pg_fatal(
"attempt to exit pipeline mode failed when it should've succeeded: %s",
1255 Oid param_oids[1] = {INT4OID};
1256 Oid expected_oids[4];
1259 fprintf(stderr,
"prepared... ");
1265 1, param_oids) != 1)
1267 expected_oids[0] = INT4OID;
1268 expected_oids[1] = TEXTOID;
1269 expected_oids[2] = NUMERICOID;
1270 expected_oids[3] = INTERVALOID;
1278 pg_fatal(
"PQgetResult returned null");
1288 pg_fatal(
"PQgetResult returned NULL");
1292 pg_fatal(
"expected %zu columns, got %d",
1297 if (typ != expected_oids[
i])
1298 pg_fatal(
"field %d: expected type %u, got %u",
1299 i, expected_oids[
i], typ);
1310 fprintf(stderr,
"closing statement..");
1318 pg_fatal(
"expected non-NULL result");
1345 fprintf(stderr,
"creating portal... ");
1347 PQexec(
conn,
"DECLARE cursor_one CURSOR FOR SELECT 1");
1355 pg_fatal(
"PQgetResult returned null");
1361 pg_fatal(
"portal: expected type %u, got %u",
1371 fprintf(stderr,
"closing portal... ");
1379 pg_fatal(
"expected non-NULL result");
1413 int *n_notices = (
int *)
arg;
1416 fprintf(stderr,
"NOTICE %d: %s", *n_notices, message);
1426 fprintf(stderr,
"\npipeline idle...\n");
1438 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
1441 pg_fatal(
"unexpected result code %s from first pipeline item",
1446 pg_fatal(
"did not receive terminating NULL");
1450 pg_fatal(
"exiting pipeline succeeded when it shouldn't");
1452 strlen(
"cannot exit pipeline mode")) != 0)
1453 pg_fatal(
"did not get expected error; got: %s",
1458 pg_fatal(
"unexpected result code %s from second pipeline item",
1463 pg_fatal(
"did not receive terminating NULL");
1468 pg_fatal(
"got %d notice(s)", n_notices);
1474 if (
PQsendQueryParams(
conn,
"SELECT pg_catalog.pg_advisory_unlock(1,1)", 0, NULL, NULL, NULL, NULL, 0) != 1)
1479 pg_fatal(
"unexpected NULL result received");
1491 const char *dummy_params[1] = {
"1"};
1492 Oid dummy_param_oids[1] = {INT4OID};
1494 fprintf(stderr,
"simple pipeline... ");
1505 pg_fatal(
"Expected blocking connection mode");
1511 1, dummy_param_oids, dummy_params,
1512 NULL, NULL, 0) != 1)
1516 pg_fatal(
"exiting pipeline mode with work in progress should fail, but succeeded");
1523 pg_fatal(
"PQgetResult returned null when there's a pipeline item: %s",
1527 pg_fatal(
"Unexpected result code %s from first pipeline item",
1534 pg_fatal(
"PQgetResult returned something extra after first query result.");
1541 pg_fatal(
"exiting pipeline mode after query but before sync succeeded incorrectly");
1545 pg_fatal(
"PQgetResult returned null when sync result PGRES_PIPELINE_SYNC expected: %s",
1549 pg_fatal(
"Unexpected result code %s instead of PGRES_PIPELINE_SYNC, error: %s",
1556 pg_fatal(
"PQgetResult returned something extra after pipeline end: %s",
1561 pg_fatal(
"Fell out of pipeline mode somehow");
1565 pg_fatal(
"attempt to exit pipeline mode failed when it should've succeeded: %s",
1569 pg_fatal(
"Exiting pipeline mode didn't seem to work");
1579 bool pipeline_ended =
false;
1582 pg_fatal(
"failed to enter pipeline mode: %s",
1586 for (
i = 0;
i < 3;
i++)
1593 "SELECT generate_series(42, $1)",
1596 (
const char **) param,
1600 pg_fatal(
"failed to send query: %s",
1607 for (
i = 0; !pipeline_ended;
i++)
1610 bool saw_ending_tuplesok;
1611 bool isSingleTuple =
false;
1617 pg_fatal(
"PQsetSingleRowMode() failed for i=%d",
i);
1621 saw_ending_tuplesok =
false;
1628 fprintf(stderr,
"end of pipeline reached\n");
1629 pipeline_ended =
true;
1632 pg_fatal(
"Expected three results, got %d",
i);
1640 pg_fatal(
"Expected PGRES_SINGLE_TUPLE for query %d, got %s",
1643 pg_fatal(
"Expected PGRES_TUPLES_OK for query %d, got %s",
1653 saw_ending_tuplesok =
true;
1657 fprintf(stderr,
"all tuples received in query %d\n",
i);
1659 pg_fatal(
"Expected to follow PGRES_SINGLE_TUPLE, but received PGRES_TUPLES_OK directly instead");
1664 isSingleTuple =
true;
1673 if (!pipeline_ended && !saw_ending_tuplesok)
1674 pg_fatal(
"didn't get expected terminating TUPLES_OK");
1683 0, NULL, NULL, NULL, NULL, 0) != 1)
1684 pg_fatal(
"failed to send query: %s",
1687 pg_fatal(
"failed to send flush request");
1689 pg_fatal(
"PQsetSingleRowMode() failed");
1694 pg_fatal(
"Expected PGRES_SINGLE_TUPLE, got %s",
1700 pg_fatal(
"Expected PGRES_TUPLES_OK, got %s",
1706 0, NULL, NULL, NULL, NULL, 0) != 1)
1707 pg_fatal(
"failed to send query: %s",
1710 pg_fatal(
"failed to send flush request");
1715 pg_fatal(
"Expected PGRES_TUPLES_OK, got %s",
1725 0, NULL, NULL, NULL, NULL, 0) != 1)
1726 pg_fatal(
"failed to send query: %s",
1729 pg_fatal(
"failed to send flush request");
1731 pg_fatal(
"PQsetChunkedRowsMode() failed");
1736 pg_fatal(
"Expected PGRES_TUPLES_CHUNK, got %s: %s",
1745 pg_fatal(
"Expected PGRES_TUPLES_CHUNK, got %s",
1753 pg_fatal(
"Expected PGRES_TUPLES_OK, got %s",
1778 "CREATE TABLE pq_pipeline_tst (id int)");
1780 pg_fatal(
"failed to create test table: %s",
1785 pg_fatal(
"failed to enter pipeline mode: %s",
1788 pg_fatal(
"could not send prepare on pipeline: %s",
1793 0, NULL, NULL, NULL, NULL, 0) != 1)
1794 pg_fatal(
"failed to send query: %s",
1798 0, NULL, NULL, NULL, NULL, 0) != 1)
1799 pg_fatal(
"failed to send query: %s",
1807 pg_fatal(
"failed to execute prepared: %s",
1812 "INSERT INTO pq_pipeline_tst VALUES (1)",
1813 0, NULL, NULL, NULL, NULL, 0) != 1)
1814 pg_fatal(
"failed to send query: %s",
1825 "INSERT INTO pq_pipeline_tst VALUES (2)",
1826 0, NULL, NULL, NULL, NULL, 0) != 1)
1827 pg_fatal(
"failed to send query: %s",
1838 pg_fatal(
"failed to execute prepared: %s",
1846 "INSERT INTO pq_pipeline_tst VALUES (3)",
1847 0, NULL, NULL, NULL, NULL, 0) != 1)
1848 pg_fatal(
"failed to send query: %s",
1858 expect_null =
false;
1859 for (
int i = 0;;
i++)
1866 printf(
"%d: got NULL result\n",
i);
1868 pg_fatal(
"did not expect NULL here");
1869 expect_null =
false;
1880 printf(
": command didn't run because pipeline aborted\n");
1894 pg_fatal(
"returned something extra after all the syncs: %s",
1907 pg_fatal(
"did not get expected tuple");
1923 Oid paramTypes[2] = {INT8OID, INT8OID};
1924 const char *paramValues[2];
1930 bool read_done =
false;
1931 bool write_done =
false;
1932 bool error_sent =
false;
1933 bool got_error =
false;
1939 fprintf(stderr,
"uniqviol ...");
1943 paramValues[0] = paramValue0;
1944 paramValues[1] = paramValue1;
1948 "create table ppln_uniqviol(id bigint primary key, idata bigint)");
1957 "insert into ppln_uniqviol values ($1, $2) returning id",
1963 pg_fatal(
"failed to enter pipeline mode");
1978 if (results >= numsent)
1987 if (new_error && got_error)
1989 got_error |= new_error;
1990 if (results++ >= numsent - 1)
2002 FD_SET(sock, &out_fds);
2005 FD_SET(sock, &in_fds);
2007 if (
select(sock + 1, &in_fds, write_done ? NULL : &out_fds, NULL, NULL) == -1)
2021 if (!write_done && FD_ISSET(sock, &out_fds))
2031 if (switched >= 1 && !error_sent && ctr % socketful >= socketful / 2)
2033 sprintf(paramValue0,
"%d", numsent / 2);
2040 sprintf(paramValue0,
"%d", ctr++);
2048 if (socketful != 0 && numsent % socketful == 42 && error_sent)
2051 pg_fatal(
"failed to send flush request");
2053 fprintf(stderr,
"\ndone writing\n");
2065 socketful = numsent;
2066 fprintf(stderr,
"\nswitch to reading\n");
2075 pg_fatal(
"did not get expected error");
2090 bool got_error =
false;
2119 fprintf(stderr,
"result %d/%d: pipeline aborted\n", results, numsent);
2141 fprintf(stderr,
"\nOptions:\n");
2142 fprintf(stderr,
" -t TRACEFILE generate a libpq trace to TRACEFILE\n");
2143 fprintf(stderr,
" -r NUMROWS use NUMROWS as the test size\n");
2150 printf(
"disallowed_in_pipeline\n");
2151 printf(
"multi_pipelines\n");
2153 printf(
"pipeline_abort\n");
2154 printf(
"pipeline_idle\n");
2155 printf(
"pipelined_insert\n");
2157 printf(
"simple_pipeline\n");
2166 const char *conninfo =
"";
2170 int numrows = 10000;
2174 while ((
c =
getopt(argc, argv,
"r:t:")) != -1)
2180 numrows = strtol(
optarg, NULL, 10);
2181 if (errno != 0 || numrows <= 0)
2183 fprintf(stderr,
"couldn't parse \"%s\" as a positive integer\n",
2205 if (strcmp(testname,
"tests") == 0)
2221 fprintf(stderr,
"Connection to database failed: %s\n",
2251 if (strcmp(testname,
"cancel") == 0)
2253 else if (strcmp(testname,
"disallowed_in_pipeline") == 0)
2255 else if (strcmp(testname,
"multi_pipelines") == 0)
2257 else if (strcmp(testname,
"nosync") == 0)
2259 else if (strcmp(testname,
"pipeline_abort") == 0)
2261 else if (strcmp(testname,
"pipeline_idle") == 0)
2263 else if (strcmp(testname,
"pipelined_insert") == 0)
2265 else if (strcmp(testname,
"prepared") == 0)
2267 else if (strcmp(testname,
"simple_pipeline") == 0)
2269 else if (strcmp(testname,
"singlerow") == 0)
2271 else if (strcmp(testname,
"transaction") == 0)
2273 else if (strcmp(testname,
"uniqviol") == 0)
2277 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)
PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn)
void PQcancelFinish(PGcancelConn *cancelConn)
int PQrequestCancel(PGconn *conn)
void PQfreeCancel(PGcancel *cancel)
int PQcancelSocket(const PGcancelConn *cancelConn)
char * PQcancelErrorMessage(const PGcancelConn *cancelConn)
int PQcancelStart(PGcancelConn *cancelConn)
PGconn * PQconnectdb(const char *conninfo)
PQconninfoOption * PQconninfo(PGconn *conn)
ConnStatusType PQstatus(const PGconn *conn)
void PQfinish(PGconn *conn)
int PQbackendPID(const PGconn *conn)
PGpipelineStatus PQpipelineStatus(const PGconn *conn)
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
char * PQerrorMessage(const PGconn *conn)
int PQsocket(const PGconn *conn)
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
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)
Oid PQftype(const PGresult *res, int field_num)
PGresult * PQdescribePrepared(PGconn *conn, const char *stmt)
PGresult * PQexecParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
int PQexitPipelineMode(PGconn *conn)
int PQsendClosePortal(PGconn *conn, const char *portal)
int PQenterPipelineMode(PGconn *conn)
PGresult * PQclosePrepared(PGconn *conn, const char *stmt)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
PGresult * PQclosePortal(PGconn *conn, const char *portal)
PGresult * PQgetResult(PGconn *conn)
ExecStatusType PQresultStatus(const PGresult *res)
int PQsendClosePrepared(PGconn *conn, const char *stmt)
int PQsendPipelineSync(PGconn *conn)
int PQntuples(const PGresult *res)
PGresult * PQprepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
char * PQresultErrorMessage(const PGresult *res)
int PQsendDescribePrepared(PGconn *conn, const char *stmt)
int PQconsumeInput(PGconn *conn)
int PQsetnonblocking(PGconn *conn, int arg)
int PQsendPrepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
PGresult * PQdescribePortal(PGconn *conn, const char *portal)
int PQsetChunkedRowsMode(PGconn *conn, int chunkSize)
char * PQresultErrorField(const PGresult *res, int fieldcode)
int PQsendQuery(PGconn *conn, const char *query)
char * PQcmdStatus(PGresult *res)
int PQpipelineSync(PGconn *conn)
int PQsendDescribePortal(PGconn *conn, const char *portal)
char * PQresStatus(ExecStatusType status)
int PQisBusy(PGconn *conn)
PGresult * PQexec(PGconn *conn, const char *query)
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)
int PQisnonblocking(const PGconn *conn)
int PQnfields(const PGresult *res)
void PQtrace(PGconn *conn, FILE *debug_port)
void PQsetTraceFlags(PGconn *conn, int flags)
void * pg_malloc(size_t size)
char * pg_strdup(const char *in)
static const JsonPathKeyword keywords[]
#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 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 PGconn * copy_connection(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)