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
Column options are ignored for GENERATED / VIRTUAL / STORED columns #13854
Comments
|
Can you try with version |
|
Issue evaluated in 4.8.1: Create table: CREATE TABLE ttt (
test int(11) NOT NULL,
testvirt varchar(11) COLLATE utf8_bin GENERATED ALWAYS AS (test) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;Go to the "Structure" tab and try to change the collation of the generated column to "utf8_general_ci". Currently the PhpMyAdmin generates: ALTER TABLE ttt CHANGE testvirt testvirt VARCHAR(11) AS (test) VIRTUAL; But it should generate something like this: ALTER TABLE ttt CHANGE testvirt testvirt VARCHAR(11) CHARACTER SET utf8
COLLATE utf8_general_ci AS (test) VIRTUAL NULL; |
|
MariaDB does not support Maybe this explains why this issue. |
|
Yes, tested on MySQL. Maria added the virtual columns support sooner and the syntax and features differs. Here is my proposal for MySQL: Currently is GUI at least for me is unsuable as I need to edit the virtual column like the normal columns. The PhpMyAdmin can generate the full ALTER parameters (collation, nullable, etc.) at least for MySQL. I have no experience with Maria DB as I use MySQL only. |
|
@mvorisek Does this issue still exist (on 4.8.6-dev) ? |
|
The issue is still presented and once virtual/generated column is changed in the edit, all the column details like collation are discarded, |
|
https://mariadb.atlassian.net/browse/MDEV-7655 CREATE TABLE `vcol_test` (
`v_col1` varchar(255) COLLATE latin1_general_ci AS (col1) VIRTUAL,
`col1` varchar(50) COLLATE latin1_general_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
works on MySQL 8.0 and not on MariaDB So this issue can no be solved in a good way |
|
Does not work: ALTER TABLE `contact` CHANGE `zdzd1` `zdzd1` VARCHAR(22) COLLATE utf8_slovenian_ci AS ( 1 + 1 ) VIRTUALALTER TABLE `contact` CHANGE `zdzd1` `zdzd1` VARCHAR(22) CHARACTER SET utf8 COLLATE utf8_slovenian_ci AS ( 1 + 1 ) VIRTUALWorks: ALTER TABLE `contact` CHANGE `zdzd1` `zdzd1` VARCHAR(22) CHARACTER SET utf8 AS ( 1 + 1 ) VIRTUAL |
|
MySQL handles the virtual/generated columns differently and the the PhpMyAdmin needs to do the same. I will update the patch with |
|
Generator fixed in PR #15275 Mysql: fixed Can the PR be merged and included in the next release? |
|
@mvorisek Yes, I think so |
|
Yes. PR is complete. Extra attributes for MySQL are fixed, non-virtual columns or columns in other databases are untouched. |
|
Hi @mvorisek I would like to merge the PR, can you implement a check to disable collation change since it does not change for MariaDB. |
|
@williamdes Please describe how to replicate.
|
|
@mvidner To reproduce go to my demo server 4.8.6 (public/public)
CREATE TABLE `vcol_test11` (
`v_col1` varchar(255) AS (col1) VIRTUAL,
`col1` varchar(50) COLLATE latin1_general_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; |
|
The same for MySQL actually. As you have written, the preview SQL it fine (and can be sucessfully commited for both MariaDB and Mysql). The "save" generates |
|
@mvorisek Yes, there is an additional query that is added if the charset changed between the initial value of the form and the real value that is submitted The preview is always not accurate since this query is always missing. |
Signed-off-by: William Desportes <williamdes@wdes.fr>
|
@williamdes Great work! |
|
@mvorisek Thanks to you ! |

Steps to reproduce
Example
Create table with one STORED column with type VARCHAR(10), collation ascii_general_ci and NOT NULL. This is currently not possible via GUI. The GUI currently also ignores these options on column def. change, resulting that all options are removed.
Expected behaviour
Configured column options should be saved as normal (not generated) columns. Columns options are fully supported by MySQL and honored / validated as for normal columns.
Actual behaviour
Column options are ignored in columns create or update via GUI.
Server configuration
any
The text was updated successfully, but these errors were encountered: