push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
{ callPackage, ... }@args:
callPackage ./. (
args
// {
version = "3.1.21";
hash = "sha256-guN3Rcsb/EV4rxPE3yhJRSsT1+z44zUetg7ZBA4WjIc=";
}
)

View File

@@ -0,0 +1,9 @@
{ callPackage, ... }@args:
callPackage ./. (
args
// {
version = "3.2.7";
hash = "sha256-F7s9fcbJiz6lsWrvlTpY+ZET8MPwlyWPKJZOvHEwBvo=";
}
)

View File

@@ -0,0 +1,9 @@
{ callPackage, ... }@args:
callPackage ./. (
args
// {
version = "3.3.5";
hash = "sha256-RLHx8PyfbfIDr6X6ky5/w0XsGMFd+v5PgmQHvYOaf+k=";
}
)

View File

@@ -0,0 +1,110 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
cmake,
curl,
openssl,
zlib,
zstd,
libiconv,
version,
hash,
...
}:
let
isVer33 = lib.versionAtLeast version "3.3";
in
stdenv.mkDerivation {
pname = "mariadb-connector-c";
inherit version;
src = fetchFromGitHub {
owner = "mariadb-corporation";
repo = "mariadb-connector-c";
rev = "v${version}";
inherit hash;
};
patches = lib.optionals (lib.versionOlder version "3.4") [
# fix compilation against gcc15
(fetchpatch {
url = "https://github.com/mariadb-corporation/mariadb-connector-c/commit/e8448137f3365568090d5c0d4051039ddc1cdb6f.patch";
hash = "sha256-aDbaaJA8DxGG5RrOa+CHhk4wuzlBy5tWyS+f/zVYU0c=";
})
# Fix the build with CMake 4.
(fetchpatch {
name = "mariadb-connector-c-fix-cmake-4.patch";
url = "https://github.com/mariadb-corporation/mariadb-connector-c/commit/598dc3d2d7a63e5d250421dd0ea88be55ea8511f.patch";
hash = "sha256-HojNRobguBmtpEdr2lVi/MpcoDAsZnb3+tw/pt376es=";
})
];
outputs = [
"out"
"dev"
];
cmakeFlags = [
"-DMARIADB_UNIX_ADDR=/run/mysqld/mysqld.sock"
"-DWITH_CURL=ON"
"-DWITH_EXTERNAL_ZLIB=ON"
"-DWITH_MYSQLCOMPAT=ON"
];
postPatch = ''
substituteInPlace mariadb_config/mariadb_config.c.in \
--replace-fail '#define INCLUDE "-I%s/@INSTALL_INCLUDEDIR@ -I%s/@INSTALL_INCLUDEDIR@/mysql"' "#define INCLUDE \"-I$dev/include -I$dev/include/mysql\"" \
--replace-fail '#define LIBS "-L%s/@INSTALL_LIBDIR@/ -lmariadb"' "#define LIBS \"-L$out/lib/mariadb -lmariadb\"" \
--replace-fail '#define PKG_LIBDIR "%s/@INSTALL_LIBDIR@"' "#define PKG_LIBDIR \"$out/lib/mariadb\"" \
--replace-fail '#define PLUGIN_DIR "%s/@INSTALL_PLUGINDIR@"' "#define PLUGIN_DIR \"$out/lib/mariadb/plugin\"" \
--replace-fail '#define PKG_PLUGINDIR "%s/@INSTALL_PLUGINDIR@"' "#define PKG_PLUGINDIR \"$out/lib/mariadb/plugin\""
''
+ lib.optionalString stdenv.hostPlatform.isStatic ''
# Disables all dynamic plugins
substituteInPlace cmake/plugins.cmake \
--replace-fail 'if(''${CC_PLUGIN_DEFAULT} STREQUAL "DYNAMIC")' 'if(''${CC_PLUGIN_DEFAULT} STREQUAL "INVALID")'
# Force building static libraries
substituteInPlace libmariadb/CMakeLists.txt \
--replace-fail 'libmariadb SHARED' 'libmariadb STATIC'
'';
# The cmake setup-hook uses $out/lib by default, this is not the case here.
preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin ''
cmakeFlagsArray+=("-DCMAKE_INSTALL_NAME_DIR=$out/lib/mariadb")
'';
nativeBuildInputs = [ cmake ];
propagatedBuildInputs = [
curl
openssl
zlib
]
++ lib.optional isVer33 zstd;
buildInputs = [ libiconv ];
postInstall = ''
moveToOutput bin/mariadb_config "$dev"
'';
postFixup = ''
ln -sv mariadb_config $dev/bin/mysql_config
ln -sv mariadb $out/lib/mysql
ln -sv mariadb $dev/include/mysql
ln -sv mariadb_version.h $dev/include/mariadb/mysql_version.h
ln -sv libmariadb.pc $dev/lib/pkgconfig/mysqlclient.pc
install -Dm644 include/ma_config.h $dev/include/mariadb/my_config.h
'';
meta = with lib; {
description = "Client library that can be used to connect to MySQL or MariaDB";
homepage = "https://github.com/mariadb-corporation/mariadb-connector-c";
license = licenses.lgpl21Plus;
maintainers = with maintainers; [ globin ];
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,390 @@
let
# shared across all versions
generic =
{
version,
hash,
lib,
stdenv,
fetchurl,
nixosTests,
buildPackages,
# Native buildInputs components
bison,
boost,
cmake,
fixDarwinDylibNames,
flex,
makeWrapper,
pkg-config,
# Common components
curl,
libiconv,
ncurses,
openssl,
pcre2,
libkrb5,
libaio,
liburing,
systemd,
cctools,
perl,
jemalloc,
less,
libedit,
# Server components
bzip2,
lz4,
lzo,
snappy,
xz,
zlib,
zstd,
cracklib,
judy,
libevent,
libxml2,
linux-pam,
numactl,
fmt,
withStorageMroonga ? true,
kytea,
libsodium,
msgpack-cxx,
zeromq,
withStorageRocks ? true,
withEmbedded ? false,
withNuma ? false,
}:
let
isCross = stdenv.buildPlatform != stdenv.hostPlatform;
libExt = stdenv.hostPlatform.extensions.sharedLibrary;
mytopEnv = buildPackages.perl.withPackages (
p: with p; [
DBDMariaDB
DBI
TermReadKey
]
);
common = rec {
# attributes common to both builds
inherit version;
src = fetchurl {
url = "https://archive.mariadb.org/mariadb-${version}/source/mariadb-${version}.tar.gz";
inherit hash;
};
outputs = [
"out"
"man"
];
nativeBuildInputs = [
cmake
pkg-config
]
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames
++ lib.optional (!stdenv.hostPlatform.isDarwin) makeWrapper;
buildInputs = [
libiconv
ncurses
zlib
pcre2
openssl
curl
]
++ lib.optionals stdenv.hostPlatform.isLinux (
[
libkrb5
systemd
]
++ (if (lib.versionOlder version "10.6") then [ libaio ] else [ liburing ])
)
++ lib.optionals stdenv.hostPlatform.isDarwin [
cctools
perl
libedit
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ jemalloc ];
prePatch = ''
sed -i 's,[^"]*/var/log,/var/log,g' storage/mroonga/vendor/groonga/CMakeLists.txt
'';
env = lib.optionalAttrs (stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isGnu) {
# MariaDB uses non-POSIX fopen64, which musl only conditionally defines.
NIX_CFLAGS_COMPILE = "-D_LARGEFILE64_SOURCE";
};
patches = [
./patch/cmake-includedir.patch
# patch for musl compatibility
./patch/include-cstdint-full.patch
]
# Fixes a build issue as documented on
# https://jira.mariadb.org/browse/MDEV-26769?focusedCommentId=206073&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-206073
++ lib.optional (
!stdenv.hostPlatform.isLinux && lib.versionAtLeast version "10.6"
) ./patch/macos-MDEV-26769-regression-fix.patch;
cmakeFlags = [
"-DBUILD_CONFIG=mysql_release"
"-DMANUFACTURER=nixos.org"
"-DDEFAULT_CHARSET=utf8mb4"
"-DDEFAULT_COLLATION=utf8mb4_unicode_ci"
"-DSECURITY_HARDENED=ON"
"-DINSTALL_UNIX_ADDRDIR=/run/mysqld/mysqld.sock"
"-DINSTALL_BINDIR=bin"
"-DINSTALL_DOCDIR=share/doc/mysql"
"-DINSTALL_DOCREADMEDIR=share/doc/mysql"
"-DINSTALL_INCLUDEDIR=include/mysql"
"-DINSTALL_LIBDIR=lib"
"-DINSTALL_PLUGINDIR=lib/mysql/plugin"
"-DINSTALL_INFODIR=share/mysql/docs"
"-DINSTALL_MANDIR=share/man"
"-DINSTALL_MYSQLSHAREDIR=share/mysql"
"-DINSTALL_SCRIPTDIR=bin"
"-DINSTALL_SUPPORTFILESDIR=share/doc/mysql"
"-DINSTALL_MYSQLTESTDIR=OFF"
"-DINSTALL_SQLBENCHDIR=OFF"
"-DINSTALL_PAMDIR=share/pam/lib/security"
"-DINSTALL_PAMDATADIR=share/pam/etc/security"
"-DWITH_ZLIB=system"
"-DWITH_SSL=system"
"-DWITH_PCRE=system"
"-DWITH_SAFEMALLOC=OFF"
"-DWITH_UNIT_TESTS=OFF"
"-DEMBEDDED_LIBRARY=OFF"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# On Darwin without sandbox, CMake will find the system java and attempt to build with java support, but
# then it will fail during the actual build. Let's just disable the flag explicitly until someone decides
# to pass in java explicitly.
"-DCONNECT_WITH_JDBC=OFF"
"-DCURSES_LIBRARY=${ncurses.out}/lib/libncurses.dylib"
]
++ lib.optionals (stdenv.hostPlatform.isDarwin && lib.versionAtLeast version "10.6") [
# workaround for https://jira.mariadb.org/browse/MDEV-29925
"-Dhave_C__Wl___as_needed="
]
++ lib.optionals isCross [
# revisit this if nixpkgs supports any architecture whose stack grows upwards
"-DSTACK_DIRECTION=-1"
"-DCMAKE_CROSSCOMPILING_EMULATOR=${stdenv.hostPlatform.emulator buildPackages}"
];
postInstall = lib.optionalString (!withEmbedded) ''
# Remove Development components. Need to use libmysqlclient.
rm "$out"/lib/mysql/plugin/daemon_example.ini
rm "$out"/lib/{libmariadb.a,libmariadbclient.a,libmysqlclient.a,libmysqlclient_r.a,libmysqlservices.a}
rm -f "$out"/bin/{mariadb-config,mariadb_config,mysql_config}
rm -r $out/include
rm -r $out/lib/pkgconfig
'';
# perlPackages.DBDmysql is broken on darwin
postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
wrapProgram $out/bin/mytop --set PATH ${
lib.makeBinPath [
less
ncurses
]
}
'';
passthru.tests =
let
testVersion = "mariadb_${builtins.replaceStrings [ "." ] [ "" ] (lib.versions.majorMinor version)}";
in
{
mariadb-galera-rsync = nixosTests.mariadb-galera.${testVersion};
mysql = nixosTests.mysql.${testVersion};
mysql-autobackup = nixosTests.mysql-autobackup.${testVersion};
mysql-backup = nixosTests.mysql-backup.${testVersion};
mysql-replication = nixosTests.mysql-replication.${testVersion};
};
meta = with lib; {
description = "Enhanced, drop-in replacement for MySQL";
homepage = "https://mariadb.org/";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ thoughtpolice ];
teams = [ teams.helsinki-systems ];
platforms = platforms.all;
};
};
client = stdenv.mkDerivation (
common
// {
pname = "mariadb-client";
patches = common.patches ++ [
./patch/cmake-plugin-includedir.patch
];
buildInputs =
common.buildInputs ++ lib.optionals (lib.versionAtLeast common.version "10.11") [ fmt ];
cmakeFlags = common.cmakeFlags ++ [
"-DPLUGIN_AUTH_PAM=NO"
"-DWITHOUT_SERVER=ON"
"-DWITH_WSREP=OFF"
"-DINSTALL_MYSQLSHAREDIR=share/mysql-client"
];
postInstall = common.postInstall + ''
rm "$out"/bin/{mariadb-test,mysqltest}
libmysqlclient_path=$(readlink -f $out/lib/libmysqlclient${libExt})
rm "$out"/lib/{libmariadb${libExt},libmysqlclient${libExt},libmysqlclient_r${libExt}}
mv "$libmysqlclient_path" "$out"/lib/libmysqlclient${libExt}
ln -sv libmysqlclient${libExt} "$out"/lib/libmysqlclient_r${libExt}
'';
}
);
in
stdenv.mkDerivation (
finalAttrs:
common
// {
pname = "mariadb-server";
nativeBuildInputs = common.nativeBuildInputs ++ [
bison
boost.dev
flex
];
buildInputs =
common.buildInputs
++ [
bzip2
lz4
lzo
snappy
xz
zstd
cracklib
judy
libevent
libxml2
]
++ lib.optional withNuma numactl
++ lib.optionals stdenv.hostPlatform.isLinux [ linux-pam ]
++ lib.optional (!stdenv.hostPlatform.isDarwin) mytopEnv
++ lib.optionals withStorageMroonga [
kytea
libsodium
msgpack-cxx
zeromq
]
++ lib.optionals (lib.versionAtLeast common.version "10.11") [ fmt ];
propagatedBuildInputs = lib.optional withNuma numactl;
postPatch = ''
substituteInPlace scripts/galera_new_cluster.sh \
--replace ":-mariadb" ":-mysql"
'';
cmakeFlags =
common.cmakeFlags
++ [
"-DMYSQL_DATADIR=/var/lib/mysql"
"-DENABLED_LOCAL_INFILE=OFF"
"-DWITH_READLINE=ON"
"-DWITH_EXTRA_CHARSETS=all"
"-DWITH_EMBEDDED_SERVER=${if withEmbedded then "ON" else "OFF"}"
"-DWITH_UNIT_TESTS=OFF"
"-DWITH_WSREP=ON"
"-DWITH_INNODB_DISALLOW_WRITES=ON"
"-DWITHOUT_EXAMPLE=1"
"-DWITHOUT_FEDERATED=1"
"-DWITHOUT_TOKUDB=1"
]
++ lib.optionals (lib.versionOlder version "11.4") [
# Fix the build with CMake 4.
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
]
++ lib.optionals withNuma [
"-DWITH_NUMA=ON"
]
++ lib.optionals (!withStorageMroonga) [
"-DWITHOUT_MROONGA=1"
]
++ lib.optionals (!withStorageRocks) [
"-DWITHOUT_ROCKSDB=1"
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin && withStorageRocks) [
"-DWITH_ROCKSDB_JEMALLOC=ON"
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
"-DWITH_JEMALLOC=yes"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
"-DPLUGIN_AUTH_PAM=NO"
"-DPLUGIN_AUTH_PAM_V1=NO"
"-DWITHOUT_OQGRAPH=1"
"-DWITHOUT_PLUGIN_S3=1"
];
preConfigure = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
patchShebangs scripts/mytop.sh
'';
postInstall =
common.postInstall
+ ''
rm -r "$out"/share/aclocal
chmod +x "$out"/bin/wsrep_sst_common
rm -f "$out"/bin/{mariadb-client-test,mariadb-test,mysql_client_test,mysqltest}
''
+ lib.optionalString withStorageMroonga ''
mv "$out"/share/{groonga,groonga-normalizer-mysql} "$out"/share/doc/mysql
''
+ lib.optionalString (!stdenv.hostPlatform.isDarwin && lib.versionAtLeast common.version "10.4") ''
mv "$out"/OFF/suite/plugins/pam/pam_mariadb_mtr.so "$out"/share/pam/lib/security
mv "$out"/OFF/suite/plugins/pam/mariadb_mtr "$out"/share/pam/etc/security
rm -r "$out"/OFF
'';
CXXFLAGS = lib.optionalString stdenv.hostPlatform.isi686 "-fpermissive";
passthru = {
inherit client;
server = finalAttrs.finalPackage;
};
}
);
in
self: {
# see https://mariadb.org/about/#maintenance-policy for EOLs
mariadb_106 = self.callPackage generic {
# Supported until 2026-07-06
version = "10.6.23";
hash = "sha256-uvS/N6BR6JLnFyTudSiRrbfPxpzSjQhzXDYH0wxpPCM=";
};
mariadb_1011 = self.callPackage generic {
# Supported until 2028-02-16
version = "10.11.14";
hash = "sha256-ilccsU+x1ONmPY6Y89QgDAQvyLKkqqq0lYYN6ot9BS8=";
};
mariadb_114 = self.callPackage generic {
# Supported until 2029-05-29
version = "11.4.8";
hash = "sha256-UvpNyixfgK/BZn1SOifAYXbZhTIpimsMMe1zUF9J4Vw=";
};
mariadb_118 = self.callPackage generic {
# Supported until 2028-06-04
version = "11.8.3";
hash = "sha256-EBSoXHaN6PnpxtS/C0JhfzsViL4a03H3FnTqMrhxGcA=";
};
}

View File

