New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moving Columns with DEFAULT NULL doesn't work on MariaDB 10.2+ #14951
Comments
|
On further testing I can confirm that the bug is somehow dependent on Server version. The latest snapshot works fine with MariaDB 10.1.38, but fails with newer MariaDB 10.2.22 and 10.3.12, whereas MySQL 5.7/8.0 do not seem to be affected. Tested using docker images on Ubuntu 18.04 with apache and phpMyAdmin-5.0+snapshot-all-languages.tar.gz |
|
@williamdes, Hey it's working fine for me both on mariadb and mySql Server on demo server. I'll share the screenshot with you and in preview Sql mode also its working fine for me |
|
@kartik1000 Can you please try on https://phpmyadmin-pr-6.wdes.eu.org and https://phpmyadmin-pr-7.wdes.eu.org public/public |
|
@williamdes, Hey Yes You are right It ain't working on these servers switching col 1 to top does give back an error and the error is same as stated by @adwiv , and moreover https://phpmyadmin-pr-7.wdes.eu.org does not show sql preview option whereas the other one does. |
|
Thank you @kartik1000 :) |
|
@williamdes The demo servers referred by you use MariaDB 10.1.26 whereas the errors happen with newer 10.2 or 10.3. |
|
On my demo servers https://phpmyadmin-pr-7.wdes.eu.org/ (QA_4_9) The servers are User [EDIT] Reproduced: you need to move col2 to first position and then try to move it back ! |
Yes, if the column type is VARCHAR, the move changes NULL default value to string "NULL". If you use the following schema, it will show the error everytime. CREATE TABLE test (
col1 int(11) DEFAULT NULL,
col2 varchar(20) DEFAULT NULL
)In short, the code is somehow interpreting NULL default value as string "NULL". In case of any non-text column, it will show error. And in case of text column, it won't show error but will corrupt the schema. |
|
Okay. I figured out the cause of issue. Starting with MariaDB 10.2, they have made some changes to the Information Scheme Table which deviates from MySQL. ChangeLog Here
So, when we have a nullable column with NULL default in MariaDb, instead of getting a null value from the information_schema table for COLUMN_DEFAULT, we get a literal string with value NULL. |
|
@adwiv, you must be right because I checked the changes made in the codebase when moving columns, and checked if what change possibly triggered this issue as it was working fine earlier but couldn't find any. @williamdes what can we now do possibly to fix the issue? |
|
@kartik1000 I would add an override to the existing code |
|
@kartik1000 It will implement the desired code after checking the MariaDB version right? |
|
@kartik1000 Yes, perfect :) |
|
@kartik1000 @williamdes There is another problem introduced due to a recent commit 98a7479 which results in column always becoming NOT NULL when moved. This commit changed the expected value of phpmyadmin/libraries/classes/Table.php Lines 559 to 563 in d3ef2ce
However, the expected value was not not updated in
So, in case of moving a nullable field, Thanks. |
|
@adwiv Thank you so much for your comment! |
…on MariaDB 10.2+ Ref: 98a7479 Signed-off-by: William Desportes <williamdes@wdes.fr>
Signed-off-by: William Desportes <williamdes@wdes.fr>
|
Good evening! Was this problem fixed? Because it still concerns me when I try to move columns:
|
|
I see, thanks for the fast response. Seems I have to wait since 4.6.6deb4 is the most recent available version in Debian Buster 10.2. |



Describe the bug
When a column is nullable with default value NULL, trying to move it using the "Move Columns" popup either does not work or works incorrectly with disastrous side effects.
It appears that the SQL generated for moving the column converts the NULL keyword value into 'NULL' string value. If the column is a text column, the default value is changed to 'NULL' String instead of the NULL VALUE. If the column is some other type (eg int), the column moving fails with an error since the string 'NULL' is not a valid integer value.
To Reproduce
Create a simple table
Click on the
Structuretab and select "Move Columns". Try to move col2 to top of table. The SQL generated is:Notice the 'NULL' in quotes which changes the default value of the column.
Now try moving column col1 to top of table again. This generates the following SQL
This time running it fails with error
#1366 - Incorrect integer value: 'NULL' for column 'col1' at row 1Expected behavior
Columns should have moved without any side effects. The default value should have remained NULL, and not converted to string 'NULL'
Server configuration
The text was updated successfully, but these errors were encountered: