Repository navigation
Translate COPY FROM STDIN into the INSERT of its rows - #156
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
LucaCappelletti94
force-pushed
the
upstream/copy-from-stdin-inserts
branch
from
October 24, 2026 17:13
ac9d6b3 to
3ac419a
Compare
Base automatically changed from
upstream/insert-string-literal-coercion
to
main
October 24, 2026 17:13
LucaCappelletti94
force-pushed
the
upstream/copy-from-stdin-inserts
branch
from
October 24, 2026 17:13
3ac419a to
9417dd6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pg_dumpwrites every table's data asCOPY ... FROM stdinwith the rows inline, so a dump carrying data stopped at its firstCOPY, which pg2sqlite refused because sqlparser used to flatten the payload. sqlparser now keeps the payload verbatim, and the statement becomes one multi-rowINSERT, so the load stays as atomic as theCOPYwas.The payload is decoded with PostgreSQL's own rules, the text format with its backslash escapes and a null string matched before they are resolved, and CSV with quoted fields,
HEADER,QUOTE,ESCAPE,FORCE_NULLandFORCE_NOT_NULL. Each field becomes a string literal, which PostgreSQL reads with the same input functionCOPYcalls, and theINSERTthen takes the ordinary translation, so every column conversion applies to it as it does to a written-out insert. Options PostgreSQL rejects, a payload without its\.line and a row with the wrong number of fields are refused, as arebinary,FREEZE,ENCODINGandFORCE_QUOTE.COPY TOand file or program sources stay refused.A restore runs as the table owner, whom PostgreSQL lets past row-level security, so a
COPYinto a secured table writes its backing table, where the write exemption decides as for any trusted write.This stacks on #154, which makes the boolean and numeric text
pg_dumpwrites land as PostgreSQL stores it.