mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-15 18:13:18 +08:00
- Directory structure now matches common practices - Regression tests now run with pg_regress via the PGXS infrastructure. - Unit tests do not integrate well with pg_regress and have to be run separately. - Docker functionality is separate from main Makefile. Run with `make -f docker.mk` to build and `make -f docker.mk run` to run the database in a container.
27 lines
964 B
PL/PgSQL
27 lines
964 B
PL/PgSQL
CREATE OR REPLACE FUNCTION _iobeamdb_meta.on_change_partition()
|
|
RETURNS TRIGGER LANGUAGE PLPGSQL AS
|
|
$BODY$
|
|
BEGIN
|
|
IF TG_OP = 'INSERT' THEN
|
|
INSERT INTO _iobeamdb_catalog.partition_replica (partition_id, hypertable_id, replica_id, schema_name, table_name)
|
|
(SELECT
|
|
NEW.id,
|
|
hypertable_id,
|
|
replica_id,
|
|
h.associated_schema_name,
|
|
format('%s_%s_%s_partition', h.associated_table_prefix, NEW.id, replica_id)
|
|
FROM _iobeamdb_catalog.hypertable_replica hr
|
|
INNER JOIN _iobeamdb_catalog.hypertable h ON (h.id = hr.hypertable_id)
|
|
WHERE hypertable_id = (
|
|
SELECT hypertable_id
|
|
FROM _iobeamdb_catalog.partition_epoch
|
|
WHERE id = NEW.epoch_id
|
|
));
|
|
|
|
RETURN NEW;
|
|
END IF;
|
|
|
|
PERFORM _iobeamdb_internal.on_trigger_error(TG_OP, TG_TABLE_SCHEMA, TG_TABLE_NAME);
|
|
END
|
|
$BODY$;
|