Skip to content

Commit

Permalink
add pg_monitor permissions (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuckHend authored Sep 4, 2024
1 parent a7db92a commit 75f3f0a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion extension/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vectorize"
version = "0.18.1"
version = "0.18.2"
edition = "2021"
publish = false

Expand Down
2 changes: 1 addition & 1 deletion extension/Trunk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "The simplest way to orchestrate vector search on Postgres."
homepage = "https://github.com/tembo-io/pg_vectorize"
documentation = "https://github.com/tembo-io/pg_vectorize"
categories = ["orchestration", "machine_learning"]
version = "0.18.1"
version = "0.18.2"
loadable_libraries = [{ library_name = "vectorize", requires_restart = true }]

[build]
Expand Down
8 changes: 8 additions & 0 deletions extension/sql/meta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ CREATE TABLE vectorize.prompts (
user_prompt TEXT NOT NULL
);

-- allow pg_monitor to read from vectorize schema
GRANT USAGE ON SCHEMA vectorize TO pg_monitor;
GRANT SELECT ON ALL TABLES IN SCHEMA vectorize TO pg_monitor;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA vectorize TO pg_monitor;
ALTER DEFAULT PRIVILEGES IN SCHEMA vectorize GRANT SELECT ON TABLES TO pg_monitor;
ALTER DEFAULT PRIVILEGES IN SCHEMA vectorize GRANT SELECT ON SEQUENCES TO pg_monitor;


INSERT INTO vectorize.prompts (prompt_type, sys_prompt, user_prompt)
VALUES (
'question_answer',
Expand Down
5 changes: 5 additions & 0 deletions extension/sql/vectorize--0.18.1--0.18.2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GRANT USAGE ON SCHEMA vectorize TO pg_monitor;
GRANT SELECT ON ALL TABLES IN SCHEMA vectorize TO pg_monitor;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA vectorize TO pg_monitor;
ALTER DEFAULT PRIVILEGES IN SCHEMA vectorize GRANT SELECT ON TABLES TO pg_monitor;
ALTER DEFAULT PRIVILEGES IN SCHEMA vectorize GRANT SELECT ON SEQUENCES TO pg_monitor;
2 changes: 1 addition & 1 deletion extension/src/guc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub fn get_guc(guc: VectorizeGuc) -> Option<String> {
error!("failed to convert CStr to str");
}
} else {
info!("no value set for GUC: {:?}", guc);
debug1!("no value set for GUC: {:?}", guc);
None
}
}
Expand Down
4 changes: 2 additions & 2 deletions extension/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pub fn init_pgmq() -> Result<()> {
))?
.context("error checking if queue exists")?;
if queue_exists {
info!("queue already exists");
debug1!("queue already exists");
return Ok(());
} else {
info!("creating queue;");
debug1!("creating queue;");
let ran: Result<_, spi::Error> = Spi::connect(|mut c| {
let _r = c.update(
&format!("SELECT pgmq.create('{VECTORIZE_QUEUE}');"),
Expand Down
1 change: 0 additions & 1 deletion extension/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub fn init_table(
init::init_pgmq()?;

let guc_configs = get_guc_configs(&transformer.source);
info!("guc_configs: {:?}", guc_configs);
// validate API key where necessary and collect any optional arguments
// certain embedding services require an API key, e.g. openAI
// key can be set in a GUC, so if its required but not provided in args, and not in GUC, error
Expand Down

0 comments on commit 75f3f0a

Please sign in to comment.