MySQL cannot run an ONLINE ALTER TABLE that adds a virtual column with a concurrent index change.
ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN occurs when MySQL 5.7.11+ tries to execute ALTER TABLE ... ADD COLUMN ... VIRTUAL with other ONLINE changes. Disable ONLINE, split the statement, or create the index after the column is added to resolve the error.
ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN
MySQL raises ER_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN when an ALTER TABLE statement marked ONLINE attempts to add a virtual column together with a concurrent index or other metadata change. The storage engine cannot keep the table online while recalculating virtual column values.
The error was introduced in MySQL 5.7.11 to protect data consistency. Understanding why it fires helps avoid disruptive schema migrations and downtime.
The primary trigger is combining ADD COLUMN ... VIRTUAL with ADD INDEX or other ONLINE clauses in a single ALTER TABLE statement.
The server blocks the request because generating the virtual column on existing rows and building an index simultaneously would require a table copy or lock, breaking ONLINE guarantees.
Remove the ONLINE keyword or split the operation into two steps. First, add the virtual column, then create the index in a separate ALTER TABLE.
Alternatively, convert the virtual column to a stored column or run the change during a maintenance window when table locking is acceptable.
When adding JSON generated columns, developers often specify ONLINE to avoid downtime. MySQL rejects the statement if an index is also created. Splitting the statement keeps availability while allowing proper indexing.
CI/CD pipelines that auto append ONLINE to every ALTER TABLE may trigger this error on virtual columns. Update migration scripts to detect and adjust for virtual column alterations.
Plan schema changes in incremental steps. Test migrations in a staging database running the same MySQL version.
Use feature flags in tools like Galaxy to toggle ONLINE mode only when supported. Monitor ALTER TABLE logs and set alerts for error 3178 to react quickly.
ER_ALTER_OPERATION_NOT_SUPPORTED: Raised when ALTER TABLE includes unsupported combinations, fix by splitting actions.
ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED: Appears when an invalid function is used in a virtual column definition, correct the expression.
MySQL 5.7+ cannot keep the table online while adding a virtual column because values must be derived for all existing rows.
Creating an index in the same statement forces additional metadata changes, violating ONLINE constraints.
Tooling that blindly appends ONLINE to every ALTER TABLE may create conflicting clauses with virtual columns.
General error for unsupported ALTER TABLE combinations. Split operations to resolve.
Raised when a prohibited function is used in a virtual column expression. Replace with permitted functions.
Occurs when an action targets a generated column in an unsupported way, such as dropping a base column. Review documentation before altering.
Yes, if you only add or drop the virtual column without other changes. Combining it with index creation is what triggers error 3178.
Changing VIRTUAL to STORED allows ONLINE because the column is materialized and no value recalculation is needed on the fly.
Yes. MySQL 8.0 keeps the same restriction. Follow the same split-statement workaround.
Galaxy flags unsupported ONLINE clauses during linting and suggests splitting migrations, reducing production errors.