1--TEST-- 2PDO PgSQL Bug #62498 (pdo_pgsql inefficient when getColumnMeta() is used), 32-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 > 4) die("skip relevant for 32-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_32 (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_32 (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_32'); 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->exec("DROP TABLE IF EXISTS test62498_32"); 52?> 53--EXPECTF-- 54Begin test... 55array(9) { 56 [0]=> 57 array(8) { 58 ["pgsql:oid"]=> 59 int(21) 60 ["pgsql:table_oid"]=> 61 int(%d) 62 ["table"]=> 63 string(%s) "test62498_32" 64 ["native_type"]=> 65 string(4) "int2" 66 ["pdo_type"]=> 67 int(1) 68 ["name"]=> 69 string(7) "int2col" 70 ["len"]=> 71 int(2) 72 ["precision"]=> 73 int(-1) 74 } 75 [1]=> 76 array(8) { 77 ["pgsql:oid"]=> 78 int(23) 79 ["pgsql:table_oid"]=> 80 int(%d) 81 ["table"]=> 82 string(%s) "test62498_32" 83 ["native_type"]=> 84 string(4) "int4" 85 ["pdo_type"]=> 86 int(1) 87 ["name"]=> 88 string(7) "int4col" 89 ["len"]=> 90 int(4) 91 ["precision"]=> 92 int(-1) 93 } 94 [2]=> 95 array(8) { 96 ["pgsql:oid"]=> 97 int(20) 98 ["pgsql:table_oid"]=> 99 int(%d) 100 ["table"]=> 101 string(%s) "test62498_32" 102 ["native_type"]=> 103 string(4) "int8" 104 ["pdo_type"]=> 105 int(1) 106 ["name"]=> 107 string(7) "int8col" 108 ["len"]=> 109 int(8) 110 ["precision"]=> 111 int(-1) 112 } 113 [3]=> 114 array(8) { 115 ["pgsql:oid"]=> 116 int(1043) 117 ["pgsql:table_oid"]=> 118 int(%d) 119 ["table"]=> 120 string(%s) "test62498_32" 121 ["native_type"]=> 122 string(7) "varchar" 123 ["pdo_type"]=> 124 int(2) 125 ["name"]=> 126 string(9) "stringcol" 127 ["len"]=> 128 int(-1) 129 ["precision"]=> 130 int(259) 131 } 132 [4]=> 133 array(8) { 134 ["pgsql:oid"]=> 135 int(16) 136 ["pgsql:table_oid"]=> 137 int(%d) 138 ["table"]=> 139 string(%s) "test62498_32" 140 ["native_type"]=> 141 string(4) "bool" 142 ["pdo_type"]=> 143 int(5) 144 ["name"]=> 145 string(7) "boolcol" 146 ["len"]=> 147 int(1) 148 ["precision"]=> 149 int(-1) 150 } 151 [5]=> 152 array(8) { 153 ["pgsql:oid"]=> 154 int(1082) 155 ["pgsql:table_oid"]=> 156 int(%d) 157 ["table"]=> 158 string(%s) "test62498_32" 159 ["native_type"]=> 160 string(4) "date" 161 ["pdo_type"]=> 162 int(2) 163 ["name"]=> 164 string(7) "datecol" 165 ["len"]=> 166 int(4) 167 ["precision"]=> 168 int(-1) 169 } 170 [6]=> 171 array(8) { 172 ["pgsql:oid"]=> 173 int(25) 174 ["pgsql:table_oid"]=> 175 int(%d) 176 ["table"]=> 177 string(%s) "test62498_32" 178 ["native_type"]=> 179 string(4) "text" 180 ["pdo_type"]=> 181 int(2) 182 ["name"]=> 183 string(7) "textcol" 184 ["len"]=> 185 int(-1) 186 ["precision"]=> 187 int(-1) 188 } 189 [7]=> 190 array(8) { 191 ["pgsql:oid"]=> 192 int(1114) 193 ["pgsql:table_oid"]=> 194 int(%d) 195 ["table"]=> 196 string(%s) "test62498_32" 197 ["native_type"]=> 198 string(9) "timestamp" 199 ["pdo_type"]=> 200 int(2) 201 ["name"]=> 202 string(5) "tscol" 203 ["len"]=> 204 int(8) 205 ["precision"]=> 206 int(-1) 207 } 208 [8]=> 209 array(8) { 210 ["pgsql:oid"]=> 211 int(17) 212 ["pgsql:table_oid"]=> 213 int(%d) 214 ["table"]=> 215 string(%s) "test62498_32" 216 ["native_type"]=> 217 string(5) "bytea" 218 ["pdo_type"]=> 219 int(3) 220 ["name"]=> 221 string(8) "byteacol" 222 ["len"]=> 223 int(-1) 224 ["precision"]=> 225 int(-1) 226 } 227} 228Done 229