while ((c = getopt_long(argc, argv, "eh:ip:U:wW", long_options, &optindex)) != -1)
{ switch (c)
{ case'e':
echo = true; break; case'h':
host = pg_strdup(optarg); break; case'i':
interactive = true; break; case'p':
port = pg_strdup(optarg); break; case'U':
username = pg_strdup(optarg); break; case'w':
prompt_password = TRI_NO; break; case'W':
prompt_password = TRI_YES; break; case0: /* this covers the long options */ break; default: /* getopt_long already emitted a complaint */
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
}
}
switch (argc - optind)
{ case0: break; case1:
dropuser = argv[optind]; break; default:
pg_log_error("too many command-line arguments (first is \"%s\")",
argv[optind + 1]);
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
}
if (dropuser == NULL)
{ if (interactive)
{
dropuser = simple_prompt("Enter name of role to drop: ", true);
} else
{
pg_log_error("missing required argument role name");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
}
}
if (interactive)
{
printf(_("Role \"%s\" will be permanently removed.\n"), dropuser); if (!yesno_prompt("Are you sure?")) exit(0);
}
cparams.dbname = NULL; /* this program lacks any dbname option... */
cparams.pghost = host;
cparams.pgport = port;
cparams.pguser = username;
cparams.prompt_password = prompt_password;
cparams.override_dbname = NULL;
if (echo)
printf("%s\n", sql.data);
result = PQexec(conn, sql.data);
if (PQresultStatus(result) != PGRES_COMMAND_OK)
{
pg_log_error("removal of role \"%s\" failed: %s",
dropuser, PQerrorMessage(conn));
PQfinish(conn); exit(1);
}
PQclear(result);
PQfinish(conn); exit(0);
}
staticvoid
help(constchar *progname)
{
printf(_("%s removes a PostgreSQL role.\n\n"), progname);
printf(_("Usage:\n"));
printf(_(" %s [OPTION]... [ROLENAME]\n"), progname);
printf(_("\nOptions:\n"));
printf(_(" -e, --echo show the commands being sent to the server\n"));
printf(_(" -i, --interactive prompt before deleting anything, and prompt for\n" " role name if not specified\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" --if-exists don't report error if user doesn't exist\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\nConnection options:\n"));
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
printf(_(" -p, --port=PORT database server port\n"));
printf(_(" -U, --username=USERNAME user name to connect as (not the one to drop)\n"));
printf(_(" -w, --no-password never prompt for password\n"));
printf(_(" -W, --password force password prompt\n"));
printf(_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-08-07)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.