Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresql: support JIT compilation for version >= 11 #124804

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions nixos/tests/postgresql.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ let
CREATE TABLE xmltest ( doc xml );
INSERT INTO xmltest (doc) VALUES ('<test>ok</test>'); -- check if libxml2 enabled
'';

jit-test-sql = pkgs.writeText "postgresql-jit-test" ''
SET jit_above_cost = 1;
SET jit = 1;
EXPLAIN ANALYZE SELECT CONCAT('jit result = ', SUM(id)) FROM sth;
SELECT CONCAT('jit result = ', SUM(id)) from sth;
'';

make-postgresql-test = postgresql-name: postgresql-package: backup-all: makeTest {
name = postgresql-name;
meta = with pkgs.lib.maintainers; {
Expand Down Expand Up @@ -76,6 +84,16 @@ let
"stat -c '%a' /var/backup/postgresql/${backupName}.sql.gz | grep 600",
)

${optionalString (versionAtLeast postgresql-package.version "11") ''
with subtest("Postgresql JIT should work on postgresql >= 11"):
output = machine.succeed(
"cat ${jit-test-sql} | sudo -u postgres psql"
)
assert "JIT:" in output
assert "jit result = 5" in output
''}


with subtest("Initdb works"):
machine.succeed("sudo -u postgres initdb -D /tmp/testpostgres2")

Expand Down
11 changes: 9 additions & 2 deletions pkgs/servers/sql/postgresql/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ let
, enableSystemd ? (lib.versionAtLeast version "9.6" && !stdenv.isDarwin)
, gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic, libkrb5

# enable JIT support
, supportJIT ? (lib.versionAtLeast version "11")
, llvm, clang


# for postgreql.pkgs
, this, self, newScope, buildEnv
Expand Down Expand Up @@ -43,7 +47,9 @@ let
++ lib.optionals gssSupport [ libkrb5 ]
++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ];

nativeBuildInputs = [ makeWrapper ] ++ lib.optionals icuEnabled [ pkg-config ];
nativeBuildInputs = [ makeWrapper ]
++ lib.optionals icuEnabled [ pkg-config ]
++ lib.optionals supportJIT [ llvm clang ];

enableParallelBuilding = !stdenv.isDarwin;

Expand All @@ -66,7 +72,8 @@ let
(lib.optionalString enableSystemd "--with-systemd")
(if stdenv.isDarwin then "--with-uuid=e2fs" else "--with-ossp-uuid")
] ++ lib.optionals icuEnabled [ "--with-icu" ]
++ lib.optionals gssSupport [ "--with-gssapi" ];
++ lib.optionals gssSupport [ "--with-gssapi" ]
++ lib.optionals supportJIT [ "--with-llvm" ];

patches =
[ (if atLeast "9.4" then ./patches/disable-resolve_symlinks-94.patch else ./patches/disable-resolve_symlinks.patch)
Expand Down