@@ -0,0 +1,11 @@
--- a/include/CMakeLists.txt 2017-12-25 05:59:07.204144374 +0100
+++ b/include/CMakeLists.txt 2017-12-25 05:59:26.339552817 +0100
@@ -94,7 +94,7 @@
ENDIF()
MACRO(INSTALL_COMPAT_HEADER file footer)
- INSTALL(CODE "FILE(WRITE \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDEDIR}/${file}
+ INSTALL(CODE "FILE(WRITE ${INSTALL_INCLUDEDIR}/${file}
\"/* Do not edit this file directly, it was auto-generated by cmake */
#warning This file should not be included by clients, include only <mysql.h>

View File

@@ -0,0 +1,16 @@
diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake
index 31291d26..fad52814 100644
--- a/cmake/plugin.cmake
+++ b/cmake/plugin.cmake
@@ -34,6 +34,11 @@ MACRO(MYSQL_ADD_PLUGIN)
"LINK_LIBRARIES;DEPENDENCIES"
${ARGN}
)
+
+ IF(WITHOUT_SERVER OR ARG_CLIENT)
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+ ENDIF()
+
IF(NOT WITHOUT_SERVER OR ARG_CLIENT)
# Add common include directories

View File

@@ -0,0 +1,48 @@
diff --git a/storage/rocksdb/rocksdb/table/block_based/data_block_hash_index.h b/storage/rocksdb/rocksdb/table/block_based/data_block_hash_index.h
index f356395..3215221 100644
--- a/storage/rocksdb/rocksdb/table/block_based/data_block_hash_index.h
+++ b/storage/rocksdb/rocksdb/table/block_based/data_block_hash_index.h
@@ -5,6 +5,7 @@
#pragma once
+#include <cstdint>
#include <string>
#include <vector>
diff --git a/storage/rocksdb/rocksdb/util/string_util.h b/storage/rocksdb/rocksdb/util/string_util.h
index a761be6..064d059 100644
--- a/storage/rocksdb/rocksdb/util/string_util.h
+++ b/storage/rocksdb/rocksdb/util/string_util.h
@@ -6,6 +6,7 @@
#pragma once
+#include <cstdint>
#include <sstream>
#include <string>
#include <unordered_map>
diff --git a/storage/rocksdb/rocksdb/include/rocksdb/utilities/checkpoint.h b/storage/rocksdb/rocksdb/include/rocksdb/utilities/checkpoint.h
index c7f93b4..3c2ab80 100644
--- a/storage/rocksdb/rocksdb/include/rocksdb/utilities/checkpoint.h
+++ b/storage/rocksdb/rocksdb/include/rocksdb/utilities/checkpoint.h
@@ -8,6 +8,7 @@
#pragma once
#ifndef ROCKSDB_LITE
+#include <cstdint>
#include <string>
#include <vector>
#include "rocksdb/status.h"
diff --git a/storage/rocksdb/rocksdb/db/compaction/compaction_iteration_stats.h b/storage/rocksdb/rocksdb/db/compaction/compaction_iteration_stats.h
index 963c1d8..8d70309 100644
--- a/storage/rocksdb/rocksdb/db/compaction/compaction_iteration_stats.h
+++ b/storage/rocksdb/rocksdb/db/compaction/compaction_iteration_stats.h
@@ -6,6 +6,7 @@
#pragma once
#include "rocksdb/rocksdb_namespace.h"
+#include <cstdint>
struct CompactionIterationStats {
// Compaction statistics

View File

@@ -0,0 +1,12 @@
diff -ru a/storage/innobase/include/buf0types.h b/storage/innobase/include/buf0types.h
--- a/storage/innobase/include/buf0types.h 2021-11-17 02:37:32.000000000 -0500
+++ b/storage/innobase/include/buf0types.h 2021-11-17 02:38:50.000000000 -0500
@@ -179,7 +179,7 @@
#include "sux_lock.h"
#ifdef SUX_LOCK_GENERIC
-class page_hash_latch : private rw_lock
+class page_hash_latch : public rw_lock
{
/** Wait for a shared lock */
void read_lock_wait();

View File

@@ -0,0 +1,31 @@
{
lib,
stdenv,
fetchurl,
}:
stdenv.mkDerivation rec {
pname = "mssql-jdbc";
version = "13.2.0";
src = fetchurl {
url = "https://github.com/Microsoft/mssql-jdbc/releases/download/v${version}/mssql-jdbc-${version}.jre8.jar";
sha256 = "sha256-zC6aTII/79PMJvLY9wEw7EhaUwhZ4F6H2N7zcr7mzKc=";
};
dontUnpack = true;
installPhase = ''
runHook preInstall
mkdir -p $out/share/java
cp $src $out/share/java/mssql-jdbc.jar
runHook postInstall
'';
meta = {
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
platforms = lib.platforms.unix;
};
}

View File

@@ -0,0 +1,32 @@
{
lib,
stdenv,
fetchurl,
unzip,
}:
stdenv.mkDerivation rec {
pname = "jtds";
version = "1.3.1";
src = fetchurl {
url = "mirror://sourceforge/jtds/${version}/${pname}-${version}-dist.zip";
sha256 = "sha256-eV0P8QdjfuHXzYssH8yHhynuH0Clg7MAece2Up3S9M0";
};
sourceRoot = ".";
installPhase = ''
mkdir -p $out/share/java
cp jtds-*.jar $out/share/java/jtds-jdbc.jar
'';
nativeBuildInputs = [ unzip ];
meta = with lib; {
description = "Pure Java (type 4) JDBC 3.0 driver for Microsoft SQL Server";
homepage = "https://jtds.sourceforge.net/";
license = licenses.lgpl21;
platforms = platforms.unix;
};
}

View File

@@ -0,0 +1,130 @@
{
lib,
stdenv,
fetchurl,
bison,
cmake,
pkg-config,
boost,
icu,
libedit,
libevent,
lz4,
ncurses,
openssl,
protobuf,
re2,
readline,
zlib,
zstd,
libfido2,
numactl,
cctools,
developer_cmds,
libtirpc,
rpcsvc-proto,
curl,
DarwinTools,
nixosTests,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "mysql";
version = "8.0.43";
src = fetchurl {
url = "https://dev.mysql.com/get/Downloads/MySQL-${lib.versions.majorMinor finalAttrs.version}/mysql-${finalAttrs.version}.tar.gz";
hash = "sha256-diUKgQFch49iUhz68w3/DqmyUJeNKx3/AHQIo5jV25M=";
};
nativeBuildInputs = [
bison
cmake
pkg-config
protobuf
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ rpcsvc-proto ];
patches = [
./no-force-outline-atomics.patch # Do not force compilers to turn on -moutline-atomics switch
];
## NOTE: MySQL upstream frequently twiddles the invocations of libtool. When updating, you might proactively grep for libtool references.
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace cmake/libutils.cmake --replace-fail /usr/bin/libtool ${cctools}/bin/libtool
substituteInPlace cmake/os/Darwin.cmake --replace-fail /usr/bin/libtool ${cctools}/bin/libtool
substituteInPlace cmake/package_name.cmake --replace-fail "COMMAND sw_vers" "COMMAND ${DarwinTools}/bin/sw_vers"
'';
buildInputs = [
boost
(curl.override { inherit openssl; })
icu
libedit
libevent
lz4
ncurses
openssl
protobuf
re2
readline
zlib
zstd
libfido2
]
++ lib.optionals stdenv.hostPlatform.isLinux [
numactl
libtirpc
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
developer_cmds
];
strictDeps = true;
outputs = [
"out"
"static"
];
cmakeFlags = [
"-DFORCE_UNSUPPORTED_COMPILER=1" # To configure on Darwin.
"-DWITH_ROUTER=OFF" # It may be packaged separately.
"-DWITH_SYSTEM_LIBS=ON"
"-DWITH_UNIT_TESTS=OFF"
"-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
"-DMYSQL_DATADIR=/var/lib/mysql"
"-DINSTALL_INFODIR=share/mysql/docs"
"-DINSTALL_MANDIR=share/man"
"-DINSTALL_PLUGINDIR=lib/mysql/plugin"
"-DINSTALL_INCLUDEDIR=include/mysql"
"-DINSTALL_DOCREADMEDIR=share/mysql"
"-DINSTALL_SUPPORTFILESDIR=share/mysql"
"-DINSTALL_MYSQLSHAREDIR=share/mysql"
"-DINSTALL_MYSQLTESTDIR="
"-DINSTALL_DOCDIR=share/mysql/docs"
"-DINSTALL_SHAREDIR=share/mysql"
];
postInstall = ''
moveToOutput "lib/*.a" $static
so=${stdenv.hostPlatform.extensions.sharedLibrary}
ln -s libmysqlclient$so $out/lib/libmysqlclient_r$so
'';
passthru = {
client = finalAttrs.finalPackage;
connector-c = finalAttrs.finalPackage;
server = finalAttrs.finalPackage;
mysqlVersion = lib.versions.majorMinor finalAttrs.version;
tests = nixosTests.mysql.mysql80;
};
meta = with lib; {
homepage = "https://www.mysql.com/";
description = "World's most popular open source database";
license = licenses.gpl2Only;
maintainers = with maintainers; [ orivej ];
platforms = platforms.unix;
};
})

View File

@@ -0,0 +1,24 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 727d66011f9..acae1aada57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1338,19 +1338,6 @@ IF(UNIX AND MY_COMPILER_IS_GNU_OR_CLANG
ENDIF()
ENDIF()
-# For aarch64 some sub-architectures support LSE atomics and some don't. Thus,
-# compiling for the common denominator (-march=armv8-a) means LSE is not used.
-# The -moutline-atomics switch enables run-time detection of LSE support.
-# There are compilers (gcc 9.3.1 for example) which support this switch, but
-# do not enable it by default, even though it seems to help. So, we force it.
-IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
- MY_CHECK_CXX_COMPILER_FLAG( "-moutline-atomics" HAVE_OUTLINE_ATOMICS)
- IF(HAVE_OUTLINE_ATOMICS)
- STRING_APPEND(CMAKE_C_FLAGS " -moutline-atomics")
- STRING_APPEND(CMAKE_CXX_FLAGS " -moutline-atomics")
- ENDIF()
-ENDIF()
-
IF(LINUX)
OPTION(LINK_RANDOMIZE "Randomize the order of all symbols in the binary" OFF)
SET(LINK_RANDOMIZE_SEED "mysql"

View File

@@ -0,0 +1,215 @@
{
lib,
stdenv,
fetchurl,
fetchpatch,
gitUpdater,
bison,
cmake,
pkg-config,
boost,
icu,
libedit,
libevent,
lz4,
ncurses,
openssl,
perl,
protobuf,
re2,
readline,
zlib,
zstd,
libfido2,
numactl,
cctools,
developer_cmds,
libtirpc,
rpcsvc-proto,
curl,
DarwinTools,
nixosTests,
coreutils,
procps,
gnused,
gnugrep,
hostname,
makeWrapper,
# Percona-specific deps
cyrus_sasl,
gnumake,
openldap,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "percona-server";
version = "8.0.42-33";
src = fetchurl {
url = "https://www.percona.com/downloads/Percona-Server-8.0/Percona-Server-${finalAttrs.version}/source/tarball/percona-server-${finalAttrs.version}.tar.gz";
hash = "sha256-UDdmBz1RVjX/kRivvk69GPdtjLjWTglKxteiLxXKQGc=";
};
nativeBuildInputs = [
bison
cmake
pkg-config
makeWrapper
# required for scripts/CMakeLists.txt
coreutils
gnugrep
procps
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ rpcsvc-proto ];
patches = [
# adapted from mysql80's llvm 19 fixes
./libcpp-fixes.patch
# fixes using -DWITH_SSL=system with CMAKE_PREFIX_PATH on darwin
# https://github.com/Homebrew/homebrew-core/pull/204799
(fetchpatch {
name = "fix-system-ssl-darwin.patch";
url = "https://github.com/percona/percona-server/pull/5537/commits/a693e5d67abf6f27f5284c86361604babec529c6.patch";
hash = "sha256-fFBy3AYTMLvHvbsh0g0UvuPkmVMKZzxPsxeBKbsN8Ho=";
})
./no-force-outline-atomics.patch # Do not force compilers to turn on -moutline-atomics switch
./coredumper-explicitly-import-unistd.patch # fix build on aarch64-linux
];
## NOTE: MySQL upstream frequently twiddles the invocations of libtool. When updating, you might proactively grep for libtool references.
postPatch = ''
substituteInPlace cmake/libutils.cmake --replace /usr/bin/libtool libtool
substituteInPlace cmake/os/Darwin.cmake --replace /usr/bin/libtool libtool
# The rocksdb setup script is called with `env -i` and cannot find anything in PATH.
patchShebangs storage/rocksdb/get_rocksdb_files.sh
substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace mktemp ${coreutils}/bin/mktemp
substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace "rm $MKFILE" "${coreutils}/bin/rm $MKFILE"
substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace "make --" "${gnumake}/bin/make --"
'';
buildInputs = [
boost
(curl.override { inherit openssl; })
icu
libedit
libevent
lz4
ncurses
openssl
protobuf
re2
readline
zlib
zstd
libfido2
openldap
perl
cyrus_sasl
]
++ lib.optionals stdenv.hostPlatform.isLinux [
numactl
libtirpc
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
cctools
developer_cmds
DarwinTools
];
outputs = [
"out"
"static"
];
cmakeFlags = [
# Percona-specific flags.
"-DPORTABLE=1"
"-DWITH_LDAP=system"
"-DROCKSDB_DISABLE_AVX2=1"
"-DROCKSDB_DISABLE_MARCH_NATIVE=1"
# Flags taken from mysql package.
"-DFORCE_UNSUPPORTED_COMPILER=1" # To configure on Darwin.
"-DWITH_ROUTER=OFF" # It may be packaged separately.
"-DWITH_SYSTEM_LIBS=ON"
"-DWITH_UNIT_TESTS=OFF"
"-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
"-DMYSQL_DATADIR=/var/lib/mysql"
"-DINSTALL_INFODIR=share/mysql/docs"
"-DINSTALL_MANDIR=share/man"
"-DINSTALL_PLUGINDIR=lib/mysql/plugin"
"-DINSTALL_INCLUDEDIR=include/mysql"
"-DINSTALL_DOCREADMEDIR=share/mysql"
"-DINSTALL_SUPPORTFILESDIR=share/mysql"
"-DINSTALL_MYSQLSHAREDIR=share/mysql"
"-DINSTALL_MYSQLTESTDIR="
"-DINSTALL_DOCDIR=share/mysql/docs"
"-DINSTALL_SHAREDIR=share/mysql"
];
postInstall = ''
moveToOutput "lib/*.a" $static
so=${stdenv.hostPlatform.extensions.sharedLibrary}
ln -s libperconaserverclient$so $out/lib/libmysqlclient_r$so
wrapProgram $out/bin/mysqld_safe --prefix PATH : ${
lib.makeBinPath [
coreutils
procps
gnugrep
gnused
hostname
]
}
wrapProgram $out/bin/mysql_config --prefix PATH : ${
lib.makeBinPath [
coreutils
gnused
]
}
wrapProgram $out/bin/ps_mysqld_helper --prefix PATH : ${
lib.makeBinPath [
coreutils
gnugrep
]
}
wrapProgram $out/bin/ps-admin --prefix PATH : ${
lib.makeBinPath [
coreutils
gnugrep
]
}
wrapProgram $out/bin/mysqld_multi --prefix PATH : ${
lib.makeBinPath [
coreutils
gnugrep
]
}
'';
passthru = {
client = finalAttrs.finalPackage;
connector-c = finalAttrs.finalPackage;
server = finalAttrs.finalPackage;
mysqlVersion = lib.versions.majorMinor finalAttrs.version;
tests.percona-server =
nixosTests.mysql."percona-server_${lib.versions.major finalAttrs.version}_${lib.versions.minor finalAttrs.version}";
updateScript = gitUpdater {
url = "https://github.com/percona/percona-server";
rev-prefix = "Percona-Server-";
allowedVersions = "${lib.versions.major finalAttrs.version}\\.${lib.versions.minor finalAttrs.version}\\..+";
};
};
meta = with lib; {
homepage = "https://www.percona.com/software/mysql-database/percona-server";
description = ''
A free, fully compatible, enhanced, open source drop-in replacement for
MySQL® that provides superior performance, scalability and instrumentation.
Long-term support release.
'';
license = licenses.gpl2Only;
teams = [ teams.flyingcircus ];
platforms = platforms.unix;
};
})

View File

@@ -0,0 +1,225 @@
{
lib,
stdenv,
fetchurl,
gitUpdater,
bison,
cmake,
pkg-config,
boost,
icu,
libedit,
libevent,
lz4,
ncurses,
openssl,
perl,
protobuf,
re2,
readline,
zlib,
zstd,
libfido2,
numactl,
cctools,
developer_cmds,
libtirpc,
rpcsvc-proto,
curl,
DarwinTools,
nixosTests,
coreutils,
procps,
gnused,
gnugrep,
hostname,
makeWrapper,
systemd,
# Percona-specific deps
cyrus_sasl,
gnumake,
openldap,
# optional: different malloc implementations
withJemalloc ? false,
withTcmalloc ? false,
jemalloc,
gperftools,
}:
assert !(withJemalloc && withTcmalloc);
stdenv.mkDerivation (finalAttrs: {
pname = "percona-server";
version = "8.4.6-6";
src = fetchurl {
url = "https://downloads.percona.com/downloads/Percona-Server-${lib.versions.majorMinor finalAttrs.version}/Percona-Server-${finalAttrs.version}/source/tarball/percona-server-${finalAttrs.version}.tar.gz";
hash = "sha256-q01k+/TzvT7h52bqn9icc6VMlrUUjMDNKz0UdTyAWjU=";
};
nativeBuildInputs = [
bison
cmake
pkg-config
makeWrapper
# required for scripts/CMakeLists.txt
coreutils
gnugrep
procps
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ rpcsvc-proto ];
patches = [
./no-force-outline-atomics.patch # Do not force compilers to turn on -moutline-atomics switch
./coredumper-explicitly-import-unistd.patch # fix build on aarch64-linux
];
## NOTE: MySQL upstream frequently twiddles the invocations of libtool. When updating, you might proactively grep for libtool references.
postPatch = ''
substituteInPlace cmake/libutils.cmake --replace /usr/bin/libtool libtool
substituteInPlace cmake/os/Darwin.cmake --replace /usr/bin/libtool libtool
# The rocksdb setup script is called with `env -i` and cannot find anything in PATH.
patchShebangs storage/rocksdb/get_rocksdb_files.sh
substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace mktemp ${coreutils}/bin/mktemp
substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace "rm $MKFILE" "${coreutils}/bin/rm $MKFILE"
substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace "make --" "${gnumake}/bin/make --"
'';
buildInputs = [
boost
(curl.override { inherit openssl; })
icu
libedit
libevent
lz4
ncurses
openssl
protobuf
re2
readline
zlib
zstd
libfido2
openldap
perl
cyrus_sasl
]
++ lib.optionals stdenv.hostPlatform.isLinux [
numactl
libtirpc
systemd
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
cctools
developer_cmds
DarwinTools
]
++ lib.optional (stdenv.hostPlatform.isLinux && withJemalloc) jemalloc
++ lib.optional (stdenv.hostPlatform.isLinux && withTcmalloc) gperftools;
outputs = [
"out"
"static"
];
cmakeFlags = [
# Percona-specific flags.
"-DPORTABLE=1"
"-DWITH_LDAP=system"
"-DROCKSDB_DISABLE_AVX2=1"
"-DROCKSDB_DISABLE_MARCH_NATIVE=1"
# Flags taken from mysql package.
"-DFORCE_UNSUPPORTED_COMPILER=1" # To configure on Darwin.
"-DWITH_ROUTER=OFF" # It may be packaged separately.
"-DWITH_SYSTEM_LIBS=ON"
"-DWITH_UNIT_TESTS=OFF"
"-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
"-DMYSQL_DATADIR=/var/lib/mysql"
"-DINSTALL_INFODIR=share/mysql/docs"
"-DINSTALL_MANDIR=share/man"
"-DINSTALL_PLUGINDIR=lib/mysql/plugin"
"-DINSTALL_INCLUDEDIR=include/mysql"
"-DINSTALL_DOCREADMEDIR=share/mysql"
"-DINSTALL_SUPPORTFILESDIR=share/mysql"
"-DINSTALL_MYSQLSHAREDIR=share/mysql"
"-DINSTALL_MYSQLTESTDIR="
"-DINSTALL_DOCDIR=share/mysql/docs"
"-DINSTALL_SHAREDIR=share/mysql"
]
++ lib.optionals stdenv.hostPlatform.isLinux [
"-DWITH_SYSTEMD=1"
"-DWITH_SYSTEMD_DEBUG=1"
]
++ lib.optional (stdenv.hostPlatform.isLinux && withJemalloc) "-DWITH_JEMALLOC=1"
++ lib.optional (stdenv.hostPlatform.isLinux && withTcmalloc) "-DWITH_TCMALLOC=1";
postInstall = ''
moveToOutput "lib/*.a" $static
so=${stdenv.hostPlatform.extensions.sharedLibrary}
ln -s libperconaserverclient$so $out/lib/libmysqlclient_r$so
wrapProgram $out/bin/mysqld_safe --prefix PATH : ${
lib.makeBinPath [
coreutils
procps
gnugrep
gnused
hostname
]
}
wrapProgram $out/bin/mysql_config --prefix PATH : ${
lib.makeBinPath [
coreutils
gnused
]
}
wrapProgram $out/bin/ps_mysqld_helper --prefix PATH : ${
lib.makeBinPath [
coreutils
gnugrep
]
}
wrapProgram $out/bin/ps-admin --prefix PATH : ${
lib.makeBinPath [
coreutils
gnugrep
]
}
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
wrapProgram $out/bin/mysqld_multi --prefix PATH : ${
lib.makeBinPath [
coreutils
gnugrep
]
}
'';
passthru = {
client = finalAttrs.finalPackage;
connector-c = finalAttrs.finalPackage;
server = finalAttrs.finalPackage;
mysqlVersion = lib.versions.majorMinor finalAttrs.version;
tests.percona-server =
nixosTests.mysql."percona-server_${lib.versions.major finalAttrs.version}_${lib.versions.minor finalAttrs.version}";
updateScript = gitUpdater {
url = "https://github.com/percona/percona-server";
rev-prefix = "Percona-Server-";
allowedVersions = "${lib.versions.major finalAttrs.version}\\.${lib.versions.minor finalAttrs.version}\\..+";
};
};
meta = with lib; {
homepage = "https://www.percona.com/software/mysql-database/percona-server";
description = ''
A free, fully compatible, enhanced, open source drop-in replacement for
MySQL® that provides superior performance, scalability and instrumentation.
Long-term support release.
'';
license = licenses.gpl2Only;
teams = [ teams.flyingcircus ];
platforms = platforms.unix;
};
})

View File

@@ -0,0 +1,12 @@
diff --git a/extra/coredumper/src/thread_lister.c b/extra/coredumper/src/thread_lister.c
index 15fedac..181889b 100644
--- a/extra/coredumper/src/thread_lister.c
+++ b/extra/coredumper/src/thread_lister.c
@@ -35,6 +35,7 @@
#include <stdio.h> /* needed for NULL on some powerpc platforms (?!) */
#include <sys/prctl.h>
+#include <unistd.h>
#include "linuxthreads.h"
/* Include other thread listers here that define THREADS macro

View File

@@ -0,0 +1,16 @@
pkgs: {
# old lts
percona-server_8_0 = pkgs.callPackage ./8_0.nix {
inherit (pkgs.darwin) developer_cmds DarwinTools;
boost = pkgs.boost177; # Configure checks for specific version.
icu = pkgs.icu69;
# newer versions cause linking failures against `libabsl_spinlock_wait`
protobuf = pkgs.protobuf_21;
};
percona-server_8_4 = pkgs.callPackage ./8_4.nix {
inherit (pkgs.darwin) developer_cmds DarwinTools;
# newer versions cause linking failures against `libabsl_spinlock_wait`
protobuf = pkgs.protobuf_21;
};
percona-server = pkgs.percona-server_8_4;
}

View File

@@ -0,0 +1,207 @@
diff --git a/include/my_char_traits.h b/include/my_char_traits.h
new file mode 100644
index 00000000000..6336bc039c8
--- /dev/null
+++ b/include/my_char_traits.h
@@ -0,0 +1,65 @@
+/* Copyright (c) 2024, Oracle and/or its affiliates.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is designed to work with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have either included with
+ the program or referenced in the documentation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License, version 2.0, for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#ifndef MY_CHAR_TRAITS_INCLUDED
+#define MY_CHAR_TRAITS_INCLUDED
+
+#include <cstring>
+
+template <class CharT>
+struct my_char_traits;
+
+/*
+ This is a standards-compliant, drop-in replacement for
+ std::char_traits<unsigned char>
+ We need this because clang libc++ is removing support for it in clang 19.
+ It is not a complete implementation. Rather we implement just enough to
+ compile any usage of char_traits<uchar> we have in our codebase.
+ */
+template <>
+struct my_char_traits<unsigned char> {
+ using char_type = unsigned char;
+ using int_type = unsigned int;
+
+ static void assign(char_type &c1, const char_type &c2) { c1 = c2; }
+
+ static char_type *assign(char_type *s, std::size_t n, char_type a) {
+ return static_cast<char_type *>(memset(s, a, n));
+ }
+
+ static int compare(const char_type *s1, const char_type *s2, std::size_t n) {
+ return memcmp(s1, s2, n);
+ }
+
+ static char_type *move(char_type *s1, const char_type *s2, std::size_t n) {
+ if (n == 0) return s1;
+ return static_cast<char_type *>(memmove(s1, s2, n));
+ }
+
+ static char_type *copy(char_type *s1, const char_type *s2, std::size_t n) {
+ if (n == 0) return s1;
+ return static_cast<char_type *>(memcpy(s1, s2, n));
+ }
+};
+
+#endif // MY_CHAR_TRAITS_INCLUDED
diff --git a/sql/mdl_context_backup.h b/sql/mdl_context_backup.h
index 89e7e23df34..cf9c307ec2d 100644
--- a/sql/mdl_context_backup.h
+++ b/sql/mdl_context_backup.h
@@ -28,6 +28,7 @@
#include <map>
#include <memory>
+#include "my_char_traits.h"
#include "sql/malloc_allocator.h"
#include "sql/mdl.h"
@@ -47,7 +48,8 @@ class MDL_context_backup_manager {
/**
Key for uniquely identifying MDL_context in the MDL_context_backup map.
*/
- typedef std::basic_string<uchar> MDL_context_backup_key;
+ using MDL_context_backup_key =
+ std::basic_string<uchar, my_char_traits<uchar>>;
class MDL_context_backup;
diff --git a/sql/range_optimizer/index_range_scan_plan.cc b/sql/range_optimizer/index_range_scan_plan.cc
index 74fbb100397..8ed1f50da33 100644
--- a/sql/range_optimizer/index_range_scan_plan.cc
+++ b/sql/range_optimizer/index_range_scan_plan.cc
@@ -54,6 +54,8 @@
#include "sql/thr_malloc.h"
#include "sql_string.h"
+#include "my_char_traits.h"
+
using opt_range::null_element;
using std::max;
using std::min;
@@ -1025,8 +1027,8 @@ static bool null_part_in_key(KEY_PART *key_part, const uchar *key,
// TODO(sgunders): This becomes a bit simpler with C++20's string_view
// constructors.
-static inline std::basic_string_view<uchar> make_string_view(const uchar *start,
- const uchar *end) {
+static inline std::basic_string_view<uchar, my_char_traits<uchar>>
+make_string_view(const uchar *start, const uchar *end) {
return {start, static_cast<size_t>(end - start)};
}
diff --git a/sql/stream_cipher.h b/sql/stream_cipher.h
index 606d40645c6..358fbb41959 100644
--- a/sql/stream_cipher.h
+++ b/sql/stream_cipher.h
@@ -28,6 +28,8 @@
#include <memory>
#include <string>
+#include "my_char_traits.h"
+
/**
@file stream_cipher.h
@@ -35,7 +37,8 @@
binary log files.
*/
-typedef std::basic_string<unsigned char> Key_string;
+using Key_string =
+ std::basic_string<unsigned char, my_char_traits<unsigned char>>;
/**
@class Stream_cipher
diff --git a/unittest/gunit/binlogevents/transaction_compression-t.cc b/unittest/gunit/binlogevents/transaction_compression-t.cc
index ba13f979aa3..01af0e3a360 100644
--- a/unittest/gunit/binlogevents/transaction_compression-t.cc
+++ b/unittest/gunit/binlogevents/transaction_compression-t.cc
@@ -23,6 +23,7 @@
*/
#include <array>
+#include <string>
#include <gtest/gtest.h>
#include "libbinlogevents/include/binary_log.h"
@@ -51,14 +52,13 @@ class TransactionPayloadCompressionTest : public ::testing::Test {
using Managed_buffer_t = Decompressor_t::Managed_buffer_t;
using Size_t = Decompressor_t::Size_t;
using Char_t = Decompressor_t::Char_t;
- using String_t = std::basic_string<Char_t>;
using Decompress_status_t =
binary_log::transaction::compression::Decompress_status;
using Compress_status_t =
binary_log::transaction::compression::Compress_status;
- static String_t constant_data(Size_t size) {
- return String_t(size, (Char_t)'a');
+ static std::string constant_data(Size_t size) {
+ return std::string(size, (Char_t)'a');
}
protected:
@@ -69,7 +69,7 @@ class TransactionPayloadCompressionTest : public ::testing::Test {
void TearDown() override {}
static void compression_idempotency_test(Compressor_t &c, Decompressor_t &d,
- String_t data) {
+ const std::string &data) {
auto debug_string = concat(
binary_log::transaction::compression::type_to_string(c.get_type_code()),
" ", data.size());
@@ -104,8 +104,8 @@ class TransactionPayloadCompressionTest : public ::testing::Test {
// Check decompressed data
ASSERT_EQ(managed_buffer.read_part().size(), data.size()) << debug_string;
- ASSERT_EQ(data, String_t(managed_buffer.read_part().begin(),
- managed_buffer.read_part().end()))
+ ASSERT_EQ(data, std::string(managed_buffer.read_part().begin(),
+ managed_buffer.read_part().end()))
<< debug_string;
// Check that we reached EOF
@@ -118,7 +118,7 @@ TEST_F(TransactionPayloadCompressionTest, CompressDecompressZstdTest) {
for (auto size : buffer_sizes) {
binary_log::transaction::compression::Zstd_dec d;
binary_log::transaction::compression::Zstd_comp c;
- String_t data{TransactionPayloadCompressionTest::constant_data(size)};
+ std::string data{TransactionPayloadCompressionTest::constant_data(size)};
TransactionPayloadCompressionTest::compression_idempotency_test(c, d, data);
c.set_compression_level(22);
TransactionPayloadCompressionTest::compression_idempotency_test(c, d, data);
@@ -129,7 +129,7 @@ TEST_F(TransactionPayloadCompressionTest, CompressDecompressNoneTest) {
for (auto size : buffer_sizes) {
binary_log::transaction::compression::None_dec d;
binary_log::transaction::compression::None_comp c;
- String_t data{TransactionPayloadCompressionTest::constant_data(size)};
+ std::string data{TransactionPayloadCompressionTest::constant_data(size)};
TransactionPayloadCompressionTest::compression_idempotency_test(c, d, data);
}
}

View File

@@ -0,0 +1,24 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 727d66011f9..acae1aada57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1338,19 +1338,6 @@ IF(UNIX AND MY_COMPILER_IS_GNU_OR_CLANG
ENDIF()
ENDIF()
-# For aarch64 some sub-architectures support LSE atomics and some don't. Thus,
-# compiling for the common denominator (-march=armv8-a) means LSE is not used.
-# The -moutline-atomics switch enables run-time detection of LSE support.
-# There are compilers (gcc 9.3.1 for example) which support this switch, but
-# do not enable it by default, even though it seems to help. So, we force it.
-IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
- MY_CHECK_CXX_COMPILER_FLAG( "-moutline-atomics" HAVE_OUTLINE_ATOMICS)
- IF(HAVE_OUTLINE_ATOMICS)
- STRING_APPEND(CMAKE_C_FLAGS " -moutline-atomics")
- STRING_APPEND(CMAKE_CXX_FLAGS " -moutline-atomics")
- ENDIF()
-ENDIF()
-
IF(LINUX)
OPTION(LINK_RANDOMIZE "Randomize the order of all symbols in the binary" OFF)
SET(LINK_RANDOMIZE_SEED "mysql"

View File

@@ -0,0 +1,15 @@
import ./generic.nix {
version = "13.22";
rev = "refs/tags/REL_13_22";
hash = "sha256-6zHA+WU1FroUbGJcTAeEbPKBVQY7SKpT5+Kxe9ZhtoM=";
muslPatches = {
disable-test-collate-icu-utf8 = {
url = "https://git.alpinelinux.org/aports/plain/main/postgresql13/disable-test-collate.icu.utf8.patch?id=69faa146ec9fff3b981511068f17f9e629d4688b";
hash = "sha256-jS/qxezaiaKhkWeMCXwpz1SDJwUWn9tzN0uKaZ3Ph2Y=";
};
dont-use-locale-a = {
url = "https://git.alpinelinux.org/aports/plain/main/postgresql13/dont-use-locale-a-on-musl.patch?id=69faa146ec9fff3b981511068f17f9e629d4688b";
hash = "sha256-fk+y/SvyA4Tt8OIvDl7rje5dLs3Zw+Ln1oddyYzerOo=";
};
};
}

View File

@@ -0,0 +1,15 @@
import ./generic.nix {
version = "14.19";
rev = "refs/tags/REL_14_19";
hash = "sha256-z8MEeLae4W4YqGBNcPtKnUENxnixugnv5Q6r+LW4uu8=";
muslPatches = {
disable-test-collate-icu-utf8 = {
url = "https://git.alpinelinux.org/aports/plain/main/postgresql14/disable-test-collate.icu.utf8.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7";
hash = "sha256-jXe23AxnFjEl+TZQm4R7rStk2Leo08ctxMNmu1xr5zM=";
};
dont-use-locale-a = {
url = "https://git.alpinelinux.org/aports/plain/main/postgresql14/dont-use-locale-a-on-musl.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7";
hash = "sha256-fk+y/SvyA4Tt8OIvDl7rje5dLs3Zw+Ln1oddyYzerOo=";
};
};
}

View File

@@ -0,0 +1,11 @@
import ./generic.nix {
version = "15.14";
rev = "refs/tags/REL_15_14";
hash = "sha256-KzN0gsEY6wFLqNYMxbTj2NH+4IWO0pplWP4XO/fqRLM=";
muslPatches = {
dont-use-locale-a = {
url = "https://git.alpinelinux.org/aports/plain/main/postgresql15/dont-use-locale-a-on-musl.patch?id=f424e934e6d076c4ae065ce45e734aa283eecb9c";
hash = "sha256-fk+y/SvyA4Tt8OIvDl7rje5dLs3Zw+Ln1oddyYzerOo=";
};
};
}

View File

@@ -0,0 +1,11 @@
import ./generic.nix {
version = "16.10";
rev = "refs/tags/REL_16_10";
hash = "sha256-1zG8+G/lNA1xm0hxLVEilIaI+25d4gfpqA2aCb4+taY=";
muslPatches = {
dont-use-locale-a = {
url = "https://git.alpinelinux.org/aports/plain/main/postgresql16/dont-use-locale-a-on-musl.patch?id=08a24be262339fd093e641860680944c3590238e";
hash = "sha256-fk+y/SvyA4Tt8OIvDl7rje5dLs3Zw+Ln1oddyYzerOo=";
};
};
}

View File

@@ -0,0 +1,11 @@
import ./generic.nix {
version = "17.6";
rev = "refs/tags/REL_17_6";
hash = "sha256-/7C+bjmiJ0/CvoAc8vzTC50vP7OsrM6o0w+lmmHvKvU=";
muslPatches = {
dont-use-locale-a = {
url = "https://git.alpinelinux.org/aports/plain/main/postgresql17/dont-use-locale-a-on-musl.patch?id=d69ead2c87230118ae7f72cef7d761e761e1f37e";
hash = "sha256-6zjz3OpMx4qTETdezwZxSJPPdOvhCNu9nXvAaU9SwH8=";
};
};
}

View File

@@ -0,0 +1,11 @@
import ./generic.nix {
version = "18.0";
rev = "refs/tags/REL_18_0";
hash = "sha256-xA6gbJe4tIV9bYRFrdI4Rfy20ZwTkvyyjt7ZxvCFEec=";
muslPatches = {
dont-use-locale-a = {
url = "https://git.alpinelinux.org/aports/plain/main/postgresql17/dont-use-locale-a-on-musl.patch?id=d69ead2c87230118ae7f72cef7d761e761e1f37e";
hash = "sha256-6zjz3OpMx4qTETdezwZxSJPPdOvhCNu9nXvAaU9SwH8=";
};
};
}

View File

@@ -0,0 +1,41 @@
self:
let
# Before removing an EOL major version, make sure to check the versioning policy in:
# <nixpkgs>/nixos/modules/services/databases/postgresql.md
#
# Before removing, make sure to update it to the last minor version - and if only in
# an immediately preceding commit. This allows people relying on that old major version
# for a bit longer to still update up to this commit to at least get the latest minor
# version. In other words: Do not remove the second-to-last minor version from nixpkgs,
# yet. Update first.
versions = {
postgresql_13 = ./13.nix;
postgresql_14 = ./14.nix;
postgresql_15 = ./15.nix;
postgresql_16 = ./16.nix;
postgresql_17 = ./17.nix;
postgresql_18 = ./18.nix;
};
mkAttributes =
jitSupport:
self.lib.mapAttrs' (
version: path:
let
attrName = if jitSupport then "${version}_jit" else version;
postgresql = import path { inherit self; };
attrValue = if jitSupport then postgresql.withJIT else postgresql.withoutJIT;
in
self.lib.nameValuePair attrName attrValue
) versions;
libpq = self.callPackage ./libpq.nix { };
in
{
# variations without and with JIT
postgresqlVersions = mkAttributes false;
postgresqlJitVersions = mkAttributes true;
inherit libpq;
}

View File

@@ -0,0 +1,23 @@
self: super:
let
inherit (self) lib config;
in
(lib.packagesFromDirectoryRecursive {
inherit (super) callPackage;
directory = ./ext;
})
// {
timescaledb-apache = super.callPackage ./ext/timescaledb.nix { enableUnfree = false; };
}
// lib.optionalAttrs (!self.perlSupport) {
plperl = throw "PostgreSQL extension `plperl` is not available, because `postgresql` was built without Perl support. Override with `perlSupport = true` to enable the extension.";
}
// lib.optionalAttrs (!self.pythonSupport) {
plpython3 = throw "PostgreSQL extension `plpython3` is not available, because `postgresql` was built without Python support. Override with `pythonSupport = true` to enable the extension.";
}
// lib.optionalAttrs (!self.tclSupport) {
pltcl = throw "PostgreSQL extension `pltcl` is not available, because `postgresql` was built without Tcl support. Override with `tclSupport = true` to enable the extension.";
}
// lib.optionalAttrs config.allowAliases {
pg_embedding = throw "PostgreSQL extension `pg_embedding` has been removed since the project has been abandoned. Upstream's recommendation is to use pgvector instead (https://neon.tech/docs/extensions/pg_embedding#migrate-from-pg_embedding-to-pgvector)";
}

View File

@@ -0,0 +1,84 @@
{
bison,
fetchFromGitHub,
flex,
lib,
perl,
postgresql,
postgresqlBuildExtension,
stdenv,
}:
let
hashes = {
# Issue tracking PostgreSQL 17 support: https://github.com/apache/age/issues/2111
# "17" = "";
"16" = "sha256-sXh/vmGyYj00ALfFVdeql2DZ6nCJQDNKyNgzlOZnPAw=";
"15" = "sha256-webZWgWZGnSoXwTpk816tjbtHV1UIlXkogpBDAEL4gM=";
"14" = "sha256-jZXhcYBubpjIJ8M5JHXKV5f6VK/2BkypH3P7nLxZz3E=";
"13" = "sha256-HR6nnWt/V2a0rD5eHHUsFIZ1y7lmvLz36URt9pPJnCw=";
};
in
postgresqlBuildExtension (finalAttrs: {
pname = "age";
version = "1.5.0-rc0";
src = fetchFromGitHub {
owner = "apache";
repo = "age";
tag = "PG${lib.versions.major postgresql.version}/v${
builtins.replaceStrings [ "." ] [ "_" ] finalAttrs.version
}";
hash =
hashes.${lib.versions.major postgresql.version}
or (throw "Source for Age is not available for ${postgresql.version}");
};
makeFlags = [
"BISON=${bison}/bin/bison"
"FLEX=${flex}/bin/flex"
"PERL=${perl}/bin/perl"
];
enableUpdateScript = false;
passthru.tests = stdenv.mkDerivation {
inherit (finalAttrs) version src;
pname = "age-regression";
dontConfigure = true;
buildPhase =
let
postgresqlAge = postgresql.withPackages (_: [ finalAttrs.finalPackage ]);
in
''
# The regression tests need to be run in the order specified in the Makefile.
echo -e "include Makefile\nfiles:\n\t@echo \$(REGRESS)" > Makefile.regress
REGRESS_TESTS=$(make -f Makefile.regress files)
${lib.getDev postgresql}/lib/pgxs/src/test/regress/pg_regress \
--inputdir=./ \
--bindir='${postgresqlAge}/bin' \
--encoding=UTF-8 \
--load-extension=age \
--inputdir=./regress --outputdir=./regress --temp-instance=./regress/instance \
--port=61958 --dbname=contrib_regression \
$REGRESS_TESTS
'';
installPhase = ''
touch $out
'';
};
meta = {
broken = !builtins.elem (lib.versions.major postgresql.version) (builtins.attrNames hashes);
description = "Graph database extension for PostgreSQL";
homepage = "https://age.apache.org/";
changelog = "https://github.com/apache/age/raw/v${finalAttrs.src.rev}/RELEASE";
maintainers = [ ];
platforms = postgresql.meta.platforms;
license = lib.licenses.asl20;
};
})

View File

@@ -0,0 +1,29 @@
{
cargo-pgrx_0_16_0,
jitSupport,
lib,
nixosTests,
pg-dump-anon,
postgresql,
buildPgrxExtension,
runtimeShell,
}:
buildPgrxExtension {
pname = "postgresql_anonymizer";
inherit (pg-dump-anon) version src;
inherit postgresql;
cargo-pgrx = cargo-pgrx_0_16_0;
cargoHash = "sha256-Z1uH6Z2qLV1Axr8dXqPznuEZcacAZnv11tb3lWBh1yw=";
# Tries to copy extension into postgresql's store path.
doCheck = false;
passthru.tests = nixosTests.postgresql.anonymizer.passthru.override postgresql;
meta = lib.getAttrs [ "homepage" "teams" "license" ] pg-dump-anon.meta // {
description = "Extension to mask or replace personally identifiable information (PII) or commercially sensitive data from a PostgreSQL database";
};
}

View File

@@ -0,0 +1,71 @@
{
boost186,
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
let
version = "1.7.0";
main_src = fetchFromGitHub {
name = "datasketches-postgresql";
owner = "apache";
repo = "datasketches-postgresql";
tag = version;
hash = "sha256-W41uAs3W4V7c9O/wBw3rut65bcmY8EdQS1/tPszMGqA=";
};
cpp_src = fetchFromGitHub {
name = "datasketches-cpp";
owner = "apache";
repo = "datasketches-cpp";
tag = "5.0.2";
hash = "sha256-yGk1OckYipAgLTQK6w6p6EdHMxBIQSjPV/MMND3cDks=";
};
in
postgresqlBuildExtension (finalAttrs: {
pname = "apache_datasketches";
inherit version;
srcs = [
main_src
cpp_src
];
sourceRoot = main_src.name;
# fails to build with boost 1.87
buildInputs = [ boost186 ];
patchPhase = ''
runHook prePatch
cp -r ../${cpp_src.name} .
runHook postPatch
'';
enableUpdateScript = false;
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = ''
CREATE EXTENSION datasketches;
SELECT hll_sketch_to_string(hll_sketch_build(1));
'';
};
meta = {
description = "PostgreSQL extension providing approximate algorithms for distinct item counts, quantile estimation and frequent items detection";
longDescription = ''
apache_datasketches is an extension to support approximate algorithms on PostgreSQL. The implementation
is based on the Apache Datasketches CPP library, and provides support for HyperLogLog,
Compressed Probabilistic Counting, KLL, Frequent strings, and Theta sketches.
'';
homepage = "https://datasketches.apache.org/";
platforms = postgresql.meta.platforms;
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ mmusnjak ];
};
})

View File

@@ -0,0 +1,84 @@
{
curl,
fetchFromGitHub,
fetchpatch,
lib,
lz4,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "citus";
version = "13.0.3";
src = fetchFromGitHub {
owner = "citusdata";
repo = "citus";
tag = "v${finalAttrs.version}";
hash = "sha256-tQ2YkMUeziz+dhfXtfuK0x8PWH3vfoJiVbE+YvQ/Gzc=";
};
patches = [
# Even though this commit is on main since Sep 2023, it hasn't made its way to the release-13.0 branch, yet.
# https://github.com/citusdata/citus/pull/7221
# Fixes build for PG 16 + 17 on darwin
(fetchpatch {
url = "https://github.com/citusdata/citus/commit/0f28a69f12418d211ffba5f7ddd222fd0c47daeb.patch";
hash = "sha256-8JAM+PUswzbdlAZUpRApgO0eBsMbUHFdFGsdATsG88I=";
})
];
buildInputs = [
curl
lz4
];
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
postgresqlExtraSettings = ''
shared_preload_libraries=citus
'';
sql = ''
CREATE EXTENSION citus;
CREATE TABLE examples (
id bigserial,
shard_key int,
PRIMARY KEY (id, shard_key)
);
SELECT create_distributed_table('examples', 'shard_key');
INSERT INTO examples (shard_key) SELECT shard % 10 FROM generate_series(1,1000) shard;
'';
asserts = [
{
query = "SELECT count(*) FROM examples";
expected = "1000";
description = "Distributed table can be queried successfully.";
}
];
};
meta = {
# "Our soft policy for Postgres version compatibility is to support Citus'
# latest release with Postgres' 3 latest releases."
# https://www.citusdata.com/updates/v12-0/#deprecated_features
broken =
lib.versionOlder postgresql.version "15"
||
# PostgreSQL 18 support issue upstream: https://github.com/citusdata/citus/issues/7978
# Check after next package update.
lib.warnIf (finalAttrs.version != "13.0.3") "Is postgresql18Packages.citus still broken?" (
lib.versionAtLeast postgresql.version "18"
);
description = "Distributed PostgreSQL as an extension";
homepage = "https://www.citusdata.com/";
changelog = "https://github.com/citusdata/citus/blob/${finalAttrs.src.rev}/CHANGELOG.md";
license = lib.licenses.agpl3Only;
maintainers = [ ];
inherit (postgresql.meta) platforms;
};
})

View File

@@ -0,0 +1,31 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
protobufc,
}:
postgresqlBuildExtension {
pname = "cstore_fdw";
version = "1.7.0-unstable-2021-03-08";
buildInputs = [ protobufc ];
nativeBuildInputs = [ protobufc ];
src = fetchFromGitHub {
owner = "citusdata";
repo = "cstore_fdw";
rev = "90e22b62fbee6852529104fdd463f532cf7a3311";
hash = "sha256-02wcCqs8A5ZOZX080fgcNJTQrYQctnlwnA8+YPaRTZc=";
};
meta = {
broken = lib.versionAtLeast postgresql.version "14";
description = "Columnar storage for PostgreSQL";
homepage = "https://github.com/citusdata/cstore_fdw";
maintainers = with lib.maintainers; [ thoughtpolice ];
platforms = postgresql.meta.platforms;
license = lib.licenses.asl20;
};
}

View File

@@ -0,0 +1,59 @@
{
cmake,
fetchFromGitHub,
h3_4,
lib,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
stdenv,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "h3-pg";
version = "4.2.3";
src = fetchFromGitHub {
owner = "zachasme";
repo = "h3-pg";
tag = "v${finalAttrs.version}";
hash = "sha256-kTh0Y0C2pNB5Ul1rp77ets/5VeU1zw1WasGHkOaDMh8=";
};
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace-fail "add_subdirectory(cmake/h3)" "include_directories(${lib.getDev h3_4}/include/h3)"
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace cmake/AddPostgreSQLExtension.cmake \
--replace-fail "INTERPROCEDURAL_OPTIMIZATION TRUE" ""
'';
nativeBuildInputs = [
cmake
];
buildInputs = [
h3_4
];
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
withPackages = [ "postgis" ];
sql = ''
CREATE EXTENSION h3;
CREATE EXTENSION h3_postgis CASCADE;
SELECT h3_lat_lng_to_cell(POINT('37.3615593,-122.0553238'), 5);
SELECT ST_NPoints(h3_cell_to_boundary_geometry('8a63a9a99047fff'));
'';
};
meta = {
description = "PostgreSQL bindings for H3, a hierarchical hexagonal geospatial indexing system";
homepage = "https://github.com/zachasme/h3-pg";
license = lib.licenses.asl20;
maintainers = [ ];
inherit (postgresql.meta) platforms;
};
})

View File

@@ -0,0 +1,34 @@
{
fetchFromGitHub,
gitUpdater,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "hypopg";
version = "1.4.2";
src = fetchFromGitHub {
owner = "HypoPG";
repo = "hypopg";
tag = finalAttrs.version;
hash = "sha256-J1ltvNHB2v2I9IbYjM8w2mhXvBX31NkMasCL0O7bV8w=";
};
passthru = {
updateScript = gitUpdater {
ignoredVersions = "beta";
};
};
meta = {
description = "Hypothetical Indexes for PostgreSQL";
homepage = "https://hypopg.readthedocs.io";
changelog = "https://github.com/HypoPG/hypopg/releases/tag/${finalAttrs.version}";
license = lib.licenses.postgresql;
platforms = postgresql.meta.platforms;
maintainers = with lib.maintainers; [ bbigras ];
};
})

