Don't use LIMIT 1 if updating unique row (bug #3613109)
This commit is contained in:
parent
2f996ba014
commit
af30f59737
|
@ -17,8 +17,17 @@ if ($_POST && !$error && !isset($_GET["select"])) {
|
|||
$location = ME . "select=" . urlencode($TABLE);
|
||||
}
|
||||
|
||||
$indexes = indexes($TABLE);
|
||||
$unique_array = unique_array($_GET["where"], $indexes);
|
||||
$query_where = "\nWHERE $where";
|
||||
|
||||
if (isset($_POST["delete"])) {
|
||||
query_redirect("DELETE" . limit1("FROM " . table($TABLE), " WHERE $where"), $location, lang('Item has been deleted.'));
|
||||
$query = "FROM " . table($TABLE);
|
||||
query_redirect(
|
||||
"DELETE" . ($unique_array ? " $query$query_where" : limit1($query, $query_where)),
|
||||
$location,
|
||||
lang('Item has been deleted.')
|
||||
);
|
||||
} else {
|
||||
$set = array();
|
||||
foreach ($fields as $name => $field) {
|
||||
|
@ -32,7 +41,12 @@ if ($_POST && !$error && !isset($_GET["select"])) {
|
|||
if (!$set) {
|
||||
redirect($location);
|
||||
}
|
||||
query_redirect("UPDATE" . limit1(table($TABLE) . " SET" . implode(",", $set), "\nWHERE $where"), $location, lang('Item has been updated.'));
|
||||
$query = table($TABLE) . " SET" . implode(",", $set);
|
||||
query_redirect(
|
||||
"UPDATE" . ($unique_array ? " $query$query_where" : limit1($query, $query_where)),
|
||||
$location,
|
||||
lang('Item has been updated.')
|
||||
);
|
||||
} else {
|
||||
$result = insert_into($TABLE, $set);
|
||||
$last_id = ($result ? last_id() : 0);
|
||||
|
|
|
@ -303,7 +303,7 @@ function get_rows($query, $connection2 = null, $error = "<p class='error'>") {
|
|||
/** Find unique identifier of a row
|
||||
* @param array
|
||||
* @param array result of indexes()
|
||||
* @return array
|
||||
* @return array or null if there is no unique identifier
|
||||
*/
|
||||
function unique_array($row, $indexes) {
|
||||
foreach ($indexes as $index) {
|
||||
|
@ -318,13 +318,6 @@ function unique_array($row, $indexes) {
|
|||
return $return;
|
||||
}
|
||||
}
|
||||
$return = array();
|
||||
foreach ($row as $key => $val) {
|
||||
if (!preg_match('~^(COUNT\\((\\*|(DISTINCT )?`(?:[^`]|``)+`)\\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\\(`(?:[^`]|``)+`\\))$~', $key)) { //! columns looking like functions
|
||||
$return[$key] = $val;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/** Create SQL condition from parsed query string
|
||||
|
|
|
@ -332,6 +332,14 @@ if (!$columns) {
|
|||
|
||||
foreach ($adminer->rowDescriptions($rows, $foreign_keys) as $n => $row) {
|
||||
$unique_array = unique_array($rows[$n], $indexes);
|
||||
if (!$unique_array) {
|
||||
$unique_array = array();
|
||||
foreach ($rows[$n] as $key => $val) {
|
||||
if (!preg_match('~^(COUNT\\((\\*|(DISTINCT )?`(?:[^`]|``)+`)\\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\\(`(?:[^`]|``)+`\\))$~', $key)) { //! columns looking like functions
|
||||
$unique_array[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
$unique_idf = "";
|
||||
foreach ($unique_array as $key => $val) {
|
||||
if (strlen($val) > 64) {
|
||||
|
|
|
@ -9,6 +9,7 @@ Remove bzip2 compression support
|
|||
Constraint memory used in TAR export
|
||||
Allow exporting views dependent on each other (bug #3459151)
|
||||
Fix resetting search (bug #3612507)
|
||||
Don't use LIMIT 1 if updating unique row (bug #3613109)
|
||||
Restrict editing rows without unique identifier to search results
|
||||
Display navigation bellow main content on mobile browsers
|
||||
MySQL: Optimize create table page and Editor navigation
|
||||
|
|
Loading…
Reference in a new issue