-
Notifications
You must be signed in to change notification settings - Fork 288
Fix AUTO_INCREMENT zero handling and tests #23588
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
base: main
Are you sure you want to change the base?
Conversation
|
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UPDATEsemantics may be changed: the current logic converts 0 to NULLwhenever HasAutoColis true (including in the UPDATEprocess). This means that UPDATE t SET auto_col=0 will allocate a new auto-increment value when sql_modedoes not contain NO_AUTO_VALUE_ON_ZERO, which is inconsistent with MySQL (where UPDATEtypically treats 0 as a normal value).
| preInsert.ctr.buf.AddRowCount(bat.RowCount()) | ||
|
|
||
| if preInsert.HasAutoCol { | ||
| if shouldTreatZeroAsAutoIncr(proc) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each batch reads sql_modeand performs a string operation (ToUpper+ Contains). This incurs a small amount of string allocation and CPU overhead, consider caching this boolean value at the session level to reduce the cost.
What type of PR is this?
Which issue(s) this PR fixes:
issue #14490
What this PR does / why we need it:
Fixed MatrixOne’s AUTO_INCREMENT behavior to match MySQL: when sql_mode does not include NO_AUTO_VALUE_ON_ZERO, inserting 0 into an AUTO_INCREMENT column is treated as NULL and allocates a new id. This prevents HyBench’s “Duplicate entry '0'” errors.