View File

@@ -0,0 +1,34 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "ip4r";
version = "2.4.2";
src = fetchFromGitHub {
owner = "RhodiumToad";
repo = "ip4r";
tag = "${finalAttrs.version}";
hash = "sha256-3chAD4f4A6VlXVSI0kfC/ANcnFy4vBp4FZpT6QRAueQ=";
};
passthru.tests = {
extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = "CREATE EXTENSION ip4r;";
};
};
meta = {
description = "IPv4/v6 and IPv4/v6 range index type for PostgreSQL";
homepage = "https://github.com/RhodiumToad/ip4r";
license = lib.licenses.postgresql;
maintainers = with lib.maintainers; [ lukegb ];
inherit (postgresql.meta) platforms;
};
})

View File

@@ -0,0 +1,26 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension {
pname = "jsonb_deep_sum";
version = "0-unstable-2021-12-24";
src = fetchFromGitHub {
owner = "furstenheim";
repo = "jsonb_deep_sum";
rev = "d9c69aa6b7da860e5522a9426467e67cb787980c";
hash = "sha256-W1wNILAwTAjFPezq+grdRMA59KEnMZDz69n9xQUqdc0=";
};
meta = {
description = "PostgreSQL extension to easily add jsonb numeric";
homepage = "https://github.com/furstenheim/jsonb_deep_sum";
maintainers = with lib.maintainers; [ _1000101 ];
platforms = postgresql.meta.platforms;
license = lib.licenses.mit;
};
}

