diff --git a/ChangeLog b/ChangeLog index 4a3353d21..9c01b0282 100755 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ $Source$ * querywindow.php: wrong handling of linebreaks in query: bug #1243888 * left.php, sql.php, tbl_change.php, libraries/common.lib.php, libraries/querywindow.js: update row count in left frame bug #1243908 + * libraries/common.lib.php: + bug #1216521: display duplicate rows for failed unique key creation 2005-10-17 Michal ÄŒihaÅ™ * lang/czech: Translation fixes. diff --git a/libraries/common.lib.php b/libraries/common.lib.php index a8525f8b7..e9ccf3071 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -610,12 +610,7 @@ if ($is_minimum_common == FALSE) { } // --- echo "\n" . '' . "\n"; - echo ' ' - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . '
' . $GLOBALS['strError'] . '
'; + echo '

' . $GLOBALS['strError'] . '

' . "\n"; // if the config password is wrong, or the MySQL server does not // respond, do not show the query that would reveal the // username/password @@ -624,12 +619,14 @@ if ($is_minimum_common == FALSE) { // Robbat2 - 12 January 2003, 9:46PM // Revised, Robbat2 - 13 January 2003, 2:59PM if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) { - echo PMA_SQP_getErrorString(); + echo '
' . "\n"; + echo PMA_SQP_getErrorString() . "\n"; + echo '
' . "\n"; } // --- // modified to show me the help on sql errors (Michael Keck) - echo '

' . "\n"; - echo ' ' . $GLOBALS['strSQLQuery'] . ':' . "\n"; + echo '

' . "\n"; + echo '

' . $GLOBALS['strSQLQuery'] . ':' . "\n"; if (strstr(strtolower($formatted_sql),'select')) { // please show me help to the error on select echo PMA_showMySQLDocu('Reference', 'SELECT'); } @@ -649,10 +646,10 @@ if ($is_minimum_common == FALSE) { . ']' . "\n"; } } // end if - echo '

' . "\n" - . '

' . "\n" - . ' ' . $formatted_sql . "\n" - . '

' . "\n"; + echo '

' . "\n" + .'

' . "\n" + .' ' . $formatted_sql . "\n" + .'

' . "\n"; } // end if $tmp_mysql_error = ''; // for saving the original $error_message @@ -662,8 +659,8 @@ if ($is_minimum_common == FALSE) { $error_message = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $error_message); } // modified to show me the help on error-returns (Michael Keck) - echo '

' . "\n" - . ' ' . $GLOBALS['strMySQLSaid'] . '' + echo '

' . "\n" + . ' ' . $GLOBALS['strMySQLSaid'] . '' . PMA_showMySQLDocu('Error-returns', 'Error-returns') . "\n" . '

' . "\n"; @@ -688,47 +685,43 @@ if ($is_minimum_common == FALSE) { // 2005-01-17 modified by mkkeck bugfix if (substr($error_message, 1, 4) == '1062') { // get the duplicate entry - $mysql_error_values = array(); - $mysql_error_words = explode(' ',$tmp_mysql_error); - foreach ($mysql_error_words as $mysql_error_word) { - if (strstr($mysql_error_word, "'")) { - $mysql_error_values = explode('-', preg_replace("/'/", "", $mysql_error_word)); - break; // exit 'foreach' - } - } - $duplicate_sql_query = ''; - if (isset($mysql_error_values[0])) { - $tmp_fields = PMA_DBI_get_fields($db, $table, NULL); - if ($tmp_fields) { - foreach ($tmp_fields as $tmp_field) { - $duplicate_sql_query .= (($duplicate_sql_query!='') ? ' OR ' : '') . PMA_backquote($tmp_field['Field']) . " LIKE '" . $mysql_error_values[0] . "'"; - } - } - } - if ($duplicate_sql_query!='') { - $duplicate_sql_query = "SELECT * FROM " . PMA_backquote($table) . " WHERE (" . $duplicate_sql_query . ")"; - } else { - $duplicate_sql_query = "SELECT * FROM " . PMA_backquote($table) . ""; - } - echo '
' ."\n" - . ' ' . "\n" - . ' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n" - . ' ' . "\n" - . '
' . "\n"; + + // get table name + preg_match( '°ALTER\sTABLE\s\`([^\`]+)\`°iu', $the_query, $error_table = array() ); + $error_table = $error_table[1]; + + // get fields + preg_match( '°\(([^\)]+)\)°i', $the_query, $error_fields = array() ); + $error_fields = explode( ',', $error_fields[1] ); + + // duplicate value + preg_match( '°\'([^\']+)\'°i', $tmp_mysql_error, $duplicate_value = array() ); + $duplicate_value = $duplicate_value[1]; + + $sql = ' + SELECT * + FROM ' . PMA_backquote( $error_table ) . ' + WHERE CONCAT_WS( "-", ' . implode( ', ', $error_fields ) . ' ) + = "' . PMA_sqlAddslashes( $duplicate_value ) . '" + ORDER BY ' . implode( ', ', $error_fields ); + unset( $error_table, $error_fields, $duplicate_value ); + + echo '
' ."\n" + .' ' . "\n" + .' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n" + .' ' . "\n" + .'
' . "\n"; + unset( $sql ); } // end of show duplicate entry echo '
'; + echo '
'; if (!empty($back_url) && $exit) { - $goto_back_url=' '; - echo '
'; - echo '[' . $goto_back_url . $GLOBALS['strBack'] . ' ]'; + $goto_back_url=''; + echo '[ ' . $goto_back_url . $GLOBALS['strBack'] . ' ]'; } - echo '
' . "\n\n"; + echo ' ' . "\n\n"; if ($exit) { require_once('./footer.inc.php'); } diff --git a/themes/original/css/theme_right.css.php b/themes/original/css/theme_right.css.php index 35e28eeb8..020ee5ef5 100644 --- a/themes/original/css/theme_right.css.php +++ b/themes/original/css/theme_right.css.php @@ -206,7 +206,8 @@ span.tab, span.tabcaution { /* Warning showing div with right border and optional icon */ -div.errorhead { +.errorhead { + background-color: #FF0000; font-weight: bold; color: #ffffff; text-align: left; @@ -214,12 +215,15 @@ div.errorhead { background-image: url(../themes/original/img/s_error.png); background-repeat: no-repeat; background-position: 5px 50%; - padding: 0px 0px 0px 25px; - - margin: 0px; + padding: 0 0 0 25px; + + padding: 0.2em; + + margin: 0.5em 0 0 0; } /* tables */ +.error, .tblError { border: 1px solid #FF0000; background-color: #FFFFCC;