Skip to content

Fix fixme in upgrading to PG16#1783

Open
lss602726449 wants to merge 5 commits into
apache:mainfrom
lss602726449:fix_fixme
Open

Fix fixme in upgrading to PG16#1783
lss602726449 wants to merge 5 commits into
apache:mainfrom
lss602726449:fix_fixme

Conversation

@lss602726449
Copy link
Copy Markdown
Contributor

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


Previously, MERGE ... WHEN MATCHED THEN UPDATE SET <dist_key> = ...
was rejected with "cannot update column in merge with distributed
column". This commit adds support by extending the SplitMerge node
to handle distribution key updates via DELETE + INSERT routing.

Key changes:

Planner (preptlist.c, createplan.c, setrefs.c, cdbpath.c):
- Detect distribution key modification in MERGE UPDATE actions and
  set merge_need_split_update flag
- Add all target table columns to subplan targetlist so SplitMerge
  can project complete rows for INSERT
- Expand UPDATE action targetlists to include all columns (not just
  SET columns) using expand_insert_targetlist
- Build SplitMerge targetlist in N+M+1 format: N target table columns
  + M subplan columns + 1 DMLAction column
- Always use root table action lists (not per-partition adjusted lists)
  to ensure hashAttnos match root attribute numbers
- Add set_splitmerge_tlist_references for proper OUTER_VAR conversion

Executor (nodeSplitMerge.c, nodeModifyTable.c):
- SplitMerge splits MATCHED UPDATE into DELETE + INSERT tuple pair,
  each routed to the correct segment via hash computation
- NOT MATCHED rows get PASSTHROUGH action for normal ExecMerge processing
- ModifyTable handles DMLAction-tagged tuples from SplitMerge output
- Support lazy partition routing for CMD_MERGE DML_INSERT

Refactoring (nodeSplitMerge.c):
- Extract computeTargetSegment(), SwitchResultRelForPartition(),
  BuildRootUpdateTupleDesc() helper functions
- Define SPLITMERGE_ACTION_PASSTHROUGH constant
- Remove dead code and consolidate duplicated logic
Uncomment the two test blocks that verify view behavior when pg_depend
entries are corrupted (DELETE FROM pg_depend + ALTER TABLE + ROLLBACK).

These were previously disabled because DELETE FROM pg_depend only
affects the coordinator in a distributed environment. The fix uses
allow_segment_DML GUC combined with a helper function marked
EXECUTE ON ALL SEGMENTS to delete from segment catalogs as well.
ORCA now correctly supports runtime filter pushdown, so uncomment
the previously disabled test block that verifies pushdown behavior
with optimizer on.
Re-enable the register_dirty_segment() call in mdcreate() that was
commented out during the PG16 merge. This matches upstream PG16
behavior and ensures newly created relation files are fsync'd at
the next checkpoint, preventing data loss on power failure.
Re-enable the register_dirty_segment_ao() call in ao_insert_replay()
that was commented out during the PG16 merge. Without this, AO table
data written during standby WAL replay would not be registered for
fsync at the next checkpoint, risking data loss on power failure.
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.

1 participant