View File

@@ -0,0 +1,66 @@
{
cmake,
fetchFromGitHub,
lib,
openssl,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "postgresql-lantern";
version = "0.5.0";
src = fetchFromGitHub {
owner = "lanterndata";
repo = "lantern";
tag = "v${finalAttrs.version}";
hash = "sha256-IsDD/um5pVvbzin8onf45DQVszl+Id/pJSQ2iijgHmg=";
fetchSubmodules = true;
};
postPatch = ''
patchShebangs --build lantern_hnsw/scripts/link_llvm_objects.sh
'';
nativeBuildInputs = [
cmake
];
buildInputs = [
openssl
];
cmakeFlags = [
"-DBUILD_FOR_DISTRIBUTING=ON"
"-S ../lantern_hnsw"
];
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = ''
CREATE EXTENSION lantern;
CREATE TABLE small_world (id integer, vector real[3]);
INSERT INTO small_world (id, vector) VALUES (0, '{0,0,0}'), (1, '{0,0,1}');
CREATE INDEX ON small_world USING lantern_hnsw (vector dist_l2sq_ops)
WITH (M=2, ef_construction=10, ef=4, dim=3);
'';
};
meta = {
# PostgreSQL 18 support issue upstream: https://github.com/lanterndata/lantern/issues/375
# Check after next package update.
broken = lib.warnIf (
finalAttrs.version != "0.5.0"
) "Is postgresql18Packages.lantern still broken?" (lib.versionAtLeast postgresql.version "18");
description = "PostgreSQL vector database extension for building AI applications";
homepage = "https://lantern.dev/";
changelog = "https://github.com/lanterndata/lantern/blob/${finalAttrs.src.rev}/CHANGELOG.md";
license = lib.licenses.agpl3Only;
maintainers = [ ];
platforms = postgresql.meta.platforms;
};
})

View File

@@ -0,0 +1,100 @@
{
brotli,
clang_18,
cmake,
fetchFromGitHub,
flex,
lib,
netcat,
perl,
pkg-config,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
python3,
stdenv,
unstableGitUpdater,
}:
let
pgWithExtensions = postgresql.withPackages (ps: [ ps.plpython3 ]);
in
postgresqlBuildExtension (finalAttrs: {
pname = "omnigres";
version = "0-unstable-2025-09-26";
src = fetchFromGitHub {
owner = "omnigres";
repo = "omnigres";
rev = "247383198a95d045df0d97ece5a81adffb5c08e8";
hash = "sha256-RrdtUtrs0Mh1VyMbF89qJhr2fnCVcQy2l1/85/mJ/4Y=";
};
# This matches postInstall of PostgreSQL's generic.nix, which does this for the PGXS Makefile.
# Since omnigres uses a CMake file, which tries to replicate the things that PGXS does, we need
# to apply the same fix for darwin.
# The reason we need to do this is, because PG_BINARY will point at the postgres wrapper of
# postgresql.withPackages, which does not contain the same symbols as the original file, ofc.
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace "cmake/PostgreSQLExtension.cmake" \
--replace-fail '-bundle_loader ''${PG_BINARY}' "-bundle_loader ${postgresql}/bin/postgres"
'';
strictDeps = true;
nativeBuildInputs = [
clang_18
cmake
flex
netcat
pkg-config
perl
python3
];
buildInputs = postgresql.buildInputs ++ [
brotli
];
cmakeFlags = [
"-DOPENSSL_CONFIGURED=1"
"-DPG_CONFIG=${pgWithExtensions.pg_config}/bin/pg_config"
"-DPostgreSQL_TARGET_EXTENSION_DIR=${placeholder "out"}/share/postgresql/extension/"
"-DPostgreSQL_TARGET_PACKAGE_LIBRARY_DIR=${placeholder "out"}/lib/"
];
enableParallelBuilding = true;
doCheck = false;
preInstall = ''
patchShebangs script_omni*
mkdir -p $out/lib/
mkdir -p $out/share/postgresql/extension/
'';
# https://github.com/omnigres/omnigres?tab=readme-ov-file#building--using-extensions
installTargets = [ "install_extensions" ];
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = ''
-- https://docs.omnigres.org/omni_id/identity_type/#usage
CREATE EXTENSION omni_id;
SELECT identity_type('user_id');
'';
};
passthru.updateScript = unstableGitUpdater {
hardcodeZeroVersion = true;
};
meta = {
description = "Postgres as a Business Operating System";
homepage = "https://docs.omnigres.org";
maintainers = with lib.maintainers; [ mtrsk ];
platforms = postgresql.meta.platforms;
license = lib.licenses.asl20;
broken = lib.versionOlder postgresql.version "14";
};
})

View File

@@ -0,0 +1,26 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "periods";
version = "1.2.3";
src = fetchFromGitHub {
owner = "xocolatl";
repo = "periods";
tag = "v${finalAttrs.version}";
hash = "sha256-97v6+WNDcYb/KivlE/JBlRIZ3gYHj68AlK0fylp1cPo=";
};
meta = {
description = "PostgreSQL extension implementing SQL standard functionality for PERIODs and SYSTEM VERSIONING";
homepage = "https://github.com/xocolatl/periods";
maintainers = with lib.maintainers; [ ivan ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,47 @@
{
cmake,
fetchFromGitHub,
glib,
gvm-libs,
icu,
lib,
libical,
pcre2,
pkg-config,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg-gvm";
version = "22.6.11";
src = fetchFromGitHub {
owner = "greenbone";
repo = "pg-gvm";
tag = "v${finalAttrs.version}";
hash = "sha256-jkpZg1LMWuH5R4I/kTO3cofL3uNt11yXSgfFppSNC+o=";
};
nativeBuildInputs = [
cmake
pkg-config
];
buildInputs = [
glib
gvm-libs
icu
libical
pcre2
];
meta = {
description = "Greenbone Library for helper functions in PostgreSQL";
homepage = "https://github.com/greenbone/pg-gvm";
changelog = "https://github.com/greenbone/pg-gvm/releases/tag/v${finalAttrs.version}";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ tochiaha ];
platforms = postgresql.meta.platforms;
};
})

View File

