Skip to content

Conversation

@elianddb
Copy link
Contributor

@elianddb elianddb commented Jul 10, 2025

Move auto_increment constraint validation entirely from Dolt to go-mysql-server for better separation of concerns and MySQL compatibility.

Fixes dolthub/dolt#9481
Fixes dolthub/dolt#9470

  • Add validateAutoIncrementType() function using existing type checking
  • Fix validation order to prioritize auto_increment before index validation
  • Unskip comprehensive test coverage for all invalid data types
  • Fix bugs: YEAR and BIT types were incorrectly allowed

elianddb and others added 8 commits July 10, 2025 19:28
Move auto_increment constraint validation entirely from Dolt to
go-mysql-server for better separation of concerns and MySQL compatibility.

Changes:
- Add validateAutoIncrementType() function using existing type checking
- Fix validation order to prioritize auto_increment before index validation
- Unskip comprehensive test coverage for all invalid data types
- Fix bugs: YEAR and BIT types were incorrectly allowed
- Ensure exact MySQL error message compatibility

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Improve code readability and maintainability by replacing multiple if
statements with a comprehensive switch statement on t.Type().

- Add query import for type constants
- Explicit case handling for all data types
- Clear grouping of allowed vs disallowed types
- Better performance with single switch evaluation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Use existing types.Is*() functions instead of vitess constants
- Fix blob test expectations (column names were incorrect)
- Comprehensive validation matches MySQL behavior exactly
- All 22 data types tested: 8 valid, 14 invalid with proper errors

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Use single check for types.IsNumber() with exclusions for DECIMAL, YEAR, and BIT
- More maintainable and cleaner code structure
- Comment lists all excluded types for clarity
- All tests still passing with exact MySQL behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

@angelamayxie angelamayxie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

elianddb and others added 4 commits July 10, 2025 23:46
- Unskip float and double auto_increment tests
- Update test expectations to match MySQL 8.0.42 behavior
- FLOAT and DOUBLE are allowed with AUTO_INCREMENT in MySQL
- Fix collation expectations in SHOW CREATE TABLE tests
- All tests now pass confirming GMS matches MySQL behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Changed validateAutoIncrementType() to only allow integer types
- FLOAT/DOUBLE with AUTO_INCREMENT now properly rejected (MySQL 8.4.5 behavior)
- Updated float/double tests to expect "Incorrect column specifier" errors
- Matches MySQL 8.4.5 stricter validation requirements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Updated "auto increment on float" test to expect CREATE TABLE error
- Updated "auto increment on double" test to expect CREATE TABLE error
- Both tests now expect "Incorrect column specifier" matching MySQL 8.4.5

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…s.go

- Removed "auto increment on float" and "auto increment on double" tests
- These scenarios are now impossible since CREATE TABLE fails for float/double AUTO_INCREMENT
- Validation is already covered in script_queries.go tests
- Eliminates duplicate test coverage for the same validation logic

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

@jycor jycor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@elianddb elianddb force-pushed the elianddb/9481-auto-increment-type-validation branch from 9cc1ac5 to d3a0287 Compare July 11, 2025 15:46
Copy link
Contributor

@angelamayxie angelamayxie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

- Removed Skip: true from "set with auto increment" test
- Our validation now correctly handles SET columns with AUTO_INCREMENT
- All assertions expect "Incorrect column specifier" errors which match MySQL behavior
- Fixes issue dolthub/dolt#9470

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@elianddb elianddb force-pushed the elianddb/9481-auto-increment-type-validation branch from d1e20fa to 7bb7438 Compare July 11, 2025 17:03
@elianddb elianddb merged commit d3ba56f into main Jul 11, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent auto_increment constraint on every type other than INT SET column types cannot be auto_increment

4 participants