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