Commit 9f37f5b
Reject COPY ... FROM STDIN / TO STDOUT with HYC00 instead of poisoning the transaction
COPY ... FROM STDIN and COPY ... TO STDOUT hand the connection over to
libpq's COPY streaming sub-protocol, which this driver does not implement.
handle_execution_result had no case for the PGRES_COPY_IN/OUT/BOTH result
statuses, so a COPY fell into the default branch: we PQclear'd the result
and returned SQL_ERROR while the connection was still in copy mode. The
next command the driver issued (the per-statement SAVEPOINT teardown) then
terminated the copy abnormally ("COPY terminated by new PQexec"), aborting
the whole transaction so every following statement failed with 25P02.
Add connection_abort_active_copy(): end a copy-in with a non-NULL error
string, drain and discard a copy-out, then consume the trailing result(s)
so the connection leaves copy mode. When the unwind leaves the transaction
aborted, mark it FAILED so connection_handle_statement_error rewinds to the
per-statement savepoint and keeps the transaction usable. handle_execution_result
now has explicit PGRES_COPY_IN/OUT/BOTH cases returning HYC00 ("optional
feature not implemented"), covering both the SQLExecDirect and
SQLPrepare/SQLExecute paths.
Detection keys off the libpq result status, not the SQL text, so a
file-based COPY (COPY ... TO '/path', which returns PGRES_COMMAND_OK) or a
column literally named "stdin" is never mistaken for a client-stream COPY.
This restores upstream regression parity: commands-test.c gained a COPY
section in upstream commit bc439e8. Full suite now 60/60 on PostgreSQL 17
and 20.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 9785653 commit 9f37f5b
3 files changed
Lines changed: 90 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
758 | 758 | | |
759 | 759 | | |
760 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
418 | 431 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
406 | 435 | | |
407 | 436 | | |
408 | 437 | | |
| |||
0 commit comments