diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index abf8a73f35c..129d3495c95 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -298,6 +298,7 @@ static void load_ivorysql_ora(FILE *cmdfd); static void vacuum_db(FILE *cmdfd); static void make_template0(FILE *cmdfd); static void make_postgres(FILE *cmdfd); +static void make_ivorysql(FILE *cmdfd); static void trapsig(SIGNAL_ARGS); static void check_ok(void); static char *escape_quotes(const char *src); @@ -2101,6 +2102,16 @@ make_postgres(FILE *cmdfd) PG_CMD_PUTS("COMMENT ON DATABASE postgres IS 'default administrative connection database';\n\n"); } +/* + * copy template1 to ivorysql + */ +static void +make_ivorysql(FILE *cmdfd) +{ + PG_CMD_PUTS("CREATE DATABASE ivorysql;\n\n"); + PG_CMD_PUTS("COMMENT ON DATABASE ivorysql IS 'default administrative connection database';\n\n"); +} + /* * signal handler in case we are interrupted. * @@ -3192,6 +3203,8 @@ initialize_data_directory(void) make_template0(cmdfd); make_postgres(cmdfd); + + make_ivorysql(cmdfd); PG_CMD_CLOSE; diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 5bb8a73b374..dae5995834f 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -1361,12 +1361,13 @@ dropDBs(PGconn *conn) char *dbname = PQgetvalue(res, i, 0); /* - * Skip "postgres" and "template1"; dumpDatabases() will deal with + * Skip "postgres", "ivorysql", and "template1"; dumpDatabases() will deal with * them specially. Also, be sure to skip "template0", even if for * some reason it's not marked !datallowconn. */ if (strcmp(dbname, "template1") != 0 && strcmp(dbname, "template0") != 0 && + strcmp(dbname, "ivorysql") != 0 && strcmp(dbname, "postgres") != 0) { fprintf(OPF, "DROP DATABASE %s%s;\n", @@ -1521,14 +1522,16 @@ dumpDatabases(PGconn *conn) fprintf(OPF, "--\n-- Database \"%s\" dump\n--\n\n", dbname); /* - * We assume that "template1" and "postgres" already exist in the + * We assume that "template1", "postgres", and "ivorysql" already exist in the * target installation. dropDBs() won't have removed them, for fear * of removing the DB the restore script is initially connected to. If * --clean was specified, tell pg_dump to drop and recreate them; * otherwise we'll merely restore their contents. Other databases * should simply be created. */ - if (strcmp(dbname, "template1") == 0 || strcmp(dbname, "postgres") == 0) + if (strcmp(dbname, "template1") == 0 || + strcmp(dbname, "postgres") == 0 || + strcmp(dbname, "ivorysql") == 0) { if (output_clean) create_opts = "--clean --create"; diff --git a/src/bin/pg_rewind/t/002_databases.pl b/src/bin/pg_rewind/t/002_databases.pl index 0d480aedb48..9e065cae055 100644 --- a/src/bin/pg_rewind/t/002_databases.pl +++ b/src/bin/pg_rewind/t/002_databases.pl @@ -49,6 +49,7 @@ sub run_test 'SELECT datname FROM pg_database ORDER BY 1', qq(beforepromotion inprimary +ivorysql postgres standby_afterpromotion template0 diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c index d93aaa29d3d..777d45f798d 100644 --- a/src/bin/pg_upgrade/pg_upgrade.c +++ b/src/bin/pg_upgrade/pg_upgrade.c @@ -566,11 +566,12 @@ create_new_objects(void) snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid); /* - * postgres database will already exist in the target installation, so + * postgres database and ivorysql database will already exist in the target installation, so * tell pg_restore to drop and recreate it; otherwise we would fail to * propagate its database-level properties. */ - if (strcmp(old_db->db_name, "postgres") == 0) + if (strcmp(old_db->db_name, "postgres") == 0 || + strcmp(old_db->db_name, "ivorysql") == 0) create_opts = "--clean --create"; else create_opts = "--create"; diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 1b59a05b3a9..f4af6ba3458 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -261,7 +261,7 @@ main(int argc, char *argv[]) values[3] = password; keywords[4] = "dbname"; /* see do_connect() */ values[4] = (options.list_dbs && options.dbname == NULL) ? - "postgres" : options.dbname; + "ivorysql" : options.dbname; keywords[5] = "fallback_application_name"; values[5] = pset.progname; keywords[6] = "client_encoding";