From:             fhardy at noparking dot net
Operating system: FreeBSD 7.1-PRERELEASE
PHP version:      5.2.6
PHP Bug Type:     MySQLi related
Bug description:  multi_query does not handler ALTER TABLE... ADD CONSTRAINT...

Description:
------------
Using mysqli::multi_query() in order to create database table in innodb
format with foreign key failed with mysql 5.1 RC.
All is fine with mysql 5.0.67


Reproduce code:
---------------
<?php

$sql = 'SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
DROP TABLE IF EXISTS `bank_transactions`;
CREATE TABLE `bank_transactions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `client` (`client_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `clients`;
CREATE TABLE `clients` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
ALTER TABLE `bank_transactions` ADD CONSTRAINT `bank_transactions_ibfk_1`
FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON UPDATE CASCADE;';

$mysqli = new mysqli('myhost', 'myuser', 'mypassword', 'mydatabase');

if ($mysqli->connect_error) {
    printf('Connect failed: %s\n', mysqli_connect_error());
} else {
        if (!$mysqli->multi_query($sql)) {
                printf('Unable to execute sql');
        } else {
                do {
                        if ($result = $mysqli->store_result()) {
                                $result->free();
                        }
                } while ($mysqli->next_result());
        }

        $mysqli->close();
}

?>


Expected result:
----------------
Database "mydatabase" must contain two tables, clients and
bank_transactions, and one constraint between this tables.


Actual result:
--------------
I have an empty database and no error message from mysqli object.

-- 
Edit bug report at http://bugs.php.net/?id=46611&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46611&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46611&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46611&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46611&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46611&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46611&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46611&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46611&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46611&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46611&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46611&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46611&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46611&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46611&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46611&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46611&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46611&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46611&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46611&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46611&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46611&r=mysqlcfg

Reply via email to