24 main(
int argc,
char *argv[])
26 static struct option long_options[] = {
54 const char *maintenance_db = NULL;
64 char *
template = NULL;
66 char *strategy = NULL;
71 char *builtin_locale = NULL;
72 char *icu_locale = NULL;
86 while ((
c =
getopt_long(argc, argv,
"D:eE:h:l:O:p:S:T:U:wW", long_options, &optindex)) != -1)
166 pg_log_error(
"too many command-line arguments (first is \"%s\")",
180 if (getenv(
"PGDATABASE"))
181 dbname = getenv(
"PGDATABASE");
182 else if (getenv(
"PGUSER"))
183 dbname = getenv(
"PGUSER");
189 if (maintenance_db == NULL && strcmp(
dbname,
"postgres") == 0)
190 maintenance_db =
"template1";
192 cparams.
dbname = maintenance_db;
279 pg_log_error(
"comment creation failed (database was created): %s",
301 printf(
_(
" -D, --tablespace=TABLESPACE default tablespace for the database\n"));
302 printf(
_(
" -e, --echo show the commands being sent to the server\n"));
303 printf(
_(
" -E, --encoding=ENCODING encoding for the database\n"));
304 printf(
_(
" -l, --locale=LOCALE locale settings for the database\n"));
305 printf(
_(
" --lc-collate=LOCALE LC_COLLATE setting for the database\n"));
306 printf(
_(
" --lc-ctype=LOCALE LC_CTYPE setting for the database\n"));
307 printf(
_(
" --builtin-locale=LOCALE builtin locale setting for the database\n"));
308 printf(
_(
" --icu-locale=LOCALE ICU locale setting for the database\n"));
309 printf(
_(
" --icu-rules=RULES ICU rules setting for the database\n"));
310 printf(
_(
" --locale-provider={builtin|libc|icu}\n"
311 " locale provider for the database's default collation\n"));
312 printf(
_(
" -O, --owner=OWNER database user to own the new database\n"));
313 printf(
_(
" -S, --strategy=STRATEGY database creation strategy wal_log or file_copy\n"));
314 printf(
_(
" -T, --template=TEMPLATE template database to copy\n"));
315 printf(
_(
" -V, --version output version information, then exit\n"));
316 printf(
_(
" -?, --help show this help, then exit\n"));
317 printf(
_(
"\nConnection options:\n"));
318 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
319 printf(
_(
" -p, --port=PORT database server port\n"));
320 printf(
_(
" -U, --username=USERNAME user name to connect as\n"));
321 printf(
_(
" -w, --no-password never prompt for password\n"));
322 printf(
_(
" -W, --password force password prompt\n"));
323 printf(
_(
" --maintenance-db=DBNAME alternate maintenance database\n"));
324 printf(
_(
"\nBy default, a database with the same name as the current user is created.\n"));
325 printf(
_(
"\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
326 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
#define PG_TEXTDOMAIN(domain)
void set_pglocale_pgservice(const char *argv0, const char *app)
PGconn * connectMaintenanceDatabase(ConnParams *cparams, const char *progname, bool echo)
int main(int argc, char *argv[])
static void help(const char *progname)
char * PQerrorMessage(const PGconn *conn)
void PQfinish(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
static char locale_provider
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
#define pg_char_to_encoding
const char * get_progname(const char *argv0)
void printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void initPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
void appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
const char * fmtId(const char *rawid)
enum trivalue prompt_password
const char * get_user_name_or_exit(const char *progname)