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

Function main

src/bin/scripts/dropdb.c:23–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22
23int
24main(int argc, char *argv[])
25{
26 static int if_exists = 0;
27
28 static struct option long_options[] = {
29 {"host", required_argument, NULL, 'h'},
30 {"port", required_argument, NULL, 'p'},
31 {"username", required_argument, NULL, 'U'},
32 {"no-password", no_argument, NULL, 'w'},
33 {"password", no_argument, NULL, 'W'},
34 {"echo", no_argument, NULL, 'e'},
35 {"interactive", no_argument, NULL, 'i'},
36 {"if-exists", no_argument, &if_exists, 1},
37 {"maintenance-db", required_argument, NULL, 2},
38 {"force", no_argument, NULL, 'f'},
39 {NULL, 0, NULL, 0}
40 };
41
42 const char *progname;
43 int optindex;
44 int c;
45
46 char *dbname = NULL;
47 char *maintenance_db = NULL;
48 char *host = NULL;
49 char *port = NULL;
50 char *username = NULL;
51 enum trivalue prompt_password = TRI_DEFAULT;
52 ConnParams cparams;
53 bool echo = false;
54 bool interactive = false;
55 bool force = false;
56
57 PQExpBufferData sql;
58
59 PGconn *conn;
60 PGresult *result;
61
62 pg_logging_init(argv[0]);
63 progname = get_progname(argv[0]);
64 set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pgscripts"));
65
66 handle_help_version_opts(argc, argv, "dropdb", help);
67
68 while ((c = getopt_long(argc, argv, "h:p:U:wWeif", long_options, &optindex)) != -1)
69 {
70 switch (c)
71 {
72 case 'h':
73 host = pg_strdup(optarg);
74 break;
75 case 'p':
76 port = pg_strdup(optarg);
77 break;
78 case 'U':
79 username = pg_strdup(optarg);
80 break;

Callers

nothing calls this directly

Calls 15

pg_logging_initFunction · 0.85
get_prognameFunction · 0.85
set_pglocale_pgserviceFunction · 0.85
handle_help_version_optsFunction · 0.85
getopt_longFunction · 0.85
pg_strdupFunction · 0.85
yesno_promptFunction · 0.85
initPQExpBufferFunction · 0.85
appendPQExpBufferFunction · 0.85
fmtIdEncFunction · 0.85
PQclientEncodingFunction · 0.85

Tested by

no test coverage detected