LucaCappelletti94 opened a new pull request, #2428:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2428

   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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to