Skip to content

Support GPDB varlena layout#47

Open
Smyatkin-Maxim wants to merge 1 commit into
REL_2_STABLEfrom
varlena_compatibility
Open

Support GPDB varlena layout#47
Smyatkin-Maxim wants to merge 1 commit into
REL_2_STABLEfrom
varlena_compatibility

Conversation

@Smyatkin-Maxim

@Smyatkin-Maxim Smyatkin-Maxim commented Jul 22, 2026

Copy link
Copy Markdown

This commit allows cloudbery use GPDB varlena layout, otherwise upgrading from greenplum is blocked.
Additionally bump catalog version and write varlena layout metadata (gpdb6 compatible or native Little Endian) in controldata. This allows us to prohibit using wrong binaries with wrong data format, preventing data corruption.

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


This commit allows cloudbery use GPDB varlena layout, otherwise
upgrading from greenplum is blocked.
Additionally bump catalog version and write varlena layout metadata (gpdb6 compatible
or native Little Endian) in controldata. This allows us to prohibit using wrong binaries
with wrong data format, preventing data corruption.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi, @Smyatkin-Maxim welcome!🎊 Thanks for taking the effort to make our project better! 🙌 Keep making such awesome contributions!

@Smyatkin-Maxim

Copy link
Copy Markdown
Author

@leborchuk we probably need to update CI and builds to use the new macro -DFORCE_BIGENDIAN_VARLENA? Perhaps I have to do it in this PR as well.

@leborchuk

Copy link
Copy Markdown

@leborchuk we probably need to update CI and builds to use the new macro -DFORCE_BIGENDIAN_VARLENA? Perhaps I have to do it in this PR as well.

Yep, let's fix it in our workflow

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a GPDB6-compatible “network byte order” varlena header layout option (via -DFORCE_BIGENDIAN_VARLENA) and records the chosen on-disk varlena layout in pg_control so binaries/data-directory mismatches are detected early (startup and pg_upgrade), preventing silent data corruption.

Changes:

  • Add a build-time switch to force GPDB6 varlena 4-byte header encoding, while preserving upstream/native behavior by default.
  • Bump PG_CONTROL_VERSION and stamp the cluster’s varlena layout into ControlFileData, exposing it via pg_controldata/pg_resetwal.
  • Teach pg_upgrade and backend startup to enforce that old/new clusters (and server/data directory) agree on varlena layout.

Reviewed changes

Copilot reviewed 3 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/include/postgres.h Adds FORCE_BIGENDIAN_VARLENA-aware varlena header read/write macros.
src/include/catalog/pg_control.h Bumps control version and defines/stores varlena layout metadata in ControlFileData.
src/bin/pg_upgrade/pg_upgrade.h Adds a control-version gate and a new ControlData field for varlena layout.
src/bin/pg_upgrade/controldata.c Parses and validates varlena layout from pg_controldata output; enforces compatibility where possible.
src/bin/pg_resetwal/pg_resetwal.c Stamps/prints varlena layout in control output and guessed control values.
src/bin/pg_controldata/pg_controldata.c Prints varlena layout from pg_control.
src/backend/access/transam/xlog.c Writes layout into pg_control and adds a fatal mismatch check at startup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/include/postgres.h
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