Repository navigation
Read the type catalog on the stream's own connection before start - #155
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #155 +/- ##
==========================================
- Coverage 96.48% 96.46% -0.02%
==========================================
Files 36 36
Lines 29314 29438 +124
==========================================
+ Hits 28283 28398 +115
- Misses 1031 1040 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The catalog query can invalidate an exported snapshot, lacks metadata needed to decode several PostgreSQL types, and includes a test that assumes the bootstrap role is named postgres.
5 open issues
What changed in this PR
Adds a pre-start type catalog read on the replication stream’s own connection, extending the startup metadata API without risking a second connection reaching a different cluster.
Changes:
- Introduces
TypeInfoandtype_catalog()for type identities, binary-send capability, and related type OIDs. - Re-exports
TypeInfofrom the crate root. - Adds parsing tests and a live PostgreSQL test comparing catalog metadata with streamed column formats.
| File | Description |
|---|---|
src/stream.rs |
Adds the catalog query, public metadata API, row parsing, and unit tests. |
src/lib.rs |
Exposes TypeInfo at the crate root. |
integration-tests/startup_metadata.rs |
Tests catalog metadata and binary column formats on a live stream. |
Review effort: Balanced
52f5db6 to
a6d8032
Compare
Not only
|
|
Both are in the docs now. |

Summary
A stream started with
with_binary(true)sends a column in binary only when its type has a send function, and as text otherwise. For the built-in types with hand-assigned OIDs that is fixed, but for extension types, enums, domains and composites onlypg_typeknows, and a consumer had no way to read it on the connection the stream decodes from. A second connection can land on another cluster when the conninfo lists several hosts, the same hazard #141 removed for the startup metadata.type_catalog()reads everypg_typerow beforestart, likeslot_confirmed_flush_lsn(), and returns each type's OID, schema, name andtyptype, whether it has a send function, and its element, domain base, range subtype and composite relation. Those are the factstokio-postgresreads to resolve a type, so a consumer can decode domains, arrays, ranges and composites from this one read. Types created after it are missing, and the stream does not read the catalog again on reconnect.Related issues
None.
Type of change
Checklist
make before-git-pushpasses locally (check, build, format, audit, test, doc-check)rustls-tlsandlibpq)Performance notes
n/a, the read runs once before
startand the hot path is untouched.