Re: [PATCH] mysqli #35203 / #48065 Eliminate special case for calling procedures in mysqli

From: Date: Sun, 26 Apr 2009 07:47:02 +0000
Subject: Re: [PATCH] mysqli #35203 / #48065 Eliminate special case for calling procedures in mysqli
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-43776@lists.php.net to get a copy of this message
Andrey Hristov wrote: > could you show how you want to express that in PHP code that will work > with calling prepared statements. How the API should work? (Example PHP > code that uses the new API). Sorry, I don't understand what you're asking. There is no changes to the mysqli API in this patch, its just a bug fix for mysqli::query(). If you're asking for a demonstration of the bug, there's a phpt test in the patch and demo code in the bugs. http://bugs.php.net/bug.php?id=35203 http://bugs.php.net/bug.php?id=48065 Here's a stand alone demo of the problem this patch is fixing. <?php // Just a simple SQL statement for testing. function stmt() { return "select 1"; } // Create a stored procedure around our testing statement. function setup_database() { $mysqli = connection(); $sql = stmt(); $mysqli->query("DROP PROCEDURE IF EXISTS test_bug"); $mysqli->query(" CREATE PROCEDURE test_bug() BEGIN $sql; END "); print $mysqli->error; } // Get a database connection. // Assumes a running MySQL 5 server on localhost with // a test account and database (no password) which can // drop and create procedures. function connection() { return new mysqli("localhost", "test", "", "test"); } // Using query() to call two stored procedures using query() // will fail with "Commands out of sync" function test_double_query($query) { $mysqli = connection(); if( !$mysqli->query($query) ) printf("First query FAILED: %s\n", $mysqli->error); if( !$mysqli->query($query) ) printf("Second query FAILED: %s\n", $mysqli->error); printf("ok - $query\n\n"); } setup_database(); // querying using statements or a procedure which contains // the same statement should work the same. It doesn't. test_double_query("call test_bug"); test_double_query(stmt()); ?> -- The interface should be as clean as newly fallen snow and its behavior as explicit as Japanese eel porn.

« previous php.internals (#43776) next »