xref: /php-src/ext/pdo_mysql/tests/bug53551.phpt (revision a96cc80b)
1--TEST--
2Bug #53551 (PDOStatement execute segfaults for pdo_mysql driver)
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once __DIR__ . '/inc/mysql_pdo_test.inc';
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13$db = MySQLPDOTest::factory();
14
15$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
16
17$createSql = "CREATE TABLE `bug53551` (
18  `count` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'
19)";
20
21$db->exec($createSql);
22$db->exec("INSERT INTO bug53551 SET `count` = 1 ");
23$db->exec("SET sql_mode = 'Traditional'");
24$sql = 'UPDATE bug53551 SET `count` = :count';
25$stmt = $db->prepare($sql);
26
27$values = [
28    'count' => null,
29];
30
31echo "1\n";
32$stmt->execute($values);
33var_dump($stmt->errorInfo());
34
35echo "2\n";
36$stmt->execute($values);
37var_dump($stmt->errorInfo());
38
39echo "\ndone\n";
40?>
41--CLEAN--
42<?php
43require_once __DIR__ . '/inc/mysql_pdo_test.inc';
44$db = MySQLPDOTest::factory();
45$db->exec('DROP TABLE IF EXISTS bug53551');
46?>
47--EXPECTF--
481
49
50Warning: PDOStatement::execute(): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'count' cannot be null in %s on line %d
51array(3) {
52  [0]=>
53  string(5) "23000"
54  [1]=>
55  int(1048)
56  [2]=>
57  string(29) "Column 'count' cannot be null"
58}
592
60
61Warning: PDOStatement::execute(): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'count' cannot be null in %s on line %d
62array(3) {
63  [0]=>
64  string(5) "23000"
65  [1]=>
66  int(1048)
67  [2]=>
68  string(29) "Column 'count' cannot be null"
69}
70
71done
72