summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_rewind/parsexlog.c9
-rw-r--r--src/bin/psql/tab-complete.c4
-rw-r--r--src/bin/scripts/createdb.c10
-rw-r--r--src/bin/scripts/t/020_createdb.pl20
4 files changed, 40 insertions, 3 deletions
diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c
index 3ed2a2e811..49966e7b7f 100644
--- a/src/bin/pg_rewind/parsexlog.c
+++ b/src/bin/pg_rewind/parsexlog.c
@@ -372,7 +372,7 @@ extractPageInfo(XLogReaderState *record)
/* Is this a special record type that I recognize? */
- if (rmid == RM_DBASE_ID && rminfo == XLOG_DBASE_CREATE)
+ if (rmid == RM_DBASE_ID && rminfo == XLOG_DBASE_CREATE_FILE_COPY)
{
/*
* New databases can be safely ignored. It won't be present in the
@@ -384,6 +384,13 @@ extractPageInfo(XLogReaderState *record)
* overwriting the database created in the target system.
*/
}
+ else if (rmid == RM_DBASE_ID && rminfo == XLOG_DBASE_CREATE_WAL_LOG)
+ {
+ /*
+ * New databases can be safely ignored. It won't be present in the
+ * source system, so it will be deleted.
+ */
+ }
else if (rmid == RM_DBASE_ID && rminfo == XLOG_DBASE_DROP)
{
/*
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index c97d3e87f0..3f9dfffd57 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2791,13 +2791,15 @@ psql_completion(const char *text, int start, int end)
/* CREATE DATABASE */
else if (Matches("CREATE", "DATABASE", MatchAny))
COMPLETE_WITH("OWNER", "TEMPLATE", "ENCODING", "TABLESPACE",
- "IS_TEMPLATE",
+ "IS_TEMPLATE", "STRATEGY",
"ALLOW_CONNECTIONS", "CONNECTION LIMIT",
"LC_COLLATE", "LC_CTYPE", "LOCALE", "OID",
"LOCALE_PROVIDER", "ICU_LOCALE");
else if (Matches("CREATE", "DATABASE", MatchAny, "TEMPLATE"))
COMPLETE_WITH_QUERY(Query_for_list_of_template_databases);
+ else if (Matches("CREATE", "DATABASE", MatchAny, "STRATEGY"))
+ COMPLETE_WITH("WAL_LOG", "FILE_COPY");
/* CREATE DOMAIN */
else if (Matches("CREATE", "DOMAIN", MatchAny))
diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c
index 6f612abf7c..0bffa2f3ee 100644
--- a/src/bin/scripts/createdb.c
+++ b/src/bin/scripts/createdb.c
@@ -34,6 +34,7 @@ main(int argc, char *argv[])
{"tablespace", required_argument, NULL, 'D'},
{"template", required_argument, NULL, 'T'},
{"encoding", required_argument, NULL, 'E'},
+ {"strategy", required_argument, NULL, 'S'},
{"lc-collate", required_argument, NULL, 1},
{"lc-ctype", required_argument, NULL, 2},
{"locale", required_argument, NULL, 'l'},
@@ -60,6 +61,7 @@ main(int argc, char *argv[])
char *tablespace = NULL;
char *template = NULL;
char *encoding = NULL;
+ char *strategy = NULL;
char *lc_collate = NULL;
char *lc_ctype = NULL;
char *locale = NULL;
@@ -77,7 +79,7 @@ main(int argc, char *argv[])
handle_help_version_opts(argc, argv, "createdb", help);
- while ((c = getopt_long(argc, argv, "h:p:U:wWeO:D:T:E:l:", long_options, &optindex)) != -1)
+ while ((c = getopt_long(argc, argv, "h:p:U:wWeO:D:T:E:l:S:", long_options, &optindex)) != -1)
{
switch (c)
{
@@ -111,6 +113,9 @@ main(int argc, char *argv[])
case 'E':
encoding = pg_strdup(optarg);
break;
+ case 'S':
+ strategy = pg_strdup(optarg);
+ break;
case 1:
lc_collate = pg_strdup(optarg);
break;
@@ -215,6 +220,8 @@ main(int argc, char *argv[])
appendPQExpBufferStr(&sql, " ENCODING ");
appendStringLiteralConn(&sql, encoding, conn);
}
+ if (strategy)
+ appendPQExpBuffer(&sql, " STRATEGY %s", fmtId(strategy));
if (template)
appendPQExpBuffer(&sql, " TEMPLATE %s", fmtId(template));
if (lc_collate)
@@ -294,6 +301,7 @@ help(const char *progname)
printf(_(" --locale-provider={libc|icu}\n"
" locale provider for the database's default collation\n"));
printf(_(" -O, --owner=OWNER database user to own the new database\n"));
+ printf(_(" -S, --strategy=STRATEGY database creation strategy wal_log or file_copy\n"));
printf(_(" -T, --template=TEMPLATE template database to copy\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -?, --help show this help, then exit\n"));
diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl
index 35deec9a92..14d3a9563d 100644
--- a/src/bin/scripts/t/020_createdb.pl
+++ b/src/bin/scripts/t/020_createdb.pl
@@ -104,4 +104,24 @@ $node->command_checks_all(
],
'createdb with incorrect --lc-ctype');
+$node->command_checks_all(
+ [ 'createdb', '--strategy', "foo", 'foobar2' ],
+ 1,
+ [qr/^$/],
+ [
+ qr/^createdb: error: database creation failed: ERROR: invalid create database strategy|^createdb: error: database creation failed: ERROR: invalid create database strategy foo/s
+ ],
+ 'createdb with incorrect --strategy');
+
+# Check database creation strategy
+$node->issues_sql_like(
+ [ 'createdb', '-T', 'foobar2', 'foobar6', '-S', 'wal_log'],
+ qr/statement: CREATE DATABASE foobar6 STRATEGY wal_log TEMPLATE foobar2/,
+ 'create database with WAL_LOG strategy');
+
+$node->issues_sql_like(
+ [ 'createdb', '-T', 'foobar2', 'foobar7', '-S', 'file_copy'],
+ qr/statement: CREATE DATABASE foobar7 STRATEGY file_copy TEMPLATE foobar2/,
+ 'create database with FILE_COPY strategy');
+
done_testing();