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