timescale / timescaledb

An open-source time-series SQL database optimized for fast ingest and complex queries. Packaged as a PostgreSQL extension.
https://www.timescale.com/
Other
17.93k stars 882 forks source link

Backport to 2.17.x: #7434: Fix segfault when setting chunk replica identity #7442

Closed timescale-automation closed 1 week ago

timescale-automation commented 1 week ago

This is an automated backport of #7434: Fix segfault when setting chunk replica identity. The original issue is #7406. This PR will be merged automatically after all the relevant CI checks pass. If this fix should not be backported, or will be backported manually, just close this PR. You can use the backport branch to add your changes, it won't be modified automatically anymore.

For more details, please see the documentation

Original description

Fix segfault when setting chunk replica identity

The segfault happened executing AlterTableInternal for setting the REPLICA IDENTITY during chunk creation (introduced by https://github.com/timescale/timescaledb/issues/5512) that is dispatched by a trigger invoked by a DDL statement.

Fixed it by using our internal ts_alter_table_with_event_trigger handler function to setup the event trigger context.

Fixes #7406