fix(mtree): fetch complex-typed columns as text so their diffs repair#139
fix(mtree): fetch complex-typed columns as text so their diffs repair#139danolivo wants to merge 1 commit into
Conversation
table-repair aborted on tables with geometric, network, range, bit, enum or
xml columns when the diff came from the Merkle-tree engine: one unparseable
value fails the whole upsert batch, so nothing gets repaired. The classic
engine was largely unaffected because its row fetch already casts arrays,
json, bytea and any non-known-scalar type to ::TEXT, so those values travel
as Postgres' own text form and parse straight back on repair. The mtree
engine's row fetch used a bare SELECT *, so the same columns arrived as
opaque pgx driver structs and reached the report as Go-formatted garbage --
a JSON-quoted "(61,122)" for point, {54 154 i e true} for a range, base64
for xml.
Extract the classic engine's cast policy into a shared helper,
SelectColExpr, and build both engines' row-fetch SELECT lists with it. The
mtree fetch now names its columns explicitly with the same ::TEXT casts, so
diff reports carry identical, repairable text on both engines for every
type, with no per-type conversion code to maintain.
Since text pass-through is now the designed repair path for such types, the
per-value "unknown or complex pgType" warning (one line per row per column,
thousands in a modest repair) is demoted to a debug message; the fallbacks
for non-string values, which do indicate a value that bypassed
normalisation, still warn.
Unit tests cover the cast-policy decision table; the typed-columns
integration test now also spans point, int4range, bit, inet, xml and a real
enum type, asserting the Merkle-tree diff of 100 divergent rows repairs
completely and converges the nodes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 7 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
table-repair aborted on tables with geometric, network, range, bit, enum or xml columns when the diff came from the Merkle-tree engine: one unparseable value fails the whole upsert batch, so nothing gets repaired. The classic engine was largely unaffected because its row fetch already casts arrays, json, bytea and any non-known-scalar type to ::TEXT, so those values travel as Postgres' own text form and parse straight back on repair. The mtree engine's row fetch used a bare SELECT *, so the same columns arrived as opaque pgx driver structs and reached the report as Go-formatted garbage -- a JSON-quoted "(61,122)" for point, {54 154 i e true} for a range, base64 for xml.
Extract the classic engine's cast policy into a shared helper, SelectColExpr, and build both engines' row-fetch SELECT lists with it. The mtree fetch now names its columns explicitly with the same ::TEXT casts, so diff reports carry identical, repairable text on both engines for every type, with no per-type conversion code to maintain.
Since text pass-through is now the designed repair path for such types, the per-value "unknown or complex pgType" warning (one line per row per column, thousands in a modest repair) is demoted to a debug message; the fallbacks for non-string values, which do indicate a value that bypassed normalisation, still warn.
Unit tests cover the cast-policy decision table; the typed-columns integration test now also spans point, int4range, bit, inet, xml and a real enum type, asserting the Merkle-tree diff of 100 divergent rows repairs completely and converges the nodes.