Commit 8982351
Pdo\Pgsql: Fix getColumnMeta() for GH-15287 Pdo\Pgsql::setAttribute(PDO::ATTR_PREFETCH, 0)
As stated in the UPGRADING, using the passthrough ("single-row") mode of libpq (introduced in #15287)
forbids passing a new query while the current one's results have not been entirely consumed.
… But I didn't notice that ext/pdo_pgsql internally used new queries to fetch metadata (example use case:
a call to getColumnMeta() while fetch()ing row by row will interleave the getColumnMeta()-triggered
internal query to the database, with the results fetching for the user-called query).
This PR makes those internal calls return NULL for non-essential metadata, instead of letting libpq abort the user-called query.
It moreover includes a small tweak to table oid-to-name translation, with a 1-slot cache.
This may by chance allow the internal call to return something instead of NULL,
but it will nonetheless avoid 30 server calls to get the table name of 30 columns of the same table.
optimize calls to foreach(columns of the same table) getColumnMeta()
- each call queried the DB to know the name associated with the table's OID:
cache the result between two calls
- make pdo_pgsql_translate_oid_to_table higher-level,
with the last parameter being the handle instead of the raw connection;
thus the statement is cleaner, letting the handle do all memory handling on the table oid-to-name translation cache
(which by the way is a driver feature more than a statement one)
close GH-162491 parent 81100a7 commit 8982351
File tree
5 files changed
+109
-26
lines changed- ext/pdo_pgsql
- tests
5 files changed
+109
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
112 | 144 | | |
113 | 145 | | |
114 | 146 | | |
| |||
258 | 290 | | |
259 | 291 | | |
260 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
261 | 297 | | |
262 | 298 | | |
263 | 299 | | |
| |||
351 | 387 | | |
352 | 388 | | |
353 | 389 | | |
| 390 | + | |
354 | 391 | | |
355 | 392 | | |
356 | 393 | | |
| |||
426 | 463 | | |
427 | 464 | | |
428 | 465 | | |
| 466 | + | |
429 | 467 | | |
430 | 468 | | |
431 | 469 | | |
| |||
589 | 627 | | |
590 | 628 | | |
591 | 629 | | |
| 630 | + | |
592 | 631 | | |
593 | 632 | | |
594 | 633 | | |
| |||
696 | 735 | | |
697 | 736 | | |
698 | 737 | | |
699 | | - | |
700 | | - | |
701 | | - | |
| 738 | + | |
| 739 | + | |
702 | 740 | | |
703 | 741 | | |
704 | 742 | | |
| |||
820 | 858 | | |
821 | 859 | | |
822 | 860 | | |
823 | | - | |
824 | | - | |
825 | | - | |
| 861 | + | |
| 862 | + | |
826 | 863 | | |
827 | 864 | | |
828 | 865 | | |
| |||
916 | 953 | | |
917 | 954 | | |
918 | 955 | | |
919 | | - | |
920 | | - | |
921 | | - | |
| 956 | + | |
922 | 957 | | |
923 | 958 | | |
924 | 959 | | |
| |||
1007 | 1042 | | |
1008 | 1043 | | |
1009 | 1044 | | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
| 1045 | + | |
1013 | 1046 | | |
1014 | 1047 | | |
1015 | 1048 | | |
| |||
1461 | 1494 | | |
1462 | 1495 | | |
1463 | 1496 | | |
| 1497 | + | |
1464 | 1498 | | |
1465 | 1499 | | |
1466 | 1500 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | 59 | | |
63 | 60 | | |
64 | | - | |
65 | | - | |
| 61 | + | |
66 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
118 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
191 | | - | |
| 192 | + | |
192 | 193 | | |
193 | | - | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
705 | | - | |
| 705 | + | |
706 | 706 | | |
| 707 | + | |
707 | 708 | | |
708 | 709 | | |
709 | 710 | | |
710 | 711 | | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
711 | 728 | | |
712 | 729 | | |
713 | 730 | | |
| |||
724 | 741 | | |
725 | 742 | | |
726 | 743 | | |
| 744 | + | |
| 745 | + | |
727 | 746 | | |
728 | 747 | | |
729 | 748 | | |
| |||
752 | 771 | | |
753 | 772 | | |
754 | 773 | | |
755 | | - | |
| 774 | + | |
756 | 775 | | |
757 | | - | |
758 | | - | |
| 776 | + | |
759 | 777 | | |
760 | 778 | | |
761 | 779 | | |
| |||
794 | 812 | | |
795 | 813 | | |
796 | 814 | | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
797 | 819 | | |
798 | 820 | | |
799 | 821 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
135 | 146 | | |
136 | 147 | | |
137 | 148 | | |
| |||
181 | 192 | | |
182 | 193 | | |
183 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
0 commit comments