@@ -0,0 +1,35 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg-semver";
version = "0.40.0";
src = fetchFromGitHub {
owner = "theory";
repo = "pg-semver";
tag = "v${finalAttrs.version}";
hash = "sha256-9f+QuGupjTUK3cQk7DFDrL7MOIwDE9SAUyVZ9RfrdDM=";
};
passthru.tests = {
extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = "CREATE EXTENSION semver;";
};
};
meta = {
description = "Semantic version data type for PostgreSQL";
homepage = "https://github.com/theory/pg-semver";
changelog = "https://github.com/theory/pg-semver/blob/main/Changes";
maintainers = with lib.maintainers; [ grgi ];
inherit (postgresql.meta) platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,35 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_auto_failover";
version = "2.2";
src = fetchFromGitHub {
owner = "citusdata";
repo = "pg_auto_failover";
tag = "v${finalAttrs.version}";
hash = "sha256-lsnVry+5n08kLOun8u0B7XFvI5ijTKJtFJ84fixMHe4=";
};
buildInputs = postgresql.buildInputs;
meta = {
# PostgreSQL 18 support issue upstream: https://github.com/hapostgres/pg_auto_failover/issues/1083
# Check after next package update.
broken =
lib.warnIf (finalAttrs.version != "2.2") "Is postgresql18Packages.pg_auto_failover still broken?"
(lib.versionAtLeast postgresql.version "18");
description = "PostgreSQL extension and service for automated failover and high-availability";
mainProgram = "pg_autoctl";
homepage = "https://github.com/citusdata/pg_auto_failover";
changelog = "https://github.com/citusdata/pg_auto_failover/blob/v${finalAttrs.version}/CHANGELOG.md";
maintainers = [ ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,28 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_bigm";
version = "1.2-20250903";
src = fetchFromGitHub {
owner = "pgbigm";
repo = "pg_bigm";
tag = "v${finalAttrs.version}";
hash = "sha256-8V+sGebagYxXW1o2k2cNlGG4cFOObdRAvqCXKyR95hI=";
};
makeFlags = [ "USE_PGXS=1" ];
meta = {
description = "Text similarity measurement and index searching based on bigrams";
homepage = "https://pgbigm.osdn.jp/";
maintainers = [ ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,50 @@
{
fetchFromGitHub,
file,
lib,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_byteamagic";
version = "0.2.4";
src = fetchFromGitHub {
owner = "nmandery";
repo = "pg_byteamagic";
tag = "v${finalAttrs.version}";
hash = "sha256-0RRElMMVUm3cXLI7G3SkIVr8yA/Rk3gBsgXG+EFU3CI=";
};
buildInputs = [
file
];
passthru.tests = {
extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = ''
CREATE EXTENSION byteamagic;
SELECT byteamagic_mime('test');
'';
asserts = [
{
query = "SELECT byteamagic_mime('test')";
expected = "'text/plain'";
description = "`byteamagic_mime(...) should return proper mimetype.";
}
];
};
};
meta = {
description = "PostgreSQL extension to determinate the filetypes of bytea BLOBs";
homepage = "https://github.com/nmandery/pg_byteamagic";
changelog = "https://raw.githubusercontent.com/nmandery/pg_byteamagic/refs/tags/v${finalAttrs.version}/Changes";
license = lib.licenses.bsd2WithViews;
teams = [ lib.teams.apm ];
platforms = postgresql.meta.platforms;
};
})

View File

@@ -0,0 +1,27 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_cron";
version = "1.6.7";
src = fetchFromGitHub {
owner = "citusdata";
repo = "pg_cron";
tag = "v${finalAttrs.version}";
hash = "sha256-oQjaQeIEMbg5pipY8tT4I7bNdyDOwcr/ZJikqgcEZOs=";
};
meta = {
description = "Run Cron jobs through PostgreSQL";
homepage = "https://github.com/citusdata/pg_cron";
changelog = "https://github.com/citusdata/pg_cron/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [ thoughtpolice ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,27 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_csv";
version = "1.0.1";
src = fetchFromGitHub {
owner = "PostgREST";
repo = "pg_csv";
tag = "v${finalAttrs.version}";
hash = "sha256-hRTNFlNUmc3mjDf0wgn4CGmHoYPQ+2yfZApzooLwgW4=";
};
meta = {
description = "Flexible CSV processing for Postgres";
homepage = "https://github.com/PostgREST/pg_csv";
changelog = "https://github.com/PostgREST/pg_csv/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [ steve-chavez ];
platforms = postgresql.meta.platforms;
license = lib.licenses.mit;
};
})

View File

@@ -0,0 +1,28 @@
{
fetchFromGitLab,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_ed25519";
version = "0.2";
src = fetchFromGitLab {
owner = "dwagin";
repo = "pg_ed25519";
tag = finalAttrs.version;
hash = "sha256-IOL3ogbPCMNmwDwpeaCZSoaFLJRX0Oah+ysgyUfHg5s=";
};
meta = {
description = "PostgreSQL extension for signing and verifying ed25519 signatures";
homepage = "https://gitlab.com/dwagin/pg_ed25519";
maintainers = with lib.maintainers; [ renzo ];
platforms = postgresql.meta.platforms;
license = lib.licenses.mit;
# Broken with no upstream fix available.
broken = lib.versionAtLeast postgresql.version "16";
};
})

View File

@@ -0,0 +1,50 @@
{
buildPgrxExtension,
cargo-pgrx_0_16_0,
fetchFromGitHub,
lib,
nix-update-script,
postgresql,
}:
buildPgrxExtension (finalAttrs: {
inherit postgresql;
cargo-pgrx = cargo-pgrx_0_16_0;
pname = "pg_graphql";
version = "1.5.12-unstable-2025-09-01";
src = fetchFromGitHub {
owner = "supabase";
repo = "pg_graphql";
# ToDo: 1.5.12 has not been tagged in Git yet, hence `rev` is used instead for now
#tag = "v${finalAttrs.version}";
rev = "bae1cb506d48d14ccf2b05f6a42331f3c9c71a76";
hash = "sha256-aJPstwzizWzVIo1N/4CHKgJBJ7DJpRkrwYrzNL+z7zQ=";
};
cargoHash = "sha256-Gfvu6YY+pRGrcAXAgEIa1iZKLJlbkvMv0F3pg3X/CXQ=";
# pgrx tests try to install the extension into postgresql nix store
doCheck = false;
passthru = {
updateScript = nix-update-script { };
};
meta = {
description = "GraphQL support for PostgreSQL";
homepage = "https://supabase.github.io/pg_graphql";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ julm ];
broken =
lib.versionOlder postgresql.version "14"
|| (
# ToDo: check after next package update.
lib.versionAtLeast postgresql.version "18"
&& (
finalAttrs.version == "1.5.12-unstable-2025-09-01"
|| lib.warn "Is postgresql18Packages.pg_graphql still broken?" false
)
);
};
})

View File

@@ -0,0 +1,70 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
let
sources = {
"18" = {
version = "1.8.0";
hash = "sha256-QsDppGN5TE7CSii3mNmwqT/riNNjyRTJk6d6Xcf0JMw=";
};
"17" = {
version = "1.7.1";
hash = "sha256-9GKqyrNpi80I4WWIiRN8zeXBm5bkRuzOWrZVfpYOzag=";
};
"16" = {
version = "1.6.2";
hash = "sha256-WMmtnuGOvLwtiEmgHpYURC1k5NmkBiDg+PnQCIZp7Sk=";
};
"15" = {
version = "1.5.3";
hash = "sha256-jkU0zt1waPTdFrBLAxYNvlo+RwdhCtKQq7iqAuxthNA=";
};
"14" = {
version = "1.4.4";
hash = "sha256-8rJ4Ck0Axf9zKhOXaJ4EA/M783YZRLuWx+GMGccadVo=";
};
"13" = {
version = "1.3.11";
hash = "sha256-XTxCw1Uj6rVLcXJuHoT3RkEhdKVLGjOdR7rhFI8YJas=";
};
};
source =
sources.${lib.versions.major postgresql.version} or {
version = "";
hash = throw "Source for pg_hint_plan is not available for ${postgresql.version}";
};
in
postgresqlBuildExtension {
pname = "pg_hint_plan";
inherit (source) version;
src = fetchFromGitHub {
owner = "ossc-db";
repo = "pg_hint_plan";
tag = "REL${lib.versions.major postgresql.version}_${
builtins.replaceStrings [ "." ] [ "_" ] source.version
}";
inherit (source) hash;
};
postPatch = lib.optionalString (lib.versionOlder postgresql.version "14") ''
# https://github.com/ossc-db/pg_hint_plan/commit/e9e564ad59b8bd4a03e0f13b95b5122712e573e6
substituteInPlace Makefile --replace "LDFLAGS+=-Wl,--build-id" ""
'';
enableUpdateScript = false;
meta = {
broken = !builtins.elem (lib.versions.major postgresql.version) (builtins.attrNames sources);
description = "Extension to tweak PostgreSQL execution plans using so-called 'hints' in SQL comments";
homepage = "https://github.com/ossc-db/pg_hint_plan";
maintainers = with lib.maintainers; [ _1000101 ];
platforms = postgresql.meta.platforms;
license = lib.licenses.bsd3;
};
}

View File

@@ -0,0 +1,36 @@
{
fetchFromGitHub,
fetchpatch,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_hll";
version = "2.18";
src = fetchFromGitHub {
owner = "citusdata";
repo = "postgresql-hll";
tag = "v${finalAttrs.version}";
hash = "sha256-Latdxph1Ura8yKEokEjalJ+/GY+pAKOT3GXjuLprj6c=";
};
patches = [
(fetchpatch {
name = "fix-postgresql-18.patch";
url = "https://github.com/citusdata/postgresql-hll/commit/f998e234653ea397ddddc1278d1c02d8d011bd16.patch";
hash = "sha256-gF4f+B4Gu/QEyCGMfKLmRK6lNwgfd8lML55wMkhsSY4=";
})
];
meta = {
description = "HyperLogLog for PostgreSQL";
homepage = "https://github.com/citusdata/postgresql-hll";
changelog = "https://github.com/citusdata/postgresql-hll/blob/v${finalAttrs.version}/CHANGELOG.md";
maintainers = with lib.maintainers; [ thoughtpolice ];
platforms = postgresql.meta.platforms;
license = lib.licenses.asl20;
};
})

View File

@@ -0,0 +1,27 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_ivm";
version = "1.12";
src = fetchFromGitHub {
owner = "sraoss";
repo = "pg_ivm";
tag = "v${finalAttrs.version}";
hash = "sha256-UeRcxoUkpPw4EcQXKUxHamjczOaE59d00kSrYsijnH8=";
};
meta = {
description = "Materialized views with IVM (Incremental View Maintenance) for PostgreSQL";
homepage = "https://github.com/sraoss/pg_ivm";
changelog = "https://github.com/sraoss/pg_ivm/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [ ivan ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,39 @@
{
fetchFromGitHub,
gitUpdater,
lib,
libversion,
pkg-config,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_libversion";
version = "2.0.1";
src = fetchFromGitHub {
owner = "repology";
repo = "postgresql-libversion";
tag = finalAttrs.version;
hash = "sha256-3nqXaBwPRUSo6wUY5YMjJ/nFFKmhgP1zFKapD+RqSDw=";
};
nativeBuildInputs = [
pkg-config
];
buildInputs = [
libversion
];
passthru.updateScript = gitUpdater { };
meta = {
description = "PostgreSQL extension with support for version string comparison";
homepage = "https://github.com/repology/postgresql-libversion";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ jopejoe1 ];
platforms = postgresql.meta.platforms;
};
})

View File

@@ -0,0 +1,30 @@
{
curl,
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_net";
version = "0.19.7";
src = fetchFromGitHub {
owner = "supabase";
repo = "pg_net";
tag = "v${finalAttrs.version}";
hash = "sha256-HQiFD8vhox7SmjJIDyVnnwt8DCENKABIZTMfTjGElwU=";
};
buildInputs = [ curl ];
meta = {
description = "Async networking for Postgres";
homepage = "https://github.com/supabase/pg_net";
changelog = "https://github.com/supabase/pg_net/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [ thoughtpolice ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,28 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_partman";
version = "5.2.4";
src = fetchFromGitHub {
owner = "pgpartman";
repo = "pg_partman";
tag = "v${finalAttrs.version}";
hash = "sha256-i/o+JZEXnJRO17kfdTw87aca28+I8pvuFZsPMA/kf+w=";
};
meta = {
description = "Partition management extension for PostgreSQL";
homepage = "https://github.com/pgpartman/pg_partman";
changelog = "https://github.com/pgpartman/pg_partman/blob/v${finalAttrs.version}/CHANGELOG.md";
maintainers = with lib.maintainers; [ ggpeti ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
broken = lib.versionOlder postgresql.version "14";
};
})

View File

@@ -0,0 +1,26 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_rational";
version = "0.0.2";
src = fetchFromGitHub {
owner = "begriffs";
repo = "pg_rational";
tag = "v${finalAttrs.version}";
hash = "sha256-Sp5wuX2nP3KGyWw7MFa11rI1CPIKIWBt8nvBSsASIEw=";
};
meta = {
description = "Precise fractional arithmetic for PostgreSQL";
homepage = "https://github.com/begriffs/pg_rational";
maintainers = with lib.maintainers; [ netcrns ];
platforms = postgresql.meta.platforms;
license = lib.licenses.mit;
};
})

View File

@@ -0,0 +1,26 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_relusage";
version = "0.0.1";
src = fetchFromGitHub {
owner = "adept";
repo = "pg_relusage";
tag = "${finalAttrs.version}";
hash = "sha256-8hJNjQ9MaBk3J9a73l+yQMwMW/F2N8vr5PO2o+5GvYs=";
};
meta = {
description = "pg_relusage extension for PostgreSQL: discover and log the relations used in your statements";
homepage = "https://github.com/adept/pg_relusage";
maintainers = with lib.maintainers; [ thenonameguy ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,52 @@
{
fetchFromGitHub,
gitUpdater,
lib,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
testers,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_repack";
version = "1.5.2";
buildInputs = postgresql.buildInputs;
src = fetchFromGitHub {
owner = "reorg";
repo = "pg_repack";
tag = "ver_${finalAttrs.version}";
hash = "sha256-wfjiLkx+S3zVrAynisX1GdazueVJ3EOwQEPcgUQt7eA=";
};
passthru.updateScript = gitUpdater {
rev-prefix = "ver_";
};
passthru.tests = {
version = testers.testVersion {
package = finalAttrs.finalPackage;
};
extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = "CREATE EXTENSION pg_repack;";
};
};
meta = {
description = "Reorganize tables in PostgreSQL databases with minimal locks";
longDescription = ''
pg_repack is a PostgreSQL extension which lets you remove bloat from tables and indexes, and optionally restore
the physical order of clustered indexes. Unlike CLUSTER and VACUUM FULL it works online, without holding an
exclusive lock on the processed tables during processing. pg_repack is efficient to boot,
with performance comparable to using CLUSTER directly.
'';
homepage = "https://github.com/reorg/pg_repack";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ danbst ];
inherit (postgresql.meta) platforms;
mainProgram = "pg_repack";
};
})

View File

@@ -0,0 +1,27 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_roaringbitmap";
version = "0.5.5";
src = fetchFromGitHub {
owner = "ChenHuajun";
repo = "pg_roaringbitmap";
tag = "v${finalAttrs.version}";
hash = "sha256-5tThowu8k7R33rD/SXINOmzfgSkc4P3lVJ35BeCinZw=";
};
meta = {
description = "RoaringBitmap extension for PostgreSQL";
homepage = "https://github.com/ChenHuajun/pg_roaringbitmap";
changelog = "https://github.com/ChenHuajun/pg_roaringbitmap/blob/${finalAttrs.src.rev}/CHANGELOG.md";
license = lib.licenses.asl20;
maintainers = [ ];
inherit (postgresql.meta) platforms;
};
})

View File

@@ -0,0 +1,63 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
let
sources = {
"13" = {
version = "1.4";
hash = "sha256-1cyvVEC9MQGMr7Tg6EUbsVBrMc8ahdFS3+CmDkmAq4Y=";
};
"14" = {
version = "1.5";
hash = "sha256-RRSpkWLFuif+6RCncnsb1NnjKnIIRY9KgebKkjCN5cs=";
};
"15" = {
version = "1.5";
hash = "sha256-RRSpkWLFuif+6RCncnsb1NnjKnIIRY9KgebKkjCN5cs=";
};
"16" = {
version = "1.5";
hash = "sha256-RRSpkWLFuif+6RCncnsb1NnjKnIIRY9KgebKkjCN5cs=";
};
"17" = {
version = "1.5";
hash = "sha256-RRSpkWLFuif+6RCncnsb1NnjKnIIRY9KgebKkjCN5cs=";
};
"18" = {
version = "1.5";
hash = "sha256-RRSpkWLFuif+6RCncnsb1NnjKnIIRY9KgebKkjCN5cs=";
};
};
source =
sources."${lib.versions.major postgresql.version}" or {
version = "";
hash = throw "pg_safeupdate: version specification for pg ${postgresql.version} missing.";
};
in
postgresqlBuildExtension {
pname = "pg-safeupdate";
inherit (source) version;
src = fetchFromGitHub {
owner = "eradman";
repo = "pg-safeupdate";
tag = source.version;
inherit (source) hash;
};
meta = {
broken = !builtins.elem (lib.versions.major postgresql.version) (builtins.attrNames sources);
description = "Simple extension to PostgreSQL that requires criteria for UPDATE and DELETE";
homepage = "https://github.com/eradman/pg-safeupdate";
changelog = "https://github.com/eradman/pg-safeupdate/raw/${source.version}/NEWS";
platforms = postgresql.meta.platforms;
maintainers = with lib.maintainers; [ wolfgangwalther ];
license = lib.licenses.postgresql;
};
}

View File

@@ -0,0 +1,43 @@
{
fetchFromGitHub,
fetchpatch,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension {
pname = "pg_similarity";
version = "pg_similarity_1_0-unstable-2021-01-12";
src = fetchFromGitHub {
owner = "eulerto";
repo = "pg_similarity";
rev = "b9cb0a2d501b91e33cd1ef550b05483ca3563f71";
hash = "sha256-L04ANvyfzHgW7fINeJEY6T77Vojq3SI8P1TWiCRSPs0=";
};
patches = [
(fetchpatch {
# https://github.com/eulerto/pg_similarity/pull/43
# Also applied in debian as https://sources.debian.org/data/main/p/pg-similarity/1.0-8/debian/patches/pg16
name = "pg16.patch";
url = "https://github.com/eulerto/pg_similarity/commit/f7781ea5ace80f697a8249e03e3ce47d4b0f6b2f.patch";
hash = "sha256-MPDvWfNzSg28lXL5u5/Un9pOCJjqJ4Fz9b8XCfalgts=";
})
];
makeFlags = [ "USE_PGXS=1" ];
meta = {
description = "Extension to support similarity queries on PostgreSQL";
longDescription = ''
pg_similarity is an extension to support similarity queries on PostgreSQL. The implementation
is tightly integrated in the RDBMS in the sense that it defines operators so instead of the traditional
operators (= and <>) you can use ~~~ and ~!~ (any of these operators represents a similarity function).
'';
platforms = postgresql.meta.platforms;
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ danbst ];
};
}

