diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index 621f3105..611f94e7 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -245,7 +245,7 @@ function default_value($field) { $default = $field["default"]; if ($default === null) return ""; - if (preg_match('~^GENERATED ~i', $default)) { + if (stripos($default, "GENERATED ") === 0) { return " $default"; } diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index c4ae22d4..c613e747 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -947,8 +947,9 @@ function enum_input($type, $attrs, $field, $value, $empty = null) { */ function input($field, $value, $function) { global $types, $adminer, $jush; + $name = h(bracket_escape($field["field"])); - echo ""; + if (is_array($value) && !$function) { $args = array($value); if (version_compare(PHP_VERSION, 5.4) >= 0) { @@ -962,13 +963,18 @@ function input($field, $value, $function) { $function = null; } $functions = (isset($_GET["select"]) || $reset ? array("orig" => lang('original')) : array()) + $adminer->editFunctions($field); - $attrs = " name='fields[$name]'"; + + $disabled = stripos($field["default"], "GENERATED ALWAYS AS ") === 0 ? " disabled=''" : ""; + $attrs = " name='fields[$name]' $disabled"; + + echo ""; + if ($field["type"] == "enum") { echo h($functions[""]) . "" . $adminer->editInput($_GET["edit"], $field, $attrs, $value); } else { $has_function = (in_array($function, $functions) || isset($functions[$function])); echo (count($functions) > 1 - ? "" + ? "" . on_help("getTarget(event).value.replace(/^SQL\$/, '')", 1) . script("qsl('select').onchange = functionChange;", "") : h(reset($functions)) @@ -1033,6 +1039,11 @@ function input($field, $value, $function) { */ function process_input($field) { global $adminer, $driver; + + if (stripos($field["default"], "GENERATED ALWAYS AS ") === 0) { + return null; + } + $idf = bracket_escape($field["field"]); $function = $_POST["function"][$idf]; $value = $_POST["fields"][$idf];