bug78192.phpt 1007 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. PDO SQLite Bug #78192 SegFault when reuse statement after schema change
  3. --EXTENSIONS--
  4. pdo_sqlite
  5. --FILE--
  6. <?php
  7. $connection = new \PDO('sqlite::memory:');
  8. $connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
  9. $connection->query('CREATE TABLE user (id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(255) NOT NULL)');
  10. $stmt = $connection->prepare('INSERT INTO user (id, name) VALUES(:id, :name)');
  11. $stmt->execute([
  12. 'id' => 10,
  13. 'name' => 'test',
  14. ]);
  15. $stmt = $connection->prepare('SELECT * FROM user WHERE id = :id');
  16. $stmt->execute(['id' => 10]);
  17. var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC));
  18. $connection->query('ALTER TABLE user ADD new_col VARCHAR(255)');
  19. $stmt->execute(['id' => 10]);
  20. var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC));
  21. ?>
  22. --EXPECT--
  23. array(1) {
  24. [0]=>
  25. array(2) {
  26. ["id"]=>
  27. int(10)
  28. ["name"]=>
  29. string(4) "test"
  30. }
  31. }
  32. array(1) {
  33. [0]=>
  34. array(3) {
  35. ["id"]=>
  36. int(10)
  37. ["name"]=>
  38. string(4) "test"
  39. ["new_col"]=>
  40. NULL
  41. }
  42. }