Skip to content

fix(export): keep tables, columns and keys named alike in two Unicode forms apart on every driver - #4365

Merged
datlechin merged 5 commits into
mainfrom
fix/export-twin-drivers
Nov 20, 2026
Merged

datlechin merged 5 commits into
mainfrom
fix/export-twin-drivers

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • PostgreSQLCatalogExport.requireDistinctSpellings moves to apple/Plugins/Shared/PluginNameSpellings.swift, compiled by every plugin (DriverPlugin template) and the iOS app. PostgreSQL keeps its statements and its PostgreSQLCatalogReadError.
  • fetchAllColumnsForExport and fetchAllForeignKeysForExport run the shared reads' statements and throw when an answer names one table in two Unicode forms (NFC, NFD), so the export reads each table alone: SQLite, libSQL, Cloudflare D1, DuckDB, MySQL/MariaDB (catalog, SHOW fallback, StarRocks, Databend), Redshift, SQL Server, Oracle, ClickHouse, Snowflake, SAP HANA, BigQuery, Dameng.
  • A driver with no schema-wide key read (DuckDB, Redshift, Snowflake, SAP HANA, Dameng) exports keys table by table, as PluginKit's default does, with the table listing checked first.
  • iOS export catalogs for SQLite, DuckDB, MySQL, Redshift, SQL Server and Oracle take the same reads; ClickHouse and D1 get them through their plugin folders.
  • Inside one table, by bytes: the SQL export's generated-column exclusion, upsert key columns and keys grouped by constraint; the Data Dictionary's column references and key rows; the key-column flag of DuckDB, ClickHouse and Snowflake column reads.
  • BigQuery's table cache is keyed by bytes, so a per-table read of one twin never answers with the other.
  • No index export read changes: only PostgreSQL declares exportBulkReads, and it already guards.
  • Not guarded, their name rules rule out twins: CockroachDB (NFC-normalizes identifiers), Spanner, Cassandra and DynamoDB (ASCII names), Etcd and Memcached (one column set for every table).
  • Probe apple/scripts/probes/check-export-twin-names.sh (SQLite, DuckDB, MariaDB); the PostgreSQL probe gains column and constraint twins in one table and the product its driver now imports; the shared file is linked in the probes that build a driver folder.

Test plan

  • Fail on main: ExportUnicodeNameTests (4 new: twin columns, twin constraints, upsert, dictionary rows), SQLiteExportTwinNameTests, ClickHouseExportTwinNameTests/twinColumnIsNotAKey, iOS ExportTwinNameTests.
  • New API, do not compile on main: PluginNameSpellingsTests, MySQLExportCatalogTests (+3), RedshiftCatalogExportTests (+3), the rest of ClickHouseExportTwinNameTests.
  • Probe on main's sources: BUG on SQLite, DuckDB and MariaDB (merged column and key answers, a twin's plain column restored as NULL) and on PostgreSQL 17.11 (the dump does not restore: two keys merged into one). On this branch: OK on all four.
  • MariaDB 13.0.2, 50-table export: 112 statements on main and on this branch.

@datlechin
datlechin enabled auto-merge (squash) November 20, 2026 01:38
@datlechin
datlechin merged commit f1df5e3 into main Nov 20, 2026
14 checks passed
@datlechin
datlechin deleted the fix/export-twin-drivers branch November 20, 2026 06:51
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