Skip to content

Enable copying tables with generated columns#466

Open
postsql wants to merge 1 commit into
2ndQuadrant:REL2_x_STABLEfrom
postsql:REL2_x_STABLE
Open

Enable copying tables with generated columns#466
postsql wants to merge 1 commit into
2ndQuadrant:REL2_x_STABLEfrom
postsql:REL2_x_STABLE

Conversation

@postsql

@postsql postsql commented Apr 3, 2024

Copy link
Copy Markdown

Skip generated columns as these are not COPY-able

Currently pglogical is unable to replicate tables with generated columns, this pull request fixes this

Skip generated columns as these are not COPY-able
@postsql postsql changed the title Update pglogical_functions.c Enable coying tables with generated columns Apr 3, 2024
@postsql postsql changed the title Enable coying tables with generated columns Enable copying tables with generated columns Apr 3, 2024
@nmisch nmisch self-assigned this May 23, 2025
@nmisch nmisch self-requested a review May 23, 2025 18:55
@nmisch nmisch removed their assignment May 23, 2025

@nmisch nmisch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable. How feasible is it to add test coverage?

@willibrandon

Copy link
Copy Markdown

This fix looks correct for the COPY path, but there are a couple of additional issues with generated columns beyond initial sync:

  1. fill_missing_defaults() in pglogical_apply_heap.c doesn't skip generated columns, so the apply worker can crash when it tries to build_column_default() for a generated column during ongoing replication.

  2. ExecComputeStoredGenerated() is never called during INSERT/UPDATE apply, so generated column values aren't being recomputed on the subscriber side.

Might be worth addressing those in the same PR for a complete fix. The ExecComputeStoredGenerated signature also changed between PG 12-13 and PG 14+, so that needs a version guard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants