GNU bug report logs - #62495
[PATCH] services: postgresql: Add more role fields.

Previous Next

Package: guix-patches;

Reported by: Miguel Moreno <mmoreno <at> mmoreno.eu>

Date: Tue, 28 Mar 2023 07:17:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62495 in the body.
You can then email your comments to 62495 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#62495; Package guix-patches. (Tue, 28 Mar 2023 07:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Miguel Moreno <mmoreno <at> mmoreno.eu>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 28 Mar 2023 07:17:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Miguel Moreno <mmoreno <at> mmoreno.eu>
To: guix-patches <at> gnu.org
Subject: [PATCH] services: postgresql: Add more role fields.
Date: Mon, 27 Mar 2023 19:30:45 +0200
* 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 c49e51b72e..79d6f78e02 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -24635,7 +24635,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 b7bd1e587e..9867e4db0c 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -362,7 +362,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
@@ -391,7 +399,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"
@@ -401,7 +410,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.39.2


-- 
Best regards,
Miguel Moreno




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Thu, 10 Aug 2023 22:29:02 GMT) Full text and rfc822 format available.

Notification sent to Miguel Moreno <mmoreno <at> mmoreno.eu>:
bug acknowledged by developer. (Thu, 10 Aug 2023 22:29:02 GMT) Full text and rfc822 format available.

Message #10 received at 62495-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Miguel Moreno <mmoreno <at> mmoreno.eu>
Cc: 62495-done <at> debbugs.gnu.org
Subject: Re: bug#62495: [PATCH] services: postgresql: Add more role fields.
Date: Fri, 11 Aug 2023 00:28:14 +0200
Hi,

Miguel Moreno <mmoreno <at> mmoreno.eu> skribis:

> * gnu/services/databases.scm (postgresql-role): Add more role fields.
> (postgresql-create-roles): Honor it.
> * doc/guix.texi (Database Services): Document it.

Finally applied, thanks!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 08 Sep 2023 11:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.