Incorrect definition of table mysql.column_stats: expected column 'histogram' at position 10 to have type longblob, found type varbinary(255)

Although all seems to run fine, when I call the page /settings/admin/overview in my browser, I get these errors in my log

 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'histogram' at position 10 to have type longblob, found type varbinary(255).

 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'hist_type' at position 9 to have type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB'), found type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB').

Nextcloud version : 24
Operating system and version (eg, Ubuntu 20.04): docker with mariadb and PHP 8.0.23

if I look at the table, I see the fields:

# docker exec next${D}_db_1 mysql nextcloud -p$MYSQL_ROOT_PASSWORD -e "show fields from mysql.column_stats "                                                             
Field   Type    Null    Key     Default Extra
db_name varchar(64)     NO      PRI     NULL
table_name      varchar(64)     NO      PRI     NULL
column_name     varchar(64)     NO      PRI     NULL
min_value       varbinary(255)  YES             NULL
max_value       varbinary(255)  YES             NULL
nulls_ratio     decimal(12,4)   YES             NULL
avg_length      decimal(12,4)   YES             NULL
avg_frequency   decimal(12,4)   YES             NULL
hist_size       tinyint(3) unsigned     YES             NULL
hist_type       enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') YES             NULL
histogram       varbinary(255)  YES             NULL

1 Like

fixed with:

docker exec next${D}_db_1 mysql nextcloud -p$MYSQL_ROOT_PASSWORD -e "ALTER TABLE mysql.column_stats MODIFY histogram longblob;"
docker exec next${D}_db_1 mysql nextcloud -p$MYSQL_ROOT_PASSWORD -e "ALTER TABLE mysql.column_stats MODIFY hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB');"
7 Likes

same problem solved for

Incorrect definition of table mysql.event: expected column 'definer' at position 3 to have type varchar(, found type char(141).

with

docker exec next${D}_db_1 mysql nextcloud -p$MYSQL_ROOT_PASSWORD -e "ALTER TABLE mysql.event MODIFY definer varchar(255);"

Solved it for me after upgrade (docker compose pull + up), thanks!

I got this error after attempting to upgrade my nextcloud database that was build using the same compose file as Nextcloud. I was using yobasystems mariadb-alpine:10.x.x. After upgrading via building a new container, I had that error. To fix it I needed to actually run the upgrade command

docker exec -it nextcloud-db /bin/sh -c ‘mysql_upgrade -u root -p nextcloud -h db’

I also had to enter the password when prompt, which should be best practice anyways so important keys dont wind up in your terminal history. The "nextcloud: you see after my " -p " is not a password, but the name of the database.

Note, I don’t have bash so used /bin/sh. I also had to tell it which host to use " -h db ", since it was defaulting to localhost by default. db is my host as set in my compose files and nextcloud config.

Hopefully this will help someone else who ended up here searching for a solution to my same issue. I should get better at reading the documentation for the tools I use before searching for answers.

stumbled across this same issue… Thansk @rubo77
was in the middle of standing up a replication/DR site and noticed I had a couple 22GB *.err files in the rsync and was wondering WTH was going on.

I removed those and restarted mariadb and they started growing immediately, then saw the errors like OP has.

I resolved with same cmds, but logged directly into mariadb, so here is the slight change:

MariaDB [(none)]> show fields from mysql.column_stats;
+---------------+-----------------------------------------+------+-----+---------+-------+
| Field         | Type                                    | Null | Key | Default | Extra |
+---------------+-----------------------------------------+------+-----+---------+-------+
| db_name       | varchar(64)                             | NO   | PRI | NULL    |       |
| table_name    | varchar(64)                             | NO   | PRI | NULL    |       |
| column_name   | varchar(64)                             | NO   | PRI | NULL    |       |
| min_value     | varbinary(255)                          | YES  |     | NULL    |       |
| max_value     | varbinary(255)                          | YES  |     | NULL    |       |
| nulls_ratio   | decimal(12,4)                           | YES  |     | NULL    |       |
| avg_length    | decimal(12,4)                           | YES  |     | NULL    |       |
| avg_frequency | decimal(12,4)                           | YES  |     | NULL    |       |
| hist_size     | tinyint(3) unsigned                     | YES  |     | NULL    |       |
| hist_type     | enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') | YES  |     | NULL    |       |
| histogram     | varbinary(255)                          | YES  |     | NULL    |       |
+---------------+-----------------------------------------+------+-----+---------+-------+
11 rows in set (0.002 sec)


ALTER TABLE mysql.column_stats MODIFY histogram longblob;
ALTER TABLE mysql.column_stats MODIFY hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB');

AFTER  (notice last 2 lines showing the updates)
And no more errors spewing to *.err file

MariaDB [(none)]> show fields from mysql.column_stats;
+---------------+---------------------------------------------------+------+-----+---------+-------+
| Field         | Type                                              | Null | Key | Default | Extra |
+---------------+---------------------------------------------------+------+-----+---------+-------+
| db_name       | varchar(64)                                       | NO   | PRI | NULL    |       |
| table_name    | varchar(64)                                       | NO   | PRI | NULL    |       |
| column_name   | varchar(64)                                       | NO   | PRI | NULL    |       |
| min_value     | varbinary(255)                                    | YES  |     | NULL    |       |
| max_value     | varbinary(255)                                    | YES  |     | NULL    |       |
| nulls_ratio   | decimal(12,4)                                     | YES  |     | NULL    |       |
| avg_length    | decimal(12,4)                                     | YES  |     | NULL    |       |
| avg_frequency | decimal(12,4)                                     | YES  |     | NULL    |       |
| hist_size     | tinyint(3) unsigned                               | YES  |     | NULL    |       |
| hist_type     | enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') | YES  |     | NULL    |       |
| histogram     | longblob                                          | YES  |     | NULL    |       |
+---------------+---------------------------------------------------+------+-----+---------+-------+
11 rows in set (0.001 sec)

Is also a bug I would say that NC is not picking up these error in the UI check.