Definition at line 24 of file dropdb.c.
25{
27
28 static struct option long_options[] = {
39 {NULL, 0, NULL, 0}
40 };
41
43 int optindex;
45
47 char *maintenance_db = NULL;
48 char *host = NULL;
53 bool echo = false;
54 bool interactive = false;
55 bool force = false;
56
58
61
65
67
68 while ((
c =
getopt_long(argc, argv,
"efh:ip:U:wW", long_options, &optindex)) != -1)
69 {
71 {
72 case 'e':
73 echo = true;
74 break;
75 case 'f':
76 force = true;
77 break;
78 case 'h':
80 break;
81 case 'i':
82 interactive = true;
83 break;
84 case 'p':
86 break;
87 case 'U':
89 break;
90 case 'w':
92 break;
93 case 'W':
95 break;
96 case 0:
97
98 break;
99 case 2:
101 break;
102 default:
103
106 }
107 }
108
110 {
111 case 0:
112 pg_log_error(
"missing required argument database name");
115 case 1:
117 break;
118 default:
119 pg_log_error(
"too many command-line arguments (first is \"%s\")",
123 }
124
125 if (interactive)
126 {
127 printf(
_(
"Database \"%s\" will be permanently removed.\n"),
dbname);
130 }
131
133
137 force ? " WITH (FORCE)" : "");
138
139
140 if (maintenance_db == NULL && strcmp(
dbname,
"postgres") == 0)
141 maintenance_db = "template1";
142
143 cparams.
dbname = maintenance_db;
149
151
152 if (echo)
156 {
160 }
161
165}
bool yesno_prompt(const char *question)
#define PG_TEXTDOMAIN(domain)
void set_pglocale_pgservice(const char *argv0, const char *app)
PGconn * connectMaintenanceDatabase(ConnParams *cparams, const char *progname, bool echo)
static void help(const char *progname)
void PQfinish(PGconn *conn)
char * PQerrorMessage(const PGconn *conn)
ExecStatusType PQresultStatus(const PGresult *res)
PGresult * PQexec(PGconn *conn, const char *query)
char * pg_strdup(const char *in)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
void pg_logging_init(const char *argv0)
#define pg_log_error(...)
#define pg_log_error_hint(...)
void handle_help_version_opts(int argc, char *argv[], const char *fixed_progname, help_handler hlp)
PGDLLIMPORT char * optarg
const char * get_progname(const char *argv0)
void initPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
const char * fmtId(const char *rawid)
enum trivalue prompt_password
References _, appendPQExpBuffer(), conn, connectMaintenanceDatabase(), PQExpBufferData::data, dbname, _connParams::dbname, exit(), fmtId(), get_progname(), getopt_long(), handle_help_version_opts(), help(), if_exists, initPQExpBuffer(), no_argument, optarg, optind, _connParams::override_dbname, pg_log_error, pg_log_error_hint, pg_logging_init(), pg_strdup(), PG_TEXTDOMAIN, _connParams::pghost, _connParams::pgport, PGRES_COMMAND_OK, _connParams::pguser, port, PQclear(), PQerrorMessage(), PQexec(), PQfinish(), PQresultStatus(), printf, progname, _connParams::prompt_password, required_argument, set_pglocale_pgservice(), TRI_DEFAULT, TRI_NO, TRI_YES, username, and yesno_prompt().