Bug #73260 [NEW]: Multi SQL queries with CREATE TRIGGER inbetween adds flawed ; to trigger code
| From: | php_net at milania dot de | Date: | Thu, 06 Oct 2016 19:27:18 +0000 |
| Subject: | Bug #73260 [NEW]: Multi SQL queries with CREATE TRIGGER inbetween adds flawed ; to trigger code | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-204518@lists.php.net to get a copy of this message | ||
From: php_net at milania dot de
Operating system: Win10x64
PHP version: 7.0.11
Package: MySQL related
Bug Type: Bug
Bug description:Multi SQL queries with CREATE TRIGGER inbetween adds flawed ; to trigger code
Description:
------------
Calling sql query containing multiple statements with a CREATE TRIGGER
statement inbetween results in an additional (flawed) ; to be added to
the trigger code.
The semicolon will only be added, if an additional statement follows
after the CREATE TRIGGER statement (like 'SELECT * FROM Student;' in the
example below). If the CREATE TRIGGER statement is the last, no
semicolon is added (what is ok).
The error happens with both, PDO (mysqlnd 5.0.12-dev - 20150407) and
mysqli (mysqlnd 5.0.12-dev - 20150407) drivers.
The error does not happen when the queries are executed from phpMyAdmin
or from the mysql console (mysql -u root -h localhost test <
triggerTest.sql).
Tested with 10.1.16-MariaDB and 5.5.46-0 MySQL.
If you wonder what the problem with the ; is about: it breaks mysqldump
resulting in syntax errors.
Test script:
---------------
$sql = "DROP TRIGGER IF EXISTS TriggerStudent;
DROP TABLE IF EXISTS Student;
CREATE TABLE
test.Student(
id INT NOT NULL AUTO_INCREMENT,
idInc INT NOT NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB;
CREATE TRIGGER TriggerStudent BEFORE INSERT ON Student
FOR EACH ROW
SET NEW.idInc = NEW.id + 1;
SELECT *
FROM Student;";
$db = new PDO("mysql:host=localhost;dbname=test;charset=UTF8", "root",
"");
$erg = $db->exec($sql);
//$mysqli = new mysqli("localhost", "root", "", "test");
// Same
problem
//$mysqli->multi_query($sql);
Expected result:
----------------
SET NEW.idInc = NEW.id + 1
in the Statement column of SHOW TRIGGERS.
Actual result:
--------------
SET NEW.idInc = NEW.id + 1;
in the Statement column of SHOW TRIGGERS.
--
Edit bug report at https://bugs.php.net/bug.php?id=73260&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73260&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73260&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73260&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73260&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73260&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73260&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73260&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73260&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73260&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73260&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73260&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73260&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73260&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73260&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73260&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73260&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73260&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73260&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73260&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73260&r=mysqlcfg