diff --git a/nixos/tests/postgresql.nix b/nixos/tests/postgresql.nix index 1f4f43a26669..0ce37b55bb7b 100644 --- a/nixos/tests/postgresql.nix +++ b/nixos/tests/postgresql.nix @@ -13,8 +13,10 @@ let INSERT INTO sth (id) VALUES (1); INSERT INTO sth (id) VALUES (1); INSERT INTO sth (id) VALUES (1); + CREATE TABLE xmltest ( doc xml ); + INSERT INTO xmltest (doc) VALUES ('ok'); -- check if libxml2 enabled ''; - make-postgresql-test = postgresql-name: postgresql-package: { + make-postgresql-test = postgresql-name: postgresql-package: makeTest { name = postgresql-name; meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ zagy ]; @@ -27,17 +29,23 @@ let }; testScript = '' + sub check_count { + my ($select, $nlines) = @_; + return 'test $(sudo -u postgres psql postgres -tAc "' . $select . '"|wc -l) -eq ' . $nlines; + } + $machine->start; $machine->waitForUnit("postgresql"); # postgresql should be available just after unit start - $machine->succeed("cat ${test-sql} | psql postgres"); + $machine->succeed("cat ${test-sql} | sudo -u postgres psql"); $machine->shutdown; # make sure that postgresql survive restart (bug #1735) sleep(2); $machine->start; $machine->waitForUnit("postgresql"); - $machine->fail('test $(psql postgres -tAc "SELECT * FROM sth;"|wc -l) -eq 3'); - $machine->succeed('test $(psql postgres -tAc "SELECT * FROM sth;"|wc -l) -eq 5'); - $machine->fail('test $(psql postgres -tAc "SELECT * FROM sth;"|wc -l) -eq 4'); + $machine->fail(check_count("SELECT * FROM sth;", 3)); + $machine->succeed(check_count("SELECT * FROM sth;", 5)); + $machine->fail(check_count("SELECT * FROM sth;", 4)); + $machine->succeed(check_count("SELECT xpath(\'/test/text()\', doc) FROM xmltest;", 1)); $machine->shutdown; ''; diff --git a/pkgs/servers/sql/postgresql/default.nix b/pkgs/servers/sql/postgresql/default.nix index 28f916935755..b9c940a01cdf 100644 --- a/pkgs/servers/sql/postgresql/default.nix +++ b/pkgs/servers/sql/postgresql/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, glibc, fetchurl, zlib, readline, libossp_uuid, openssl, makeWrapper }: +{ lib, stdenv, glibc, fetchurl, zlib, readline, libossp_uuid, openssl, libxml2, makeWrapper }: let @@ -15,7 +15,7 @@ let setOutputFlags = false; # $out retains configureFlags :-/ buildInputs = - [ zlib readline openssl makeWrapper ] + [ zlib readline openssl libxml2 makeWrapper ] ++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ]; enableParallelBuilding = true; @@ -24,6 +24,7 @@ let configureFlags = [ "--with-openssl" + "--with-libxml" "--sysconfdir=/etc" "--libdir=$(lib)/lib" ]