Skip to content

Run COPY FROM a file of the server - #441

Merged
tamnd merged 2 commits into
mainfrom
copy-from-file
Oct 20, 2026
Merged

tamnd merged 2 commits into
mainfrom
copy-from-file

Conversation

@tamnd

@tamnd tamnd commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Summary

COPY ... FROM 'file' now reads a file of the server, as BeginCopyFrom of copyfrom.c opens it. The regression suite loads its tables with this form in test_setup.sql.

Changes

  • The session holds the Io of the server and reads the whole file through it. The rows then go through the same path as COPY FROM STDIN, with the same line errors and context.
  • A role that is not a superuser gets 42501 "permission denied to COPY from a file", with the detail and the hint of PostgreSQL.
  • A directory gives 42809, and a file that cannot be opened gives "could not open file ... for reading" with the text of the OS error.
  • The simple and the extended protocol both run the statement.

Known differences

  • COPY FROM PROGRAM gives 0A000.
  • The session reads the whole file before it parses the rows. PostgreSQL reads the file in parts.

Tests

  • copy_from_file runs a file of rows, a file with a bad line, a file that does not exist, and the extended protocol, on a simulated file system.
  • fmt, clippy, the workspace tests and the checks of xtask pass on server1.

@tamnd tamnd added kind/feature It does not do something that it must do. area/session Sessions, settings, pooling and the server runtime. area/sql The grammar, the lexer, the analyzer and the rewriter. labels Oct 20, 2026
@tamnd
tamnd merged commit b81ba46 into main Oct 20, 2026
5 checks passed
@tamnd
tamnd deleted the copy-from-file branch October 20, 2026 06:08
@tamnd tamnd mentioned this pull request Oct 20, 2026
1 of 17 tasks
tamnd added a commit that referenced this pull request Oct 20, 2026
* Add the changelog entry for #441

* Run VACUUM and ANALYZE as checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/session Sessions, settings, pooling and the server runtime. area/sql The grammar, the lexer, the analyzer and the rewriter. kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant