Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 10e99b1

Browse files
authored
Merge pull request #24 from supabase/or/citus
Citus extension
2 parents 65eaf49 + c8fb92f commit 10e99b1

File tree

5 files changed

+71
-1
lines changed

5 files changed

+71
-1
lines changed

ext/citus.nix

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{ lib, curl, lz4, zstd, krb5, icu, stdenv, fetchFromGitHub, postgresql }:
2+
3+
stdenv.mkDerivation rec {
4+
pname = "citus";
5+
version = "12.0.0";
6+
7+
buildInputs = [ curl lz4 zstd krb5 icu.dev postgresql];
8+
9+
src = fetchFromGitHub {
10+
owner = "citusdata";
11+
repo = pname;
12+
rev = "refs/tags/v${version}";
13+
hash = "sha256-HH9/slsCRe2yIVIqwR8sDyqXFonf8BHhJhLzHNv1CF0=";
14+
};
15+
16+
installPhase = ''
17+
mkdir -p $out/{lib,share/postgresql/extension}
18+
19+
cp src/backend/columnar/citus_columnar.so $out/lib
20+
cp src/backend/columnar/citus_columnar.control $out/share/postgresql/extension
21+
cp src/backend/columnar/build/sql/*.sql $out/share/postgresql/extension
22+
23+
cp src/backend/distributed/citus.so $out/lib
24+
cp src/backend/distributed/citus.control $out/share/postgresql/extension
25+
cp src/backend/distributed/build/sql/*.sql $out/share/postgresql/extension
26+
'';
27+
28+
meta = with lib; {
29+
description = "Distributed PostgreSQL as an extension";
30+
homepage = "https://github.com/citusdata/${pname}";
31+
maintainers = with maintainers; [ olirice ];
32+
platforms = postgresql.meta.platforms;
33+
license = licenses.agpl3Plus;
34+
};
35+
}

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
# rollout new versions of these critical things easier without having to
8888
# go through the upstream release engineering process.
8989
ourExtensions = [
90+
./ext/citus.nix
9091
./ext/pgsql-http.nix
9192
./ext/pg_plan_filter.nix
9293
./ext/pg_net.nix

tests/postgresql.conf.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ default_text_search_config = 'pg_catalog.english'
717717

718718
#local_preload_libraries = ''
719719
#session_preload_libraries = ''
720-
shared_preload_libraries = 'auto_explain,pgsodium'
720+
shared_preload_libraries = 'citus,auto_explain,pgsodium'
721721
#jit_provider = 'llvmjit' # JIT library to use
722722

723723
# - Other Defaults -

tests/prime.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ CREATE EXTENSION IF NOT EXISTS wrappers;
1818
CREATE EXTENSION IF NOT EXISTS http;
1919
CREATE EXTENSION IF NOT EXISTS pg_graphql;
2020
CREATE EXTENSION IF NOT EXISTS pg_jsonschema;
21+
22+
CREATE EXTENSION IF NOT EXISTS citus;

tests/smoke/0004-citus.sql

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
BEGIN;
2+
3+
select plan(3);
4+
5+
SELECT lives_ok($$
6+
CREATE TABLE events (
7+
device_id bigint,
8+
event_id bigserial,
9+
event_time timestamptz default now(),
10+
data jsonb not null,
11+
PRIMARY KEY (device_id, event_id)
12+
);
13+
$$);
14+
15+
-- citus distributed test
16+
SELECT lives_ok($$
17+
SELECT create_distributed_table('events', 'device_id');
18+
$$);
19+
20+
-- citus columnar test
21+
SELECT lives_ok($$
22+
CREATE TABLE events_columnar (
23+
device_id bigint,
24+
event_id bigserial,
25+
event_time timestamptz default now(),
26+
data jsonb not null
27+
)
28+
USING columnar;
29+
$$);
30+
31+
SELECT * FROM finish();
32+
ROLLBACK;

0 commit comments

Comments
 (0)