diff --git a/ChangeLog b/ChangeLog index 7c67c01fc..39615ede1 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2006-04-09 Marc Delisle + * tbl_replace.php, libraries/dbi/mysqli.dbi.lib.php: bug #1255923, + detect and report silent truncation (mysqli only) + 2006-04-08 Marc Delisle * libraries/display_import.lib.php, lang/*: bug #1449793, respect file_uploads = Off diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index 7726edb8c..6f36e9341 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -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" diff --git a/tbl_replace.php b/tbl_replace.php index 1323ccfa3..44947c14e 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -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
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