From fbb1d7d73f8e23a3a61e702629c53cef48cb0918 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 1 Jul 2014 20:10:38 -0400 Subject: Allow CREATE/ALTER DATABASE to manipulate datistemplate and datallowconn. Historically these database properties could be manipulated only by manually updating pg_database, which is error-prone and only possible for superusers. But there seems no good reason not to allow database owners to set them for their databases, so invent CREATE/ALTER DATABASE options to do that. Adjust a couple of places that were doing it the hard way to use the commands instead. Vik Fearing, reviewed by Pavel Stehule --- src/bin/initdb/initdb.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/bin/initdb') diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 5228f134222..a25965ce4c9 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -2288,11 +2288,7 @@ make_template0(void) PG_CMD_DECL; const char **line; static const char *template0_setup[] = { - "CREATE DATABASE template0;\n", - "UPDATE pg_database SET " - " datistemplate = 't', " - " datallowconn = 'f' " - " WHERE datname = 'template0';\n", + "CREATE DATABASE template0 IS_TEMPLATE = true ALLOW_CONNECTIONS = false;\n", /* * We use the OID of template0 to determine lastsysoid -- cgit v1.2.3