Skip to content

Fix column encoding handling in pg_dump - #2375

Open
doefimov wants to merge 1 commit into
apache:mainfrom
doefimov:fix/pg-dump-attencoding
Open

doefimov wants to merge 1 commit into
apache:mainfrom
doefimov:fix/pg-dump-attencoding

Conversation

@doefimov

Copy link
Copy Markdown

Refs #2330

What does this PR do?

getTableAttrs() allocates an encoding array for each table based on the total number of attributes in the query result. Size the array to the current table's column count to avoid exhausting memory during schema-only dumps.

Restore the pg_attribute_encoding join lost in the PostgreSQL 16 merge and read each encoding from the matching result row.

Type of Change

  • Bug fix (non-breaking change)

Test Plan

  • Integration tests added/updated

The new TAP case dumps two AOCO tables together and checks that the second table retains its own compression level. It fails before the patch and passes after it.

With 600 tables of 100 columns each and a 192 MiB client address-space limit, pg_dump -s and pg_dumpall -s ran out of memory before the patch and succeeded after it.

The same existing failures reproduced on unpatched and patched main in 002_pg_dump.pl, 004_pg_dump_parallel.pl, and 011_restore.pl.

Checklist

  • This PR contains AI-assisted code generation

Additional Context

REL_2_STABLE already has the catalog join. Only the allocation and row-index fixes need to be backported.

Allocate attencoding for the current table's columns. Sizing it by
the full attribute result for each table can exhaust memory during
schema-only dumps.

Restore the pg_attribute_encoding join lost in the PostgreSQL 16
merge and read each encoding from the matching result row. Add a
TAP case that dumps two AOCO tables with different compression levels.

Refs apache#2330

@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, @doefimov welcome!🎊 Thanks for taking the effort to make our project better! 🙌 Keep making such awesome contributions!

@tuhaihe

tuhaihe commented Nov 20, 2026

Copy link
Copy Markdown
Member

We can rebase this PR after #2243. #2243 will add the pg_dump test run to the workflow, helping us verify the related changes.

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.

2 participants