uw Tue, 26 Jul 2011 15:37:59 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=313737
Log:
Check what happens if switching DB via API fails. Expected: no change of
current DB/schema.
Changed paths:
U php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_select_db.phpt
U php/php-src/branches/PHP_5_4/ext/mysqli/tests/mysqli_select_db.phpt
U php/php-src/trunk/ext/mysqli/tests/mysqli_select_db.phpt
Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_select_db.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_select_db.phpt
2011-07-26 15:33:47 UTC (rev 313736)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_select_db.phpt
2011-07-26 15:37:59 UTC (rev 313737)
@@ -55,15 +55,33 @@
mysqli_free_result($res);
}
- mysqli_report(MYSQLI_REPORT_OFF);
+ if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
+ printf("[012] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[013] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ $current_db = $row['dbname'];
+
+ mysqli_report(MYSQLI_REPORT_OFF);
mysqli_select_db($link, 'I can not imagine that this database exists');
mysqli_report(MYSQLI_REPORT_ERROR);
mysqli_select_db($link, 'I can not imagine that this database exists');
+ if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
+ printf("[014] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[015] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ if (strtolower($row['dbname']) != strtolower($current_db))
+ printf("[016] Current DB should not change if set fails\n");
+
+
mysqli_close($link);
if (NULL !== ($tmp = mysqli_select_db($link, $db)))
- printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp),
$tmp);
+ printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp),
$tmp);
print "done!\n";
?>
Modified: php/php-src/branches/PHP_5_4/ext/mysqli/tests/mysqli_select_db.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/mysqli/tests/mysqli_select_db.phpt
2011-07-26 15:33:47 UTC (rev 313736)
+++ php/php-src/branches/PHP_5_4/ext/mysqli/tests/mysqli_select_db.phpt
2011-07-26 15:37:59 UTC (rev 313737)
@@ -55,15 +55,33 @@
mysqli_free_result($res);
}
- mysqli_report(MYSQLI_REPORT_OFF);
+ if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
+ printf("[012] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[013] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ $current_db = $row['dbname'];
+
+ mysqli_report(MYSQLI_REPORT_OFF);
mysqli_select_db($link, 'I can not imagine that this database exists');
mysqli_report(MYSQLI_REPORT_ERROR);
mysqli_select_db($link, 'I can not imagine that this database exists');
+ if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
+ printf("[014] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[015] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ if (strtolower($row['dbname']) != strtolower($current_db))
+ printf("[016] Current DB should not change if set fails\n");
+
+
mysqli_close($link);
if (NULL !== ($tmp = mysqli_select_db($link, $db)))
- printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp),
$tmp);
+ printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp),
$tmp);
print "done!\n";
?>
Modified: php/php-src/trunk/ext/mysqli/tests/mysqli_select_db.phpt
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/mysqli_select_db.phpt 2011-07-26
15:33:47 UTC (rev 313736)
+++ php/php-src/trunk/ext/mysqli/tests/mysqli_select_db.phpt 2011-07-26
15:37:59 UTC (rev 313737)
@@ -55,15 +55,33 @@
mysqli_free_result($res);
}
- mysqli_report(MYSQLI_REPORT_OFF);
+ if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
+ printf("[012] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[013] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ $current_db = $row['dbname'];
+
+ mysqli_report(MYSQLI_REPORT_OFF);
mysqli_select_db($link, 'I can not imagine that this database exists');
mysqli_report(MYSQLI_REPORT_ERROR);
mysqli_select_db($link, 'I can not imagine that this database exists');
+ if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
+ printf("[014] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[015] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+ if (strtolower($row['dbname']) != strtolower($current_db))
+ printf("[016] Current DB should not change if set fails\n");
+
+
mysqli_close($link);
if (NULL !== ($tmp = mysqli_select_db($link, $db)))
- printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp),
$tmp);
+ printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp),
$tmp);
print "done!\n";
?>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php