Error
Error Code:
3109
MySQL Error 3109: Generated Column Auto-Increment Reference
Description
This error occurs when you attempt to define a generated column (a column whose value is computed from an expression) that directly or indirectly references an `AUTO_INCREMENT` column within its generation expression. MySQL prohibits this to avoid complex dependencies and potential data integrity issues, as `AUTO_INCREMENT` values are assigned at row insertion time and can change behavior depending on the insertion context.
Error Message
Generated column '%s' cannot refer to auto-increment column.
Known Causes
3 known causesDirect Auto-Increment Column Usage
The generated column's definition expression explicitly includes the name of an `AUTO_INCREMENT` column.
Indirect Dependency on Auto-Increment
The generated column's expression uses a function or another column that ultimately derives its value from an `AUTO_INCREMENT` column.
Misunderstanding Generated Column Scope
Attempting to use `AUTO_INCREMENT` values, which are dynamic upon insertion, in a static generated column definition.
Solutions
Coming SoonGeneral Troubleshooting Tips
- Check the error message carefully for specific details
- Review recent changes that might have caused the error
- Search for the exact error code in the official documentation
- Check log files for additional context
- Try restarting the application or service