PostgreSQL Source Code  git master
oid2name.c
Go to the documentation of this file.
1 /*
2  * oid2name, a PostgreSQL app to map OIDs on the filesystem
3  * to table and database names.
4  *
5  * Originally by
6  * B. Palmer, bpalmer@crimelabs.net 1-17-2001
7  *
8  * contrib/oid2name/oid2name.c
9  */
10 #include "postgres_fe.h"
11 
12 #include "catalog/pg_class_d.h"
13 #include "common/logging.h"
14 #include "fe_utils/connect.h"
15 #include "getopt_long.h"
16 #include "libpq-fe.h"
17 #include "pg_getopt.h"
18 
19 /* an extensible array to keep track of elements to show */
20 typedef struct
21 {
22  char **array;
23  int num;
24  int alloc;
25 } eary;
26 
27 /* these are the opts structures for command line params */
28 struct options
29 {
33 
34  bool quiet;
35  bool systables;
36  bool indexes;
37  bool nodb;
38  bool extended;
40 
41  char *dbname;
42  char *hostname;
43  char *port;
44  char *username;
45  const char *progname;
46 };
47 
48 /* function prototypes */
49 static void help(const char *progname);
50 void get_opts(int, char **, struct options *);
51 void add_one_elt(char *eltname, eary *eary);
52 char *get_comma_elts(eary *eary);
53 PGconn *sql_conn(struct options *);
54 int sql_exec(PGconn *, const char *sql, bool quiet);
55 void sql_exec_dumpalldbs(PGconn *, struct options *);
56 void sql_exec_dumpalltables(PGconn *, struct options *);
57 void sql_exec_searchtables(PGconn *, struct options *);
58 void sql_exec_dumpalltbspc(PGconn *, struct options *);
59 
60 /* function to parse command line options and check for some usage errors. */
61 void
62 get_opts(int argc, char **argv, struct options *my_opts)
63 {
64  static struct option long_options[] = {
65  {"dbname", required_argument, NULL, 'd'},
66  {"host", required_argument, NULL, 'h'},
67  {"host", required_argument, NULL, 'H'}, /* deprecated */
68  {"filenode", required_argument, NULL, 'f'},
69  {"indexes", no_argument, NULL, 'i'},
70  {"oid", required_argument, NULL, 'o'},
71  {"port", required_argument, NULL, 'p'},
72  {"quiet", no_argument, NULL, 'q'},
73  {"tablespaces", no_argument, NULL, 's'},
74  {"system-objects", no_argument, NULL, 'S'},
75  {"table", required_argument, NULL, 't'},
76  {"username", required_argument, NULL, 'U'},
77  {"version", no_argument, NULL, 'V'},
78  {"extended", no_argument, NULL, 'x'},
79  {"help", no_argument, NULL, '?'},
80  {NULL, 0, NULL, 0}
81  };
82 
83  int c;
84  const char *progname;
85  int optindex;
86 
87  pg_logging_init(argv[0]);
88  progname = get_progname(argv[0]);
89 
90  /* set the defaults */
91  my_opts->quiet = false;
92  my_opts->systables = false;
93  my_opts->indexes = false;
94  my_opts->nodb = false;
95  my_opts->extended = false;
96  my_opts->tablespaces = false;
97  my_opts->dbname = NULL;
98  my_opts->hostname = NULL;
99  my_opts->port = NULL;
100  my_opts->username = NULL;
101  my_opts->progname = progname;
102 
103  if (argc > 1)
104  {
105  if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
106  {
107  help(progname);
108  exit(0);
109  }
110  if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
111  {
112  puts("oid2name (PostgreSQL) " PG_VERSION);
113  exit(0);
114  }
115  }
116 
117  /* get opts */
118  while ((c = getopt_long(argc, argv, "d:f:h:H:io:p:qsSt:U:x", long_options, &optindex)) != -1)
119  {
120  switch (c)
121  {
122  /* specify the database */
123  case 'd':
124  my_opts->dbname = pg_strdup(optarg);
125  break;
126 
127  /* specify one filenode to show */
128  case 'f':
129  add_one_elt(optarg, my_opts->filenodes);
130  break;
131 
132  /* host to connect to */
133  case 'H': /* deprecated */
134  case 'h':
135  my_opts->hostname = pg_strdup(optarg);
136  break;
137 
138  /* also display indexes */
139  case 'i':
140  my_opts->indexes = true;
141  break;
142 
143  /* specify one Oid to show */
144  case 'o':
145  add_one_elt(optarg, my_opts->oids);
146  break;
147 
148  /* port to connect to on remote host */
149  case 'p':
150  my_opts->port = pg_strdup(optarg);
151  break;
152 
153  /* don't show headers */
154  case 'q':
155  my_opts->quiet = true;
156  break;
157 
158  /* dump tablespaces only */
159  case 's':
160  my_opts->tablespaces = true;
161  break;
162 
163  /* display system tables */
164  case 'S':
165  my_opts->systables = true;
166  break;
167 
168  /* specify one tablename to show */
169  case 't':
170  add_one_elt(optarg, my_opts->tables);
171  break;
172 
173  /* username */
174  case 'U':
175  my_opts->username = pg_strdup(optarg);
176  break;
177 
178  /* display extra columns */
179  case 'x':
180  my_opts->extended = true;
181  break;
182 
183  default:
184  fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
185  exit(1);
186  }
187  }
188 
189  if (optind < argc)
190  {
191  fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
192  progname, argv[optind]);
193  fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
194  exit(1);
195  }
196 }
197 
198 static void
199 help(const char *progname)
200 {
201  printf("%s helps examining the file structure used by PostgreSQL.\n\n"
202  "Usage:\n"
203  " %s [OPTION]...\n"
204  "\nOptions:\n"
205  " -f, --filenode=FILENODE show info for table with given file node\n"
206  " -i, --indexes show indexes and sequences too\n"
207  " -o, --oid=OID show info for table with given OID\n"
208  " -q, --quiet quiet (don't show headers)\n"
209  " -s, --tablespaces show all tablespaces\n"
210  " -S, --system-objects show system objects too\n"
211  " -t, --table=TABLE show info for named table\n"
212  " -V, --version output version information, then exit\n"
213  " -x, --extended extended (show additional columns)\n"
214  " -?, --help show this help, then exit\n"
215  "\nConnection options:\n"
216  " -d, --dbname=DBNAME database to connect to\n"
217  " -h, --host=HOSTNAME database server host or socket directory\n"
218  " -H same as -h, deprecated option\n"
219  " -p, --port=PORT database server port number\n"
220  " -U, --username=USERNAME connect as specified database user\n"
221  "\nThe default action is to show all database OIDs.\n\n"
222  "Report bugs to <%s>.\n"
223  "%s home page: <%s>\n",
224  progname, progname, PACKAGE_BUGREPORT, PACKAGE_NAME, PACKAGE_URL);
225 }
226 
227 /*
228  * add_one_elt
229  *
230  * Add one element to a (possibly empty) eary struct.
231  */
232 void
233 add_one_elt(char *eltname, eary *eary)
234 {
235  if (eary->alloc == 0)
236  {
237  eary ->alloc = 8;
238  eary ->array = (char **) pg_malloc(8 * sizeof(char *));
239  }
240  else if (eary->num >= eary->alloc)
241  {
242  eary ->alloc *= 2;
243  eary ->array = (char **) pg_realloc(eary->array,
244  eary->alloc * sizeof(char *));
245  }
246 
247  eary ->array[eary->num] = pg_strdup(eltname);
248  eary ->num++;
249 }
250 
251 /*
252  * get_comma_elts
253  *
254  * Return the elements of an eary as a (freshly allocated) single string, in
255  * single quotes, separated by commas and properly escaped for insertion in an
256  * SQL statement.
257  */
258 char *
260 {
261  char *ret,
262  *ptr;
263  int i,
264  length = 0;
265 
266  if (eary->num == 0)
267  return pg_strdup("");
268 
269  /*
270  * PQescapeString wants 2 * length + 1 bytes of breath space. Add two
271  * chars per element for the single quotes and one for the comma.
272  */
273  for (i = 0; i < eary->num; i++)
274  length += strlen(eary->array[i]);
275 
276  ret = (char *) pg_malloc(length * 2 + 4 * eary->num);
277  ptr = ret;
278 
279  for (i = 0; i < eary->num; i++)
280  {
281  if (i != 0)
282  sprintf(ptr++, ",");
283  sprintf(ptr++, "'");
284  ptr += PQescapeString(ptr, eary->array[i], strlen(eary->array[i]));
285  sprintf(ptr++, "'");
286  }
287 
288  return ret;
289 }
290 
291 /* establish connection with database. */
292 PGconn *
293 sql_conn(struct options *my_opts)
294 {
295  PGconn *conn;
296  bool have_password = false;
297  char password[100];
298  bool new_pass;
299  PGresult *res;
300 
301  /*
302  * Start the connection. Loop until we have a password if requested by
303  * backend.
304  */
305  do
306  {
307 #define PARAMS_ARRAY_SIZE 7
308 
309  const char *keywords[PARAMS_ARRAY_SIZE];
310  const char *values[PARAMS_ARRAY_SIZE];
311 
312  keywords[0] = "host";
313  values[0] = my_opts->hostname;
314  keywords[1] = "port";
315  values[1] = my_opts->port;
316  keywords[2] = "user";
317  values[2] = my_opts->username;
318  keywords[3] = "password";
319  values[3] = have_password ? password : NULL;
320  keywords[4] = "dbname";
321  values[4] = my_opts->dbname;
322  keywords[5] = "fallback_application_name";
323  values[5] = my_opts->progname;
324  keywords[6] = NULL;
325  values[6] = NULL;
326 
327  new_pass = false;
328  conn = PQconnectdbParams(keywords, values, true);
329 
330  if (!conn)
331  {
332  pg_log_error("could not connect to database %s",
333  my_opts->dbname);
334  exit(1);
335  }
336 
337  if (PQstatus(conn) == CONNECTION_BAD &&
339  !have_password)
340  {
341  PQfinish(conn);
342  simple_prompt("Password: ", password, sizeof(password), false);
343  have_password = true;
344  new_pass = true;
345  }
346  } while (new_pass);
347 
348  /* check to see that the backend connection was successfully made */
349  if (PQstatus(conn) == CONNECTION_BAD)
350  {
351  pg_log_error("could not connect to database %s: %s",
352  my_opts->dbname, PQerrorMessage(conn));
353  PQfinish(conn);
354  exit(1);
355  }
356 
358  if (PQresultStatus(res) != PGRES_TUPLES_OK)
359  {
360  pg_log_error("could not clear search_path: %s",
361  PQerrorMessage(conn));
362  PQclear(res);
363  PQfinish(conn);
364  exit(-1);
365  }
366  PQclear(res);
367 
368  /* return the conn if good */
369  return conn;
370 }
371 
372 /*
373  * Actual code to make call to the database and print the output data.
374  */
375 int
376 sql_exec(PGconn *conn, const char *todo, bool quiet)
377 {
378  PGresult *res;
379 
380  int nfields;
381  int nrows;
382  int i,
383  j,
384  l;
385  int *length;
386  char *pad;
387 
388  /* make the call */
389  res = PQexec(conn, todo);
390 
391  /* check and deal with errors */
392  if (!res || PQresultStatus(res) > 2)
393  {
394  pg_log_error("query failed: %s", PQerrorMessage(conn));
395  pg_log_error("query was: %s", todo);
396 
397  PQclear(res);
398  PQfinish(conn);
399  exit(-1);
400  }
401 
402  /* get the number of fields */
403  nrows = PQntuples(res);
404  nfields = PQnfields(res);
405 
406  /* for each field, get the needed width */
407  length = (int *) pg_malloc(sizeof(int) * nfields);
408  for (j = 0; j < nfields; j++)
409  length[j] = strlen(PQfname(res, j));
410 
411  for (i = 0; i < nrows; i++)
412  {
413  for (j = 0; j < nfields; j++)
414  {
415  l = strlen(PQgetvalue(res, i, j));
416  if (l > length[j])
417  length[j] = strlen(PQgetvalue(res, i, j));
418  }
419  }
420 
421  /* print a header */
422  if (!quiet)
423  {
424  for (j = 0, l = 0; j < nfields; j++)
425  {
426  fprintf(stdout, "%*s", length[j] + 2, PQfname(res, j));
427  l += length[j] + 2;
428  }
429  fprintf(stdout, "\n");
430  pad = (char *) pg_malloc(l + 1);
431  MemSet(pad, '-', l);
432  pad[l] = '\0';
433  fprintf(stdout, "%s\n", pad);
434  free(pad);
435  }
436 
437  /* for each row, dump the information */
438  for (i = 0; i < nrows; i++)
439  {
440  for (j = 0; j < nfields; j++)
441  fprintf(stdout, "%*s", length[j] + 2, PQgetvalue(res, i, j));
442  fprintf(stdout, "\n");
443  }
444 
445  /* cleanup */
446  PQclear(res);
447  free(length);
448 
449  return 0;
450 }
451 
452 /*
453  * Dump all databases. There are no system objects to worry about.
454  */
455 void
457 {
458  char todo[1024];
459 
460  /* get the oid and database name from the system pg_database table */
461  snprintf(todo, sizeof(todo),
462  "SELECT d.oid AS \"Oid\", datname AS \"Database Name\", "
463  "spcname AS \"Tablespace\" FROM pg_catalog.pg_database d JOIN pg_catalog.pg_tablespace t ON "
464  "(dattablespace = t.oid) ORDER BY 2");
465 
466  sql_exec(conn, todo, opts->quiet);
467 }
468 
469 /*
470  * Dump all tables, indexes and sequences in the current database.
471  */
472 void
474 {
475  char todo[1024];
476  char *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" ";
477 
478  snprintf(todo, sizeof(todo),
479  "SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s "
480  "FROM pg_catalog.pg_class c "
481  " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace "
482  " LEFT JOIN pg_catalog.pg_database d ON d.datname = pg_catalog.current_database(),"
483  " pg_catalog.pg_tablespace t "
484  "WHERE relkind IN (" CppAsString2(RELKIND_RELATION) ","
485  CppAsString2(RELKIND_MATVIEW) "%s%s) AND "
486  " %s"
487  " t.oid = CASE"
488  " WHEN reltablespace <> 0 THEN reltablespace"
489  " ELSE dattablespace"
490  " END "
491  "ORDER BY relname",
492  opts->extended ? addfields : "",
493  opts->indexes ? "," CppAsString2(RELKIND_INDEX) "," CppAsString2(RELKIND_SEQUENCE) : "",
494  opts->systables ? "," CppAsString2(RELKIND_TOASTVALUE) : "",
495  opts->systables ? "" : "n.nspname NOT IN ('pg_catalog', 'information_schema') AND n.nspname !~ '^pg_toast' AND");
496 
497  sql_exec(conn, todo, opts->quiet);
498 }
499 
500 /*
501  * Show oid, filenode, name, schema and tablespace for each of the
502  * given objects in the current database.
503  */
504 void
506 {
507  char *todo;
508  char *qualifiers,
509  *ptr;
510  char *comma_oids,
511  *comma_filenodes,
512  *comma_tables;
513  bool written = false;
514  char *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" ";
515 
516  /* get tables qualifiers, whether names, filenodes, or OIDs */
517  comma_oids = get_comma_elts(opts->oids);
518  comma_tables = get_comma_elts(opts->tables);
519  comma_filenodes = get_comma_elts(opts->filenodes);
520 
521  /* 80 extra chars for SQL expression */
522  qualifiers = (char *) pg_malloc(strlen(comma_oids) + strlen(comma_tables) +
523  strlen(comma_filenodes) + 80);
524  ptr = qualifiers;
525 
526  if (opts->oids->num > 0)
527  {
528  ptr += sprintf(ptr, "c.oid IN (%s)", comma_oids);
529  written = true;
530  }
531  if (opts->filenodes->num > 0)
532  {
533  if (written)
534  ptr += sprintf(ptr, " OR ");
535  ptr += sprintf(ptr, "pg_catalog.pg_relation_filenode(c.oid) IN (%s)", comma_filenodes);
536  written = true;
537  }
538  if (opts->tables->num > 0)
539  {
540  if (written)
541  ptr += sprintf(ptr, " OR ");
542  sprintf(ptr, "c.relname ~~ ANY (ARRAY[%s])", comma_tables);
543  }
544  free(comma_oids);
545  free(comma_tables);
546  free(comma_filenodes);
547 
548  /* now build the query */
549  todo = psprintf("SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s\n"
550  "FROM pg_catalog.pg_class c\n"
551  " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
552  " LEFT JOIN pg_catalog.pg_database d ON d.datname = pg_catalog.current_database(),\n"
553  " pg_catalog.pg_tablespace t\n"
554  "WHERE relkind IN (" CppAsString2(RELKIND_RELATION) ","
555  CppAsString2(RELKIND_MATVIEW) ","
556  CppAsString2(RELKIND_INDEX) ","
557  CppAsString2(RELKIND_SEQUENCE) ","
558  CppAsString2(RELKIND_TOASTVALUE) ") AND\n"
559  " t.oid = CASE\n"
560  " WHEN reltablespace <> 0 THEN reltablespace\n"
561  " ELSE dattablespace\n"
562  " END AND\n"
563  " (%s)\n"
564  "ORDER BY relname\n",
565  opts->extended ? addfields : "",
566  qualifiers);
567 
568  free(qualifiers);
569 
570  sql_exec(conn, todo, opts->quiet);
571 }
572 
573 void
575 {
576  char todo[1024];
577 
578  snprintf(todo, sizeof(todo),
579  "SELECT oid AS \"Oid\", spcname as \"Tablespace Name\"\n"
580  "FROM pg_catalog.pg_tablespace");
581 
582  sql_exec(conn, todo, opts->quiet);
583 }
584 
585 int
586 main(int argc, char **argv)
587 {
588  struct options *my_opts;
589  PGconn *pgconn;
590 
591  my_opts = (struct options *) pg_malloc(sizeof(struct options));
592 
593  my_opts->oids = (eary *) pg_malloc(sizeof(eary));
594  my_opts->tables = (eary *) pg_malloc(sizeof(eary));
595  my_opts->filenodes = (eary *) pg_malloc(sizeof(eary));
596 
597  my_opts->oids->num = my_opts->oids->alloc = 0;
598  my_opts->tables->num = my_opts->tables->alloc = 0;
599  my_opts->filenodes->num = my_opts->filenodes->alloc = 0;
600 
601  /* parse the opts */
602  get_opts(argc, argv, my_opts);
603 
604  if (my_opts->dbname == NULL)
605  {
606  my_opts->dbname = "postgres";
607  my_opts->nodb = true;
608  }
609  pgconn = sql_conn(my_opts);
610 
611  /* display only tablespaces */
612  if (my_opts->tablespaces)
613  {
614  if (!my_opts->quiet)
615  printf("All tablespaces:\n");
616  sql_exec_dumpalltbspc(pgconn, my_opts);
617 
618  PQfinish(pgconn);
619  exit(0);
620  }
621 
622  /* display the given elements in the database */
623  if (my_opts->oids->num > 0 ||
624  my_opts->tables->num > 0 ||
625  my_opts->filenodes->num > 0)
626  {
627  if (!my_opts->quiet)
628  printf("From database \"%s\":\n", my_opts->dbname);
629  sql_exec_searchtables(pgconn, my_opts);
630 
631  PQfinish(pgconn);
632  exit(0);
633  }
634 
635  /* no elements given; dump the given database */
636  if (my_opts->dbname && !my_opts->nodb)
637  {
638  if (!my_opts->quiet)
639  printf("From database \"%s\":\n", my_opts->dbname);
640  sql_exec_dumpalltables(pgconn, my_opts);
641 
642  PQfinish(pgconn);
643  exit(0);
644  }
645 
646  /* no database either; dump all databases */
647  if (!my_opts->quiet)
648  printf("All databases:\n");
649  sql_exec_dumpalldbs(pgconn, my_opts);
650 
651  PQfinish(pgconn);
652  return 0;
653 }
int sql_exec(PGconn *, const char *sql, bool quiet)
Definition: oid2name.c:376
static char password[100]
Definition: streamutil.c:53
int PQnfields(const PGresult *res)
Definition: fe-exec.c:2777
char * PQerrorMessage(const PGconn *conn)
Definition: fe-connect.c:6684
Definition: oid2name.c:20
void sql_exec_dumpalltbspc(PGconn *, struct options *)
Definition: oid2name.c:574
size_t PQescapeString(char *to, const char *from, size_t length)
Definition: fe-exec.c:3428
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3163
char * PQfname(const PGresult *res, int field_num)
Definition: fe-exec.c:2855
void * pg_malloc(size_t size)
Definition: fe_memutils.c:47
const char * get_progname(const char *argv0)
Definition: path.c:453
PGconn * sql_conn(struct options *)
Definition: oid2name.c:293
#define pg_log_error(...)
Definition: logging.h:79
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
Definition: getopt_long.c:57
void get_opts(int, char **, struct options *)
Definition: oid2name.c:62
void pg_logging_init(const char *argv0)
Definition: logging.c:76
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
#define PARAMS_ARRAY_SIZE
void PQfinish(PGconn *conn)
Definition: fe-connect.c:4182
#define MemSet(start, val, len)
Definition: c.h:971
#define printf(...)
Definition: port.h:198
char * hostname
Definition: oid2name.c:42
bool nodb
Definition: oid2name.c:37
int PQntuples(const PGresult *res)
Definition: fe-exec.c:2769
char * username
Definition: oid2name.c:44
#define fprintf
Definition: port.h:196
ExecStatusType PQresultStatus(const PGresult *res)
Definition: fe-exec.c:2692
int main(int argc, char **argv)
Definition: oid2name.c:586
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:640
bool tablespaces
Definition: oid2name.c:39
char ** array
Definition: oid2name.c:22
static void help(const char *progname)
Definition: oid2name.c:199
void sql_exec_dumpalldbs(PGconn *, struct options *)
Definition: oid2name.c:456
#define sprintf
Definition: port.h:194
#define required_argument
Definition: getopt_long.h:25
int optind
Definition: getopt.c:50
eary * oids
Definition: oid2name.c:31
PGconn * conn
Definition: streamutil.c:54
bool indexes
Definition: oid2name.c:36
char * c
bool systables
Definition: oid2name.c:35
void simple_prompt(const char *prompt, char *destination, size_t destlen, bool echo)
Definition: sprompt.c:37
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
void * pg_realloc(void *ptr, size_t size)
Definition: fe_memutils.c:65
eary * tables
Definition: oid2name.c:30
#define CppAsString2(x)
Definition: c.h:222
#define no_argument
Definition: getopt_long.h:24
void add_one_elt(char *eltname, eary *eary)
Definition: oid2name.c:233
const char * progname
Definition: oid2name.c:45
char * dbname
Definition: oid2name.c:41
void PQclear(PGresult *res)
Definition: fe-exec.c:694
#define free(a)
Definition: header.h:65
bool quiet
Definition: oid2name.c:34
static bool have_password
Definition: streamutil.c:52
bool extended
Definition: oid2name.c:38
char * get_comma_elts(eary *eary)
Definition: oid2name.c:259
#define ALWAYS_SECURE_SEARCH_PATH_SQL
Definition: connect.h:25
static Datum values[MAXATTR]
Definition: bootstrap.c:167
int alloc
Definition: oid2name.c:24
int PQconnectionNeedsPassword(const PGconn *conn)
Definition: fe-connect.c:6718
void sql_exec_searchtables(PGconn *, struct options *)
Definition: oid2name.c:505
char * optarg
Definition: getopt.c:52
char * port
Definition: oid2name.c:43
int i
PGresult * PQexec(PGconn *conn, const char *query)
Definition: fe-exec.c:1939
eary * filenodes
Definition: oid2name.c:32
ConnStatusType PQstatus(const PGconn *conn)
Definition: fe-connect.c:6631
#define snprintf
Definition: port.h:192
#define _(x)
Definition: elog.c:88
int num
Definition: oid2name.c:23
void sql_exec_dumpalltables(PGconn *, struct options *)
Definition: oid2name.c:473