bug #1255923, detect and report silent truncation (mysqli)

This commit is contained in:
Marc Delisle
2006-04-09 11:01:41 +00:00
parent 0a7b433275
commit 48c548e515
3 changed files with 29 additions and 3 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$
$Source$
2006-04-09 Marc Delisle <lem9@users.sourceforge.net>
* tbl_replace.php, libraries/dbi/mysqli.dbi.lib.php: bug #1255923,
detect and report silent truncation (mysqli only)
2006-04-08 Marc Delisle <lem9@users.sourceforge.net>
* libraries/display_import.lib.php, lang/*: bug #1449793,
respect file_uploads = Off

View File

@@ -168,7 +168,21 @@ function PMA_DBI_try_query($query, $link = null, $options = 0)
if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION < 40100) {
$query = PMA_convert_charset($query);
}
return mysqli_query($link, $query, $method);
$result = mysqli_query($link, $query, $method);
if (mysqli_warning_count($link)) {
// TODO: check $method ?
$warning_result = mysqli_query($link, 'SHOW WARNINGS');
if ($warning_result) {
$warning_row = mysqli_fetch_row($warning_result);
$GLOBALS['warning'] = sprintf("%s (%d): %s", $warning_row[0], $warning_row[1], $warning_row[2]);
}
} else {
unset($GLOBALS['warning']);
}
return $result;
// From the PHP manual:
// "note: returns true on success or false on failure. For SELECT,
// SHOW, DESCRIBE or EXPLAIN, mysqli_query() will return a result object"

View File

@@ -234,6 +234,7 @@ if (empty($valuelist) && empty($query)) {
$sql_query = implode(';', $query) . ';';
$total_affected_rows = 0;
$last_message = '';
$warning_message = '';
foreach ($query AS $query_index => $single_query) {
if ($cfg['IgnoreMultiSubmitErrors']) {
@@ -241,6 +242,9 @@ foreach ($query AS $query_index => $single_query) {
} else {
$result = PMA_DBI_query($single_query);
}
if (isset($GLOBALS['warning'])) {
$warning_message .= $GLOBALS['warning'] . '[br]';
}
if (!$result) {
$message .= PMA_DBI_getError();
} else {
@@ -265,6 +269,12 @@ if ($total_affected_rows != 0) {
$message .= $last_message;
if (!empty($warning_message)) {
// TODO: use a <div class="warning"> in PMA_showMessage()
// for this part of the message
$message .= '[br]' . $warning_message;
}
if ($is_gotofile) {
if ($goto == 'db_details.php' && isset($table)) {
unset($table);
@@ -274,8 +284,6 @@ if ($is_gotofile) {
require_once('./libraries/header.inc.php');
require('./' . PMA_securePath($goto));
} else {
// I don't understand this one:
//$add_query = (strpos(' ' . $goto, 'tbl_change') ? '&disp_query=' . urlencode($sql_query) : '');
// if we have seen binary,
// we do not append the query to the Location so it won't be displayed