MCPcopy Create free account
hub / github.com/apache/cloudberry / main

Function main

src/test/fdw/extended_protocol_commit_test.c:24–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24int
25main(int argc, char **argv)
26{
27 const char *conninfo;
28 PGconn *conn;
29 PGresult *res;
30
31 /*
32 * If the user supplies a parameter on the command line, use it as the
33 * conninfo string; otherwise default to setting dbname=postgres and using
34 * environment variables or defaults for all other connection parameters.
35 */
36 if (argc > 1)
37 conninfo = argv[1];
38 else
39 conninfo = "dbname = postgres";
40
41 /* Connect to the database */
42 conn = PQconnectdb(conninfo);
43 if (PQstatus(conn) != CONNECTION_OK)
44 {
45 printf("%s:%d: Connection to database failed: %s", __FILE__, __LINE__, PQerrorMessage(conn));
46 exit_nicely(conn);
47 }
48
49 /* Prepare objects for the test */
50 res = PQexec(conn, "SET client_min_messages = ERROR;");
51 if (PQresultStatus(res) != PGRES_COMMAND_OK)
52 {
53 printf("%s:%d: Execution failed: %s", __FILE__, __LINE__, PQresultErrorMessage(res));
54 exit_nicely(conn);
55 }
56 PQclear(res);
57 res = PQexec(conn, "DROP EXTENSION IF EXISTS extended_protocol_commit_test_fdw CASCADE;");
58 if (PQresultStatus(res) != PGRES_COMMAND_OK)
59 {
60 printf("%s:%d: Execution failed: %s", __FILE__, __LINE__, PQresultErrorMessage(res));
61 exit_nicely(conn);
62 }
63 PQclear(res);
64 res = PQexec(conn, "CREATE EXTENSION extended_protocol_commit_test_fdw;");
65 if (PQresultStatus(res) != PGRES_COMMAND_OK)
66 {
67 printf("%s:%d: Execution failed: %s", __FILE__, __LINE__, PQresultErrorMessage(res));
68 exit_nicely(conn);
69 }
70 PQclear(res);
71 res = PQexec(conn, "CREATE SERVER extended_protocol_commit_test_server FOREIGN DATA WRAPPER extended_protocol_commit_test_fdw;");
72 if (PQresultStatus(res) != PGRES_COMMAND_OK)
73 {
74 printf("%s:%d: Execution failed: %s", __FILE__, __LINE__, PQresultErrorMessage(res));
75 exit_nicely(conn);
76 }
77 PQclear(res);
78 res = PQexec(conn, "CREATE FOREIGN TABLE extended_protocol_commit_test_table(i INT, t TEXT) SERVER extended_protocol_commit_test_server;");
79 if (PQresultStatus(res) != PGRES_COMMAND_OK)
80 {
81 printf("%s:%d: Execution failed: %s", __FILE__, __LINE__, PQresultErrorMessage(res));

Callers

nothing calls this directly

Calls 11

PQconnectdbFunction · 0.85
PQstatusFunction · 0.85
PQerrorMessageFunction · 0.85
PQexecFunction · 0.85
PQresultStatusFunction · 0.85
PQresultErrorMessageFunction · 0.85
PQclearFunction · 0.85
PQprepareFunction · 0.85
PQexecPreparedFunction · 0.85
PQfinishFunction · 0.85
exit_nicelyFunction · 0.70

Tested by

no test coverage detected