From e0eb7c060792c72a6dc23181f78484ef2899fc65 Mon Sep 17 00:00:00 2001 From: xieydd Date: Sun, 7 Apr 2024 20:18:27 +0800 Subject: [PATCH 1/2] chore: Add document about enable pgvecto.rs extension when database initialization Signed-off-by: xieydd --- Dockerfile | 4 ---- README.md | 13 +++++++++++++ install-pgvectors.sql | 2 -- 3 files changed, 13 insertions(+), 6 deletions(-) delete mode 100644 install-pgvectors.sql diff --git a/Dockerfile b/Dockerfile index 1c2cfc2..be412e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,3 @@ RUN apt install ./pgvectors.deb USER postgres -# From https://stackoverflow.com/a/42508925 -# Note that this way of enabling the plugin only works on database init -# We should investigate alternative ways of enabling it that will always work -COPY install-pgvectors.sql /docker-entrypoint-initdb.d/ diff --git a/README.md b/README.md index 9c15ade..5cca143 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,16 @@ Container images for [cloudnative-pg](https://cloudnative-pg.io/) with the [pgve > shared_preload_libraries: > - "vectors.so" > ``` + +> [!IMPORTANT] +> The `pgvecto.rs` extension is not enabled by default. You need to enable it and set the search path when database initialization. You can configure it in your Cluster spec: +> ```yaml +> apiVersion: postgresql.cnpg.io/v1 +> kind: Cluster +> spec: +> (...) +> bootstrap: +> initdb: +> postInitSQL: +> - ALTER SYSTEM SET search_path TO "$user", public, vectors; +> - CREATE EXTENSION IF NOT EXISTS "vectors"; \ No newline at end of file diff --git a/install-pgvectors.sql b/install-pgvectors.sql deleted file mode 100644 index f757434..0000000 --- a/install-pgvectors.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER SYSTEM SET shared_preload_libraries = "vectors.so" -ALTER SYSTEM SET search_path = "$user", public, vectors From bc824958859d976aac9faa76d3e46015fab3697a Mon Sep 17 00:00:00 2001 From: bo0tzz Date: Sun, 7 Apr 2024 15:34:26 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Signed-off-by: bo0tzz --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5cca143..bf974ca 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,14 @@ Container images for [cloudnative-pg](https://cloudnative-pg.io/) with the [pgve > ``` > [!IMPORTANT] -> The `pgvecto.rs` extension is not enabled by default. You need to enable it and set the search path when database initialization. You can configure it in your Cluster spec: +> The `pgvecto.rs` extension is not enabled by default. You need to enable it and set the search path when initializing the database. You can configure it in your Cluster spec: > ```yaml > apiVersion: postgresql.cnpg.io/v1 > kind: Cluster > spec: > (...) > bootstrap: -> initdb: +> initdb: > postInitSQL: -> - ALTER SYSTEM SET search_path TO "$user", public, vectors; -> - CREATE EXTENSION IF NOT EXISTS "vectors"; \ No newline at end of file +> - ALTER SYSTEM SET search_path TO "$user", public, vectors; +> - CREATE EXTENSION IF NOT EXISTS "vectors"; \ No newline at end of file