-
Notifications
You must be signed in to change notification settings - Fork 882
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove regprocedure oid type from catalog
In #6624 we refactored the time bucket catalog table to make it more generic and save information for all Continuous Aggregates. Previously it stored only variable bucket size information. The problem is we used the `regprocedure` type to store the OID of the given time bucket function but unfortunately it is not supported by `pg_upgrade`. Fixed it by changing the column to TEXT and resolve to/from OID using builtin `regprocedurein` and `format_procedure_qualified` functions. Fixes #6935
- Loading branch information
1 parent
1d7bd07
commit 8b994c7
Showing
18 changed files
with
319 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixes: #6940 Fix `pg_upgrade` failure by removing `regprocedure` from catalog table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
CREATE TABLE _timescaledb_catalog._tmp_continuous_aggs_bucket_function AS | ||
SELECT | ||
mat_hypertable_id, | ||
bucket_func::text AS bucket_func, | ||
bucket_width, | ||
bucket_origin, | ||
bucket_offset, | ||
bucket_timezone, | ||
bucket_fixed_width | ||
FROM | ||
_timescaledb_catalog.continuous_aggs_bucket_function | ||
ORDER BY | ||
mat_hypertable_id; | ||
|
||
ALTER EXTENSION timescaledb | ||
DROP TABLE _timescaledb_catalog.continuous_aggs_bucket_function; | ||
|
||
DROP TABLE _timescaledb_catalog.continuous_aggs_bucket_function; | ||
|
||
CREATE TABLE _timescaledb_catalog.continuous_aggs_bucket_function ( | ||
mat_hypertable_id integer NOT NULL, | ||
-- The bucket function | ||
bucket_func text NOT NULL, | ||
-- `bucket_width` argument of the function, e.g. "1 month" | ||
bucket_width text NOT NULL, | ||
-- optional `origin` argument of the function provided by the user | ||
bucket_origin text, | ||
-- optional `offset` argument of the function provided by the user | ||
bucket_offset text, | ||
-- optional `timezone` argument of the function provided by the user | ||
bucket_timezone text, | ||
-- fixed or variable sized bucket | ||
bucket_fixed_width bool NOT NULL, | ||
-- table constraints | ||
CONSTRAINT continuous_aggs_bucket_function_pkey PRIMARY KEY (mat_hypertable_id), | ||
CONSTRAINT continuous_aggs_bucket_function_mat_hypertable_id_fkey FOREIGN KEY (mat_hypertable_id) REFERENCES _timescaledb_catalog.hypertable (id) ON DELETE CASCADE, | ||
CONSTRAINT continuous_aggs_bucket_function_func_check CHECK (pg_catalog.to_regprocedure(bucket_func) IS DISTINCT FROM 0) | ||
); | ||
|
||
INSERT INTO _timescaledb_catalog.continuous_aggs_bucket_function | ||
SELECT * FROM _timescaledb_catalog._tmp_continuous_aggs_bucket_function; | ||
|
||
DROP TABLE _timescaledb_catalog._tmp_continuous_aggs_bucket_function; | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.continuous_aggs_bucket_function', ''); | ||
|
||
GRANT SELECT ON TABLE _timescaledb_catalog.continuous_aggs_bucket_function TO PUBLIC; | ||
|
||
ANALYZE _timescaledb_catalog.continuous_aggs_bucket_function; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
CREATE TABLE _timescaledb_catalog._tmp_continuous_aggs_bucket_function AS | ||
SELECT | ||
mat_hypertable_id, | ||
pg_catalog.to_regprocedure(bucket_func) AS bucket_func, | ||
bucket_width, | ||
bucket_origin, | ||
bucket_offset, | ||
bucket_timezone, | ||
bucket_fixed_width | ||
FROM | ||
_timescaledb_catalog.continuous_aggs_bucket_function | ||
ORDER BY | ||
mat_hypertable_id; | ||
|
||
ALTER EXTENSION timescaledb | ||
DROP TABLE _timescaledb_catalog.continuous_aggs_bucket_function; | ||
|
||
DROP TABLE _timescaledb_catalog.continuous_aggs_bucket_function; | ||
|
||
CREATE TABLE _timescaledb_catalog.continuous_aggs_bucket_function ( | ||
mat_hypertable_id integer NOT NULL, | ||
-- The bucket function | ||
bucket_func regprocedure NOT NULL, | ||
-- `bucket_width` argument of the function, e.g. "1 month" | ||
bucket_width text NOT NULL, | ||
-- optional `origin` argument of the function provided by the user | ||
bucket_origin text, | ||
-- optional `offset` argument of the function provided by the user | ||
bucket_offset text, | ||
-- optional `timezone` argument of the function provided by the user | ||
bucket_timezone text, | ||
-- fixed or variable sized bucket | ||
bucket_fixed_width bool NOT NULL, | ||
-- table constraints | ||
CONSTRAINT continuous_aggs_bucket_function_pkey PRIMARY KEY (mat_hypertable_id), | ||
CONSTRAINT continuous_aggs_bucket_function_mat_hypertable_id_fkey FOREIGN KEY (mat_hypertable_id) REFERENCES _timescaledb_catalog.hypertable (id) ON DELETE CASCADE | ||
); | ||
|
||
INSERT INTO _timescaledb_catalog.continuous_aggs_bucket_function | ||
SELECT * FROM _timescaledb_catalog._tmp_continuous_aggs_bucket_function; | ||
|
||
DROP TABLE _timescaledb_catalog._tmp_continuous_aggs_bucket_function; | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.continuous_aggs_bucket_function', ''); | ||
|
||
GRANT SELECT ON TABLE _timescaledb_catalog.continuous_aggs_bucket_function TO PUBLIC; | ||
|
||
ANALYZE _timescaledb_catalog.continuous_aggs_bucket_function; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.