mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
e2fb651752
Make sure that JIT is actually available when using services.postgresql = { enable = true; enableJIT = true; package = pkgs.postgresql_15; }; The current behavior is counter-intuitive because the docs state that `enableJIT = true;` is sufficient even though it wasn't in that case because the declared package doesn't have the LLVM dependency. Fixed by using `package.withJIT` if `enableJIT = true;` and `package.jitSupport` is `false`. Also updated the postgresql-jit test to test for that case.
49 lines
1.4 KiB
Nix
49 lines
1.4 KiB
Nix
{ system ? builtins.currentSystem
|
|
, config ? {}
|
|
, pkgs ? import ../.. { inherit system config; }
|
|
}:
|
|
|
|
with import ../lib/testing-python.nix { inherit system pkgs; };
|
|
|
|
let
|
|
inherit (pkgs) lib;
|
|
packages = builtins.attrNames (import ../../pkgs/servers/sql/postgresql pkgs);
|
|
|
|
mkJitTest = packageName: makeTest {
|
|
name = "${packageName}";
|
|
meta.maintainers = with lib.maintainers; [ ma27 ];
|
|
nodes.machine = { pkgs, lib, ... }: {
|
|
services.postgresql = {
|
|
enable = true;
|
|
enableJIT = true;
|
|
package = pkgs.${packageName};
|
|
initialScript = pkgs.writeText "init.sql" ''
|
|
create table demo (id int);
|
|
insert into demo (id) select generate_series(1, 5);
|
|
'';
|
|
};
|
|
};
|
|
testScript = ''
|
|
machine.start()
|
|
machine.wait_for_unit("postgresql.service")
|
|
|
|
with subtest("JIT is enabled"):
|
|
machine.succeed("sudo -u postgres psql <<<'show jit;' | grep 'on'")
|
|
|
|
with subtest("Test JIT works fine"):
|
|
output = machine.succeed(
|
|
"cat ${pkgs.writeText "test.sql" ''
|
|
set jit_above_cost = 1;
|
|
EXPLAIN ANALYZE SELECT CONCAT('jit result = ', SUM(id)) FROM demo;
|
|
SELECT CONCAT('jit result = ', SUM(id)) from demo;
|
|
''} | sudo -u postgres psql"
|
|
)
|
|
assert "JIT:" in output
|
|
assert "jit result = 15" in output
|
|
|
|
machine.shutdown()
|
|
'';
|
|
};
|
|
in
|
|
lib.genAttrs packages mkJitTest
|