bug62498.phpt 4.3 KB

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