1--TEST--
2PDO PgSQL Bug #62498 (pdo_pgsql inefficient when getColumnMeta() is used), 32-bit
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
6require dirname(__FILE__) . '/config.inc';
7require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
8PDOTest::skip();
9if (PHP_INT_SIZE > 4) die("skip relevant for 32-bit only");
10?>
11--FILE--
12<?php
13echo "Begin test...\n";
14
15require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
16$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
17$db->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
18
19// create the table
20$db->exec("CREATE TEMPORARY TABLE bugtest_62498 (int2col INT2, int4col INT4, int8col INT8, stringcol VARCHAR(255), boolcol BOOLEAN, datecol DATE, textcol TEXT, tscol TIMESTAMP, byteacol BYTEA)");
21
22// insert some data
23$statement = $db->prepare("INSERT INTO bugtest_62498 (int2col, int4col, int8col, stringcol, boolcol, datecol, textcol, tscol, byteacol) VALUES (:int2val, :int4val, :int8val, :stringval, :boolval, :dateval, :textval, :tsval, :byteaval)");
24$vals = array(
25    "int2val" => "42",
26    "int4val" => "42",
27    "int8val" => "42",
28    "stringval" => "The Answer",
29    "boolval" => true,
30    "dateval" => '2015-12-14',
31    "textval" => "some text",
32    "tsval"   => 19990108,
33    "byteaval" => 0,
34);
35$statement->execute($vals);
36
37$select = $db->query('SELECT int2col, int4col, int8col, stringcol, boolcol, datecol, textcol, tscol, byteacol FROM bugtest_62498');
38$meta = [];
39for ($i=0; $i < count($vals); $i++) {
40  $meta[] = $select->getColumnMeta($i);
41}
42var_dump($meta);
43
44?>
45Done
46--EXPECTF--
47Begin test...
48array(9) {
49  [0]=>
50  array(8) {
51    ["pgsql:oid"]=>
52    int(21)
53    ["pgsql:table_oid"]=>
54    int(%d)
55    ["table"]=>
56    string(13) "bugtest_62498"
57    ["native_type"]=>
58    string(4) "int2"
59    ["name"]=>
60    string(7) "int2col"
61    ["len"]=>
62    int(2)
63    ["precision"]=>
64    int(-1)
65    ["pdo_type"]=>
66    int(1)
67  }
68  [1]=>
69  array(8) {
70    ["pgsql:oid"]=>
71    int(23)
72    ["pgsql:table_oid"]=>
73    int(%d)
74    ["table"]=>
75    string(13) "bugtest_62498"
76    ["native_type"]=>
77    string(4) "int4"
78    ["name"]=>
79    string(7) "int4col"
80    ["len"]=>
81    int(4)
82    ["precision"]=>
83    int(-1)
84    ["pdo_type"]=>
85    int(1)
86  }
87  [2]=>
88  array(8) {
89    ["pgsql:oid"]=>
90    int(20)
91    ["pgsql:table_oid"]=>
92    int(%d)
93    ["table"]=>
94    string(13) "bugtest_62498"
95    ["native_type"]=>
96    string(4) "int8"
97    ["name"]=>
98    string(7) "int8col"
99    ["len"]=>
100    int(8)
101    ["precision"]=>
102    int(-1)
103    ["pdo_type"]=>
104    int(2)
105  }
106  [3]=>
107  array(8) {
108    ["pgsql:oid"]=>
109    int(1043)
110    ["pgsql:table_oid"]=>
111    int(%d)
112    ["table"]=>
113    string(13) "bugtest_62498"
114    ["native_type"]=>
115    string(7) "varchar"
116    ["name"]=>
117    string(9) "stringcol"
118    ["len"]=>
119    int(-1)
120    ["precision"]=>
121    int(259)
122    ["pdo_type"]=>
123    int(2)
124  }
125  [4]=>
126  array(8) {
127    ["pgsql:oid"]=>
128    int(16)
129    ["pgsql:table_oid"]=>
130    int(%d)
131    ["table"]=>
132    string(13) "bugtest_62498"
133    ["native_type"]=>
134    string(4) "bool"
135    ["name"]=>
136    string(7) "boolcol"
137    ["len"]=>
138    int(1)
139    ["precision"]=>
140    int(-1)
141    ["pdo_type"]=>
142    int(5)
143  }
144  [5]=>
145  array(8) {
146    ["pgsql:oid"]=>
147    int(1082)
148    ["pgsql:table_oid"]=>
149    int(%d)
150    ["table"]=>
151    string(13) "bugtest_62498"
152    ["native_type"]=>
153    string(4) "date"
154    ["name"]=>
155    string(7) "datecol"
156    ["len"]=>
157    int(4)
158    ["precision"]=>
159    int(-1)
160    ["pdo_type"]=>
161    int(2)
162  }
163  [6]=>
164  array(8) {
165    ["pgsql:oid"]=>
166    int(25)
167    ["pgsql:table_oid"]=>
168    int(%d)
169    ["table"]=>
170    string(13) "bugtest_62498"
171    ["native_type"]=>
172    string(4) "text"
173    ["name"]=>
174    string(7) "textcol"
175    ["len"]=>
176    int(-1)
177    ["precision"]=>
178    int(-1)
179    ["pdo_type"]=>
180    int(2)
181  }
182  [7]=>
183  array(8) {
184    ["pgsql:oid"]=>
185    int(1114)
186    ["pgsql:table_oid"]=>
187    int(%d)
188    ["table"]=>
189    string(13) "bugtest_62498"
190    ["native_type"]=>
191    string(9) "timestamp"
192    ["name"]=>
193    string(5) "tscol"
194    ["len"]=>
195    int(8)
196    ["precision"]=>
197    int(-1)
198    ["pdo_type"]=>
199    int(2)
200  }
201  [8]=>
202  array(8) {
203    ["pgsql:oid"]=>
204    int(17)
205    ["pgsql:table_oid"]=>
206    int(%d)
207    ["table"]=>
208    string(13) "bugtest_62498"
209    ["native_type"]=>
210    string(5) "bytea"
211    ["name"]=>
212    string(8) "byteacol"
213    ["len"]=>
214    int(-1)
215    ["precision"]=>
216    int(-1)
217    ["pdo_type"]=>
218    int(3)
219  }
220}
221Done
222