mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 13:49:23 -05:00
services: postgresql: Use Guile datatypes.
* gnu/services/databases.scm (postgresql-config-file-compiler): Support Guile datatypes in the "extra-config" field. * gnu/tests/databases.scm (%postgresql-os): Test it. * doc/guix.texi (Database Services): Document it.
This commit is contained in:
parent
ff0ff69315
commit
a38d0b0137
3 changed files with 41 additions and 21 deletions
|
@ -19410,12 +19410,12 @@ local all all trust
|
||||||
host all all 127.0.0.1/32 md5
|
host all all 127.0.0.1/32 md5
|
||||||
host all all ::1/128 md5"))
|
host all all ::1/128 md5"))
|
||||||
(extra-config
|
(extra-config
|
||||||
'(("session_preload_libraries" "'auto_explain'")
|
'(("session_preload_libraries" "auto_explain")
|
||||||
("random_page_cost" "2")
|
("random_page_cost" 2)
|
||||||
("auto_explain.log_min_duration" "'100ms'")
|
("auto_explain.log_min_duration" "100 ms")
|
||||||
("work_mem" "'500MB'")
|
("work_mem" "500 MB")
|
||||||
("logging_collector" "on")
|
("logging_collector" #t)
|
||||||
("log_directory" "'/var/log/postgresql'")))))))
|
("log_directory" "/var/log/postgresql")))))))
|
||||||
@end lisp
|
@end lisp
|
||||||
|
|
||||||
@table @asis
|
@table @asis
|
||||||
|
@ -19435,6 +19435,12 @@ List of additional keys and values to include in the PostgreSQL config
|
||||||
file. Each entry in the list should be a list where the first element
|
file. Each entry in the list should be a list where the first element
|
||||||
is the key, and the remaining elements are the values.
|
is the key, and the remaining elements are the values.
|
||||||
|
|
||||||
|
The values can be numbers, booleans or strings and will be mapped to
|
||||||
|
PostgreSQL parameters types @code{Boolean}, @code{String},
|
||||||
|
@code{Numeric}, @code{Numeric with Unit} and @code{Enumerated} described
|
||||||
|
@uref{https://www.postgresql.org/docs/current/config-setting.html,
|
||||||
|
here}.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
|
|
|
@ -115,22 +115,28 @@ (define-gexp-compiler (postgresql-config-file-compiler
|
||||||
(match file
|
(match file
|
||||||
(($ <postgresql-config-file> log-destination hba-file
|
(($ <postgresql-config-file> log-destination hba-file
|
||||||
ident-file extra-config)
|
ident-file extra-config)
|
||||||
(define (single-quote string)
|
;; See: https://www.postgresql.org/docs/current/config-setting.html.
|
||||||
(if string
|
(define (format-value value)
|
||||||
(list "'" string "'")
|
(cond
|
||||||
'()))
|
((boolean? value)
|
||||||
|
(list (if value "on" "off")))
|
||||||
|
((number? value)
|
||||||
|
(list (number->string value)))
|
||||||
|
(else
|
||||||
|
(list "'" value "'"))))
|
||||||
|
|
||||||
(define contents
|
(define contents
|
||||||
(append-map
|
(append-map
|
||||||
(match-lambda
|
(match-lambda
|
||||||
((key) '())
|
((key) '())
|
||||||
((key . #f) '())
|
((key . #f) '())
|
||||||
((key values ...) `(,key " = " ,@values "\n")))
|
((key values ...)
|
||||||
|
`(,key " = " ,@(append-map format-value values) "\n")))
|
||||||
|
|
||||||
`(("log_destination" ,@(single-quote log-destination))
|
`(("log_destination" ,log-destination)
|
||||||
("hba_file" ,@(single-quote hba-file))
|
("hba_file" ,hba-file)
|
||||||
("ident_file" ,@(single-quote ident-file))
|
("ident_file" ,ident-file)
|
||||||
,@extra-config)))
|
,@extra-config)))
|
||||||
|
|
||||||
(gexp->derivation
|
(gexp->derivation
|
||||||
"postgresql.conf"
|
"postgresql.conf"
|
||||||
|
|
|
@ -218,7 +218,15 @@ (define %postgresql-os
|
||||||
(simple-operating-system
|
(simple-operating-system
|
||||||
(service postgresql-service-type
|
(service postgresql-service-type
|
||||||
(postgresql-configuration
|
(postgresql-configuration
|
||||||
(postgresql postgresql-10)))))
|
(postgresql postgresql-10)
|
||||||
|
(config-file
|
||||||
|
(postgresql-config-file
|
||||||
|
(extra-config
|
||||||
|
'(("session_preload_libraries" "auto_explain")
|
||||||
|
("random_page_cost" 2)
|
||||||
|
("auto_explain.log_min_duration" "100 ms")
|
||||||
|
("work_mem" "500 MB")
|
||||||
|
("debug_print_plan" #t)))))))))
|
||||||
|
|
||||||
(define (run-postgresql-test)
|
(define (run-postgresql-test)
|
||||||
"Run tests in %POSTGRESQL-OS."
|
"Run tests in %POSTGRESQL-OS."
|
||||||
|
|
Loading…
Reference in a new issue