imp_res_prefetch.phpt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. --TEST--
  2. Oracle Database 12c Implicit Result Sets: basic test
  3. --EXTENSIONS--
  4. oci8
  5. --SKIPIF--
  6. <?php
  7. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  8. require(__DIR__.'/skipif.inc');
  9. preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
  10. if (!(isset($matches[0]) && $matches[1] >= 12)) {
  11. die("skip expected output only valid when using Oracle Database 12c or greater");
  12. }
  13. preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
  14. if (!(isset($matches[0]) && $matches[0] >= 12)) {
  15. die("skip works only with Oracle 12c or greater version of Oracle client libraries");
  16. }
  17. ?>
  18. --FILE--
  19. <?php
  20. require(__DIR__.'/connect.inc');
  21. // Initialization
  22. $stmtarray = array(
  23. "drop table imp_res_prefetch_tab_1",
  24. "create table imp_res_prefetch_tab_1 (c1 number, c2 varchar2(10))",
  25. "insert into imp_res_prefetch_tab_1 values (1, 'abcde')",
  26. "insert into imp_res_prefetch_tab_1 values (2, 'fghij')",
  27. "insert into imp_res_prefetch_tab_1 values (3, 'klmno')",
  28. "drop table imp_res_prefetch_tab_2",
  29. "create table imp_res_prefetch_tab_2 (c3 varchar2(1))",
  30. "insert into imp_res_prefetch_tab_2 values ('t')",
  31. "insert into imp_res_prefetch_tab_2 values ('u')",
  32. "insert into imp_res_prefetch_tab_2 values ('v')",
  33. "create or replace procedure imp_res_prefetch_proc as
  34. c1 sys_refcursor;
  35. begin
  36. open c1 for select * from imp_res_prefetch_tab_1 order by 1;
  37. dbms_sql.return_result(c1);
  38. open c1 for select * from imp_res_prefetch_tab_2 order by 1;
  39. dbms_sql.return_result(c1);
  40. end;"
  41. );
  42. oci8_test_sql_execute($c, $stmtarray);
  43. // Run Test
  44. echo "Test 1 - prefetch 0\n";
  45. $s = oci_parse($c, "begin imp_res_prefetch_proc(); end;");
  46. oci_execute($s);
  47. var_dump(oci_set_prefetch($s, 0));
  48. while (($row = oci_fetch_row($s)) != false)
  49. var_dump($row);
  50. echo "\nTest 1 - prefetch 1\n";
  51. $s = oci_parse($c, "begin imp_res_prefetch_proc(); end;");
  52. oci_execute($s);
  53. var_dump(oci_set_prefetch($s, 1));
  54. while (($row = oci_fetch_row($s)) != false)
  55. var_dump($row);
  56. echo "\nTest 1 - prefetch 2\n";
  57. $s = oci_parse($c, "begin imp_res_prefetch_proc(); end;");
  58. oci_execute($s);
  59. var_dump(oci_set_prefetch($s, 2));
  60. while (($row = oci_fetch_row($s)) != false)
  61. var_dump($row);
  62. // Clean up
  63. $stmtarray = array(
  64. "drop procedure imp_res_prefetch_proc",
  65. "drop table imp_res_prefetch_tab_1",
  66. "drop table imp_res_prefetch_tab_2"
  67. );
  68. oci8_test_sql_execute($c, $stmtarray);
  69. ?>
  70. --EXPECT--
  71. Test 1 - prefetch 0
  72. bool(true)
  73. array(2) {
  74. [0]=>
  75. string(1) "1"
  76. [1]=>
  77. string(5) "abcde"
  78. }
  79. array(2) {
  80. [0]=>
  81. string(1) "2"
  82. [1]=>
  83. string(5) "fghij"
  84. }
  85. array(2) {
  86. [0]=>
  87. string(1) "3"
  88. [1]=>
  89. string(5) "klmno"
  90. }
  91. array(1) {
  92. [0]=>
  93. string(1) "t"
  94. }
  95. array(1) {
  96. [0]=>
  97. string(1) "u"
  98. }
  99. array(1) {
  100. [0]=>
  101. string(1) "v"
  102. }
  103. Test 1 - prefetch 1
  104. bool(true)
  105. array(2) {
  106. [0]=>
  107. string(1) "1"
  108. [1]=>
  109. string(5) "abcde"
  110. }
  111. array(2) {
  112. [0]=>
  113. string(1) "2"
  114. [1]=>
  115. string(5) "fghij"
  116. }
  117. array(2) {
  118. [0]=>
  119. string(1) "3"
  120. [1]=>
  121. string(5) "klmno"
  122. }
  123. array(1) {
  124. [0]=>
  125. string(1) "t"
  126. }
  127. array(1) {
  128. [0]=>
  129. string(1) "u"
  130. }
  131. array(1) {
  132. [0]=>
  133. string(1) "v"
  134. }
  135. Test 1 - prefetch 2
  136. bool(true)
  137. array(2) {
  138. [0]=>
  139. string(1) "1"
  140. [1]=>
  141. string(5) "abcde"
  142. }
  143. array(2) {
  144. [0]=>
  145. string(1) "2"
  146. [1]=>
  147. string(5) "fghij"
  148. }
  149. array(2) {
  150. [0]=>
  151. string(1) "3"
  152. [1]=>
  153. string(5) "klmno"
  154. }
  155. array(1) {
  156. [0]=>
  157. string(1) "t"
  158. }
  159. array(1) {
  160. [0]=>
  161. string(1) "u"
  162. }
  163. array(1) {
  164. [0]=>
  165. string(1) "v"
  166. }