bug #1216521: display duplicate rows for failed unique key creation
This commit is contained in:
@@ -9,6 +9,8 @@ $Source$
|
|||||||
* querywindow.php: wrong handling of linebreaks in query: bug #1243888
|
* querywindow.php: wrong handling of linebreaks in query: bug #1243888
|
||||||
* left.php, sql.php, tbl_change.php, libraries/common.lib.php,
|
* left.php, sql.php, tbl_change.php, libraries/common.lib.php,
|
||||||
libraries/querywindow.js: update row count in left frame bug #1243908
|
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ř <michal@cihar.com>
|
2005-10-17 Michal Čihař <michal@cihar.com>
|
||||||
* lang/czech: Translation fixes.
|
* lang/czech: Translation fixes.
|
||||||
|
@@ -610,12 +610,7 @@ if ($is_minimum_common == FALSE) {
|
|||||||
}
|
}
|
||||||
// ---
|
// ---
|
||||||
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
|
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
|
||||||
echo ' <table border="0" cellpadding="2" cellspacing="1">'
|
echo ' <h1 class="errorhead">' . $GLOBALS['strError'] . '</h1>' . "\n";
|
||||||
. ' <tr>' . "\n"
|
|
||||||
. ' <th class="tblHeadError"><div class="errorhead">' . $GLOBALS['strError'] . '</div></th>' . "\n"
|
|
||||||
. ' </tr>' . "\n"
|
|
||||||
. ' <tr>' . "\n"
|
|
||||||
. ' <td>';
|
|
||||||
// if the config password is wrong, or the MySQL server does not
|
// if the config password is wrong, or the MySQL server does not
|
||||||
// respond, do not show the query that would reveal the
|
// respond, do not show the query that would reveal the
|
||||||
// username/password
|
// username/password
|
||||||
@@ -624,12 +619,14 @@ if ($is_minimum_common == FALSE) {
|
|||||||
// Robbat2 - 12 January 2003, 9:46PM
|
// Robbat2 - 12 January 2003, 9:46PM
|
||||||
// Revised, Robbat2 - 13 January 2003, 2:59PM
|
// Revised, Robbat2 - 13 January 2003, 2:59PM
|
||||||
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
|
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
|
||||||
echo PMA_SQP_getErrorString();
|
echo '<div class="error">' . "\n";
|
||||||
|
echo PMA_SQP_getErrorString() . "\n";
|
||||||
|
echo '</div>' . "\n";
|
||||||
}
|
}
|
||||||
// ---
|
// ---
|
||||||
// modified to show me the help on sql errors (Michael Keck)
|
// modified to show me the help on sql errors (Michael Keck)
|
||||||
echo '<div class="tblWarn"><p>' . "\n";
|
echo '<div class="error">' . "\n";
|
||||||
echo ' <b>' . $GLOBALS['strSQLQuery'] . ':</b>' . "\n";
|
echo ' <p><strong>' . $GLOBALS['strSQLQuery'] . ':</strong>' . "\n";
|
||||||
if (strstr(strtolower($formatted_sql),'select')) { // please show me help to the error on select
|
if (strstr(strtolower($formatted_sql),'select')) { // please show me help to the error on select
|
||||||
echo PMA_showMySQLDocu('Reference', 'SELECT');
|
echo PMA_showMySQLDocu('Reference', 'SELECT');
|
||||||
}
|
}
|
||||||
@@ -649,10 +646,10 @@ if ($is_minimum_common == FALSE) {
|
|||||||
. ']' . "\n";
|
. ']' . "\n";
|
||||||
}
|
}
|
||||||
} // end if
|
} // end if
|
||||||
echo '</p>' . "\n"
|
echo ' </p>' . "\n"
|
||||||
. '<p>' . "\n"
|
.' <p>' . "\n"
|
||||||
. ' ' . $formatted_sql . "\n"
|
.' ' . $formatted_sql . "\n"
|
||||||
. '</p></div>' . "\n";
|
.' </p></div>' . "\n";
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
$tmp_mysql_error = ''; // for saving the original $error_message
|
$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);
|
$error_message = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $error_message);
|
||||||
}
|
}
|
||||||
// modified to show me the help on error-returns (Michael Keck)
|
// modified to show me the help on error-returns (Michael Keck)
|
||||||
echo '<div class="tblWarn"><p>' . "\n"
|
echo '<div class="error"><p>' . "\n"
|
||||||
. ' <b>' . $GLOBALS['strMySQLSaid'] . '</b>'
|
. ' <strong>' . $GLOBALS['strMySQLSaid'] . '</strong>'
|
||||||
. PMA_showMySQLDocu('Error-returns', 'Error-returns')
|
. PMA_showMySQLDocu('Error-returns', 'Error-returns')
|
||||||
. "\n"
|
. "\n"
|
||||||
. '</p>' . "\n";
|
. '</p>' . "\n";
|
||||||
@@ -688,47 +685,43 @@ if ($is_minimum_common == FALSE) {
|
|||||||
// 2005-01-17 modified by mkkeck bugfix
|
// 2005-01-17 modified by mkkeck bugfix
|
||||||
if (substr($error_message, 1, 4) == '1062') {
|
if (substr($error_message, 1, 4) == '1062') {
|
||||||
// get the duplicate entry
|
// get the duplicate entry
|
||||||
$mysql_error_values = array();
|
|
||||||
$mysql_error_words = explode(' ',$tmp_mysql_error);
|
// get table name
|
||||||
foreach ($mysql_error_words as $mysql_error_word) {
|
preg_match( '<27>ALTER\sTABLE\s\`([^\`]+)\`<60>iu', $the_query, $error_table = array() );
|
||||||
if (strstr($mysql_error_word, "'")) {
|
$error_table = $error_table[1];
|
||||||
$mysql_error_values = explode('-', preg_replace("/'/", "", $mysql_error_word));
|
|
||||||
break; // exit 'foreach'
|
// get fields
|
||||||
}
|
preg_match( '<27>\(([^\)]+)\)<29>i', $the_query, $error_fields = array() );
|
||||||
}
|
$error_fields = explode( ',', $error_fields[1] );
|
||||||
$duplicate_sql_query = '';
|
|
||||||
if (isset($mysql_error_values[0])) {
|
// duplicate value
|
||||||
$tmp_fields = PMA_DBI_get_fields($db, $table, NULL);
|
preg_match( '<27>\'([^\']+)\'<27>i', $tmp_mysql_error, $duplicate_value = array() );
|
||||||
if ($tmp_fields) {
|
$duplicate_value = $duplicate_value[1];
|
||||||
foreach ($tmp_fields as $tmp_field) {
|
|
||||||
$duplicate_sql_query .= (($duplicate_sql_query!='') ? ' OR ' : '') . PMA_backquote($tmp_field['Field']) . " LIKE '" . $mysql_error_values[0] . "'";
|
$sql = '
|
||||||
}
|
SELECT *
|
||||||
}
|
FROM ' . PMA_backquote( $error_table ) . '
|
||||||
}
|
WHERE CONCAT_WS( "-", ' . implode( ', ', $error_fields ) . ' )
|
||||||
if ($duplicate_sql_query!='') {
|
= "' . PMA_sqlAddslashes( $duplicate_value ) . '"
|
||||||
$duplicate_sql_query = "SELECT * FROM " . PMA_backquote($table) . " WHERE (" . $duplicate_sql_query . ")";
|
ORDER BY ' . implode( ', ', $error_fields );
|
||||||
} else {
|
unset( $error_table, $error_fields, $duplicate_value );
|
||||||
$duplicate_sql_query = "SELECT * FROM " . PMA_backquote($table) . "";
|
|
||||||
}
|
echo ' <form method="post" action="import.php" style="padding: 0; margin: 0">' ."\n"
|
||||||
echo ' <form method="post" action="import.php" style="padding: 0px; margin: 0px">' ."\n"
|
.' <input type="hidden" name="sql_query" value="' . htmlentities( $sql ) . '" />' . "\n"
|
||||||
. ' <input type="hidden" name="sql_query" value="' . $duplicate_sql_query . '" />' . "\n"
|
.' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n"
|
||||||
. ' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n"
|
.' <input type="submit" name="submit" value="' . $GLOBALS['strBrowse'] . '" />' . "\n"
|
||||||
. ' <input type="submit" name="submit" value="' . $GLOBALS['strBrowse'] . '" />' . "\n"
|
.' </form>' . "\n";
|
||||||
. ' </form>' . "\n";
|
unset( $sql );
|
||||||
} // end of show duplicate entry
|
} // end of show duplicate entry
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
echo '<fieldset class="tblFooters">';
|
||||||
|
|
||||||
if (!empty($back_url) && $exit) {
|
if (!empty($back_url) && $exit) {
|
||||||
$goto_back_url='<a href="' . (strstr($back_url, '?') ? $back_url . '&no_history=true' : $back_url . '?no_history=true') . '"> ';
|
$goto_back_url='<a href="' . (strstr($back_url, '?') ? $back_url . '&no_history=true' : $back_url . '?no_history=true') . '">';
|
||||||
echo ' </td> ' . "\n"
|
echo '[ ' . $goto_back_url . $GLOBALS['strBack'] . '</a> ]';
|
||||||
. ' </tr>' . "\n"
|
|
||||||
. ' <tr><td class="tblHeaders" align="center">';
|
|
||||||
echo '[' . $goto_back_url . $GLOBALS['strBack'] . ' </a>]';
|
|
||||||
}
|
}
|
||||||
echo ' </td>' . "\n"
|
echo ' </fieldset>' . "\n\n";
|
||||||
. ' </tr>' . "\n"
|
|
||||||
. ' </table>' . "\n\n";
|
|
||||||
if ($exit) {
|
if ($exit) {
|
||||||
require_once('./footer.inc.php');
|
require_once('./footer.inc.php');
|
||||||
}
|
}
|
||||||
|
@@ -206,7 +206,8 @@ span.tab, span.tabcaution {
|
|||||||
|
|
||||||
/* Warning showing div with right border and optional icon */
|
/* Warning showing div with right border and optional icon */
|
||||||
|
|
||||||
div.errorhead {
|
.errorhead {
|
||||||
|
background-color: #FF0000;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
@@ -214,12 +215,15 @@ div.errorhead {
|
|||||||
background-image: url(../themes/original/img/s_error.png);
|
background-image: url(../themes/original/img/s_error.png);
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: 5px 50%;
|
background-position: 5px 50%;
|
||||||
padding: 0px 0px 0px 25px;
|
padding: 0 0 0 25px;
|
||||||
<?php } ?>
|
<?php } else {?>
|
||||||
margin: 0px;
|
padding: 0.2em;
|
||||||
|
<?php }?>
|
||||||
|
margin: 0.5em 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tables */
|
/* tables */
|
||||||
|
.error,
|
||||||
.tblError {
|
.tblError {
|
||||||
border: 1px solid #FF0000;
|
border: 1px solid #FF0000;
|
||||||
background-color: #FFFFCC;
|
background-color: #FFFFCC;
|
||||||
|
Reference in New Issue
Block a user