mirror of
https://github.com/vrana/adminer.git
synced 2025-08-31 18:11:52 +02:00
MariaDB: Fix comparing CURRENT_TIMESTAMP definition while altering a table
This commit is contained in:
@@ -221,12 +221,17 @@ function process_type($field, $collate = "COLLATE") {
|
|||||||
* @return array array("field", "type", "NULL", "DEFAULT", "ON UPDATE", "COMMENT", "AUTO_INCREMENT")
|
* @return array array("field", "type", "NULL", "DEFAULT", "ON UPDATE", "COMMENT", "AUTO_INCREMENT")
|
||||||
*/
|
*/
|
||||||
function process_field($field, $type_field) {
|
function process_field($field, $type_field) {
|
||||||
|
// MariaDB exports CURRENT_TIMESTAMP as a function.
|
||||||
|
if ($field["on_update"]) {
|
||||||
|
$field["on_update"] = str_ireplace("current_timestamp()", "CURRENT_TIMESTAMP", $field["on_update"]);
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
idf_escape(trim($field["field"])),
|
idf_escape(trim($field["field"])),
|
||||||
process_type($type_field),
|
process_type($type_field),
|
||||||
($field["null"] ? " NULL" : " NOT NULL"), // NULL for timestamp
|
($field["null"] ? " NULL" : " NOT NULL"), // NULL for timestamp
|
||||||
default_value($field),
|
default_value($field),
|
||||||
(preg_match('~timestamp|datetime~', $field["type"]) && $field["on_update"] ? " ON UPDATE $field[on_update]" : ""),
|
(preg_match('~timestamp|datetime~', $field["type"]) && $field["on_update"] ? " ON UPDATE " . $field["on_update"] : ""),
|
||||||
(support("comment") && $field["comment"] != "" ? " COMMENT " . q($field["comment"]) : ""),
|
(support("comment") && $field["comment"] != "" ? " COMMENT " . q($field["comment"]) : ""),
|
||||||
($field["auto_increment"] ? auto_increment() : null),
|
($field["auto_increment"] ? auto_increment() : null),
|
||||||
);
|
);
|
||||||
@@ -244,6 +249,9 @@ function default_value($field) {
|
|||||||
return " $default";
|
return " $default";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MariaDB exports CURRENT_TIMESTAMP as a function.
|
||||||
|
$default = str_ireplace("current_timestamp()", "CURRENT_TIMESTAMP", $default);
|
||||||
|
|
||||||
$quote = preg_match('~char|binary|text|enum|set~', $field["type"]) || preg_match('~^(?![a-z])~i', $default);
|
$quote = preg_match('~char|binary|text|enum|set~', $field["type"]) || preg_match('~^(?![a-z])~i', $default);
|
||||||
|
|
||||||
return " DEFAULT " . ($quote ? q($default) : $default);
|
return " DEFAULT " . ($quote ? q($default) : $default);
|
||||||
|
Reference in New Issue
Block a user