List:Commits« Previous MessageNext Message »
From:uwendel Date:September 4 2007 8:03pm
Subject:PHP mysqlnd svn commit: r984 - trunk/tests/ext/mysqli
View as plain text  
Author: uwendel
Date: 2007-09-04 20:03:54 +0200 (Tue, 04 Sep 2007)
New Revision: 984

Modified:
   trunk/tests/ext/mysqli/mysqli_stmt_bind_result_format.phpt
Log:
More testing related to http://bugs.php.net/bug.php?id=42378.
Can't reproduce the memory issues reported.



Modified: trunk/tests/ext/mysqli/mysqli_stmt_bind_result_format.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_stmt_bind_result_format.phpt	2007-09-04 15:21:24 UTC
(rev 983)
+++ trunk/tests/ext/mysqli/mysqli_stmt_bind_result_format.phpt	2007-09-04 18:03:54 UTC
(rev 984)
@@ -200,6 +200,132 @@
 		$expected[$k] = number_format(round($v), 0, '.', ',');
 	test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 240);
 
+	// http://bugs.php.net/bug.php?id=42378
+	if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+		printf("[300] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	}
+
+	if (mysqli_query($link, "CREATE TABLE `test` (
+  `targetport` int(11) NOT NULL default '0',
+  `sources` double(17,4) default NULL,
+  `current_sources` double(17,0) default NULL,
+  `reports` double(17,4) default NULL,
+  `current_reports` double(17,0) default NULL,
+  `targets` double(17,4) default NULL,
+  `current_targets` double(17,0) default NULL,
+  `maxsources` int(11) default NULL,
+  `maxtargets` int(11) default NULL,
+  `maxreports` int(11) default NULL,
+  `trend` float default NULL,
+  PRIMARY KEY  (`targetport`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1")) {
+
+		do {
+			$values = array();
+			for ($i = 0; $i < 200; $i++) {
+				$current_targets = mt_rand(-100000, 100000) / 10;
+				do {
+					$trend = (mt_rand(0, 3) > 1) ? (mt_rand(-10000, 10000) / 100) : 'NULL';
+				} while (isset($values[$trend]));
+
+				$sql = sprintf('INSERT INTO test(targetport, current_targets, maxreports, trend)
VALUES (%d, %f, %s, %s)',
+					$i,
+					$current_targets,
+					(mt_rand(0, 1) > 0) ? mt_rand(0, 1000) : 'NULL',
+					$trend);
+				if (!mysqli_query($link, $sql)) {
+					printf("[301] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+					break 2;
+				}
+				if ($current_targets > 0 && $trend != 'NULL')
+					$values[$trend] = $i;
+			}
+			krsort($values);
+
+			if (!$stmt = mysqli_stmt_init($link)) {
+				printf("[302] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+				break;
+			}
+
+			if (!mysqli_stmt_prepare($stmt, 'SELECT trend, targetport, FORMAT(trend, 2) FROM test
WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) {
+				printf("[303] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+				break;
+			}
+
+			if (!mysqli_stmt_execute($stmt)) {
+				printf("[304] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+				break;
+			}
+
+			if (!mysqli_stmt_store_result($stmt)) {
+				printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+				break;
+			}
+
+			$trend = $targetport = $format = null;
+			if (!mysqli_stmt_bind_result($stmt, $trend, $targetport, $format)) {
+
+				printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+				break;
+			}
+
+			reset($values);
+			while (mysqli_stmt_fetch($stmt)) {
+				list($exp_trend, $exp_targetport) = each($values);
+				if ($targetport != $exp_targetport) {
+					printf("[306] Values fetched from MySQL seem to be wrong, check manually\n");
+					printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport,
$format);
+				}
+			}
+			mysqli_stmt_free_result($stmt);
+			mysqli_stmt_close($stmt);
+
+			// same but OO interface
+			if (!$stmt = mysqli_stmt_init($link)) {
+				printf("[307] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+				break;
+			}
+
+			if (!$stmt->prepare('SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE
current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) {
+				printf("[308] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+				break;
+			}
+
+			if (!$stmt->execute()) {
+				printf("[309] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+				break;
+			}
+
+			if (!$stmt->store_result()) {
+				printf("[310] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+				break;
+			}
+
+			$trend = $targetport = $format = null;
+			if (!$stmt->bind_result($trend, $targetport, $format)) {
+
+				printf("[311] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+				break;
+			}
+
+			reset($values);
+			while ($stmt->fetch()) {
+				list($exp_trend, $exp_targetport) = each($values);
+				if ($targetport != $exp_targetport) {
+					printf("[312] Values fetched from MySQL seem to be wrong, check manually\n");
+					printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport,
$format);
+				}
+			}
+			$stmt->free_result();
+			$stmt->close();
+
+		} while (false);
+
+	} else {
+		var_dump(mysqli_error($link));
+	}
+
+
 	mysqli_close($link);
 	print "done!";
 ?>

Thread
PHP mysqlnd svn commit: r984 - trunk/tests/ext/mysqliuwendel4 Sep