Skip to content

fix(export): keep tables and schemas whose names differ only in Unicode form apart - #4359

Merged
datlechin merged 3 commits into
mainfrom
fix/export-unicode-name-groups
Nov 19, 2026
Merged

datlechin merged 3 commits into
mainfrom
fix/export-unicode-name-groups

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • PostgreSQL keeps apart relation and schema names that differ only in Unicode form (NFC and NFD), while Swift's String equates them. The SQL export and the Data Dictionary keyed their schema-wide reads by String, so such tables took each other's columns, keys and indexes.
  • SQL export: a table named like another in a different Unicode form was dropped from the dump entirely (the foreign key sort folded the two). Sort nodes now get one name per byte spelling.
  • SQL export: the container span, and the sequence and enum type dedupe, compare names by bytes, so two such schemas get qualified names and two such sequences or types are each created.
  • SQL export: columns and foreign keys go through SQLExportGroupReads. They are still read by group from every source; a group read that fails, reaches the row limit or holds the name in another spelling now reads that table alone instead of dropping its metadata.
  • Data Dictionary: group reads and sizes are keyed by bytes, lookups follow the same rule, and the document qualifies names and links keys by bytes.
  • Objects the export itself holds in two spellings of one name are read alone, whatever the source's group answer holds.
  • The byte rule moves from SQLExportGroupReads to apple/Plugins/Shared/PluginExportSpelling.swift, shared by both plugins and the iOS app.
  • PluginKit, additive in the untagged kit 46 (minimum 19): fetchAllColumnsForExport, fetchAllForeignKeysForExport and fetchAllIndexesForExport on PluginDatabaseDriver, defaulting to the shared reads. ExportDataSourceAdapter and the iOS export catalogs call them.
  • PostgreSQL implements them with the shared reads' statements and decoding, and throws when any row set names one relation in two spellings, so the export reads each table alone. The shared reads behind the sidebar, completion, compare, ER diagram, MCP and AI are unchanged.
  • New probe apple/scripts/probes/check-postgres-export-unicode-names.sh. The P20 probe and the column type corpus probe link the new shared file.

Test plan

  • New ExportUnicodeNameTests (FormatPluginTests): two such tables both dumped with their own columns, keys and order, from a source that throws or merges; two such schemas read and qualified apart; two such sequences and types each created; a failed column group read falls back per table; another spelling in an answer reads alone; Data Dictionary schemas, relations, anchors and qualification. 9 of 9 failed on main's plugin sources, the merging-source cases also on the first commit here.
  • New cases in PostgreSQLExportSchemaReadTests, ExportDataSourceAdapterCatalogTests, PostgreSQLExportCatalogTests (iOS) and PluginExportReadDefaultsTests (PluginKit).
  • Probe on PostgreSQL 17.11: BUG on main's sources (dumps and dictionaries differ, the dump does not restore), OK here (same dump and dictionary per table and per schema, the restore matches the dumped catalog and rows).
  • 50-table export (P20's fifty schema) through a counting proxy: 209 queries on main and here, the same dump.
  • verify.sh: build, plugins, abi (changed, kit 46 against v0.88.0-beta.1), test, lint, ios.

@datlechin
datlechin enabled auto-merge (squash) November 19, 2026 20:34
@datlechin
datlechin merged commit 4ddfb64 into main Nov 19, 2026
14 checks passed
@datlechin
datlechin deleted the fix/export-unicode-name-groups branch November 19, 2026 23:10
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.

1 participant