| 143 | } |
| 144 | |
| 145 | int |
| 146 | main(int argc, char **argv) |
| 147 | { |
| 148 | char *pghost, |
| 149 | *pgport, |
| 150 | *pgoptions, |
| 151 | *pgoptions_retrieve_mode, |
| 152 | *pgtty; |
| 153 | char *dbName, |
| 154 | *dbUser; |
| 155 | int i; |
| 156 | int retVal; /* return value for this func */ |
| 157 | |
| 158 | PGconn *master_conn, |
| 159 | **endpoint_conns = NULL; |
| 160 | size_t endpoint_conns_num = 0; |
| 161 | char **tokens = NULL, |
| 162 | **endpoint_names = NULL; |
| 163 | |
| 164 | PGresult *res1; |
| 165 | |
| 166 | if (argc != 3) |
| 167 | { |
| 168 | fprintf(stderr, "usage: %s dbUser dbName\n", argv[0]); |
| 169 | fprintf(stderr, " show how to use PARALLEL RETRIEVE CURSOR to parallelly retrieve data from multiple endpoints.\n"); |
| 170 | exit(1); |
| 171 | } |
| 172 | dbUser = argv[1]; |
| 173 | dbName = argv[2]; |
| 174 | |
| 175 | /* |
| 176 | * begin, by setting the parameters for a backend connection if the |
| 177 | * parameters are null, then the system will try to use reasonable |
| 178 | * defaults by looking up environment variables or, failing that, using |
| 179 | * hardwired constants |
| 180 | */ |
| 181 | pghost = NULL; /* host name of the backend */ |
| 182 | pgport = NULL; /* port of the backend */ |
| 183 | pgoptions = NULL; /* special options to start up the backend |
| 184 | * server */ |
| 185 | pgoptions_retrieve_mode = "-c gp_retrieve_conn=true"; /* specify this |
| 186 | * connection is for |
| 187 | * retrieve only */ |
| 188 | pgtty = NULL; /* debugging tty for the backend */ |
| 189 | |
| 190 | /* make a connection to the database */ |
| 191 | master_conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName); |
| 192 | check_prepare_conn(master_conn, dbName, MASTER_CONNECT_INDEX); |
| 193 | |
| 194 | /* do some preparation for test */ |
| 195 | if (exec_sql_without_resultset(master_conn, "DROP TABLE IF EXISTS public.tab_parallel_cursor;", MASTER_CONNECT_INDEX) != 0) |
| 196 | goto LABEL_ERR; |
| 197 | if (exec_sql_without_resultset(master_conn, "CREATE TABLE public.tab_parallel_cursor AS SELECT id FROM pg_catalog.generate_series(1,100) id;", MASTER_CONNECT_INDEX) != 0) |
| 198 | goto LABEL_ERR; |
| 199 | |
| 200 | /* |
| 201 | * start a transaction block because PARALLEL RETRIEVE CURSOR only |
| 202 | * supports WITHOUT HOLD option |
nothing calls this directly
no test coverage detected