error_parse.phpt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. --TEST--
  2. Test error handling when persistent connection is passed to oci_error()
  3. --EXTENSIONS--
  4. oci8
  5. --FILE--
  6. <?php
  7. // As part of the fix for Bug 42134, an error handling difference was
  8. // noticed when oci_error() was passed a persistent connection. This
  9. // was fixed and the behavior of oci_error() for all connections types
  10. // was made consistent.
  11. require(__DIR__.'/details.inc');
  12. // Test parse error for normal connection
  13. if (!empty($dbase)) {
  14. $c1 = oci_connect($user,$password,$dbase);
  15. }
  16. else {
  17. $c1 = oci_connect($user,$password);
  18. }
  19. $s = @oci_parse($c1, "select ' from dual");
  20. if (!$s) {
  21. echo "Normal connection: Parse error\n";
  22. $m = oci_error($c1);
  23. var_dump($m);
  24. }
  25. // Test parse error for new connection
  26. if (!empty($dbase)) {
  27. $c2 = oci_new_connect($user,$password,$dbase);
  28. }
  29. else {
  30. $c2 = oci_new_connect($user,$password);
  31. }
  32. $s = @oci_parse($c2, "select ' from dual");
  33. if (!$s) {
  34. echo "New connection: Parse error\n";
  35. $m = oci_error($c2);
  36. var_dump($m);
  37. }
  38. // Test parse error for persistent connection
  39. if (!empty($dbase)) {
  40. $c3 = oci_pconnect($user,$password,$dbase);
  41. }
  42. else {
  43. $c3 = oci_pconnect($user,$password);
  44. }
  45. $s = @oci_parse($c3, "select ' from dual");
  46. if (!$s) {
  47. echo "Persistent connection: Parse error\n";
  48. $m = oci_error($c3);
  49. var_dump($m);
  50. }
  51. // Verify that passing no connection doesn't affect future calls
  52. $m = oci_error();
  53. echo "No connection: error: ";
  54. var_dump($m);
  55. // Check the errors are still accessible in the respective handles
  56. $m = oci_error($c1);
  57. echo "Normal connection (take #2): Parse error: ";
  58. echo $m["message"], "\n";
  59. $m = oci_error($c2);
  60. echo "New connection (take #2): Parse error: ";
  61. echo $m["message"], "\n";
  62. $m = oci_error($c3);
  63. echo "Persistent connection (take #2): Parse error: ";
  64. echo $m["message"], "\n";
  65. // Now create a new error for a normal connection and check all again
  66. $s = @oci_new_collection($c1, "ABC");
  67. $m = oci_error($c1);
  68. echo "Normal connection: New Collection error: ";
  69. echo $m["message"], "\n";
  70. $m = oci_error($c2);
  71. echo "New connection (take #3): Parse error: ";
  72. echo $m["message"], "\n";
  73. $m = oci_error($c3);
  74. echo "Persistent connection (take #3): Parse error: ";
  75. echo $m["message"], "\n";
  76. echo "Done\n";
  77. ?>
  78. --EXPECTF--
  79. Normal connection: Parse error
  80. array(4) {
  81. ["code"]=>
  82. int(1756)
  83. ["message"]=>
  84. string(48) "ORA-01756: %s"
  85. ["offset"]=>
  86. int(0)
  87. ["sqltext"]=>
  88. string(0) ""
  89. }
  90. New connection: Parse error
  91. array(4) {
  92. ["code"]=>
  93. int(1756)
  94. ["message"]=>
  95. string(48) "ORA-01756: %s"
  96. ["offset"]=>
  97. int(0)
  98. ["sqltext"]=>
  99. string(0) ""
  100. }
  101. Persistent connection: Parse error
  102. array(4) {
  103. ["code"]=>
  104. int(1756)
  105. ["message"]=>
  106. string(48) "ORA-01756: %s"
  107. ["offset"]=>
  108. int(0)
  109. ["sqltext"]=>
  110. string(0) ""
  111. }
  112. No connection: error: bool(false)
  113. Normal connection (take #2): Parse error: ORA-01756: %s
  114. New connection (take #2): Parse error: ORA-01756: %s
  115. Persistent connection (take #2): Parse error: ORA-01756: %s
  116. Normal connection: New Collection error: OCI-22303: type ""."ABC" not found
  117. New connection (take #3): Parse error: ORA-01756: %s
  118. Persistent connection (take #3): Parse error: ORA-01756: %s
  119. Done