From d99d4164a49c037e4672d7bd6dfe245592df312a Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Fri, 13 Nov 2026 05:36:56 +0700 Subject: [PATCH] docs(features): load COPY FROM STDIN rows in SQL import and the editor --- features/import-export.mdx | 2 +- features/sql-editor.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/import-export.mdx b/features/import-export.mdx index 4b77d14..508c096 100644 --- a/features/import-export.mdx +++ b/features/import-export.mdx @@ -320,7 +320,7 @@ The import runs on the connection's own session, and afterwards puts back the se On SQL Server a file that holds a `GO` line runs a batch at a time, cut at its `GO` lines the way `sqlcmd` cuts it, so every count and failure here is a batch rather than a statement. A file with no `GO` line runs a statement at a time. See [Scripts and batches](/databases/mssql#scripts-and-batches). -On PostgreSQL a file stops at a `COPY ... FROM STDIN`, the form `pg_dump` writes table rows in by default, before sending it, and the error names its line: TablePro cannot send the rows that follow it, and never runs them as SQL. Restore such a file with `psql`, or dump it again with `pg_dump --inserts`. The `\restrict` and `\unrestrict` lines a current `pg_dump` writes run nothing. On MySQL and MariaDB a `DELIMITER` line is read as the `mysql` client reads it: only as the first thing on its line, before any statement text. +On PostgreSQL, CockroachDB and KingbaseES the rows after a `COPY ... FROM STDIN`, the form `pg_dump` writes table rows in by default, load through the server's copy protocol inside the import's transaction, read from the file as they are sent. They run up to the line holding only `\.`, which is not sent, and never run as SQL. Text and CSV rows load. Binary rows cannot come from a file, so that `COPY` fails with no rows sent. The progress line counts the rows sent, and **Stop** asks its question once the `COPY` has finished. On Redshift and PGlite, which cannot take rows this way, the file stops at the `COPY` before sending it, and the error names its line: dump it again with `pg_dump --inserts`. The `\restrict` and `\unrestrict` lines a current `pg_dump` writes run nothing. On MySQL and MariaDB a `DELIMITER` line is read as the `mysql` client reads it: only as the first thing on its line, before any statement text. SQL Server SQL imports do not automatically commit or roll back after a file batch runs, even with **Wrap in transaction** selected and even without a `GO` line. A batch can change which transaction is open. Read the completion message: if a transaction remains open, commit or roll it back on this connection. This also applies after a successful import. Imports into a selected table from CSV, JSON, or XLSX use the row-import transaction options instead. diff --git a/features/sql-editor.mdx b/features/sql-editor.mdx index 82b8204..ad2a9c9 100644 --- a/features/sql-editor.mdx +++ b/features/sql-editor.mdx @@ -136,7 +136,7 @@ The editor marks which statement it is about to send. - A `BEGIN … END` body counts as one statement, so a trigger or stored procedure gets one button rather than one per line inside it. `BEGIN;` and `BEGIN TRANSACTION;` are statements of their own. On Oracle, a whole [PL/SQL block or unit](/databases/oracle#pl%2Fsql) is one statement. - On SQL Server an `IF` stays one statement through its `ELSE`, even when a `;` ends the `IF`'s branch: `IF @a = 1 SELECT 1; ELSE SELECT 2;`. - On MySQL and MariaDB a `DELIMITER //` line runs nothing, and `//` then ends a statement, as the `mysql` client reads a script. The line counts only as the first thing on its line, before any statement text. A `;` still ends a statement outside a routine body. -- On PostgreSQL the rows after `COPY ... FROM STDIN`, up to the line holding only `\.`, belong to the `COPY` and never run as SQL. The editor cannot send them, so the `COPY` stops with a message that no rows were sent. Load them with `psql`, or write the rows as `INSERT` statements. The `\restrict` and `\unrestrict` lines `pg_dump` writes run nothing. +- On PostgreSQL the rows after `COPY ... FROM STDIN`, up to the line holding only `\.`, belong to the `COPY` and never run as SQL. Running the `COPY` sends them to the server as its data, as `psql` does, without the `\.` line. On Redshift and PGlite, which cannot take rows this way, the `COPY` stops before anything is sent. The `\restrict` and `\unrestrict` lines `pg_dump` writes run nothing. Turn either marker off in **Settings > Editor** with **Highlight current statement** and **Run button beside each statement**.