List:Commits« Previous MessageNext Message »
From:uwendel Date:April 3 2008 12:17pm
Subject:PHP mysqlnd svn commit: r1373 - trunk/tests/ext/pdo_mysql
View as plain text  
Author: uwendel
Date: 2008-04-03 14:17:29 +0200 (Thu, 03 Apr 2008)
New Revision: 1373

Added:
   trunk/tests/ext/pdo_mysql/pdo_mysql_mantis_364.phpt
Log:
Mantis #364: crash and wrong results (also wrong results with libmysql)



Added: trunk/tests/ext/pdo_mysql/pdo_mysql_mantis_364.phpt
===================================================================
--- trunk/tests/ext/pdo_mysql/pdo_mysql_mantis_364.phpt	                        (rev 0)
+++ trunk/tests/ext/pdo_mysql/pdo_mysql_mantis_364.phpt	2008-04-03 12:17:29 UTC (rev 1373)
@@ -0,0 +1,78 @@
+--TEST--
+Mantis #364 (bind - crash on cleanup?) - remove test after fix!
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('mysql_pdo_test.inc');
+MySQLPDOTest::skip();
+$db = MySQLPDOTest::factory();
+?>
+--FILE--
+<?php
+	require_once('mysql_pdo_test.inc');
+
+	$db = MySQLPDOTest::factory();
+
+	$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), grp
VARCHAR(10))');
+	$db->exec('INSERT INTO test VALUES(1, \'A\', \'Group1\')');
+	$db->exec('INSERT INTO test VALUES(2, \'B\', \'Group2\')');
+
+	$stmt = $db->prepare('SELECT id FROM test WHERE id > ? ORDER BY id ASC');
+	$in = 1;
+	$out = 1;
+
+	if (true !== ($tmp = $stmt->bindParam(1, $in)))
+		printf("[001] Expecting boolean true got %s, %s %s\n",
+			var_export($tmp, true),
+			var_export($stmt->errorCode(), true),	var_export($stmt->errorInfo(), true));
+
+	$stmt->execute();
+	var_dump($stmt->fetchAll());
+
+	$in2 = 0;
+	$in =& $in2;
+	printf("Executing statement again with in =& in2, in2 = 0 (SELECT id FROM test WHERE
id > 0 ORDER BY id ASC -> 2 rows)\n");
+	/*
+	NOTE: should return 2 rows!
+
+	http://www.php.net/manual/en/function.PDOStatement-bindParam.php
+	Binds a PHP variable to a corresponding named or question mark placeholder in the SQL
+	statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
+	the variable is bound as a reference and will only be evaluated at the time
+	that PDOStatement->execute() is called.
+	*/
+	$stmt->execute();
+	var_dump($stmt->fetchAll());
+
+	// This will crash
+	$db = MySQLPDOTest::factory();
+
+	print "done!";
+--EXPECTF--
+array(1) {
+  [0]=>
+  array(2) {
+    ["id"]=>
+    string(1) "2"
+    [0]=>
+    string(1) "2"
+  }
+}
+Executing statement again with in =& in2, in2 = 0 (SELECT id FROM test WHERE id >
0 ORDER BY id ASC -> 2 rows)
+array(2) {
+  [0]=>
+  array(2) {
+    ["id"]=>
+    string(1) "1"
+    [0]=>
+    string(1) "1"
+  }
+  [1]=>
+  array(2) {
+    ["id"]=>
+    string(1) "2"
+    [0]=>
+    string(1) "2"
+  }
+}
+done!
\ No newline at end of file

Thread
PHP mysqlnd svn commit: r1373 - trunk/tests/ext/pdo_mysqluwendel3 Apr