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