1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-10 16:44:17 +02:00

MariaDB: Fix creating and altering generated columns (fixes #897)

This commit is contained in:
Jakub Vrana
2025-03-10 19:17:22 +01:00
parent 35274f18bb
commit e589ee3fde
2 changed files with 4 additions and 1 deletions

View File

@@ -786,12 +786,14 @@ if (!defined('Adminer\DRIVER')) {
* @return bool
*/
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
global $connection;
$alter = array();
foreach ($fields as $field) {
if ($field[1]) {
$default = $field[1][3];
if (preg_match('~ GENERATED~', $default)) {
$field[1][3] = $field[1][2];
// swap default and null
$field[1][3] = (preg_match('~MariaDB~', $connection->server_info) ? "" : $field[1][2]); // MariaDB doesn't support NULL on virtual columns
$field[1][2] = $default;
}
$alter[] = ($table != "" ? ($field[0] != "" ? "CHANGE " . idf_escape($field[0]) : "ADD") : " ") . " " . implode($field[1]) . ($table != "" ? $field[2] : "");

View File

@@ -2,6 +2,7 @@ Adminer dev:
Fix gzip export (bug #896)
Fix importing multiple SQL files not terminated by semicolon
Use <datalist> for altering collations
MariaDB: Fix creating and altering generated columns (bug #897)
Adminer 5.0.2 (released 2025-03-10):
PostgreSQL: Fix setting NULL and original value on enum (bug #884)