View File

@@ -0,0 +1,51 @@
{
fetchFromGitHub,
lib,
nix-update-script,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_squeeze";
version = "1.9.1";
src = fetchFromGitHub {
owner = "cybertec-postgresql";
repo = "pg_squeeze";
tag = "REL${lib.replaceString "." "_" finalAttrs.version}";
hash = "sha256-KbCS3kg2MoxKHl+35UOFCSF4kPPsIMeO7AfwfHZYZVg=";
};
passthru.updateScript = nix-update-script {
extraArgs = [ "--version-regex=^REL(\\d+)_(\\d+)_(\\d+)$" ];
};
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
postgresqlExtraSettings = ''
wal_level = logical
shared_preload_libraries = 'pg_squeeze'
'';
sql = ''
CREATE EXTENSION pg_squeeze;
SELECT squeeze.start_worker();
CREATE TABLE a(i int PRIMARY KEY, j int);
INSERT INTO a(i, j) SELECT x, x FROM generate_series(1, 20) AS g(x);
INSERT INTO squeeze.tables (tabschema, tabname, schedule)
VALUES ('public', 'a', ('{30}', '{22}', NULL, NULL, '{3, 5}'));
SELECT squeeze.squeeze_table('public', 'a', NULL, NULL, NULL);
'';
};
meta = {
description = "PostgreSQL extension for automatic bloat cleanup";
homepage = "https://github.com/cybertec-postgresql/pg_squeeze";
changelog = "https://github.com/cybertec-postgresql/pg_squeeze/blob/${finalAttrs.src.rev}/NEWS";
license = lib.licenses.mit;
maintainers = [ ];
platforms = postgresql.meta.platforms;
};
})

View File

@@ -0,0 +1,29 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension rec {
pname = "pg_tle";
version = "1.5.2";
src = fetchFromGitHub {
owner = "aws";
repo = "pg_tle";
tag = "v${version}";
hash = "sha256-DB7aPSgW2/cjDWwXsFiEfJ5xhlHnhtII0quxtgwZg5c=";
};
buildInputs = postgresql.buildInputs;
meta = {
description = "Framework for building trusted language extensions for PostgreSQL";
homepage = "https://github.com/aws/pg_tle";
changelog = "https://github.com/aws/pg_tle/releases/tag/v${version}";
maintainers = [ lib.maintainers.benchand ];
platforms = postgresql.meta.platforms;
license = lib.licenses.asl20;
};
}

View File

@@ -0,0 +1,27 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension rec {
pname = "pg_topn";
version = "2.7.0";
src = fetchFromGitHub {
owner = "citusdata";
repo = "postgresql-topn";
tag = "v${version}";
hash = "sha256-lP6Iil/BUv4ga+co+oBpKv1FBqFuBGfNjueEolM6png=";
};
meta = {
description = "Efficient querying of 'top values' for PostgreSQL";
homepage = "https://github.com/citusdata/postgresql-topn";
changelog = "https://github.com/citusdata/postgresql-topn/raw/v${version}/CHANGELOG.md";
maintainers = with lib.maintainers; [ thoughtpolice ];
platforms = postgresql.meta.platforms;
license = lib.licenses.agpl3Only;
};
}

View File

@@ -0,0 +1,27 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pg_uuidv7";
version = "1.6.0";
src = fetchFromGitHub {
owner = "fboulnois";
repo = "pg_uuidv7";
tag = "v${finalAttrs.version}";
hash = "sha256-lG6dCnbLALnfQc4uclqXXXfYjK/WXLV0lo5I8l1E5p4=";
};
meta = {
description = "Tiny Postgres extension to create version 7 UUIDs";
homepage = "https://github.com/fboulnois/pg_uuidv7";
changelog = "https://github.com/fboulnois/pg_uuidv7/blob/main/CHANGELOG.md";
maintainers = with lib.maintainers; [ gaelreyrol ];
platforms = postgresql.meta.platforms;
license = lib.licenses.mpl20;
};
})

View File

