Skip to content

Capture the COPY ... FROM STDIN payload verbatim - #2428

Open
LucaCappelletti94 wants to merge 1 commit into
apache:mainfrom
LucaCappelletti94:copy-stdin-verbatim-payload
Open

LucaCappelletti94 wants to merge 1 commit into
apache:mainfrom
LucaCappelletti94:copy-stdin-verbatim-payload

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

Parsing COPY t (a, b) FROM stdin; with two rows of two columns produced six values with nothing marking where the first row ended, so the rows could not be recovered even by counting columns. Printing the statement did not reproduce its input either, and every print and re-parse cycle inserted one more tab before each field, without bound.

The cause is that the payload was being split on tabs and newlines with \N interpreted, which is a partial implementation of the PostgreSQL text format. This removes that rather than completing it. Statement::Copy now carries payload: Option<String>, holding the text between the command and the \. terminator exactly as written, and Display writes it back unchanged. What a tab or a \N means is left to whoever consumes the statement. None means the statement carried no inline data, so a bare COPY t FROM STDIN; still prints without an invented terminator, while Some("") is an explicitly empty payload.

This breaks Statement::Copy, and Parser::parse_tsv and Parser::parse_tab_value are removed along with the format handling. Every other COPY sub-parser was already private.

My suggestion here is that either we go full csv parsing (which I agree might be a bit much), or no parsing at all (which is what I am suggesting we do in this PR), as the current impl was neither and broken.

@LucaCappelletti94
LucaCappelletti94 marked this pull request as ready for review August 4, 2026 20:28
@LucaCappelletti94
LucaCappelletti94 force-pushed the copy-stdin-verbatim-payload branch 2 times, most recently from 5c2e10e to de77ad2 Compare August 24, 2026 11:50
@LucaCappelletti94
LucaCappelletti94 force-pushed the copy-stdin-verbatim-payload branch from de77ad2 to 35a7fe0 Compare September 3, 2026 17:05
@LucaCappelletti94
LucaCappelletti94 force-pushed the copy-stdin-verbatim-payload branch 4 times, most recently from 01250ba to 75ca5f6 Compare September 22, 2026 21:20
LucaCappelletti94 added a commit to LucaCappelletti94/sqlparser-rs that referenced this pull request Oct 2, 2026
@codecov-commenter

codecov-commenter commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.31%. Comparing base (ada8314) to head (74d64d8).

Files with missing lines Patch % Lines
src/ast/mod.rs 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2428      +/-   ##
==========================================
+ Coverage   81.28%   81.31%   +0.03%     
==========================================
  Files          42       42              
  Lines       33920    33906      -14     
  Branches    33920    33906      -14     
==========================================
- Hits        27571    27570       -1     
+ Misses       2785     2772      -13     
  Partials     3564     3564              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94
LucaCappelletti94 force-pushed the copy-stdin-verbatim-payload branch from d9944b2 to 652c896 Compare October 2, 2026 16:15
@LucaCappelletti94
LucaCappelletti94 force-pushed the copy-stdin-verbatim-payload branch from 652c896 to d3d3881 Compare October 17, 2026 01:00
@LucaCappelletti94
LucaCappelletti94 force-pushed the copy-stdin-verbatim-payload branch from d3d3881 to 74d64d8 Compare October 18, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants