Skip to content

Commit

Permalink
add Trusted Language Extensions (#405)
Browse files Browse the repository at this point in the history
* add flex, fix copy pasta.

* chore: pg_tle in Docker (#542)

* chore: set pg_tle as 29th extension

* chore: place pg_tle in vars.yml

* chore: add pg_tle to Dockerfile

* chore: bump version

* chore: new line

* chore: add test for pg_tle

* fix: remove specified schema

* chore: update sql test formatting

---------

Co-authored-by: Han Qiao <[email protected]>

* chore: update release checksum

* Update ansible/Dockerfile

* fix: reinstate pg_tle in docker (#556)

* fix: reinstate pg_tle in Dockerfile

* fix

* fix: put back flex

---------

Co-authored-by: dragarcia <[email protected]>
Co-authored-by: Han Qiao <[email protected]>
  • Loading branch information
3 people authored Feb 22, 2023
1 parent 65b709f commit 141e7da
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 2 deletions.
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ARG wrappers_release=0.1.7
ARG hypopg_release=1.3.1
ARG pg_repack_release=1.4.8
ARG pgvector_release=0.4.0
ARG pg_tle_release=1.0.1

FROM postgres:${postgresql_release} as base
# Redeclare args for use in subsequent stages
Expand Down Expand Up @@ -692,6 +693,27 @@ RUN --mount=type=cache,target=/ccache,from=public.ecr.aws/supabase/postgres:ccac
# Create debian package
RUN checkinstall -D --install=no --fstrans=no --backup=no --pakdir=/tmp --nodoc

####################
# 29-pg_tle.yml
####################
FROM ccache as pg_tle
ARG pg_tle_release
ARG pg_tle_release_checksum
ADD --checksum=${pg_tle_release_checksum} \
"https://github.com/aws/pg_tle/archive/refs/tags/v${pg_tle_release}.tar.gz" \
/tmp/pg_tle.tar.gz
RUN tar -xvf /tmp/pg_tle.tar.gz -C /tmp && \
rm -rf /tmp/pg_tle.tar.gz
RUN apt-get update && apt-get install -y --no-install-recommends \
flex \
&& rm -rf /var/lib/apt/lists/*
# Build from source
WORKDIR /tmp/pg_tle-${pg_tle_release}
RUN --mount=type=cache,target=/ccache,from=public.ecr.aws/supabase/postgres:ccache \
make -j$(nproc)
# Create debian package
RUN checkinstall -D --install=no --fstrans=no --backup=no --pakdir=/tmp --nodoc

####################
# Collect extension packages
####################
Expand Down Expand Up @@ -723,6 +745,7 @@ COPY --from=wrappers /tmp/*.deb /tmp/
COPY --from=hypopg /tmp/*.deb /tmp/
COPY --from=pg_repack /tmp/*.deb /tmp/
COPY --from=pgvector /tmp/*.deb /tmp/
COPY --from=pg_tle /tmp/*.deb /tmp/

####################
# Build final image
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' # (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' # (change requires restart)
jit_provider = 'llvmjit' # JIT library to use

# - Other Defaults -
Expand Down
12 changes: 12 additions & 0 deletions ansible/tasks/postgres-extensions/29-pg_tle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# pg_tle
- name: pg_tle - download
git:
repo: https://github.com/aws/pg_tle.git
dest: /tmp/pg_tle
version: v{{ pg_tle_release }}

- name: pg_tle - install
make:
chdir: /tmp/pg_tle
target: install
become: yes
3 changes: 3 additions & 0 deletions ansible/tasks/setup-extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
- name: Install pgvector
import_tasks: tasks/postgres-extensions/28-pgvector.yml

- name: Install Trusted Language Extensions
import_tasks: tasks/postgres-extensions/29-pg_tle.yml

- name: Verify async task status
import_tasks: tasks/postgres-extensions/99-finish_async_tasks.yml
when: async_mode
3 changes: 3 additions & 0 deletions ansible/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,6 @@ pg_repack_release_checksum: sha256:18b4d871c1abf78cf0b1b1fe6081d435d183a8dc5eb97

pgvector_release: "0.4.0"
pgvector_release_checksum: sha256:b76cf84ddad452cc880a6c8c661d137ddd8679c000a16332f4f03ecf6e10bcc8

pg_tle_release: "1.0.1"
pg_tle_release_checksum: sha256:c536b818ffcda478c2ea67d2cd30c70cab1fecdc3dd8146a5411377ba5f12950
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.0.44"
postgres-version = "15.1.0.45"
1 change: 1 addition & 0 deletions migrations/tests/extensions/29-pg_tle.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create extension if not exists pg_tle;
1 change: 1 addition & 0 deletions migrations/tests/extensions/test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
\ir 26-hypopg.sql
\ir 27-pg_repack.sql
\ir 28-pgvector.sql
\ir 29-pg_tle.sql

0 comments on commit 141e7da

Please sign in to comment.