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

Function main

src/bin/scripts/createuser.c:24–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22static void help(const char *progname);
23
24int
25main(int argc, char *argv[])
26{
27 static struct option long_options[] = {
28 {"host", required_argument, NULL, 'h'},
29 {"port", required_argument, NULL, 'p'},
30 {"username", required_argument, NULL, 'U'},
31 {"role", required_argument, NULL, 'g'},
32 {"no-password", no_argument, NULL, 'w'},
33 {"password", no_argument, NULL, 'W'},
34 {"echo", no_argument, NULL, 'e'},
35 {"createdb", no_argument, NULL, 'd'},
36 {"no-createdb", no_argument, NULL, 'D'},
37 {"superuser", no_argument, NULL, 's'},
38 {"no-superuser", no_argument, NULL, 'S'},
39 {"createrole", no_argument, NULL, 'r'},
40 {"no-createrole", no_argument, NULL, 'R'},
41 {"inherit", no_argument, NULL, 'i'},
42 {"no-inherit", no_argument, NULL, 'I'},
43 {"login", no_argument, NULL, 'l'},
44 {"no-login", no_argument, NULL, 'L'},
45 {"replication", no_argument, NULL, 1},
46 {"no-replication", no_argument, NULL, 2},
47 {"interactive", no_argument, NULL, 3},
48 {"connection-limit", required_argument, NULL, 'c'},
49 {"pwprompt", no_argument, NULL, 'P'},
50 {"encrypted", no_argument, NULL, 'E'},
51 {NULL, 0, NULL, 0}
52 };
53
54 const char *progname;
55 int optindex;
56 int c;
57 const char *newuser = NULL;
58 char *host = NULL;
59 char *port = NULL;
60 char *username = NULL;
61 SimpleStringList roles = {NULL, NULL};
62 enum trivalue prompt_password = TRI_DEFAULT;
63 ConnParams cparams;
64 bool echo = false;
65 bool interactive = false;
66 int conn_limit = -2; /* less than minimum valid value */
67 bool pwprompt = false;
68 char *newpassword = NULL;
69
70 /* Tri-valued variables. */
71 enum trivalue createdb = TRI_DEFAULT,
72 superuser = TRI_DEFAULT,
73 createrole = TRI_DEFAULT,
74 inherit = TRI_DEFAULT,
75 login = TRI_DEFAULT,
76 replication = TRI_DEFAULT;
77
78 PQExpBufferData sql;
79
80 PGconn *conn;
81 PGresult *result;

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
simple_promptFunction · 0.85
get_user_name_or_exitFunction · 0.85
yesno_promptFunction · 0.85
setFmtEncodingFunction · 0.85

Tested by

no test coverage detected