Definition at line 25 of file dropuser.c.
26{
28
29 static struct option long_options[] = {
38 {NULL, 0, NULL, 0}
39 };
40
42 int optindex;
44
45 char *dropuser = NULL;
46 char *host = NULL;
51 bool echo = false;
52 bool interactive = false;
53
55
58
62
64
65 while ((
c =
getopt_long(argc, argv,
"eh:ip:U:wW", long_options, &optindex)) != -1)
66 {
68 {
69 case 'e':
70 echo = true;
71 break;
72 case 'h':
74 break;
75 case 'i':
76 interactive = true;
77 break;
78 case 'p':
80 break;
81 case 'U':
83 break;
84 case 'w':
86 break;
87 case 'W':
89 break;
90 case 0:
91
92 break;
93 default:
94
97 }
98 }
99
101 {
102 case 0:
103 break;
104 case 1:
106 break;
107 default:
108 pg_log_error(
"too many command-line arguments (first is \"%s\")",
112 }
113
114 if (dropuser == NULL)
115 {
116 if (interactive)
117 {
118 dropuser =
simple_prompt(
"Enter name of role to drop: ",
true);
119 }
120 else
121 {
125 }
126 }
127
128 if (interactive)
129 {
130 printf(
_(
"Role \"%s\" will be permanently removed.\n"), dropuser);
133 }
134
141
143
147
148 if (echo)
151
153 {
158 }
159
163}
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,...)
char * simple_prompt(const char *prompt, bool echo)
const char * fmtId(const char *rawid)
enum trivalue prompt_password
References _, appendPQExpBuffer(), conn, connectMaintenanceDatabase(), PQExpBufferData::data, _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(), simple_prompt(), TRI_DEFAULT, TRI_NO, TRI_YES, username, and yesno_prompt().