Skip to content

Commit 396377d

Browse files
authored
[DPE-3159] Add pgvector extension/plugin (#313)
* add pgvector extension/plugin * fix charm unit tests * add pgvector integration test * fix lint test * Update snap to revision 95 to revision 96
1 parent 8407fde commit 396377d

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ options:
219219
default: false
220220
type: boolean
221221
description: Enable spi extension
222+
plugin_vector_enable:
223+
default: false
224+
type: boolean
225+
description: Enable pgvector extension
222226
profile:
223227
description: |
224228
Profile representing the scope of deployment, and used to tune resource allocation.

src/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class CharmConfig(BaseConfigModel):
6464
plugin_tsm_system_time_enable: bool
6565
plugin_uuid_ossp_enable: bool
6666
plugin_spi_enable: bool
67+
plugin_vector_enable: bool
6768
request_date_style: Optional[str]
6869
request_standard_conforming_strings: Optional[bool]
6970
request_time_zone: Optional[str]

src/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# Snap constants.
3333
PGBACKREST_EXECUTABLE = "charmed-postgresql.pgbackrest"
3434
POSTGRESQL_SNAP_NAME = "charmed-postgresql"
35-
SNAP_PACKAGES = [(POSTGRESQL_SNAP_NAME, {"revision": "95"})]
35+
SNAP_PACKAGES = [(POSTGRESQL_SNAP_NAME, {"revision": "96"})]
3636

3737
SNAP_COMMON_PATH = "/var/snap/charmed-postgresql/common"
3838
SNAP_CURRENT_PATH = "/var/snap/charmed-postgresql/current"

tests/integration/test_plugins.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
AUTOINC_EXTENSION_STATEMENT = "CREATE TABLE ids (id int4, idesc text);CREATE TRIGGER ids_nextid BEFORE INSERT OR UPDATE ON ids FOR EACH ROW EXECUTE PROCEDURE autoinc (id, next_id);"
5858
INSERT_USERNAME_EXTENSION_STATEMENT = "CREATE TABLE username_test (name text, username text not null);CREATE TRIGGER insert_usernames BEFORE INSERT OR UPDATE ON username_test FOR EACH ROW EXECUTE PROCEDURE insert_username (username);"
5959
MODDATETIME_EXTENSION_STATEMENT = "CREATE TABLE mdt (moddate timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL);CREATE TRIGGER mdt_moddatetime BEFORE UPDATE ON mdt FOR EACH ROW EXECUTE PROCEDURE moddatetime (moddate);"
60+
VECTOR_EXTENSION_STATEMENT = (
61+
"CREATE TABLE vector_test (id bigserial PRIMARY KEY, embedding vector(3));"
62+
)
6063

6164

6265
@pytest.mark.group(1)
@@ -110,6 +113,7 @@ async def test_plugins(ops_test: OpsTest) -> None:
110113
INSERT_USERNAME_EXTENSION_STATEMENT,
111114
MODDATETIME_EXTENSION_STATEMENT,
112115
],
116+
"plugin_vector_enable": VECTOR_EXTENSION_STATEMENT,
113117
}
114118

115119
def enable_disable_config(enabled: False):

tests/unit/test_charm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ def test_enable_disable_extensions(self, _):
396396
plugin_spi_enable:
397397
default: false
398398
type: boolean
399+
plugin_vector_enable:
400+
default: false
401+
type: boolean
399402
profile:
400403
default: production
401404
type: string"""

0 commit comments

Comments
 (0)