Skip to content

Commit cb95314

Browse files
pashkinelfesamrose
andauthored
feat: add our updated fork of pg_backtrace (supabase#1098)
* feat: add our updated fork of pg_backtrace * Fix nix tests + use version 1.1 * test: use postgres release version for docker tag (supabase#1099) * test: use postgres release version for docker tag * fix: ref the var correct * fix: use correct Dockerfile --------- Co-authored-by: Sam Rose <samuel@supabase.io>
1 parent 570dbb3 commit cb95314

File tree

9 files changed

+53
-12
lines changed

9 files changed

+53
-12
lines changed

.github/workflows/test.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
POSTGRES_PASSWORD: password
2424
steps:
2525
- uses: actions/checkout@v3
26+
- id: settings
27+
# Remove spaces and quotes to get the raw version string
28+
run: sed -r 's/(\s|\")+//g' common-nix.vars.pkr.hcl >> $GITHUB_OUTPUT
29+
2630
- id: args
2731
uses: mikefarah/yq@master
2832
with:
@@ -36,23 +40,23 @@ jobs:
3640
with:
3741
load: true
3842
context: .
43+
file: "Dockerfile-156"
3944
target: production
4045
build-args: |
4146
${{ steps.args.outputs.result }}
42-
tags: supabase/postgres:latest
47+
tags: supabase/postgres:${{ steps.settings.outputs.postgres-version }}
4348
cache-from: |
44-
type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
45-
type=gha,scope=${{ github.base_ref }}-latest-${{ matrix.arch }}
46-
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
49+
type=gha,scope=${{ github.ref_name }}-${{ steps.settings.outputs.postgres-version }}-${{ matrix.arch }}
50+
type=gha,scope=${{ github.base_ref }}-${{ steps.settings.outputs.postgres-version }}-${{ matrix.arch }}
51+
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-${{ steps.settings.outputs.postgres-version }}-${{ matrix.arch }}
4752

4853
- name: Start Postgres
4954
run: |
5055
docker run --rm --pull=never \
5156
-e POSTGRES_PASSWORD=${{ env.POSTGRES_PASSWORD }} \
5257
-p ${{ env.POSTGRES_PORT }}:5432 \
5358
--name supabase_postgres \
54-
-d supabase/postgres:latest
55-
59+
-d supabase/postgres:${{ steps.settings.outputs.postgres-version }}
5660
- name: Install psql
5761
run: |
5862
sudo apt update

ansible/files/postgresql_config/postgresql.conf.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ default_text_search_config = 'pg_catalog.english'
688688
#local_preload_libraries = ''
689689
#session_preload_libraries = ''
690690

691-
shared_preload_libraries = 'pg_stat_statements, pg_stat_monitor, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, pg_tle, plan_filter' # (change requires restart)
691+
shared_preload_libraries = 'pg_stat_statements, pg_stat_monitor, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, pg_tle, plan_filter, pg_backtrace' # (change requires restart)
692692
jit_provider = 'llvmjit' # JIT library to use
693693

694694
# - Other Defaults -

common-nix.vars.pkr.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.6.1.104"
1+
postgres-version = "15.6.1.106"

common.vars.pkr.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.1.1.86"
1+
postgres-version = "15.1.1.88"

flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
./nix/ext/postgis.nix
103103
./nix/ext/pgrouting.nix
104104
./nix/ext/pgtap.nix
105+
./nix/ext/pg_backtrace.nix
105106
./nix/ext/pg_cron.nix
106107
./nix/ext/pgsql-http.nix
107108
./nix/ext/pg_plan_filter.nix

nix/ext/pg_backtrace.nix

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{ lib, stdenv, fetchFromGitHub, postgresql }:
2+
3+
stdenv.mkDerivation rec {
4+
pname = "pg_backtrace";
5+
version = "1.1";
6+
7+
buildInputs = [ postgresql ];
8+
9+
src = fetchFromGitHub {
10+
owner = "pashkinelfe";
11+
repo = pname;
12+
rev = "d100bac815a7365e199263f5b3741baf71b14c70";
13+
hash = "sha256-IVCL4r4oj1Ams03D8y+XCFkckPFER/W9tQ68GkWQQMY=";
14+
};
15+
16+
makeFlags = [ "USE_PGXS=1" ];
17+
18+
installPhase = ''
19+
mkdir -p $out/{lib,share/postgresql/extension}
20+
21+
cp *.so $out/lib
22+
cp *.sql $out/share/postgresql/extension
23+
cp *.control $out/share/postgresql/extension
24+
'';
25+
26+
meta = with lib; {
27+
description = "Updated fork of pg_backtrace";
28+
homepage = "https://github.com/pashkinelfe/pg_backtrace";
29+
maintainers = with maintainers; [ samrose ];
30+
platforms = postgresql.meta.platforms;
31+
license = licenses.postgresql;
32+
};
33+
}

nix/tests/expected/extensions_sql_interface.out

+4-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ order by
7272
moddatetime | t
7373
old_snapshot | t
7474
pageinspect | t
75+
pg_backtrace | t
7576
pg_buffercache | t
7677
pg_freespacemap | t
7778
pg_graphql | f
@@ -120,7 +121,7 @@ order by
120121
vector | t
121122
wrappers | f
122123
xml2 | f
123-
(77 rows)
124+
(78 rows)
124125

125126
/*
126127

@@ -1100,6 +1101,7 @@ order by
11001101
pageinspect | public | page_header | page bytea, OUT lsn pg_lsn, OUT checksum smallint, OUT flags smallint, OUT lower integer, OUT upper integer, OUT special integer, OUT pagesize integer, OUT version smallint, OUT prune_xid xid | record
11011102
pageinspect | public | tuple_data_split | rel_oid oid, t_data bytea, t_infomask integer, t_infomask2 integer, t_bits text | bytea[]
11021103
pageinspect | public | tuple_data_split | rel_oid oid, t_data bytea, t_infomask integer, t_infomask2 integer, t_bits text, do_detoast boolean | bytea[]
1104+
pg_backtrace | public | pg_backtrace_init | | void
11031105
pg_buffercache | public | pg_buffercache_pages | | SETOF record
11041106
pg_freespacemap | public | pg_freespace | regclass, bigint | smallint
11051107
pg_freespacemap | public | pg_freespace | rel regclass, OUT blkno bigint, OUT avail smallint | SETOF record
@@ -5090,7 +5092,7 @@ order by
50905092
xml2 | public | xpath_table | text, text, text, text, text | SETOF record
50915093
xml2 | public | xslt_process | text, text | text
50925094
xml2 | public | xslt_process | text, text, text | text
5093-
(4940 rows)
5095+
(4941 rows)
50945096

50955097
/*
50965098

nix/tests/postgresql.conf.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ default_text_search_config = 'pg_catalog.english'
718718

719719
#local_preload_libraries = ''
720720
#session_preload_libraries = ''
721-
shared_preload_libraries = 'pg_stat_statements, pg_stat_monitor, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, pg_tle, plan_filter' # (change requires restart)
721+
shared_preload_libraries = 'pg_stat_statements, pg_stat_monitor, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, pgsodium, timescaledb, auto_explain, pg_tle, plan_filter, pg_backtrace' # (change requires restart)
722722
jit_provider = 'llvmjit' # JIT library to use
723723

724724

nix/tests/prime.sql

+1
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,4 @@ create extension xml2;
9999

100100

101101

102+
CREATE EXTENSION IF NOT EXISTS pg_backtrace;

0 commit comments

Comments
 (0)