mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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
This commit is contained in:
@ -540,9 +540,8 @@ set_frozenxids(void)
|
||||
*/
|
||||
if (strcmp(datallowconn, "f") == 0)
|
||||
PQclear(executeQueryOrDie(conn_template1,
|
||||
"UPDATE pg_catalog.pg_database "
|
||||
"SET datallowconn = true "
|
||||
"WHERE datname = '%s'", datname));
|
||||
"ALTER DATABASE %s ALLOW_CONNECTIONS = true",
|
||||
quote_identifier(datname)));
|
||||
|
||||
conn = connectToServer(&new_cluster, datname);
|
||||
|
||||
@ -558,9 +557,8 @@ set_frozenxids(void)
|
||||
/* Reset datallowconn flag */
|
||||
if (strcmp(datallowconn, "f") == 0)
|
||||
PQclear(executeQueryOrDie(conn_template1,
|
||||
"UPDATE pg_catalog.pg_database "
|
||||
"SET datallowconn = false "
|
||||
"WHERE datname = '%s'", datname));
|
||||
"ALTER DATABASE %s ALLOW_CONNECTIONS = false",
|
||||
quote_identifier(datname)));
|
||||
}
|
||||
|
||||
PQclear(dbres);
|
||||
|
Reference in New Issue
Block a user