summaryrefslogtreecommitdiff
path: root/ext/pdo_pgsql/tests/bug62498.phpt
blob: 1620e7e77aedb748c1b9d8326d0f2e2eda72ca8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
--TEST--
PDO PgSQL Bug #62498 (pdo_pgsql inefficient when getColumnMeta() is used), 64-bit
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
require __DIR__ . '/config.inc';
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
if (PHP_INT_SIZE < 8) die("skip valid for 64-bit only");
?>
--FILE--
<?php
echo "Begin test...\n";

require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

// create the table
$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)");

// insert some data
$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)");
$vals = array(
    "int2val" => "42",
    "int4val" => "42",
    "int8val" => "42",
    "stringval" => "The Answer",
    "boolval" => true,
    "dateval" => '2015-12-14',
    "textval" => "some text",
    "tsval"   => 19990108,
    "byteaval" => 0,
);
$statement->execute($vals);

$select = $db->query('SELECT int2col, int4col, int8col, stringcol, boolcol, datecol, textcol, tscol, byteacol FROM bugtest_62498');
$meta = [];
for ($i=0; $i < count($vals); $i++) {
  $meta[] = $select->getColumnMeta($i);
}
var_dump($meta);

?>
Done
--EXPECTF--
Begin test...
array(9) {
  [0]=>
  array(8) {
    ["pgsql:oid"]=>
    int(21)
    ["pgsql:table_oid"]=>
    int(%d)
    ["table"]=>
    string(13) "bugtest_62498"
    ["native_type"]=>
    string(4) "int2"
    ["name"]=>
    string(7) "int2col"
    ["len"]=>
    int(2)
    ["precision"]=>
    int(-1)
    ["pdo_type"]=>
    int(1)
  }
  [1]=>
  array(8) {
    ["pgsql:oid"]=>
    int(23)
    ["pgsql:table_oid"]=>
    int(%d)
    ["table"]=>
    string(13) "bugtest_62498"
    ["native_type"]=>
    string(4) "int4"
    ["name"]=>
    string(7) "int4col"
    ["len"]=>
    int(4)
    ["precision"]=>
    int(-1)
    ["pdo_type"]=>
    int(1)
  }
  [2]=>
  array(8) {
    ["pgsql:oid"]=>
    int(20)
    ["pgsql:table_oid"]=>
    int(%d)
    ["table"]=>
    string(13) "bugtest_62498"
    ["native_type"]=>
    string(4) "int8"
    ["name"]=>
    string(7) "int8col"
    ["len"]=>
    int(8)
    ["precision"]=>
    int(-1)
    ["pdo_type"]=>
    int(1)
  }
  [3]=>
  array(8) {
    ["pgsql:oid"]=>
    int(1043)
    ["pgsql:table_oid"]=>
    int(%d)
    ["table"]=>
    string(13) "bugtest_62498"
    ["native_type"]=>
    string(7) "varchar"
    ["name"]=>
    string(9) "stringcol"
    ["len"]=>
    int(-1)
    ["precision"]=>
    int(259)
    ["pdo_type"]=>
    int(2)
  }
  [4]=>
  array(8) {
    ["pgsql:oid"]=>
    int(16)
    ["pgsql:table_oid"]=>
    int(%d)
    ["table"]=>
    string(13) "bugtest_62498"
    ["native_type"]=>
    string(4) "bool"
    ["name"]=>
    string(7) "boolcol"
    ["len"]=>
    int(1)
    ["precision"]=>
    int(-1)
    ["pdo_type"]=>
    int(5)
  }
  [5]=>
  array(8) {
    ["pgsql:oid"]=>
    int(1082)
    ["pgsql:table_oid"]=>
    int(%d)
    ["table"]=>
    string(13) "bugtest_62498"
    ["native_type"]=>
    string(4) "date"
    ["name"]=>
    string(7) "datecol"
    ["len"]=>
    int(4)
    ["precision"]=>
    int(-1)
    ["pdo_type"]=>
    int(2)
  }
  [6]=>
  array(8) {
    ["pgsql:oid"]=>
    int(25)
    ["pgsql:table_oid"]=>
    int(%d)
    ["table"]=>
    string(13) "bugtest_62498"
    ["native_type"]=>
    string(4) "text"
    ["name"]=>
    string(7) "textcol"
    ["len"]=>
    int(-1)
    ["precision"]=>
    int(-1)
    ["pdo_type"]=>
    int(2)
  }
  [7]=>
  array(8) {
    ["pgsql:oid"]=>
    int(1114)
    ["pgsql:table_oid"]=>
    int(%d)
    ["table"]=>
    string(13) "bugtest_62498"
    ["native_type"]=>
    string(9) "timestamp"
    ["name"]=>
    string(5) "tscol"
    ["len"]=>
    int(8)
    ["precision"]=>
    int(-1)
    ["pdo_type"]=>
    int(2)
  }
  [8]=>
  array(8) {
    ["pgsql:oid"]=>
    int(17)
    ["pgsql:table_oid"]=>
    int(%d)
    ["table"]=>
    string(13) "bugtest_62498"
    ["native_type"]=>
    string(5) "bytea"
    ["name"]=>
    string(8) "byteacol"
    ["len"]=>
    int(-1)
    ["precision"]=>
    int(-1)
    ["pdo_type"]=>
    int(3)
  }
}
Done