Skip to content

Invisible virtual column syntax is generated wrong #2266

@LukasWieditz

Description

@LukasWieditz

Description

When altering a table to modify a virtual column to be invisible, the application produces invalid SQL syntax:

ALTER TABLE `my_table`
	CHANGE COLUMN `my_virtual_column` `my_virtual_column` BIT(1) INVISIBLE AS ((`some_reference_column` > 0)) virtual AFTER `some_other_column`;

The invisible statement is placed before the virtual statement, but must come after. The correct SQL statement would be:

ALTER TABLE `my_table`
	CHANGE COLUMN `my_virtual_column` `my_virtual_column` BIT(1) AS ((`some_reference_column` > 0)) virtual INVISIBLE AFTER `some_other_column`;

The same problem can be observed when creating a new table:

CREATE TABLE `my_table` (
	`my_virtual_column` INT INVISIBLE AS (1 + 1) VIRTUAL
)

From the documentation:

column_definition: {
   data_type
      // ...
  | data_type
      [COLLATE collation_name]
      [GENERATED ALWAYS] AS (expr)
      [VIRTUAL | STORED] [NOT NULL | NULL]
      [VISIBLE | INVISIBLE]
      // ...
}

HeidiSQL version

12.11.0.7065

Database server version

Reproduction recipe

  • Create a new table or alter an existing table
  • Make a new column in the table definition
  • Declare the column as virtual (or stored) and invisible
  • Observe generated SQL syntax (or run code, to see error in action)

Error/Backtrace

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDefective behaviour in HeidiSQLconfirmedIssue verified by project membernettype-mysqlMySQL and/or MariaDB specific issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions