From 666bd075a999b44c7ea4ff843b6994303377cbaa Mon Sep 17 00:00:00 2001 From: albertlast Date: Sun, 6 Sep 2026 15:15:26 +0200 Subject: [PATCH] Writes a column type MySQL knows in the SQL that rebuilds a table list_columns() reports SMF's own name for a type the database spells differently: a varbinary(16) holding an address comes back as an inet. table_sql() wrote that name straight into its CREATE TABLE, so MySQL was asked for a column of a type it does not have. ERROR 1064 (42000): ... near 'inet DEFAULT NULL' Ten tables on a stock forum carry such a column, all of them the ones that record an address. Signed-off-by: albertlast --- Sources/Db/APIs/MySQL.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/Db/APIs/MySQL.php b/Sources/Db/APIs/MySQL.php index 73a09be6fc..6cd669e1db 100644 --- a/Sources/Db/APIs/MySQL.php +++ b/Sources/Db/APIs/MySQL.php @@ -1169,10 +1169,16 @@ public function table_sql(string $table_name): string $inner_lines = []; foreach ($structure['columns'] as $column) { - $line = ' `' . $column['name'] . '` ' . $column['type']; + // The structure reports SMF's own name for a type that MySQL + // spells differently -- a varbinary(16) holding an address comes + // back as an inet -- so it has to be turned back into something + // MySQL knows before it can be written into a CREATE TABLE. + list($type, $size) = $this->calculate_type($column['type'], $column['size']); - if (is_numeric($column['size'])) { - $line .= '(' . $column['size'] . ')'; + $line = ' `' . $column['name'] . '` ' . $type; + + if (is_numeric($size)) { + $line .= '(' . $size . ')'; } if (!empty($column['unsigned'])) {