Repository navigation
Releases
Releases · gmr/libpgdump
v2.3.1
Fixed
Dump::save()now sorts ROLE, USER and GROUP entries before all other TOC entries, with TABLESPACE entries directly after them, matching pg_dumpall's order. Previously these sorted last, sopg_restoreof a sorted archive failed when anALTER ... OWNER TOorCREATE TABLESPACEnamed a role that did not exist yet. USER MAPPING placement is unchanged. (#21)
v2.3.0
Added
Dump::sorts_on_save()andDump::set_sort_on_save()to control whether saving reorders the TOC (#16)
Changed
- Saving an archive that was loaded and not modified now preserves its TOC order instead of re-sorting it. pg_dump's ordering is authoritative, so rewriting it could only lose fidelity. Dumps built with
new(), and loaded dumps whose entries are added to or modified, still sort on save as before (#16) - TOC sorting now reproduces pg_dump's placement rules: the ENCODING/STDSTRINGS/SEARCHPATH prelude keeps pg_dump's order, comments, security labels and ACLs follow the object they describe, constraint-like entries sort on the object name rather than the
"<table> <name>"tag, and statistics sort by the kind of object they describe. Every test fixture except data-only archives now sorts into exactly the order pg_dump wrote (#16, #18) - Updated dependencies: lz4_flex from 0.11 to 0.14, zstd from 0.13 to 0.14, flate2 to 1.1.10, thiserror to 2.0.20 (#19)
Fixed
- A dependency cycle no longer puts its members at the front of the archive, ahead of their schema and the prelude, which produced archives
pg_restorecould not read. One edge of the cycle is now dropped and the sort re-run, as pg_dump does (#15) - Column ACLs no longer sort to the end of the archive (#16)
get_entry_mut()no longer marks the TOC order stale when the lookup finds nothing (#16)
Known limitation
Data-only archives still sort differently from pg_dump. pg_dump orders TABLE DATA by foreign-key dependencies recorded against table entries that a data-only archive does not contain, so the order cannot be reconstructed from the archive. Loaded archives are no longer re-sorted on save, so this does not affect round-tripping.
v2.2.0
What's Changed
Archives written by libpgdump could not be read by pg_restore in directory or tar format, and archives rewritten in any format were rejected by pg_restore before PostgreSQL 12. Anyone writing archives should upgrade.
Fixed
- Directory and tar writers stored a NULL extra-TOC filename for entries with no data file. pg_dump writes an empty string, and pg_restore's
_ReadExtraToccallsstrlen()on it, so every directory or tar archive we wrote crashed pg_restore — includingpg_restore -l(#12) - Tar members were written in filename order. pg_restore reads tar archives sequentially and rejected data members that came before the member of an earlier TOC entry, failing restores partway with "restoring data out of order is not supported in this archive format" (#12)
- The directory writer renamed blob TOC files, which pg_restore 16 and earlier reject, and blob TOC filenames read from an archive are now rejected if they escape the output directory (#12)
read_string()collapsed empty strings to NULL. pg_dump writes""for fields such as an entry's owner and drop statement, and pg_restore before PostgreSQL 12 callsstrlen()on them with no NULL check, so rewritten archives segfaulted those versions in all three formats (#13)set_compression()left the archive version alone, so selecting lz4 or zstd on an archive older than 1.15 — the version pg_dump 15 and earlier writes — failed withUnsupportedCompression. It now raises the version to 1.15, which added nothing but the compression-algorithm byte (#13)
Added
tar::read_metadata()reads a tar archive's header and TOC while seeking past the data members.pgdump-tocuses it, and no longer refuses tar archives with "unsupported format: 3" (#13)- Compressed data support in
CustomReader::read_entry_reader()(#7), and apgdump-tocCLI for inspecting an archive's header and TOC (#8), both by @NickCrews
Changed
- Empty strings now read as
Some("")rather thanNone.Entryfields such asowner,drop_stmt, andtablespacecarry the distinction pg_dump makes between an empty string and NULL, so code matching onNonefor those fields may need updating - CI now tests against PostgreSQL 13 through 18, up from 16 through 18, and archives written by libpgdump are checked with a real
pg_restoreacross every format and compression algorithm
Internal
Timestamp,Blob, andArchiveDatamoved totypes.rs, withread_timestamp()/write_timestamp()deduplicated (#9), and per-chunk allocation removed from the data reader (#7), both by @NickCrews
Full Changelog: v2.1.0...v2.2.0
v2.1.0
What's Changed
Added
- Lazy
CustomReaderfor custom format archives that reads only the header and TOC on construction, deferring data block reads until explicitly requested — enables working with archives too large to fit in memory (#5) (#6) - Buffered on-demand data reading via
CustomReader::read_entry_data()returningEntryDataenum - Streaming on-demand data reading via
CustomReader::read_entry_reader()returning anEntryReaderthat implementsRead CustomReader::into_dump()for eager conversion to a fullDumpafter TOC inspection
Improved
- CI release workflow now uses
--lockedto preventCargo.lockdrift
v2.0.0
Breaking Changes
Entry.descis nowObjectTypeinstead ofString— Thedescfield onEntryis now a strongly-typedObjectTypeenum with 50+ variants covering all known pg_dump object types, plusOther(String)for forward compatibility.Dump::add_entry()takesObjectTypeinstead of&str— PassObjectType::Table,ObjectType::TableData, etc. instead of string literals.Dump::lookup_entry()takes&ObjectTypeinstead of&strfor the desc parameter.Error::EntityNotFound.descis nowObjectTypeinstead ofString.
New Features
- Weighted topological sort — TOC entries are automatically sorted on
Dump::save()using the same two-phase algorithm as pg_dump (pg_dump_sort.c): cosmetic sort by type priority, namespace, and name, followed by Kahn's algorithm with a max-heap to satisfy dependencies while preserving order. Also available viaDump::sort_entries(). ObjectTypeenum — Type-safe representation of all pg_dump object types withsection(),priority(),as_str(),Display,Ord, andFrom<&str>/From<String>conversions. Unknown types preserved viaOther(String)for round-trip fidelity.Dump::get_entry_mut()— Mutable access to entries by dump_id.
Improvements
- Format readers now return an error on missing/NULL descriptors instead of silently defaulting to
Other(""). ObjectType::as_str()returns&'static strfor known variants, eliminating heap allocations in sort comparisons and format writers.constants.rsreduced to just theMAGICconstant — all object type strings and section mapping are now methods onObjectType.