Don't update unmodified blob (thanks to crempa)

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@563 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-03-04 17:22:28 +00:00
parent 3b17d67e9a
commit 19e4d597c4
2 changed files with 8 additions and 6 deletions

View file

@ -15,10 +15,12 @@ if ($_POST && !$error && !isset($_GET["select"])) {
$set = array();
foreach ($fields as $name => $field) {
$val = process_input($name, $field);
if ($val !== false) {
if (!isset($_GET["default"])) {
$set[] = idf_escape($name) . " = $val";
} elseif ($field["type"] == "timestamp") {
if (!isset($_GET["default"])) {
if ($val !== false || !$update) {
$set[] = idf_escape($name) . " = " . ($val !== false ? $val : "''");
}
} elseif ($val !== false) {
if ($field["type"] == "timestamp") {
$set[] = " MODIFY " . idf_escape($name) . " timestamp" . ($field["null"] ? " NULL" : "") . " DEFAULT $val" . ($_POST["on_update"][bracket_escape($name)] ? " ON UPDATE CURRENT_TIMESTAMP" : "");
} else {
$set[] = " ALTER " . idf_escape($name) . ($val == ($field["null"] || $field["type"] == "enum" ? "NULL" : "''") ? " DROP DEFAULT" : " SET DEFAULT $val");
@ -45,7 +47,7 @@ if ($_POST) {
} elseif ($where) {
$select = array();
foreach ($fields as $name => $field) {
if (isset($field["privileges"]["select"]) && !preg_match('~binary|blob~', $field["type"]) && (!$_GET["clone"] || !$field["auto_increment"])) {
if (isset($field["privileges"]["select"]) && (!$_GET["clone"] || !$field["auto_increment"])) {
$select[] = ($field["type"] == "enum" || $field["type"] == "set" ? "1*" . idf_escape($name) . " AS " : "") . idf_escape($name);
}
}

View file

@ -68,7 +68,7 @@ function process_input($name, $field) {
return (isset($_GET["default"]) ? "'" . implode(",", array_map(array($mysql, 'escape_string'), (array) $value)) . "'" : array_sum((array) $value));
} elseif (preg_match('~binary|blob~', $field["type"])) {
$file = get_file($idf);
if (!is_string($file) && ($file != UPLOAD_ERR_NO_FILE || !$field["null"])) {
if (!is_string($file)) {
return false; //! report errors
}
return "_binary'" . (is_string($file) ? $mysql->escape_string($file) : "") . "'";