@@ -0,0 +1,70 @@
{
fetchFromGitHub,
lib,
libkrb5,
openssl,
postgresql,
postgresqlBuildExtension,
}:
let
sources = {
# v18: No upstream ticket, yet (2025-07-07)
"17" = {
version = "17.1";
hash = "sha256-9St/ESPiFq2NiPKqbwHLwkIyATKUkOGxFcUrWgT+Iqo=";
};
"16" = {
version = "16.1";
hash = "sha256-fzoAcXEKmA+xD4HtcHZgcduh1XmSgL8ZS4R72og7RGQ=";
};
"15" = {
version = "1.7.1";
hash = "sha256-emwoTowT7WKFX0RQDqJXjIblrzqaUIUkzqSqBCHVKQ8=";
};
"14" = {
version = "1.6.3";
hash = "sha256-KgLidJHjUK9BTp6ffmGUj1chcwIe6IzlcadRpGCfNdM=";
};
"13" = {
version = "1.5.3";
hash = "sha256-IU4Clec3DkKWT7+kw0VtQNybt94i7M2rSSgJG/XdcRs=";
};
};
source =
sources.${lib.versions.major postgresql.version} or {
version = "";
hash = throw "Source for pgaudit is not available for ${postgresql.version}";
};
in
postgresqlBuildExtension {
pname = "pgaudit";
inherit (source) version;
src = fetchFromGitHub {
owner = "pgaudit";
repo = "pgaudit";
tag = source.version;
inherit (source) hash;
};
buildInputs = [
libkrb5
openssl
];
makeFlags = [ "USE_PGXS=1" ];
enableUpdateScript = false;
meta = {
broken = !builtins.elem (lib.versions.major postgresql.version) (builtins.attrNames sources);
description = "Open Source PostgreSQL Audit Logging";
homepage = "https://github.com/pgaudit/pgaudit";
changelog = "https://github.com/pgaudit/pgaudit/releases/tag/${source.version}";
maintainers = with lib.maintainers; [ idontgetoutmuch ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
}

View File

@@ -0,0 +1,49 @@
{
fetchFromGitHub,
lib,
perl,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pgddl";
version = "0.30";
src = fetchFromGitHub {
owner = "lacanoid";
repo = "pgddl";
tag = finalAttrs.version;
hash = "sha256-w08IgnobIhlwRGrz+feEnZbI1KrWrMRI4BvNVUZFSSg=";
};
nativeBuildInputs = [
perl
];
preBuild = ''
patchShebangs --build ./bin/ ./docs
'';
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = ''
CREATE EXTENSION ddlx;
CREATE TABLE a(i int PRIMARY KEY, j int);
SELECT ddlx_create('a'::regclass);
SELECT ddlx_drop('a'::regclass);
SELECT ddlx_script('a'::regclass);
'';
};
meta = {
description = "DDL eXtractor functions for PostgreSQL";
homepage = "https://github.com/lacanoid/pgddl";
changelog = "https://github.com/lacanoid/pgddl/releases/tag/${finalAttrs.version}";
platforms = postgresql.meta.platforms;
maintainers = [ lib.maintainers.joshainglis ];
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,45 @@
{
fetchFromGitHub,
lib,
nixosTests,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
unstableGitUpdater,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pgjwt";
version = "0-unstable-2023-03-02";
src = fetchFromGitHub {
owner = "michelp";
repo = "pgjwt";
rev = "f3d82fd30151e754e19ce5d6a06c71c20689ce3d";
hash = "sha256-nDZEDf5+sFc1HDcG2eBNQj+kGcdAYRXJseKi9oww+JU=";
};
passthru.updateScript = unstableGitUpdater { };
passthru.tests = lib.recurseIntoAttrs {
pgjwt = nixosTests.postgresql.pgjwt.passthru.override postgresql;
extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = ''
CREATE EXTENSION pgjwt CASCADE;
SELECT sign('{"sub":"1234567890","name":"John Doe","admin":true}', 'secret');
'';
};
};
meta = {
description = "PostgreSQL implementation of JSON Web Tokens";
longDescription = ''
sign() and verify() functions to create and verify JSON Web Tokens.
'';
license = lib.licenses.mit;
platforms = postgresql.meta.platforms;
maintainers = with lib.maintainers; [ spinus ];
};
})

View File

@@ -0,0 +1,31 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pgmq";
version = "1.7.0";
src = fetchFromGitHub {
owner = "tembo-io";
repo = "pgmq";
tag = "v${finalAttrs.version}";
hash = "sha256-CnXweDsLO2yE+z1tPADqz54Q1rswsKoUVYbdiZFEbPs=";
};
sourceRoot = "${finalAttrs.src.name}/pgmq-extension";
dontConfigure = true;
meta = {
description = "Lightweight message queue like AWS SQS and RSMQ but on Postgres";
homepage = "https://tembo.io/pgmq";
changelog = "https://github.com/tembo-io/pgmq/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [ takeda ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,50 @@
{
fetchFromGitHub,
groonga,
lib,
msgpack-c,
pkg-config,
postgresql,
postgresqlBuildExtension,
xxHash,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pgroonga";
version = "4.0.4";
src = fetchFromGitHub {
owner = "pgroonga";
repo = "pgroonga";
tag = "${finalAttrs.version}";
hash = "sha256-SXQH+L7FKhu+2+9QyQTNi+3nFYtkE7WXv2A5LdvjG2w=";
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [
msgpack-c
groonga
xxHash
];
makeFlags = [
"HAVE_XXHASH=1"
"HAVE_MSGPACK=1"
"MSGPACK_PACKAGE_NAME=msgpack-c"
];
meta = {
description = "PostgreSQL extension to use Groonga as the index";
longDescription = ''
PGroonga is a PostgreSQL extension to use Groonga as the index.
PostgreSQL supports full text search against languages that use only alphabet and digit.
It means that PostgreSQL doesn't support full text search against Japanese, Chinese and so on.
You can use super fast full text search feature against all languages by installing PGroonga into your PostgreSQL.
'';
homepage = "https://pgroonga.github.io/";
changelog = "https://github.com/pgroonga/pgroonga/releases/tag/${finalAttrs.version}";
license = lib.licenses.postgresql;
platforms = postgresql.meta.platforms;
maintainers = with lib.maintainers; [ DerTim1 ];
};
})

View File

@@ -0,0 +1,37 @@
{
boost,
cmake,
fetchFromGitHub,
lib,
perl,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pgrouting";
version = "3.8.0";
nativeBuildInputs = [
cmake
perl
];
buildInputs = [ boost ];
src = fetchFromGitHub {
owner = "pgRouting";
repo = "pgrouting";
tag = "v${finalAttrs.version}";
hash = "sha256-Lvf7TQ3GywbzZmcd9wi3s8I5sCXIQAPeXNTRk/J46to=";
};
meta = {
description = "PostgreSQL/PostGIS extension that provides geospatial routing functionality";
homepage = "https://pgrouting.org/";
changelog = "https://github.com/pgRouting/pgrouting/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [ steve-chavez ];
teams = [ lib.teams.geospatial ];
platforms = postgresql.meta.platforms;
license = lib.licenses.gpl2Plus;
};
})

View File

@@ -0,0 +1,55 @@
{
bash,
fetchFromGitHub,
lib,
libsodium,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pgsodium";
version = "3.1.9";
src = fetchFromGitHub {
owner = "michelp";
repo = "pgsodium";
tag = "v${finalAttrs.version}";
hash = "sha256-Y8xL3PxF1GQV1JIgolMI1e8oGcUvWAgrPv84om7wKP8=";
};
buildInputs = [
bash # required for patchShebangs
libsodium
];
postInstall = ''
install -D -t $out/share/pgsodium/getkey_scripts getkey_scripts/*
ln -s $out/share/pgsodium/getkey_scripts/pgsodium_getkey_urandom.sh $out/share/postgresql/extension/pgsodium_getkey
'';
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
postgresqlExtraSettings = ''
shared_preload_libraries=pgsodium
'';
sql = ''
CREATE EXTENSION pgsodium;
SELECT pgsodium.version();
SELECT pgsodium.crypto_auth_keygen();
SELECT pgsodium.randombytes_random() FROM generate_series(0, 5);
SELECT * FROM pgsodium.crypto_box_new_keypair();
'';
};
meta = {
description = "Modern cryptography for PostgreSQL using libsodium";
homepage = "https://github.com/michelp/pgsodium";
changelog = "https://github.com/michelp/pgsodium/releases/tag/v${finalAttrs.version}";
license = lib.licenses.postgresql;
maintainers = [ ];
platforms = postgresql.meta.platforms;
};
})

View File

@@ -0,0 +1,31 @@
{
curl,
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pgsql-http";
version = "1.7.0";
src = fetchFromGitHub {
owner = "pramsey";
repo = "pgsql-http";
tag = "v${finalAttrs.version}";
hash = "sha256-tgmty8ZYpSEccwQouI/Ho2M495k6DizbMaaJ0+aW03Q=";
};
buildInputs = [ curl ];
nativeBuildInputs = [ curl ];
meta = {
description = "HTTP client for PostgreSQL, retrieve a web page from inside the database";
homepage = "https://github.com/pramsey/pgsql-http";
changelog = "https://github.com/pramsey/pgsql-http/releases/tag/v${finalAttrs.version}";
maintainers = [ ];
platforms = postgresql.meta.platforms;
license = lib.licenses.mit;
};
})

View File

@@ -0,0 +1,69 @@
{
fetchFromGitHub,
lib,
perl,
perlPackages,
postgresql,
postgresqlBuildExtension,
postgresqlTestHook,
stdenv,
which,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pgtap";
version = "1.3.3";
src = fetchFromGitHub {
owner = "theory";
repo = "pgtap";
tag = "v${finalAttrs.version}";
hash = "sha256-YgvfLGF7pLVcCKD66NnWAydDxtoYHH1DpLiYTEKHJ0E=";
};
nativeBuildInputs = [
perl
perlPackages.TAPParserSourceHandlerpgTAP
which
];
passthru.tests.extension = stdenv.mkDerivation {
name = "pgtap-test";
dontUnpack = true;
doCheck = true;
nativeCheckInputs = [
postgresqlTestHook
(postgresql.withPackages (_: [ finalAttrs.finalPackage ]))
];
passAsFile = [ "sql" ];
sql = ''
CREATE EXTENSION pgtap;
BEGIN;
SELECT plan(1);
SELECT pass('Test passed');
SELECT * FROM finish();
ROLLBACK;
'';
checkPhase = ''
runHook preCheck
psql -a -v ON_ERROR_STOP=1 -f $sqlPath
runHook postCheck
'';
installPhase = "touch $out";
};
meta = {
description = "Unit testing framework for PostgreSQL";
longDescription = ''
pgTAP is a unit testing framework for PostgreSQL written in PL/pgSQL and PL/SQL.
It includes a comprehensive collection of TAP-emitting assertion functions,
as well as the ability to integrate with other TAP-emitting test frameworks.
It can also be used in the xUnit testing style.
'';
maintainers = [ ];
homepage = "https://pgtap.org";
inherit (postgresql.meta) platforms;
license = lib.licenses.mit;
};
})

View File

@@ -0,0 +1,19 @@
diff --git a/crates/c/build.rs b/crates/c/build.rs
index 8d822e5..8b7e371 100644
--- a/crates/c/build.rs
+++ b/crates/c/build.rs
@@ -1,9 +1,13 @@
fn main() {
println!("cargo:rerun-if-changed=src/f16.h");
println!("cargo:rerun-if-changed=src/f16.c");
+ println!("cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS");
cc::Build::new()
- .compiler("clang-16")
+ .compiler("@clang@")
.file("./src/f16.c")
+ // read env var set by rustPlatform.bindgenHook
+ .try_flags_from_environment("BINDGEN_EXTRA_CLANG_ARGS")
+ .expect("the BINDGEN_EXTRA_CLANG_ARGS environment variable must be specified and UTF-8")
.opt_level(3)
.debug(true)
.compile("vectorsc");

View File

@@ -0,0 +1,21 @@
diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs
index 18172b9..6fc7e82 100644
--- a/crates/common/src/lib.rs
+++ b/crates/common/src/lib.rs
@@ -1,3 +1,4 @@
+#![warn(dangerous_implicit_autorefs)]
pub mod clean;
pub mod dir_ops;
pub mod file_atomic;
diff --git a/src/lib.rs b/src/lib.rs
index 068c65d..82609e9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,6 +6,7 @@
#![allow(clippy::needless_range_loop)]
#![allow(clippy::single_match)]
#![allow(clippy::too_many_arguments)]
+#![warn(dangerous_implicit_autorefs)]
mod bgworker;
mod datatype;

View File

@@ -0,0 +1,119 @@
{
buildPgrxExtension,
cargo-pgrx_0_12_0_alpha_1,
clang,
fetchFromGitHub,
lib,
nix-update-script,
openssl,
pkg-config,
postgresql,
postgresqlTestExtension,
replaceVars,
}:
buildPgrxExtension (finalAttrs: {
inherit postgresql;
cargo-pgrx = cargo-pgrx_0_12_0_alpha_1;
pname = "pgvecto-rs";
version = "0.3.0";
buildInputs = [ openssl ];
nativeBuildInputs = [ pkg-config ];
patches = [
# Tell the `c` crate to use the flags from the rust bindgen hook
(replaceVars ./0001-read-clang-flags-from-environment.diff {
clang = lib.getExe clang;
})
# Rust 1.89 denies implicit autorefs by default, making the compilation fail.
# This restores the behaviour of previous rust versions by making the lint throw a warning instead.
./0002-allow-dangerous-implicit-autorefs.diff
];
src = fetchFromGitHub {
owner = "tensorchord";
repo = "pgvecto.rs";
tag = "v${finalAttrs.version}";
hash = "sha256-X7BY2Exv0xQNhsS/GA7GNvj9OeVDqVCd/k3lUkXtfgE=";
};
cargoHash = "sha256-8otJ1uqGrCmlxAqvfAL3OjhBI4I6dAu6EoajstO46Sw=";
# Set appropriate version on vectors.control, otherwise it won't show up on PostgreSQL
postPatch = ''
substituteInPlace ./vectors.control --subst-var-by CARGO_VERSION ${finalAttrs.version}
'';
# Include upgrade scripts in the final package
# https://github.com/tensorchord/pgvecto.rs/blob/v0.2.0/scripts/ci_package.sh#L6-L8
postInstall = ''
cp sql/upgrade/* $out/share/postgresql/extension/
'';
env = {
# Needed to get openssl-sys to use pkg-config.
OPENSSL_NO_VENDOR = 1;
# Bypass rust nightly features not being available on rust stable
RUSTC_BOOTSTRAP = 1;
};
# This crate does not have the "pg_test" feature
usePgTestCheckFeature = false;
passthru = {
updateScript = nix-update-script { };
tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
postgresqlExtraSettings = ''
shared_preload_libraries='vectors'
'';
sql = ''
CREATE EXTENSION vectors;
CREATE TABLE items (
id bigserial PRIMARY KEY,
content text NOT NULL,
embedding vectors.vector(3) NOT NULL -- 3 dimensions
);
INSERT INTO items (content, embedding) VALUES
('a fat cat sat on a mat and ate a fat rat', '[1, 2, 3]'),
('a fat dog sat on a mat and ate a fat rat', '[4, 5, 6]'),
('a thin cat sat on a mat and ate a thin rat', '[7, 8, 9]'),
('a thin dog sat on a mat and ate a thin rat', '[10, 11, 12]');
'';
asserts = [
{
query = "SELECT default_version FROM pg_available_extensions WHERE name = 'vectors'";
expected = "'${finalAttrs.version}'";
description = "Extension vectors has correct version.";
}
{
query = "SELECT COUNT(embedding) FROM items WHERE to_tsvector('english', content) @@ 'cat & rat'::tsquery";
expected = "2";
description = "Stores and returns vectors.";
}
];
};
};
meta = {
# Upstream removed support for PostgreSQL 13 on 0.3.0: https://github.com/tensorchord/pgvecto.rs/issues/343
broken =
(lib.versionOlder postgresql.version "14")
||
# PostgreSQL 17 support issue upstream: https://github.com/tensorchord/pgvecto.rs/issues/607
# Check after next package update.
lib.versionAtLeast postgresql.version "17" && finalAttrs.version == "0.3.0";
description = "Scalable, Low-latency and Hybrid-enabled Vector Search in Postgres";
homepage = "https://github.com/tensorchord/pgvecto.rs";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [
diogotcorreia
esclear
];
};
})

View File

@@ -0,0 +1,27 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "pgvector";
version = "0.8.1";
src = fetchFromGitHub {
owner = "pgvector";
repo = "pgvector";
tag = "v${finalAttrs.version}";
hash = "sha256-4EqazYWstczL9T3YFqq2gtbcKIj6zWU8ItYt2nnwPYo=";
};
meta = {
description = "Open-source vector similarity search for PostgreSQL";
homepage = "https://github.com/pgvector/pgvector";
changelog = "https://github.com/pgvector/pgvector/raw/v${finalAttrs.version}/CHANGELOG.md";
license = lib.licenses.postgresql;
platforms = postgresql.meta.platforms;
maintainers = [ ];
};
})

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,80 @@
{
buildPgrxExtension,
cargo-pgrx_0_12_6,
postgresql,
fetchFromGitHub,
lib,
postgresqlTestExtension,
}:
buildPgrxExtension (finalAttrs: {
pname = "pgvectorscale";
version = "0.7.0";
src = fetchFromGitHub {
owner = "timescale";
repo = "pgvectorscale";
tag = finalAttrs.version;
hash = "sha256-dy481k2SvyYXwwcsyLZSl3XlhSk9C5+4LfEfciB1DK4=";
};
doCheck = false;
cargoHash = "sha256-CeRyDn9VhxfjWFJ1/Z/XvOUQOSnDoHHZAqgfYTeKU0o=";
cargoPatches = [
./add-Cargo.lock.patch
];
cargoPgrxFlags = [
"-p"
"vectorscale"
];
inherit postgresql;
cargo-pgrx = cargo-pgrx_0_12_6;
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
withPackages = [ "pgvector" ];
sql = ''
CREATE EXTENSION vectorscale CASCADE;
CREATE TABLE document_embedding (
id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
embedding VECTOR(3)
);
INSERT INTO document_embedding (id, embedding) VALUES
(10, '[1,2,4]'),
(20, '[1,2,5]');
CREATE INDEX document_embedding_idx ON document_embedding
USING diskann (embedding vector_cosine_ops);
'';
asserts = [
{
query = "SELECT id FROM document_embedding WHERE embedding <-> '[1,2,3]' = 1";
expected = "10";
description = "Expected vector of row with ID=10 to have an euclidean distance from [1,2,3] of 1.";
}
{
query = "SELECT id FROM document_embedding WHERE embedding <-> '[1,2,3]' = 2";
expected = "20";
description = "Expected vector of row with ID=20 to have an euclidean distance from [1,2,3] of 2.";
}
];
};
meta = {
# PostgreSQL 18 support issue upstream: https://github.com/timescale/pgvectorscale/issues/249
# Check after next package update.
broken =
lib.warnIf (finalAttrs.version != "0.7.0") "Is postgresql18Packages.pgvectorscale still broken?"
(lib.versionAtLeast postgresql.version "18");
homepage = "https://github.com/timescale/pgvectorscale";
teams = [ lib.teams.flyingcircus ];
description = "Complement to pgvector for high performance, cost efficient vector search on large workloads";
license = lib.licenses.postgresql;
platforms = postgresql.meta.platforms;
changelog = "https://github.com/timescale/pgvectorscale/releases/tag/${finalAttrs.version}";
};
})

View File

@@ -0,0 +1,58 @@
{
buildPgrxExtension,
cargo-pgrx_0_12_6,
fetchFromGitHub,
lib,
nix-update-script,
postgresql,
util-linux,
}:
buildPgrxExtension (finalAttrs: {
inherit postgresql;
cargo-pgrx = cargo-pgrx_0_12_6;
pname = "pgx_ulid";
version = "0.2.0";
src = fetchFromGitHub {
owner = "pksunkara";
repo = "pgx_ulid";
tag = "v${finalAttrs.version}";
hash = "sha256-VdLWwkUA0sVs5Z/Lyf5oTRhcHVzPmhgnYQhIM8MWJ0c=";
};
cargoHash = "sha256-OyrfwLMHn2aihfijHxE5oaz+XQC1HFlYbTp8Sw8RcK0=";
postInstall = ''
# Upstream renames the extension when packaging
# https://github.com/pksunkara/pgx_ulid/blob/084778c3e2af08d16ec5ec3ef4e8f345ba0daa33/.github/workflows/release.yml#L81
# Upgrade scripts should be added later, so we also rename them with wildcard
# https://github.com/pksunkara/pgx_ulid/issues/49
${util-linux}/bin/rename pgx_ulid ulid $out/share/postgresql/extension/pgx_ulid*
'';
# pgrx tests try to install the extension into postgresql nix store
doCheck = false;
passthru = {
updateScript = nix-update-script { };
};
meta = {
# Support for PostgreSQL 13 was removed in 0.2.0: https://github.com/pksunkara/pgx_ulid/blob/084778c3e2af08d16ec5ec3ef4e8f345ba0daa33/CHANGELOG.md?plain=1#L6
broken =
lib.versionOlder postgresql.version "14"
||
# PostgreSQL 18 support issue upstream: https://github.com/pksunkara/pgx_ulid/issues/65
# Note: already fixed on `master` branch.
# Check after next package update.
lib.warnIf (finalAttrs.version != "0.2.0") "Is postgresql18Packages.pgx_ulid still broken?" (
lib.versionAtLeast postgresql.version "18"
);
description = "ULID Postgres extension written in Rust";
homepage = "https://github.com/pksunkara/pgx_ulid";
changelog = "https://github.com/pksunkara/pgx_ulid/blob/v${finalAttrs.version}/CHANGELOG.md";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ myypo ];
};
})

View File

@@ -0,0 +1,45 @@
{
buildEnv,
perl,
postgresql,
postgresqlTestExtension,
}:
let
withPackages =
f:
let
perl' = perl.withPackages f;
finalPackage = buildEnv {
name = "${postgresql.pname}-plperl-${postgresql.version}";
paths = [ postgresql.plperl ];
passthru = {
inherit withPackages;
wrapperArgs = [
''--set PERL5LIB "${perl'}/${perl'.libPrefix}"''
];
tests.extension = postgresqlTestExtension {
finalPackage = finalPackage.withPackages (ps: [ ps.boolean ]);
sql = ''
CREATE EXTENSION plperlu;
DO LANGUAGE plperlu $$
use boolean;
$$;
'';
};
};
meta = {
inherit (postgresql.meta)
homepage
license
changelog
teams
platforms
;
description = "PL/Perl - Perl Procedural Language";
};
};
in
finalPackage;
in
withPackages (_: [ ])

View File

@@ -0,0 +1,34 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "plpgsql-check";
version = "2.8.2";
src = fetchFromGitHub {
owner = "okbob";
repo = "plpgsql_check";
tag = "v${finalAttrs.version}";
hash = "sha256-NjqnXbQ+wyKVFFdffOQpxrCWT9vrzgh8lk2G3L9i6G8=";
};
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = "CREATE EXTENSION plpgsql_check;";
};
meta = {
description = "Linter tool for language PL/pgSQL";
homepage = "https://github.com/okbob/plpgsql_check";
changelog = "https://github.com/okbob/plpgsql_check/releases/tag/v${finalAttrs.version}";
platforms = postgresql.meta.platforms;
license = lib.licenses.mit;
maintainers = [ ];
broken = lib.versionOlder postgresql.version "14";
};
})

View File

@@ -0,0 +1,45 @@
{
buildEnv,
postgresql,
postgresqlTestExtension,
python3,
}:
let
withPackages =
f:
let
python = python3.withPackages f;
finalPackage = buildEnv {
name = "${postgresql.pname}-plpython3-${postgresql.version}";
paths = [ postgresql.plpython3 ];
passthru = {
inherit withPackages;
wrapperArgs = [
''--set PYTHONPATH "${python}/${python.sitePackages}"''
];
tests.extension = postgresqlTestExtension {
finalPackage = finalPackage.withPackages (ps: [ ps.base58 ]);
sql = ''
CREATE EXTENSION plpython3u;
DO LANGUAGE plpython3u $$
import base58
$$;
'';
};
};
meta = {
inherit (postgresql.meta)
homepage
license
changelog
teams
platforms
;
description = "PL/Python - Python Procedural Language";
};
};
in
finalPackage;
in
withPackages (_: [ ])

View File

@@ -0,0 +1,67 @@
{
buildEnv,
fetchFromGitHub,
lib,
nix-update-script,
pkg-config,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
R,
rPackages,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "plr";
version = "8.4.8";
src = fetchFromGitHub {
owner = "postgres-plr";
repo = "plr";
tag = "REL${lib.replaceString "." "_" finalAttrs.version}";
hash = "sha256-FLL61HsZ6WaWBP9NqrJjhMFSVyVBIpVO0wv+kXMuAaU=";
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ R ];
makeFlags = [ "USE_PGXS=1" ];
passthru = {
updateScript = nix-update-script {
extraArgs = [ "--version-regex=^REL(\\d+)_(\\d+)_(\\d+)$" ];
};
withPackages =
f:
let
pkgs = f rPackages;
paths = lib.concatMapStringsSep ":" (pkg: "${pkg}/library") pkgs;
in
buildEnv {
name = "${finalAttrs.pname}-with-packages-${finalAttrs.version}";
paths = [ finalAttrs.finalPackage ];
passthru.wrapperArgs = [
''--set R_LIBS_SITE "${paths}"''
];
};
tests.extension = postgresqlTestExtension {
finalPackage = finalAttrs.finalPackage.withPackages (ps: [ ps.base64enc ]);
sql = ''
CREATE EXTENSION plr;
DO LANGUAGE plr $$
require('base64enc')
base64encode(1:100)
$$;
'';
};
};
meta = {
description = "PL/R - R Procedural Language for PostgreSQL";
homepage = "https://github.com/postgres-plr/plr";
changelog = "https://github.com/postgres-plr/plr/blob/${finalAttrs.src.rev}/changelog.md";
maintainers = with lib.maintainers; [ qoelet ];
platforms = postgresql.meta.platforms;
license = lib.licenses.gpl2Only;
};
})

View File

@@ -0,0 +1,52 @@
{
buildEnv,
lib,
postgresql,
postgresqlTestExtension,
tclPackages,
}:
let
withPackages =
f:
let
pkgs = f tclPackages;
paths = lib.concatMapStringsSep " " (pkg: "${pkg}/lib") pkgs;
finalPackage = buildEnv {
name = "${postgresql.pname}-pltcl-${postgresql.version}";
paths = [ postgresql.pltcl ];
passthru = {
inherit withPackages;
wrapperArgs = [
''--set TCLLIBPATH "${paths}"''
];
tests.extension = postgresqlTestExtension {
finalPackage = finalPackage.withPackages (ps: [
ps.mustache-tcl
ps.tcllib
]);
sql = ''
CREATE EXTENSION pltclu;
CREATE FUNCTION test() RETURNS VOID
LANGUAGE pltclu AS $$
package require mustache
$$;
SELECT test();
'';
};
};
meta = {
inherit (postgresql.meta)
homepage
license
changelog
teams
platforms
;
description = "PL/Tcl - Tcl Procedural Language";
};
};
in
finalPackage;
in
withPackages (_: [ ])

View File

@@ -0,0 +1,44 @@
diff --git a/Makefile b/Makefile
index a705c11..08b952b 100644
--- a/Makefile
+++ b/Makefile
@@ -13,11 +13,14 @@ OBJS = $(SRCS:.cc=.o)
MODULE_big = plv8-$(PLV8_VERSION)
EXTENSION = plv8
PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql
+USE_SYSTEM_V8 = 0
ifeq ($(OS),Windows_NT)
# noop for now
else
+ ifeq ($(USE_SYSTEM_V8),0)
SHLIB_LINK += -Ldeps/v8-cmake/build
+ endif
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
CCFLAGS += -stdlib=libc++
@@ -34,6 +37,7 @@ ifeq ($(NUMPROC),0)
NUMPROC = 1
endif
+ifeq ($(USE_SYSTEM_V8),0)
SHLIB_LINK += -Ldeps/v8-cmake/build
all: v8 $(OBJS)
@@ -46,11 +50,16 @@ deps/v8-cmake/build/libv8_libbase.a:
@cd deps/v8-cmake && mkdir -p build && cd build && cmake -Denable-fPIC=ON -DCMAKE_BUILD_TYPE=Release ../ && make -j $(NUMPROC)
v8: deps/v8-cmake/build/libv8_libbase.a
+else
+all: $(OBJS)
+endif
# enable direct jsonb conversion by default
CCFLAGS += -DJSONB_DIRECT_CONVERSION
+ifeq ($(USE_SYSTEM_V8),0)
CCFLAGS += -Ideps/v8-cmake/v8/include -std=c++17
+endif
ifdef EXECUTION_TIMEOUT
CCFLAGS += -DEXECUTION_TIMEOUT

View File

@@ -0,0 +1,141 @@
{
fetchFromGitHub,
lib,
nodejs_20,
perl,
postgresql,
postgresqlBuildExtension,
stdenv,
# For test
coreutils,
gnugrep,
runCommand,
}:
let
libv8 = nodejs_20.libv8;
in
postgresqlBuildExtension (finalAttrs: {
pname = "plv8";
version = "3.2.4";
src = fetchFromGitHub {
owner = "plv8";
repo = "plv8";
tag = "v${finalAttrs.version}";
hash = "sha256-v4r/6qwDwb3+PQPYV3FqmIcDEkSr8F46PVlFnhUWUGc=";
};
patches = [
# Allow building with system v8.
# https://github.com/plv8/plv8/pull/505 (rejected)
./0001-build-Allow-using-V8-from-system.patch
];
nativeBuildInputs = [
perl
];
buildInputs = [
libv8
];
buildFlags = [ "all" ];
makeFlags = [
# Nixpkgs build a v8 monolith instead of separate v8_libplatform.
"USE_SYSTEM_V8=1"
"SHLIB_LINK=-lv8"
"V8_OUTDIR=${libv8}/lib"
];
# No configure script.
dontConfigure = true;
postPatch = ''
patchShebangs ./generate_upgrade.sh
'';
passthru = {
tests =
let
postgresqlWithSelf = postgresql.withPackages (_: [
finalAttrs.finalPackage
]);
in
{
smoke = runCommand "plv8-smoke-test" { } ''
export PATH=${
lib.makeBinPath [
postgresqlWithSelf
coreutils
gnugrep
]
}
db="$PWD/testdb"
initdb "$db"
postgres -k "$db" -D "$db" &
pid="$!"
for i in $(seq 1 100); do
if psql -h "$db" -d postgres -c "" 2>/dev/null; then
break
elif ! kill -0 "$pid"; then
exit 1
else
sleep 0.1
fi
done
psql -h "$db" -d postgres -c 'CREATE EXTENSION plv8; DO $$ plv8.elog(NOTICE, plv8.version); $$ LANGUAGE plv8;' 2> "$out"
grep -q "${finalAttrs.version}" "$out"
kill -0 "$pid"
'';
regression = stdenv.mkDerivation {
name = "plv8-regression";
inherit (finalAttrs)
src
patches
nativeBuildInputs
buildInputs
dontConfigure
;
buildPhase = ''
runHook preBuild
# The regression tests need to be run in the order specified in the Makefile.
echo -e "include Makefile\nprint_regress_files:\n\t@echo \$(REGRESS)" > Makefile.regress
REGRESS_TESTS=$(make -f Makefile.regress print_regress_files)
${lib.getDev postgresql}/lib/pgxs/src/test/regress/pg_regress \
--bindir='${postgresqlWithSelf}/bin' \
--temp-instance=regress-instance \
--dbname=contrib_regression \
$REGRESS_TESTS
runHook postBuild
'';
installPhase = ''
runHook preInstall
touch "$out"
runHook postInstall
'';
};
};
};
meta = {
description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL";
homepage = "https://plv8.github.io/";
changelog = "https://github.com/plv8/plv8/blob/v${finalAttrs.version}/Changes";
maintainers = [ ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
broken = stdenv.hostPlatform.isDarwin;
};
})

View File

@@ -0,0 +1,178 @@
{
autoconf,
automake,
cunit,
docbook5,
fetchFromGitHub,
gdalMinimal,
geos,
jitSupport,
json_c,
lib,
libiconv,
libtool,
libxml2,
libxslt,
llvm,
pcre2,
perl,
pkg-config,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
postgresqlTestHook,
proj,
protobufc,
stdenv,
which,
withSfcgal ? false,
sfcgal,
}:
let
gdal = gdalMinimal;
in
postgresqlBuildExtension (finalAttrs: {
pname = "postgis";
version = "3.6.0";
outputs = [
"out"
"doc"
];
src = fetchFromGitHub {
owner = "postgis";
repo = "postgis";
tag = finalAttrs.version;
hash = "sha256-L8k3yk1Dn4Dk7UyHse+8RJsjYsYMebdsiZp6fS7cC0Y=";
};
buildInputs = [
geos
proj
gdal
json_c
protobufc
pcre2.dev
]
++ lib.optional stdenv.hostPlatform.isDarwin libiconv
++ lib.optional withSfcgal sfcgal;
nativeBuildInputs = [
autoconf
automake
libtool
libxml2
perl
pkg-config
protobufc
which
]
++ lib.optional jitSupport llvm;
dontDisableStatic = true;
checkInputs = [
cunit
];
nativeCheckInputs = [
postgresql
postgresqlTestHook
libxslt
];
postgresqlTestUserOptions = "LOGIN SUPERUSER";
# postgis config directory assumes /include /lib from the same root for json-c library
env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib";
setOutputFlags = false;
preConfigure = ''
./autogen.sh
'';
configureFlags =
let
isCross = stdenv.hostPlatform.config != stdenv.buildPlatform.config;
in
[
(lib.enableFeature false "extension-upgrades-install")
(lib.withFeatureAs true "pgconfig" "${postgresql.pg_config}/bin/pg_config")
(lib.withFeatureAs true "gdalconfig" "${gdal}/bin/gdal-config")
(lib.withFeatureAs true "jsondir" (lib.getDev json_c))
(lib.withFeatureAs true "xml2config" (lib.getExe' (lib.getDev libxml2) "xml2-config"))
(lib.withFeatureAs withSfcgal "sfcgal" "${sfcgal}/bin/sfcgal-config")
(lib.withFeature (!isCross) "json") # configure: error: cannot check for file existence when cross compiling
];
makeFlags = [
"PERL=${perl}/bin/perl"
];
doCheck = stdenv.hostPlatform.isLinux;
preCheck = ''
substituteInPlace doc/postgis-out.xml --replace-fail "http://docbook.org/xml/5.0/dtd/docbook.dtd" "${docbook5}/xml/dtd/docbook/docbookx.dtd"
# The test suite hardcodes it to use /tmp.
export PGIS_REG_TMPDIR="$TMPDIR/pgis_reg"
'';
# create aliases for all commands adding version information
postInstall = ''
for prog in $out/bin/*; do # */
ln -s $prog $prog-${finalAttrs.version}
done
mkdir -p $doc/share/doc/postgis
mv doc/* $doc/share/doc/postgis/
'';
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = ''
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_raster;
CREATE EXTENSION postgis_topology;
-- st_makepoint goes through c code
select st_makepoint(1, 1);
''
+ lib.optionalString withSfcgal ''
CREATE EXTENSION postgis_sfcgal;
CREATE TABLE geometries (
name varchar,
geom geometry(PolygonZ) NOT NULL
);
INSERT INTO geometries(name, geom) VALUES
('planar geom', 'PolygonZ((1 1 0, 1 2 0, 2 2 0, 2 1 0, 1 1 0))'),
('nonplanar geom', 'PolygonZ((1 1 1, 1 2 -1, 2 2 2, 2 1 0, 1 1 1))');
SELECT name from geometries where cg_isplanar(geom);
'';
asserts = [
{
query = "postgis_version()";
expected = "'${lib.versions.major finalAttrs.version}.${lib.versions.minor finalAttrs.version} USE_GEOS=1 USE_PROJ=1 USE_STATS=1'";
description = "postgis_version() returns correct values.";
}
]
++ lib.optional withSfcgal {
query = "postgis_sfcgal_version()";
expected = "'${sfcgal.version}'";
description = "postgis_sfcgal_version() returns correct value.";
};
};
meta = {
description = "Geographic Objects for PostgreSQL";
homepage = "https://postgis.net/";
changelog = "https://git.osgeo.org/gitea/postgis/postgis/raw/tag/${finalAttrs.version}/NEWS";
license = lib.licenses.gpl2Plus;
maintainers = with lib.maintainers; [ marcweber ];
teams = [ lib.teams.geospatial ];
inherit (postgresql.meta) platforms;
};
})

View File

@@ -0,0 +1,36 @@
{
curl,
fetchFromGitHub,
flex,
json_c,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "repmgr";
version = "5.5.0";
src = fetchFromGitHub {
owner = "EnterpriseDB";
repo = "repmgr";
tag = "v${finalAttrs.version}";
hash = "sha256-8G2CzzkWTKEglpUt1Gr7d/DuHJvCIEjsbYDMl3Zt3cs=";
};
nativeBuildInputs = [ flex ];
buildInputs = postgresql.buildInputs ++ [
curl
json_c
];
meta = {
homepage = "https://repmgr.org/";
description = "Replication manager for PostgreSQL cluster";
license = lib.licenses.postgresql;
platforms = postgresql.meta.platforms;
maintainers = with lib.maintainers; [ zimbatm ];
};
})

View File

@@ -0,0 +1,43 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "rum";
version = "1.3.14";
src = fetchFromGitHub {
owner = "postgrespro";
repo = "rum";
tag = finalAttrs.version;
hash = "sha256-VsfpxQqRBu9bIAP+TfMRXd+B3hSjuhU2NsutocNiCt8=";
};
makeFlags = [ "USE_PGXS=1" ];
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = ''
CREATE EXTENSION rum;
CREATE TABLE test_table (t text, v tsvector);
CREATE INDEX test_table_rumindex ON test_table USING rum (v rum_tsvector_ops);
'';
};
meta = {
# PostgreSQL 18 support issue upstream: https://github.com/postgrespro/rum/issues/156
# Check after next package update.
broken = lib.warnIf (finalAttrs.version != "1.3.14") "Is postgresql18Packages.rum still broken?" (
lib.versionAtLeast postgresql.version "18"
);
description = "Full text search index method for PostgreSQL";
homepage = "https://github.com/postgrespro/rum";
license = lib.licenses.postgresql;
platforms = postgresql.meta.platforms;
maintainers = with lib.maintainers; [ DeeUnderscore ];
};
})

View File

@@ -0,0 +1,29 @@
{
fetchgit,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension {
pname = "smlar-unstable";
version = "2021-11-08";
src = fetchgit {
url = "git://sigaev.ru/smlar.git";
rev = "f2522d5f20a46a3605a761d34a3aefcdffb94e71";
hash = "sha256-AC6w7uYw0OW70pQpWbK1A3rkCnMvTJzTCAdFiY3rO7A=";
};
makeFlags = [ "USE_PGXS=1" ];
meta = {
description = "Compute similary of any one-dimensional arrays";
homepage = "http://sigaev.ru/git/gitweb.cgi?p=smlar.git";
platforms = postgresql.meta.platforms;
license = lib.licenses.bsd2;
maintainers = [ ];
# Broken with no upstream fix available.
broken = lib.versionAtLeast postgresql.version "16";
};
}

View File

@@ -0,0 +1,38 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
sqlite,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "sqlite_fdw";
version = "2.5.0";
src = fetchFromGitHub {
owner = "pgspider";
repo = "sqlite_fdw";
tag = "v${finalAttrs.version}";
hash = "sha256-zPVIFzUv6UFFHq0Zi5MeQOcvgsfZAKGkkNIGxkTJ+oo=";
};
buildInputs = [ sqlite ];
makeFlags = [ "USE_PGXS=1" ];
meta = {
# PostgreSQL 18 support issue upstream: https://github.com/pgspider/sqlite_fdw/issues/117
# Note: already fixed on `master` branch.
# Check after next package update.
broken = lib.warnIf (
finalAttrs.version != "2.5.0"
) "Is postgresql18Packages.sqlite_fdw still broken?" (lib.versionAtLeast postgresql.version "18");
description = "SQLite Foreign Data Wrapper for PostgreSQL";
homepage = "https://github.com/pgspider/sqlite_fdw";
changelog = "https://github.com/pgspider/sqlite_fdw/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [ apfelkuchen6 ];
platforms = lib.platforms.unix;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,28 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "system_stats";
version = "3.2";
src = fetchFromGitHub {
owner = "EnterpriseDB";
repo = "system_stats";
tag = "v${finalAttrs.version}";
hash = "sha256-/xXnui0S0ZjRw7P8kMAgttHVv8T41aOhM3pM8P0OTig=";
};
buildFlags = [ "PG_CFLAGS=-Wno-error=vla" ];
meta = {
description = "Postgres extension for exposing system metrics such as CPU, memory and disk information";
homepage = "https://github.com/EnterpriseDB/system_stats";
changelog = "https://github.com/EnterpriseDB/system_stats/raw/v${finalAttrs.version}/CHANGELOG.md";
maintainers = with lib.maintainers; [ shivaraj-bh ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,30 @@
{
fetchFromGitHub,
freetds,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "tds_fdw";
version = "2.0.5";
buildInputs = [ freetds ];
src = fetchFromGitHub {
owner = "tds-fdw";
repo = "tds_fdw";
tag = "v${finalAttrs.version}";
hash = "sha256-4ecdErksaZ7SyCKzvSY5sD7rrKljq7BMn+gI9Yz49r0=";
};
meta = {
description = "PostgreSQL foreign data wrapper to connect to TDS databases (Sybase and Microsoft SQL Server)";
homepage = "https://github.com/tds-fdw/tds_fdw";
changelog = "https://github.com/tds-fdw/tds_fdw/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [ steve-chavez ];
platforms = postgresql.meta.platforms;
license = lib.licenses.postgresql;
};
})

View File

@@ -0,0 +1,26 @@
{
fetchFromGitHub,
lib,
postgresql,
postgresqlBuildExtension,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "temporal_tables";
version = "1.2.2";
src = fetchFromGitHub {
owner = "arkhipov";
repo = "temporal_tables";
tag = "v${finalAttrs.version}";
hash = "sha256-7+DCSPAPhsokWDq/5IXNhd7jY6FfzxxUjlsg/VJeD3k=";
};
meta = {
description = "Temporal Tables PostgreSQL Extension";
homepage = "https://github.com/arkhipov/temporal_tables";
maintainers = with lib.maintainers; [ ggpeti ];
platforms = postgresql.meta.platforms;
license = lib.licenses.bsd2;
};
})

View File

@@ -0,0 +1,113 @@
{
cmake,
fetchFromGitHub,
lib,
libkrb5,
openssl,
postgresql,
postgresqlBuildExtension,
postgresqlTestExtension,
enableUnfree ? true,
}:
postgresqlBuildExtension (finalAttrs: {
pname = "timescaledb${lib.optionalString (!enableUnfree) "-apache"}";
version = "2.22.1";
src = fetchFromGitHub {
owner = "timescale";
repo = "timescaledb";
tag = finalAttrs.version;
hash = "sha256-SEuxHbSxgTC4Uk6nnznVzUqvoZMGgF+KSMNzkYfgfpI=";
};
nativeBuildInputs = [ cmake ];
buildInputs = [
openssl
libkrb5
];
cmakeFlags = [
(lib.cmakeBool "SEND_TELEMETRY_DEFAULT" false)
(lib.cmakeBool "REGRESS_CHECKS" false)
(lib.cmakeBool "TAP_CHECKS" false)
(lib.cmakeBool "APACHE_ONLY" (!enableUnfree))
];
# Fix the install phase which tries to install into the pgsql extension dir,
# and cannot be manually overridden. This is rather fragile but works OK.
postPatch = ''
for x in CMakeLists.txt sql/CMakeLists.txt; do
substituteInPlace "$x" \
--replace-fail 'DESTINATION "''${PG_SHAREDIR}/extension"' "DESTINATION \"$out/share/postgresql/extension\""
done
for x in src/CMakeLists.txt src/loader/CMakeLists.txt tsl/src/CMakeLists.txt; do
substituteInPlace "$x" \
--replace-fail 'DESTINATION ''${PG_PKGLIBDIR}' "DESTINATION \"$out/lib\""
done
'';
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
withPackages = [ "timescaledb_toolkit" ];
postgresqlExtraSettings = ''
shared_preload_libraries='timescaledb'
'';
sql = ''
CREATE EXTENSION timescaledb;
CREATE EXTENSION timescaledb_toolkit;
CREATE TABLE sth (
time TIMESTAMPTZ NOT NULL,
value DOUBLE PRECISION
);
SELECT create_hypertable('sth', 'time');
INSERT INTO sth (time, value) VALUES
('2003-04-12 04:05:06 America/New_York', 1.0),
('2003-04-12 04:05:07 America/New_York', 2.0),
('2003-04-12 04:05:08 America/New_York', 3.0),
('2003-04-12 04:05:09 America/New_York', 4.0),
('2003-04-12 04:05:10 America/New_York', 5.0)
;
WITH t AS (
SELECT
time_bucket('1 day'::interval, time) AS dt,
stats_agg(value) AS stats
FROM sth
GROUP BY time_bucket('1 day'::interval, time)
)
SELECT
average(stats)
FROM t;
'';
asserts = [
{
query = "SELECT count(*) FROM sth";
expected = "5";
description = "hypertable can be queried successfully.";
}
];
};
meta = {
description = "Scales PostgreSQL for time-series data via automatic partitioning across time and space";
homepage = "https://www.timescale.com/";
changelog = "https://github.com/timescale/timescaledb/blob/${finalAttrs.version}/CHANGELOG.md";
maintainers = with lib.maintainers; [ kirillrdy ];
platforms = postgresql.meta.platforms;
license = with lib.licenses; if enableUnfree then tsl else asl20;
broken =
lib.versionOlder postgresql.version "15"
||
# PostgreSQL 18 support issue upstream: https://github.com/timescale/timescaledb/issues/8233
# Check after next package update.
lib.warnIf (finalAttrs.version != "2.22.1") "Is postgresql18Packages.timescaledb still broken?" (
lib.versionAtLeast postgresql.version "18"
);
};
})

View File

@@ -0,0 +1,53 @@
{
buildPgrxExtension,
cargo-pgrx_0_12_6,
fetchFromGitHub,
lib,
nix-update-script,
postgresql,
}:
buildPgrxExtension (finalAttrs: {
inherit postgresql;
cargo-pgrx = cargo-pgrx_0_12_6;
pname = "timescaledb_toolkit";
version = "1.21.0";
src = fetchFromGitHub {
owner = "timescale";
repo = "timescaledb-toolkit";
tag = finalAttrs.version;
hash = "sha256-gGGSNvvJprqLkVwPr7cfmGY1qEUTXMdqdvwPYIzXaTA=";
};
cargoHash = "sha256-kyUpfNEXJ732VO6JDxU+dIoL57uWzG4Ff03/GnvsxLE=";
buildAndTestSubdir = "extension";
postInstall = ''
cargo run --manifest-path ./tools/post-install/Cargo.toml -- --dir "$out"
'';
passthru = {
updateScript = nix-update-script { };
tests = postgresql.pkgs.timescaledb.tests;
};
# tests take really long
doCheck = false;
meta = {
description = "Provide additional tools to ease all things analytic when using TimescaleDB";
homepage = "https://github.com/timescale/timescaledb-toolkit";
maintainers = with lib.maintainers; [ typetetris ];
platforms = postgresql.meta.platforms;
license = lib.licenses.tsl;
broken =
lib.versionOlder postgresql.version "15"
||
# Check after next package update.
lib.warnIf (finalAttrs.version != "1.21.0")
"Is postgresql18Packages.timescaledb_toolkit still broken?"
(lib.versionAtLeast postgresql.version "18");
};
})

View File

@@ -0,0 +1,60 @@
{
fetchzip,
lib,
mecab,
postgresql,
postgresqlTestExtension,
stdenv,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "tsja";
version = "0.5.0";
src = fetchzip {
url = "https://www.amris.jp/tsja/tsja-${finalAttrs.version}.tar.xz";
hash = "sha256-h59UhUG/7biN8NaDiGK6kXDqfhR9uMzt8CpwbJ+PpEM=";
};
postPatch = ''
substituteInPlace Makefile \
--replace-fail /usr/local/pgsql ${lib.getDev postgresql} \
--replace-fail -L/usr/local/lib "" \
--replace-fail -I/usr/local/include ""
substituteInPlace tsja.c --replace-fail /usr/local/lib/mecab ${mecab}/lib/mecab
'';
buildInputs = [
mecab
postgresql
];
installPhase = ''
mkdir -p $out/lib $out/share/postgresql/extension
mv libtsja.so $out/lib
mv dbinit_libtsja.txt $out/share/postgresql/extension/libtsja_dbinit.sql
'';
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql = ''
\i ${finalAttrs.finalPackage}/share/postgresql/extension/libtsja_dbinit.sql
'';
asserts = [
{
query = "EXISTS (SELECT 1 FROM ts_debug('japanese', 'PostgreSQL') WHERE lexemes = '{}')";
expected = "true";
description = "make sure '' is parsed as a separate lexeme";
}
];
};
meta = {
description = "PostgreSQL extension implementing Japanese text search";
homepage = "https://www.amris.jp/tsja/index.html";
maintainers = with lib.maintainers; [ chayleaf ];
# GNU-specific linker options are used
platforms = lib.platforms.gnu;
license = lib.licenses.gpl2Only;
};
})

View File

@@ -0,0 +1,29 @@
diff --git a/crates/simd/build.rs b/crates/simd/build.rs
index 12ce198..aed5588 100644
--- a/crates/simd/build.rs
+++ b/crates/simd/build.rs
@@ -17,17 +17,24 @@ use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
println!("cargo::rerun-if-changed=cshim");
+ println!("cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS");
let target_arch = var("CARGO_CFG_TARGET_ARCH")?;
match target_arch.as_str() {
"aarch64" => {
let mut build = cc::Build::new();
build.file("./cshim/aarch64.c");
+ build.compiler("@clang@");
+ // read env var set by rustPlatform.bindgenHook
+ build.try_flags_from_environment("BINDGEN_EXTRA_CLANG_ARGS").expect("the BINDGEN_EXTRA_CLANG_ARGS environment variable must be specified and UTF-8");
build.opt_level(3);
build.compile("simd_cshim");
}
"x86_64" => {
let mut build = cc::Build::new();
build.file("./cshim/x86_64.c");
+ build.compiler("@clang@");
+ // read env var set by rustPlatform.bindgenHook
+ build.try_flags_from_environment("BINDGEN_EXTRA_CLANG_ARGS").expect("the BINDGEN_EXTRA_CLANG_ARGS environment variable must be specified and UTF-8");
build.opt_level(3);
build.compile("simd_cshim");
}

View File

@@ -0,0 +1,24 @@
diff --git a/crates/algorithm/src/lib.rs b/crates/algorithm/src/lib.rs
index 853a280..f88acbf 100644
--- a/crates/algorithm/src/lib.rs
+++ b/crates/algorithm/src/lib.rs
@@ -13,6 +13,7 @@
// Copyright (c) 2025 TensorChord Inc.
#![feature(select_unpredictable)]
+#![feature(let_chains)]
#![allow(clippy::type_complexity)]
mod build;
diff --git a/src/lib.rs b/src/lib.rs
index 654b4d1..2b11d03 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -13,6 +13,7 @@
// Copyright (c) 2025 TensorChord Inc.
#![allow(unsafe_code)]
+#![feature(let_chains)]
mod datatype;
mod index;

Some files were not shown because too many files have changed in this diff Show More