Skip to content

Conversation

@robll-v1
Copy link
Collaborator

What type of PR is this?

  • API-change
  • [ ✅] BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

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.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@XuPeng-SH XuPeng-SH left a 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) {
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants