GNU bug report logs -
#63926
[PATCH] services: postgresql: Add more role fields.
Previous Next
To reply to this bug, email your comments to 63926 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#63926
; Package
guix-patches
.
(Tue, 06 Jun 2023 13:50:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Miguel Ángel Moreno <me <at> mianmoreno.com>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Tue, 06 Jun 2023 13:50:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* gnu/services/databases.scm (postgresql-role): Add more role fields.
(postgresql-create-roles): Honor it.
* doc/guix.texi (Database Services): Document it.
---
doc/guix.texi | 16 +++++++++++++++-
gnu/services/databases.scm | 19 ++++++++++++++++---
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 60972f408d..e384a3a13d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -24784,7 +24784,21 @@ Database Services
@code{superuser}.
@item @code{create-database?} (default: @code{#f})
-Whether to create a database with the same name as the role.
+whether to create a database with the same name as the role.
+
+@item @code{encoding} (default: @code{"UTF8"})
+The character set to use for storing text in the database.
+
+@item @code{collation} (default: @code{"en_US.utf8"})
+The string sort order locale setting.
+
+@item @code{ctype} (default: @code{"en_US.utf8"})
+The character classification locale setting.
+
+@item @code{template} (default: @code{"template1"})
+The default template to copy the new database from when creating it.
+Use @code{"template0"} for a pristine database with no system-local
+modifications.
@end table
@end deftp
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index e8e42d3b7b..7148971c1d 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -363,7 +363,15 @@ (define-record-type* <postgresql-role>
(permissions postgresql-role-permissions
(default '(createdb login))) ;list
(create-database? postgresql-role-create-database? ;boolean
- (default #f)))
+ (default #f))
+ (encoding postgresql-role-encoding ;string
+ (default "UTF8"))
+ (collation postgresql-role-collation ;string
+ (default "en_US.utf8"))
+ (ctype postgresql-role-ctype ;string
+ (default "en_US.utf8"))
+ (template postgresql-role-template ;string
+ (default "template1")))
(define-record-type* <postgresql-role-configuration>
postgresql-role-configuration make-postgresql-role-configuration
@@ -392,7 +400,8 @@ (define (postgresql-create-roles config)
(append-map
(lambda (role)
(match-record role <postgresql-role>
- (name permissions create-database?)
+ (name permissions create-database? encoding collation ctype
+ template)
`("SELECT NOT(EXISTS(SELECT 1 FROM pg_catalog.pg_roles WHERE \
rolname = '" ,name "')) as not_exists;\n"
"\\gset\n"
@@ -402,7 +411,11 @@ (define (postgresql-create-roles config)
";\n"
,@(if create-database?
`("CREATE DATABASE \"" ,name "\""
- " OWNER \"" ,name "\";\n")
+ " OWNER \"" ,name "\"\n"
+ " ENCODING '" ,encoding "'\n"
+ " LC_COLLATE '" ,collation "'\n"
+ " LC_CTYPE '" ,ctype "'\n"
+ " TEMPLATE " ,template ";")
'())
"\\endif\n")))
roles)))
--
2.40.1
--
Best regards,
Miguel Ángel Moreno
Information forwarded
to
guix-patches <at> gnu.org
:
bug#63926
; Package
guix-patches
.
(Wed, 14 Jun 2023 10:39:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 63926 <at> debbugs.gnu.org (full text, mbox):
Hi,
(Cc: Christopher Baines who knows pgsql better than I do.)
Miguel Ángel Moreno <me <at> mianmoreno.com> skribis:
> * gnu/services/databases.scm (postgresql-role): Add more role fields.
> (postgresql-create-roles): Honor it.
> * doc/guix.texi (Database Services): Document it.
That looks like an improvement! Some comments:
> @item @code{create-database?} (default: @code{#f})
> -Whether to create a database with the same name as the role.
> +whether to create a database with the same name as the role.
This change is unnecessary (leftover?).
> +@item @code{encoding} (default: @code{"UTF8"})
> +The character set to use for storing text in the database.
Or "UTF-8"? It might be worth mentioning the naming convention for
encodings, especially if it differs from
<http://www.iana.org/assignments/character-sets>.
> +@item @code{collation} (default: @code{"en_US.utf8"})
> +The string sort order locale setting.
> +
> +@item @code{ctype} (default: @code{"en_US.utf8"})
> +The character classification locale setting.
> +
> +@item @code{template} (default: @code{"template1"})
> +The default template to copy the new database from when creating it.
> +Use @code{"template0"} for a pristine database with no system-local
> +modifications.
Are these defaults equivalent to those that were previously in effect?
If would be ideal.
Thanks, and apologies for the delay!
Ludo’.
Added tag(s) moreinfo.
Request was from
Ludovic Courtès <ludo <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Sun, 08 Oct 2023 21:33:02 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 257 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.