xref: /php-src/ext/pdo_firebird/tests/ddl.phpt (revision d6a0b3af)
1--TEST--
2PDO_Firebird: DDL/transactions
3--EXTENSIONS--
4pdo_firebird
5--SKIPIF--
6<?php require('skipif.inc'); ?>
7--XLEAK--
8A bug in firebird causes a memory leak when calling `isc_attach_database()`.
9See https://github.com/FirebirdSQL/firebird/issues/7849
10--FILE--
11<?php
12
13require("testdb.inc");
14
15$dbh = getDbConnection();
16$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
17@$dbh->exec('DROP TABLE test_ddl');
18@$dbh->exec('DROP GENERATOR gen_test_ddl_id');
19@$dbh->exec('DROP TRIGGER test_ddl_bi');
20
21$dbh->exec("CREATE TABLE test_ddl (id INT NOT NULL PRIMARY KEY, text BLOB SUB_TYPE 1)");
22$dbh->exec("CREATE GENERATOR gen_test_ddl_id");
23$dbh->exec("CREATE TRIGGER test_ddl_bi FOR test_ddl BEFORE INSERT AS
24    BEGIN IF (NEW.id IS NULL) THEN NEW.id=GEN_ID(gen_test_ddl_id,1); END");
25
26$dbh->setAttribute(PDO::ATTR_AUTOCOMMIT,0);
27
28$dbh->beginTransaction();
29var_dump($dbh->exec("INSERT INTO test_ddl (text) VALUES ('bla')"));
30var_dump($dbh->exec("UPDATE test_ddl SET text='blabla'"));
31$dbh->rollback();
32
33$dbh->beginTransaction();
34var_dump($dbh->exec("DELETE FROM test_ddl"));
35$dbh->commit();
36
37@$dbh->exec('DROP TABLE test_ddl');
38@$dbh->exec('DROP GENERATOR gen_test_ddl_id');
39@$dbh->exec('DROP TRIGGER test_ddl_bi');
40
41unset($dbh);
42echo "done\n";
43?>
44--EXPECT--
45int(1)
46int(1)
47int(0)
48done
49