Skip to content

feat(linux): export a database to a SQL file and import SQL files - #4052

Merged
datlechin merged 23 commits into
mainfrom
feat/db-dump-import
Nov 6, 2026
Merged

datlechin merged 23 commits into
mainfrom
feat/db-dump-import

Conversation

@datlechin

@datlechin datlechin commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Export Database in the main menu writes a whole database or one schema, structure and rows, to a .sql or .sql.gz file in the order pg_dump and mysqldump use, so the engine's own client loads it too.
  • Each driver owns its part: Connection::read_dump_catalog reads the catalog (server text where the engine keeps one) and SqlDialect::dump frames the file (mysqldump's SET header and DELIMITER ;;, GO batches, pg_dump's header). tablepro_core::dump::write_dump orders it by what each object names and writes rows as multi-row INSERTs through stream_read.
  • The export result lists what the file leaves out and why: encrypted or CLR routines, remote tables, rows a row-level policy hides, and the like.
  • PostgreSQL user collations and SQL Server column collations go in the file, so a database with another default reads the same.
  • Import SQL File in the main menu runs a .sql or .sql.gz file of any size on an editor session of its own, split as the engine's client splits it (ScriptReader: DELIMITER, GO n, routine bodies, dollar quotes), with Stop at First Error or continue, one transaction on PostgreSQL, SQL Server, SQLite and DuckDB, progress with Stop, and a summary of failures by line.
  • pg_dump plain files load: COPY ... FROM stdin rows run as INSERTs, \restrict and \unrestrict are passed over, other psql commands are refused by line.
  • Safe Mode Read-Only turns Import SQL File off; on Confirm Writes the import dialog is the one question for the file.
  • Redis, MongoDB, Cassandra and ScyllaDB get neither menu item.
  • Core ADR 0011 records why the core writes and reads the file in process instead of calling pg_dump or mysqldump.
  • SQL Server's Show CREATE TABLE keeps a column's identity seed and increment instead of writing IDENTITY(1,1).
Light Dark
Menu, before Main menu on main, light Main menu on main, dark
Menu, after Main menu with Export Database and Import SQL File, light Main menu with Export Database and Import SQL File, dark
Export Database Export Database dialog, light Export Database dialog, dark
Import SQL File Import SQL File dialog, light Import SQL File dialog, dark

Deliberately not fixed here

  • DuckDB macros and views made after SET schema keep unqualified names in their stored text, and DuckDB does not record which schema bound them. Such a body fails to load from a file. Rewriting the names needs the binder's resolution, which DuckDB does not expose.
  • Rows of PostgreSQL extension configuration tables (pg_extension_config_dump, such as pg_partman's) are not written; the extension makes the tables again, empty. Their row filters are SQL text the browse reader cannot take.
  • Object order comes from the names each definition holds, with the server's dependency catalogs unread. A cycle of names is broken at names read outside a relation or call position.
  • SQL Server temporal tables load as ordinary tables with their period times, and an indexed view loads without its indexes. The export lists each one.

Test plan

  • dump_loads_back_into_an_empty_database on PostgreSQL, MySQL, MariaDB, SQL Server and ClickHouse (Docker) and SQLite and DuckDB (unit suite): the sample database is dumped, loaded into an empty database through the import, and dumped again to the same file.
  • native_dump_loads_through_the_import: files written by pg_dump 18, mysqldump 8.4, mariadb-dump 11.4 and sqlite3 3.46 load, as one transaction and as written.
  • Unit tests for the reader cut into pieces of every size, long lines, COPY rows, gzip, object order across kinds, source database and catalog qualifiers, INSERT batching, and the import dialog.

…nd hold NOT VALID domain checks for after the rows
…les and refuse two-phase commands in an import
…n and read routine bodies under their sql_mode
…ort partition expressions and never commit a stopped import
…r SQL Server outcome and list indexed-view indexes
@datlechin
datlechin marked this pull request as ready for review November 5, 2026 11:09
@datlechin
datlechin enabled auto-merge (squash) November 5, 2026 11:09
@datlechin
datlechin merged commit f2bf331 into main Nov 6, 2026
34 of 49 checks passed
@datlechin
datlechin deleted the feat/db-dump-import branch November 6, 2026 03:03
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