Skip to content

feat: 整合四種資料庫匯出匯入精靈與修整 - #54

Merged
shadowjohn merged 12 commits into
masterfrom
codex/db-wizard-repairs
Oct 16, 2026
Merged

shadowjohn merged 12 commits into
masterfrom
codex/db-wizard-repairs

Conversation

@shadowjohn

Copy link
Copy Markdown
Owner

整合 MySQL/MariaDB、SQLite、PostgreSQL 與 Oracle 的四步 SQL 匯出/匯入精靈,提供選表、輸出/執行選項、進度與 ETA、Punky 動畫及結果/錯誤日誌。這個 PR 包含原始功能分支堆疊,以及後續針對 MySQL、SQLite、Oracle 的資料安全與正確性修整。

MySQL 原先遇到非 InnoDB 或空間欄位時,可能開始後才停止。例如 city_geometry.SHAPE 在處理前面資料表後才觸發失敗;現在先檢查整份選取範圍,再開始寫檔,普通 2D Geometry 以 WKB 加每筆 SRID 輸出。

主要變更

  • MySQL:修正 SQL 目標與字串值處理、既有物件策略及 generated 欄位;快照只提供給已確認的 InnoDB 選表,其餘顯示一般模式的一致性風險。補 WKB/SRID、提前相容性/大小檢查,以及失敗/取消後調整設定重試。
  • SQLite:修正 DROP/衝突策略、trigger、交易與失敗結果、UTF-8/文字 bytes、generated 欄位、rowid/序號及來源遺失處理。
  • Oracle:修正 provider 失敗被當成功、來源唯讀交易、逐列 reader/bounded LOB、SRID/空間 metadata、owner/view/FK 範圍與型別保真限制。
  • 三種已修整 provider 的精靈使用獨立工作連線;匯出以暫存檔驗證後原子發布,發布失敗保留舊檔與完成的暫存檔。單表入口預設只處理指定資料表。
  • 執行失敗後清除仍在顯示的速率/ETA,保留已處理筆數並標示未發布;100% 只代表成功產出檔案。

驗證

  • 完整 304 組 smoke tests + AutoReleasePolicy 通過,Debug/Release 編譯通過。
  • MySQL 專項 27 組通過,涵蓋實際 exporter/parser/import runner 的 recording-provider、大小/競態/舊檔保護及精靈生命週期測試。SQLite 包含專用小型實際資料庫往返測試;Oracle 使用 recording-provider contracts。
  • 使用者於 2026-10-16 回報:在自己的環境中,MySQL 匯出、匯入都成功。這是使用者實際操作的流程驗收;沒有另外取得逐列資料/WKB/SRID 比對結果。
  • 舊版執行檔能重現空間欄位失敗與未提前阻擋的相容性檢查,新版對應回歸通過。來源檔編碼/BOM/換行與 diff whitespace 檢查通過。

審查範圍與限制

  • PostgreSQL 原始精靈也在分支堆疊中;它的 provider 專屬程式未被本輪三種 provider 修整修改,也尚未做本輪完整獨立覆核。304 組測試通過不等於 PostgreSQL/PostGIS 全面驗收。
  • MySQL 仍保留來源單列 1 MiB、每頁 16 列與 INSERT 8 MiB 限制。Geometry 以相容引擎/SRS 往返為目標;跨版本/跨 vendor 地理座標軸語意及自訂 SRS 搬移未驗證。
  • Oracle/PostgreSQL 實機、完整空間資料保真、SSH、多 GiB 壓力及 DPI/音效等驗收仍待補充。匯入若失敗,前面已提交的 DDL/DML 可能保留,不能視為整份檔案可回滾。

詳細支援範圍、修整覆核與證據:驗證紀錄、MySQL Geometry 修整。

- 實作 SqliteExportWizardForm 與 SqliteSqlExportService:
  * 全 64KB 串流 StreamWriter 寫入與私有 Staging 檔案原子替換,杜絕整庫 StringBuilder 造成的 OOM。
  * 深度支援 SpatiaLite 與 GeoPackage 空間特色:幾何 BLOB 無損轉 X'...' HEX 字面量、支援排除龐大空間中繼表 (spatial_ref_sys)。
  * 自動辨識並排除 R-Tree/FTS 虛擬表影子表 (_node, _rowid, _parent 等),避免還原時 SQLite 報錯。
  * 支援 BEGIN IMMEDIATE 一致性交易、側車註解結構傾印,以及腳本末尾 Native Manifest (SHA-256 與逐表筆數)。
- 實作 SqliteImportWizardForm 與 SqliteImportRunner:
  * 串流狀態機 Lexer 預檢 (Preflight),精確識別字串與註解內分號,並自動偵測 SpatiaLite 特徵。
  * 支援動態加載 mod_spatialite.dll 空間延伸模組。
  * 4 種既有物件處理策略(保留現存/全部替換/刪表重建/清空重匯),單一連線 Session 執行與自動交易保護。
  * Punky 看板娘雙緩衝動畫、音效切換與 2,000 行滑動視窗終端機風格日誌。
  * 每次執行產出獨立 Log 至 %LOCALAPPDATA%\mySQLPunk\ImportLogs。
  * 匯入後自動讀取 Manifest 比對現存表與實際寫入筆數。
- 主視窗 Form1 路由整合與測試:
  * 新增 Form1.SqliteExport.cs 與 Form1.SqliteImport.cs,對齊 MSSQL/MySQL 路由規範。
  * 新增 SmokeTests.SqliteExport.cs 與 SmokeTests.SqliteImport.cs (6 項測試),全數通過 (254/254)。
…atial and PL/SQL support

- Implement OracleSqlExportService with 64KB StreamWriter and .writing staging atomic replacement to prevent OOM
- Losslessly dump MDSYS.SDO_GEOMETRY via SDO_UTIL.FROM_WKBGEOMETRY(HEXTORAW('...')) and register USER_SDO_GEOM_METADATA
- Automatically filter out internal R-Tree spatial shadow tables (MDRT_*, MDXT_*, MDRS_*)
- Add OracleImportPreflightScanner with PL/SQL slash (/) block lexer and NUL byte corruption detection
- Implement OracleImportRunner supporting 4 conflict strategies (KeepExisting, ReplaceAll, DropAndRecreate, TruncateAndInsert) and FIFO 2,000-line terminal log
- Add 4-step wizard UI (OracleExportWizardForm, OracleImportWizardForm) integrated with Punky mascot animation and sound
- Register full regression suite in SmokeTests (268/268 passed, auto-release policy passed)
- Update TODO.md marking Oracle alignment as completed
@shadowjohn
shadowjohn merged commit 77076ce into master Oct 16, 2026
1 check passed
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