forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9485516
committed
Make psql handle EOF during COPY FROM STDIN properly on all platforms.
When stdin is a terminal, it's possible to end a COPY FROM STDIN witha keyboard EOF signal (typically control-D), and then keep on issuingSQL commands. One would expect another COPY FROM STDIN to work as well,but on some platforms it did not. This turns out to be because we werenot resetting the stream's feof() flag, and BSD-ish versions of fread()and fgets() won't attempt to read more data if that's set.The misbehavior is observed on BSDen (including macOS), but not Linux,Windows, or SysV-ish Unixen, which makes this a portability bug notjust a missing feature.Add a clearerr() call to fix the behavior, and improve the prompt that'sissued when copying from a TTY to mention that EOF signals work.It's been like this forever, so back-patch to all supported branches.Thomas MunroDiscussion:https://postgr.es/m/CAEepm=0MCGfYf=JAMiYhO6JPtv9-3ZfBo8fcGeCZ8oMzaw+Z+Q@mail.gmail.com1 parent944dc0f commit9485516
1 file changed
+11
-1
lines changedLines changed: 11 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
540 | 540 |
| |
541 | 541 |
| |
542 | 542 |
| |
543 |
| - | |
| 543 | + | |
544 | 544 |
| |
545 | 545 |
| |
546 | 546 |
| |
| |||
673 | 673 |
| |
674 | 674 |
| |
675 | 675 |
| |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
676 | 686 |
| |
677 | 687 |
| |
678 | 688 |
| |
|
0 commit comments
Comments
(0)