|
| 1 | +--TEST-- |
| 2 | +Bug #63185: nextRowset() ignores MySQL errors with native prepared statements |
| 3 | +--SKIPIF-- |
| 4 | +<?php |
| 5 | +if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded'); |
| 6 | +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); |
| 7 | +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); |
| 8 | +MySQLPDOTest::skip(); |
| 9 | +?> |
| 10 | +--FILE-- |
| 11 | +<?php |
| 12 | +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); |
| 13 | + |
| 14 | +$pdo = MySQLPDOTest::factory(); |
| 15 | +$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 16 | + |
| 17 | +$pdo->exec('DROP PROCEDURE IF EXISTS test_procedure_error_at_second'); |
| 18 | +$pdo->exec('CREATE PROCEDURE test_procedure_error_at_second () |
| 19 | + BEGIN |
| 20 | + SELECT "x" as foo; |
| 21 | + SELECT * FROM no_such_table; |
| 22 | + END'); |
| 23 | + |
| 24 | +$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 25 | +$st = $pdo->query('CALL test_procedure_error_at_second()'); |
| 26 | +var_dump($st->fetchAll()); |
| 27 | +try { |
| 28 | + var_dump($st->nextRowset()); |
| 29 | +} catch (PDOException $e) { |
| 30 | + echo $e->getMessage(), "\n"; |
| 31 | +} |
| 32 | +unset($st); |
| 33 | + |
| 34 | +$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); |
| 35 | +$st = $pdo->query('CALL test_procedure_error_at_second()'); |
| 36 | +var_dump($st->fetchAll()); |
| 37 | +try { |
| 38 | + var_dump($st->nextRowset()); |
| 39 | +} catch (PDOException $e) { |
| 40 | + echo $e->getMessage(), "\n"; |
| 41 | +} |
| 42 | +var_dump($st->fetchAll()); |
| 43 | + |
| 44 | +?> |
| 45 | +--EXPECTF-- |
| 46 | +array(1) { |
| 47 | + [0]=> |
| 48 | + array(2) { |
| 49 | + ["foo"]=> |
| 50 | + string(1) "x" |
| 51 | + [0]=> |
| 52 | + string(1) "x" |
| 53 | + } |
| 54 | +} |
| 55 | +SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.no_such_table' doesn't exist |
| 56 | +array(1) { |
| 57 | + [0]=> |
| 58 | + array(2) { |
| 59 | + ["foo"]=> |
| 60 | + string(1) "x" |
| 61 | + [0]=> |
| 62 | + string(1) "x" |
| 63 | + } |
| 64 | +} |
| 65 | +SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.no_such_table' doesn't exist |
| 66 | +array(0) { |
| 67 | +} |
0 commit comments