Skip to content

Commit

Permalink
feat: add our updated fork of pg_backtrace (#1098)
Browse files Browse the repository at this point in the history
* feat: add our updated fork of pg_backtrace

* Fix nix tests + use version 1.1

* test: use postgres release version for docker tag (#1099)

* test: use postgres release version for docker tag

* fix: ref the var correct

* fix: use correct Dockerfile

---------

Co-authored-by: Sam Rose <[email protected]>
  • Loading branch information
pashkinelfe and samrose authored Aug 8, 2024
1 parent 570dbb3 commit cb95314
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 12 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
POSTGRES_PASSWORD: password
steps:
- uses: actions/checkout@v3
- id: settings
# Remove spaces and quotes to get the raw version string
run: sed -r 's/(\s|\")+//g' common-nix.vars.pkr.hcl >> $GITHUB_OUTPUT

- id: args
uses: mikefarah/yq@master
with:
Expand All @@ -36,23 +40,23 @@ jobs:
with:
load: true
context: .
file: "Dockerfile-156"
target: production
build-args: |
${{ steps.args.outputs.result }}
tags: supabase/postgres:latest
tags: supabase/postgres:${{ steps.settings.outputs.postgres-version }}
cache-from: |
type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
type=gha,scope=${{ github.base_ref }}-latest-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
type=gha,scope=${{ github.ref_name }}-${{ steps.settings.outputs.postgres-version }}-${{ matrix.arch }}
type=gha,scope=${{ github.base_ref }}-${{ steps.settings.outputs.postgres-version }}-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-${{ steps.settings.outputs.postgres-version }}-${{ matrix.arch }}

- name: Start Postgres
run: |
docker run --rm --pull=never \
-e POSTGRES_PASSWORD=${{ env.POSTGRES_PASSWORD }} \
-p ${{ env.POSTGRES_PORT }}:5432 \
--name supabase_postgres \
-d supabase/postgres:latest
-d supabase/postgres:${{ steps.settings.outputs.postgres-version }}
- name: Install psql
run: |
sudo apt update
Expand Down
2 changes: 1 addition & 1 deletion ansible/files/postgresql_config/postgresql.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ default_text_search_config = 'pg_catalog.english'
#local_preload_libraries = ''
#session_preload_libraries = ''

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)
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)
jit_provider = 'llvmjit' # JIT library to use

# - Other Defaults -
Expand Down
2 changes: 1 addition & 1 deletion common-nix.vars.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
postgres-version = "15.6.1.104"
postgres-version = "15.6.1.106"
2 changes: 1 addition & 1 deletion common.vars.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
postgres-version = "15.1.1.86"
postgres-version = "15.1.1.88"
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
./nix/ext/postgis.nix
./nix/ext/pgrouting.nix
./nix/ext/pgtap.nix
./nix/ext/pg_backtrace.nix
./nix/ext/pg_cron.nix
./nix/ext/pgsql-http.nix
./nix/ext/pg_plan_filter.nix
Expand Down
33 changes: 33 additions & 0 deletions nix/ext/pg_backtrace.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ lib, stdenv, fetchFromGitHub, postgresql }:

stdenv.mkDerivation rec {
pname = "pg_backtrace";
version = "1.1";

buildInputs = [ postgresql ];

src = fetchFromGitHub {
owner = "pashkinelfe";
repo = pname;
rev = "d100bac815a7365e199263f5b3741baf71b14c70";
hash = "sha256-IVCL4r4oj1Ams03D8y+XCFkckPFER/W9tQ68GkWQQMY=";
};

makeFlags = [ "USE_PGXS=1" ];

installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}
cp *.so $out/lib
cp *.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';

meta = with lib; {
description = "Updated fork of pg_backtrace";
homepage = "https://github.com/pashkinelfe/pg_backtrace";
maintainers = with maintainers; [ samrose ];
platforms = postgresql.meta.platforms;
license = licenses.postgresql;
};
}
6 changes: 4 additions & 2 deletions nix/tests/expected/extensions_sql_interface.out
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ order by
moddatetime | t
old_snapshot | t
pageinspect | t
pg_backtrace | t
pg_buffercache | t
pg_freespacemap | t
pg_graphql | f
Expand Down Expand Up @@ -120,7 +121,7 @@ order by
vector | t
wrappers | f
xml2 | f
(77 rows)
(78 rows)

/*

Expand Down Expand Up @@ -1100,6 +1101,7 @@ order by
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
pageinspect | public | tuple_data_split | rel_oid oid, t_data bytea, t_infomask integer, t_infomask2 integer, t_bits text | bytea[]
pageinspect | public | tuple_data_split | rel_oid oid, t_data bytea, t_infomask integer, t_infomask2 integer, t_bits text, do_detoast boolean | bytea[]
pg_backtrace | public | pg_backtrace_init | | void
pg_buffercache | public | pg_buffercache_pages | | SETOF record
pg_freespacemap | public | pg_freespace | regclass, bigint | smallint
pg_freespacemap | public | pg_freespace | rel regclass, OUT blkno bigint, OUT avail smallint | SETOF record
Expand Down Expand Up @@ -5090,7 +5092,7 @@ order by
xml2 | public | xpath_table | text, text, text, text, text | SETOF record
xml2 | public | xslt_process | text, text | text
xml2 | public | xslt_process | text, text, text | text
(4940 rows)
(4941 rows)

/*

Expand Down
2 changes: 1 addition & 1 deletion nix/tests/postgresql.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ default_text_search_config = 'pg_catalog.english'

#local_preload_libraries = ''
#session_preload_libraries = ''
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)
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)
jit_provider = 'llvmjit' # JIT library to use


Expand Down
1 change: 1 addition & 0 deletions nix/tests/prime.sql
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ create extension xml2;



CREATE EXTENSION IF NOT EXISTS pg_backtrace;

0 comments on commit cb95314

Please sign in to comment.