mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-18 03:23:37 +08:00
Disallow triggers on CAggs
We don't support triggers on CAggs yet. Disallow that explicitly till we support them later. Fixes #6500
This commit is contained in:
parent
095504938d
commit
7ae7cc5713
2
.unreleased/fix_6522
Normal file
2
.unreleased/fix_6522
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Fixes: #6522 Disallow triggers on CAggs
|
||||||
|
Thanks: @HollowMan6 Thanks for reporting this issue
|
@ -3851,12 +3851,19 @@ process_create_trigger_start(ProcessUtilityArgs *args)
|
|||||||
Cache *hcache;
|
Cache *hcache;
|
||||||
Hypertable *ht;
|
Hypertable *ht;
|
||||||
ObjectAddress PG_USED_FOR_ASSERTS_ONLY address;
|
ObjectAddress PG_USED_FOR_ASSERTS_ONLY address;
|
||||||
|
Oid relid = RangeVarGetRelid(stmt->relation, NoLock, true);
|
||||||
|
|
||||||
hcache = ts_hypertable_cache_pin();
|
hcache = ts_hypertable_cache_pin();
|
||||||
ht = ts_hypertable_cache_get_entry_rv(hcache, stmt->relation);
|
ht = ts_hypertable_cache_get_entry(hcache, relid, CACHE_FLAG_MISSING_OK);
|
||||||
if (ht == NULL)
|
if (ht == NULL)
|
||||||
{
|
{
|
||||||
ts_cache_release(hcache);
|
ts_cache_release(hcache);
|
||||||
|
/* check if it's a cagg. We don't support triggers on them yet */
|
||||||
|
if (ts_continuous_agg_find_by_relid(relid) != NULL)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
|
errmsg("triggers are not supported on continuous aggregate")));
|
||||||
|
|
||||||
return DDL_CONTINUE;
|
return DDL_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,6 +321,14 @@ INNER JOIN _timescaledb_catalog.hypertable h ON(h.id = ca.mat_hypertable_id)
|
|||||||
WHERE user_view_name = 'mat_with_test'
|
WHERE user_view_name = 'mat_with_test'
|
||||||
\gset
|
\gset
|
||||||
\set ON_ERROR_STOP 0
|
\set ON_ERROR_STOP 0
|
||||||
|
-- triggers not allowed on continuous aggregate
|
||||||
|
CREATE OR REPLACE FUNCTION not_allowed() RETURNS trigger AS $$
|
||||||
|
BEGIN
|
||||||
|
RETURN NEW;
|
||||||
|
END; $$ LANGUAGE plpgsql;
|
||||||
|
CREATE TRIGGER not_allowed_trigger INSTEAD OF INSERT ON mat_with_test
|
||||||
|
FOR EACH ROW EXECUTE FUNCTION not_allowed();
|
||||||
|
ERROR: triggers are not supported on continuous aggregate
|
||||||
ALTER MATERIALIZED VIEW mat_with_test SET(timescaledb.create_group_indexes = 'false');
|
ALTER MATERIALIZED VIEW mat_with_test SET(timescaledb.create_group_indexes = 'false');
|
||||||
ERROR: cannot alter create_group_indexes option for continuous aggregates
|
ERROR: cannot alter create_group_indexes option for continuous aggregates
|
||||||
ALTER MATERIALIZED VIEW mat_with_test SET(timescaledb.create_group_indexes = 'true');
|
ALTER MATERIALIZED VIEW mat_with_test SET(timescaledb.create_group_indexes = 'true');
|
||||||
|
@ -290,6 +290,15 @@ WHERE user_view_name = 'mat_with_test'
|
|||||||
\gset
|
\gset
|
||||||
|
|
||||||
\set ON_ERROR_STOP 0
|
\set ON_ERROR_STOP 0
|
||||||
|
-- triggers not allowed on continuous aggregate
|
||||||
|
CREATE OR REPLACE FUNCTION not_allowed() RETURNS trigger AS $$
|
||||||
|
BEGIN
|
||||||
|
RETURN NEW;
|
||||||
|
END; $$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
CREATE TRIGGER not_allowed_trigger INSTEAD OF INSERT ON mat_with_test
|
||||||
|
FOR EACH ROW EXECUTE FUNCTION not_allowed();
|
||||||
|
|
||||||
ALTER MATERIALIZED VIEW mat_with_test SET(timescaledb.create_group_indexes = 'false');
|
ALTER MATERIALIZED VIEW mat_with_test SET(timescaledb.create_group_indexes = 'false');
|
||||||
ALTER MATERIALIZED VIEW mat_with_test SET(timescaledb.create_group_indexes = 'true');
|
ALTER MATERIALIZED VIEW mat_with_test SET(timescaledb.create_group_indexes = 'true');
|
||||||
ALTER MATERIALIZED VIEW mat_with_test ALTER timec DROP default;
|
ALTER MATERIALIZED VIEW mat_with_test ALTER timec DROP default;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user