|
| 1 | +--TEST-- |
| 2 | +Bug GH-9372 (HY010 when binding overlong parameter) |
| 3 | +--EXTENSIONS-- |
| 4 | +pdo_odbc |
| 5 | +--SKIPIF-- |
| 6 | +<?php |
| 7 | +require 'ext/pdo/tests/pdo_test.inc'; |
| 8 | +PDOTest::skip(); |
| 9 | +?> |
| 10 | +--FILE-- |
| 11 | +<?php |
| 12 | +// Executing the statements fails with some drivers, but not others. |
| 13 | +// The test is written in a way to always pass, unless the execution |
| 14 | +// fails with a different code than 22001 (String data, right truncation). |
| 15 | + |
| 16 | +require 'ext/pdo/tests/pdo_test.inc'; |
| 17 | +$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); |
| 18 | +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 19 | + |
| 20 | +$db->exec("CREATE TABLE gh9372 (col VARCHAR(10))"); |
| 21 | +$db->exec("INSERT INTO gh9372 VALUES ('something')"); |
| 22 | + |
| 23 | +$stmt = $db->prepare("SELECT * FROM gh9372 WHERE col = ?"); |
| 24 | +$stmt->bindValue(1, 'something else'); |
| 25 | +try { |
| 26 | + $stmt->execute(); |
| 27 | +} catch (PDOException $ex) { |
| 28 | + if ($ex->getCode() !== "22001") { |
| 29 | + var_dump($ex->getMessage()); |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +$stmt = $db->prepare("SELECT * FROM gh9372 WHERE col = ?"); |
| 34 | +$stream = fopen("php://memory", "w+"); |
| 35 | +fwrite($stream, 'something else'); |
| 36 | +rewind($stream); |
| 37 | +$stmt->bindvalue(1, $stream, PDO::PARAM_LOB); |
| 38 | +try { |
| 39 | + $stmt->execute(); |
| 40 | +} catch (PDOException $ex) { |
| 41 | + if ($ex->getCode() !== "22001") { |
| 42 | + var_dump($ex->getMessage()); |
| 43 | + } |
| 44 | +} |
| 45 | +?> |
| 46 | +--CLEAN-- |
| 47 | +<?php |
| 48 | +require 'ext/pdo/tests/pdo_test.inc'; |
| 49 | +$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); |
| 50 | +$db->exec("DROP TABLE gh9372"); |
| 51 | +?> |
| 52 | +--EXPECT-- |
0 commit comments