From 70cd3b0c5c4b571888ff1daec9ef36273772e0a1 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 31 Jul 2023 11:28:25 +0200 Subject: [PATCH] Fix quoting owners in sql scripts. When referring to a role from a string type, it must be properly quoted using pg_catalog.quote_ident before it can be casted to regrole. Fixed this, especially in update scripts. --- .unreleased/PR_5906 | 3 +++ sql/updates/2.10.1--2.10.2.sql | 6 +++--- sql/updates/2.11.0--2.10.3.sql | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .unreleased/PR_5906 diff --git a/.unreleased/PR_5906 b/.unreleased/PR_5906 new file mode 100644 index 00000000000..d1ba94459d3 --- /dev/null +++ b/.unreleased/PR_5906 @@ -0,0 +1,3 @@ +Fixes: #5906 Fix quoting owners in sql scripts. + +Thanks: @mrksngl diff --git a/sql/updates/2.10.1--2.10.2.sql b/sql/updates/2.10.1--2.10.2.sql index 56ad15acd78..43e9c16040e 100644 --- a/sql/updates/2.10.1--2.10.2.sql +++ b/sql/updates/2.10.1--2.10.2.sql @@ -11,8 +11,8 @@ DROP VIEW IF EXISTS timescaledb_experimental.policies; ALTER TABLE _timescaledb_config.bgw_job ALTER COLUMN owner DROP DEFAULT, - ALTER COLUMN owner TYPE regrole USING owner::regrole, - ALTER COLUMN owner SET DEFAULT current_role::regrole; + ALTER COLUMN owner TYPE regrole USING pg_catalog.quote_ident(owner)::regrole, + ALTER COLUMN owner SET DEFAULT pg_catalog.quote_ident(current_role)::regrole; CREATE TABLE _timescaledb_config.bgw_job_tmp AS SELECT * FROM _timescaledb_config.bgw_job; ALTER EXTENSION timescaledb DROP TABLE _timescaledb_config.bgw_job; @@ -40,7 +40,7 @@ CREATE TABLE _timescaledb_config.bgw_job ( retry_period interval NOT NULL, proc_schema name NOT NULL, proc_name name NOT NULL, - owner regrole NOT NULL DEFAULT current_role::regrole, + owner regrole NOT NULL DEFAULT pg_catalog.quote_ident(current_role)::regrole, scheduled bool NOT NULL DEFAULT TRUE, fixed_schedule bool not null default true, initial_start timestamptz, diff --git a/sql/updates/2.11.0--2.10.3.sql b/sql/updates/2.11.0--2.10.3.sql index 0bb88052325..9bdd7ab019d 100644 --- a/sql/updates/2.11.0--2.10.3.sql +++ b/sql/updates/2.11.0--2.10.3.sql @@ -198,7 +198,7 @@ END $BODY$ SET search_path TO pg_catalog, pg_temp; ALTER TABLE _timescaledb_config.bgw_job - ALTER COLUMN owner SET DEFAULT current_role::regrole; + ALTER COLUMN owner SET DEFAULT pg_catalog.quote_ident(current_role)::regrole; -- Rebuild the _timescaledb_catalog.continuous_agg_migrate_plan_step definition ALTER TABLE _timescaledb_catalog.continuous_agg_migrate_plan_step