- Notifications
You must be signed in to change notification settings - Fork5
Commit33766e6
committed
Here's a patch against 7.1.3 that fixes a problem with sending larger
queries over non-blocking connections with libpq. "Larger" herebasically means that it doesn't fit into the output buffer.The basic strategy is to fix pqFlush and pqPutBytes.The problem with pqFlush as it stands now is that it returns EOF when anerror occurs or when not all data could be sent. The latter case isclearly not an error for a non-blocking connection but the caller can'tdistringuish it from an error very well.The first part of the fix is therefore to fix pqFlush. This is done byto renaming it to pqSendSome which only differs from pqFlush in itsreturn values to allow the caller to make the above distinction and anew pqFlush which is implemented in terms of pqSendSome and behavesexactly like the old pqFlush.The second part of the fix modifies pqPutBytes to use pqSendSome insteadof pqFlush and to either send all the data or if not all data can besent on a non-blocking connection to at least put all data into theoutput buffer, enlarging it if necessary. The callers of pqPutBytesdon't have to be changed because from their point of view pqPutBytesbehaves like before. It either succeeds in queueing all output data orfails with an error.I've also added a new API function PQsendSome which analogously toPQflush just calls pqSendSome. Programs using non-blocking queriesshould use this new function. The main difference is that this functionwill have to be called repeatedly (calling select() properly in between)until all data has been written.AFAICT, the code in CVS HEAD hasn't changed with respect to non-blockingqueries and this fix should work there, too, but I haven't tested thatyet.Bernhard Herzog1 parent9446718 commit33766e6
File tree
4 files changed
+128
-57
lines changed- src/interfaces/libpq
4 files changed
+128
-57
lines changedLines changed: 9 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
2429 | 2429 |
| |
2430 | 2430 |
| |
2431 | 2431 |
| |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + |
Lines changed: 111 additions & 54 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
28 |
| - | |
| 28 | + | |
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| |||
110 | 110 |
| |
111 | 111 |
| |
112 | 112 |
| |
113 |
| - | |
114 |
| - | |
115 | 113 |
| |
116 |
| - | |
117 |
| - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
118 | 121 |
| |
119 |
| - | |
| 122 | + | |
| 123 | + | |
120 | 124 |
| |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
121 | 136 |
| |
122 |
| - | |
123 |
| - | |
124 |
| - | |
125 |
| - | |
126 |
| - | |
127 |
| - | |
| 137 | + | |
| 138 | + | |
128 | 139 |
| |
129 |
| - | |
| 140 | + | |
130 | 141 |
| |
131 |
| - | |
132 |
| - | |
133 |
| - | |
134 |
| - | |
135 |
| - | |
136 |
| - | |
137 |
| - | |
138 |
| - | |
139 |
| - | |
| 142 | + | |
140 | 143 |
| |
141 |
| - | |
142 |
| - | |
143 |
| - | |
144 |
| - | |
145 |
| - | |
146 |
| - | |
147 |
| - | |
148 |
| - | |
149 |
| - | |
150 |
| - | |
151 |
| - | |
152 |
| - | |
153 |
| - | |
154 |
| - | |
155 |
| - | |
156 |
| - | |
157 |
| - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
158 | 183 |
| |
159 |
| - | |
160 |
| - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
161 | 189 |
| |
162 | 190 |
| |
163 | 191 |
| |
| |||
603 | 631 |
| |
604 | 632 |
| |
605 | 633 |
| |
606 |
| - | |
607 |
| - | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
608 | 647 |
| |
609 | 648 |
| |
610 |
| - | |
| 649 | + | |
611 | 650 |
| |
612 | 651 |
| |
613 | 652 |
| |
| |||
685 | 724 |
| |
686 | 725 |
| |
687 | 726 |
| |
688 |
| - | |
| 727 | + | |
689 | 728 |
| |
690 | 729 |
| |
691 | 730 |
| |
692 | 731 |
| |
693 | 732 |
| |
694 | 733 |
| |
695 |
| - | |
| 734 | + | |
696 | 735 |
| |
697 | 736 |
| |
698 | 737 |
| |
| |||
707 | 746 |
| |
708 | 747 |
| |
709 | 748 |
| |
710 |
| - | |
| 749 | + | |
711 | 750 |
| |
712 | 751 |
| |
713 | 752 |
| |
| |||
719 | 758 |
| |
720 | 759 |
| |
721 | 760 |
| |
722 |
| - | |
| 761 | + | |
723 | 762 |
| |
724 | 763 |
| |
725 | 764 |
| |
726 | 765 |
| |
727 | 766 |
| |
728 | 767 |
| |
729 |
| - | |
| 768 | + | |
730 | 769 |
| |
731 | 770 |
| |
732 | 771 |
| |
| |||
738 | 777 |
| |
739 | 778 |
| |
740 | 779 |
| |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
741 | 797 |
| |
742 | 798 |
| |
743 | 799 |
| |
| |||
756 | 812 |
| |
757 | 813 |
| |
758 | 814 |
| |
759 |
| - | |
| 815 | + | |
760 | 816 |
| |
761 | 817 |
| |
762 | 818 |
| |
| |||
857 | 913 |
| |
858 | 914 |
| |
859 | 915 |
| |
860 |
| - | |
| 916 | + | |
861 | 917 |
| |
862 | 918 |
| |
863 | 919 |
| |
864 | 920 |
| |
865 |
| - | |
866 |
| - | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
867 | 924 |
| |
868 | 925 |
| |
869 | 926 |
| |
870 | 927 |
| |
871 | 928 |
| |
872 |
| - | |
| 929 | + | |
873 | 930 |
| |
874 | 931 |
| |
875 | 932 |
| |
|
Lines changed: 6 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
282 | 282 |
| |
283 | 283 |
| |
284 | 284 |
| |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
285 | 290 |
| |
286 | 291 |
| |
287 | 292 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
15 |
| - | |
| 15 | + | |
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
| |||
323 | 323 |
| |
324 | 324 |
| |
325 | 325 |
| |
| 326 | + | |
326 | 327 |
| |
327 | 328 |
| |
328 | 329 |
| |
|
0 commit comments
Comments
(0)