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