bug51291_1.phpt 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. --TEST--
  2. Bug #51291 (oci_error() doesn't report last error when called two times)
  3. --EXTENSIONS--
  4. oci8
  5. --FILE--
  6. <?php
  7. require(__DIR__.'/connect.inc');
  8. echo "Test 1 - Parse\n";
  9. $s = @oci_parse($c, "select ' from dual");
  10. if (!$s) {
  11. var_dump(oci_error($c));
  12. echo "2nd call\n";
  13. var_dump(oci_error($c));
  14. }
  15. echo "\nTest 2 - Parse\n";
  16. $s = @oci_parse($c, "select ' from dual");
  17. if (!$s) {
  18. var_dump(oci_error(), oci_error($c));
  19. echo "2nd call\n";
  20. var_dump(oci_error(), oci_error($c));
  21. }
  22. echo "\nTest 3 - Execute\n";
  23. $s = @oci_parse($c, 'select doesnotexist from dual');
  24. $r = @oci_execute($s, OCI_DEFAULT);
  25. if (!$r) {
  26. var_dump(oci_error($s));
  27. echo "2nd call\n";
  28. var_dump(oci_error($s));
  29. }
  30. echo "\nTest 4 - Execute - consecutive oci_error calls of different kinds\n";
  31. $s = @oci_parse($c, 'select doesnotexist from dual');
  32. $r = @oci_execute($s, OCI_DEFAULT);
  33. if (!$r) {
  34. var_dump(oci_error(), oci_error($c), oci_error($s));
  35. echo "2nd call\n";
  36. var_dump(oci_error(), oci_error($c), oci_error($s));
  37. }
  38. echo "\nTest 5 - Execute - after oci_rollback\n";
  39. $s = @oci_parse($c, 'select doesnotexist from dual');
  40. $r = @oci_execute($s, OCI_DEFAULT);
  41. if (!$r) {
  42. var_dump(oci_error(), oci_error($c), oci_error($s));
  43. $r = oci_rollback($c);
  44. echo "Rollback status is ";
  45. if (is_null($r)) echo "null";
  46. else if ($r === false) echo "false";
  47. else if ($r === true) echo "true";
  48. else echo $r;
  49. echo "\n";
  50. echo "2nd call after oci_rollback\n";
  51. var_dump(oci_error(), oci_error($c), oci_error($s));
  52. }
  53. echo "\nTest 6 - Execute - after successful 2nd query with new handle\n";
  54. $s = @oci_parse($c, 'select doesnotexist from dual');
  55. $r = @oci_execute($s, OCI_DEFAULT);
  56. if (!$r) {
  57. var_dump(oci_error(), oci_error($c), oci_error($s));
  58. $s2 = oci_parse($c, 'select 1 from dual');
  59. $r = oci_execute($s2, OCI_DEFAULT);
  60. echo "Execute status is ";
  61. if (is_null($r)) echo "null";
  62. else if ($r === false) echo "false";
  63. else if ($r === true) echo "true";
  64. else echo $r;
  65. echo "\n";
  66. echo "2nd call after successful execute\n";
  67. var_dump(oci_error(), oci_error($c), oci_error($s), oci_error($s2));
  68. }
  69. echo "\nTest 7 - Execute - after successful 2nd query with same handle\n";
  70. $s = @oci_parse($c, 'select doesnotexist from dual');
  71. $r = @oci_execute($s, OCI_DEFAULT);
  72. if (!$r) {
  73. var_dump(oci_error(), oci_error($c), oci_error($s));
  74. $s = oci_parse($c, 'select 1 from dual');
  75. $r = oci_execute($s, OCI_DEFAULT);
  76. echo "Execute status is ";
  77. if (is_null($r)) echo "null";
  78. else if ($r === false) echo "false";
  79. else if ($r === true) echo "true";
  80. else echo $r;
  81. echo "\n";
  82. echo "2nd call after successful execute\n";
  83. var_dump(oci_error(), oci_error($c), oci_error($s));
  84. }
  85. echo "\nTest 8 - Execute - after unsuccessful 2nd query with new handle\n";
  86. $s = @oci_parse($c, 'select doesnotexist from dual');
  87. $r = @oci_execute($s, OCI_DEFAULT);
  88. if (!$r) {
  89. var_dump(oci_error(), oci_error($c), oci_error($s));
  90. $s2 = oci_parse($c, 'select reallynothere from dual');
  91. $r = oci_execute($s2, OCI_DEFAULT);
  92. echo "Execute status is ";
  93. if (is_null($r)) echo "null";
  94. else if ($r === false) echo "false";
  95. else if ($r === true) echo "true";
  96. else echo $r;
  97. echo "\n";
  98. echo "2nd call after unsuccessful execute\n";
  99. var_dump(oci_error(), oci_error($c), oci_error($s), oci_error($s2));
  100. }
  101. echo "\nTest 9 - Execute - after unsuccessful 2nd query with same handle\n";
  102. $s = @oci_parse($c, 'select doesnotexist from dual');
  103. $r = @oci_execute($s, OCI_DEFAULT);
  104. if (!$r) {
  105. var_dump(oci_error(), oci_error($c), oci_error($s));
  106. $s = oci_parse($c, 'select reallynothere from dual');
  107. $r = oci_execute($s, OCI_DEFAULT);
  108. echo "Execute status is ";
  109. if (is_null($r)) echo "null";
  110. else if ($r === false) echo "false";
  111. else if ($r === true) echo "true";
  112. else echo $r;
  113. echo "\n";
  114. echo "2nd call after unsuccessful execute\n";
  115. var_dump(oci_error(), oci_error($c), oci_error($s));
  116. }
  117. ?>
  118. --EXPECTF--
  119. Test 1 - Parse
  120. array(4) {
  121. ["code"]=>
  122. int(1756)
  123. ["message"]=>
  124. string(48) "ORA-01756: %s"
  125. ["offset"]=>
  126. int(0)
  127. ["sqltext"]=>
  128. string(0) ""
  129. }
  130. 2nd call
  131. array(4) {
  132. ["code"]=>
  133. int(1756)
  134. ["message"]=>
  135. string(48) "ORA-01756: %s"
  136. ["offset"]=>
  137. int(0)
  138. ["sqltext"]=>
  139. string(0) ""
  140. }
  141. Test 2 - Parse
  142. bool(false)
  143. array(4) {
  144. ["code"]=>
  145. int(1756)
  146. ["message"]=>
  147. string(48) "ORA-01756: %s"
  148. ["offset"]=>
  149. int(0)
  150. ["sqltext"]=>
  151. string(0) ""
  152. }
  153. 2nd call
  154. bool(false)
  155. array(4) {
  156. ["code"]=>
  157. int(1756)
  158. ["message"]=>
  159. string(48) "ORA-01756: %s"
  160. ["offset"]=>
  161. int(0)
  162. ["sqltext"]=>
  163. string(0) ""
  164. }
  165. Test 3 - Execute
  166. array(4) {
  167. ["code"]=>
  168. int(904)
  169. ["message"]=>
  170. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  171. ["offset"]=>
  172. int(%d)
  173. ["sqltext"]=>
  174. string(29) "select doesnotexist from dual"
  175. }
  176. 2nd call
  177. array(4) {
  178. ["code"]=>
  179. int(904)
  180. ["message"]=>
  181. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  182. ["offset"]=>
  183. int(%d)
  184. ["sqltext"]=>
  185. string(29) "select doesnotexist from dual"
  186. }
  187. Test 4 - Execute - consecutive oci_error calls of different kinds
  188. bool(false)
  189. bool(false)
  190. array(4) {
  191. ["code"]=>
  192. int(904)
  193. ["message"]=>
  194. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  195. ["offset"]=>
  196. int(%d)
  197. ["sqltext"]=>
  198. string(29) "select doesnotexist from dual"
  199. }
  200. 2nd call
  201. bool(false)
  202. bool(false)
  203. array(4) {
  204. ["code"]=>
  205. int(904)
  206. ["message"]=>
  207. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  208. ["offset"]=>
  209. int(%d)
  210. ["sqltext"]=>
  211. string(29) "select doesnotexist from dual"
  212. }
  213. Test 5 - Execute - after oci_rollback
  214. bool(false)
  215. bool(false)
  216. array(4) {
  217. ["code"]=>
  218. int(904)
  219. ["message"]=>
  220. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  221. ["offset"]=>
  222. int(%d)
  223. ["sqltext"]=>
  224. string(29) "select doesnotexist from dual"
  225. }
  226. Rollback status is true
  227. 2nd call after oci_rollback
  228. bool(false)
  229. bool(false)
  230. array(4) {
  231. ["code"]=>
  232. int(904)
  233. ["message"]=>
  234. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  235. ["offset"]=>
  236. int(%d)
  237. ["sqltext"]=>
  238. string(29) "select doesnotexist from dual"
  239. }
  240. Test 6 - Execute - after successful 2nd query with new handle
  241. bool(false)
  242. bool(false)
  243. array(4) {
  244. ["code"]=>
  245. int(904)
  246. ["message"]=>
  247. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  248. ["offset"]=>
  249. int(%d)
  250. ["sqltext"]=>
  251. string(29) "select doesnotexist from dual"
  252. }
  253. Execute status is true
  254. 2nd call after successful execute
  255. bool(false)
  256. bool(false)
  257. array(4) {
  258. ["code"]=>
  259. int(904)
  260. ["message"]=>
  261. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  262. ["offset"]=>
  263. int(%d)
  264. ["sqltext"]=>
  265. string(29) "select doesnotexist from dual"
  266. }
  267. bool(false)
  268. Test 7 - Execute - after successful 2nd query with same handle
  269. bool(false)
  270. bool(false)
  271. array(4) {
  272. ["code"]=>
  273. int(904)
  274. ["message"]=>
  275. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  276. ["offset"]=>
  277. int(%d)
  278. ["sqltext"]=>
  279. string(29) "select doesnotexist from dual"
  280. }
  281. Execute status is true
  282. 2nd call after successful execute
  283. bool(false)
  284. bool(false)
  285. bool(false)
  286. Test 8 - Execute - after unsuccessful 2nd query with new handle
  287. bool(false)
  288. bool(false)
  289. array(4) {
  290. ["code"]=>
  291. int(904)
  292. ["message"]=>
  293. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  294. ["offset"]=>
  295. int(%d)
  296. ["sqltext"]=>
  297. string(29) "select doesnotexist from dual"
  298. }
  299. Warning: oci_execute(): ORA-00904: %sREALLYNOTHERE%s in %sbug51291_1.php on line %d
  300. Execute status is false
  301. 2nd call after unsuccessful execute
  302. bool(false)
  303. bool(false)
  304. array(4) {
  305. ["code"]=>
  306. int(904)
  307. ["message"]=>
  308. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  309. ["offset"]=>
  310. int(%d)
  311. ["sqltext"]=>
  312. string(29) "select doesnotexist from dual"
  313. }
  314. array(4) {
  315. ["code"]=>
  316. int(904)
  317. ["message"]=>
  318. string(%d) "ORA-00904%sREALLYNOTHERE%s"
  319. ["offset"]=>
  320. int(%d)
  321. ["sqltext"]=>
  322. string(30) "select reallynothere from dual"
  323. }
  324. Test 9 - Execute - after unsuccessful 2nd query with same handle
  325. bool(false)
  326. bool(false)
  327. array(4) {
  328. ["code"]=>
  329. int(904)
  330. ["message"]=>
  331. string(%d) "ORA-00904:%sDOESNOTEXIST%s"
  332. ["offset"]=>
  333. int(%d)
  334. ["sqltext"]=>
  335. string(29) "select doesnotexist from dual"
  336. }
  337. Warning: oci_execute(): ORA-00904: %sREALLYNOTHERE%s in %sbug51291_1.php on line %d
  338. Execute status is false
  339. 2nd call after unsuccessful execute
  340. bool(false)
  341. bool(false)
  342. array(4) {
  343. ["code"]=>
  344. int(904)
  345. ["message"]=>
  346. string(%d) "ORA-00904%sREALLYNOTHERE%s"
  347. ["offset"]=>
  348. int(%d)
  349. ["sqltext"]=>
  350. string(30) "select reallynothere from dual"
  351. }