-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
ddl, table: allow using SHARD_ROW_ID_BITS with auto_incremental columns #10759
Conversation
dbcfbb1
to
22f42fc
Compare
Codecov Report
@@ Coverage Diff @@
## master #10759 +/- ##
================================================
+ Coverage 79.8572% 79.8958% +0.0385%
================================================
Files 415 415
Lines 88270 88310 +40
================================================
+ Hits 70490 70556 +66
+ Misses 12572 12548 -24
+ Partials 5208 5206 -2 |
Codecov Report
@@ Coverage Diff @@
## master #10759 +/- ##
===============================================
- Coverage 80.3175% 80.287% -0.0305%
===============================================
Files 416 416
Lines 88251 88282 +31
===============================================
- Hits 70881 70879 -2
- Misses 12178 12205 +27
- Partials 5192 5198 +6 |
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.
LGTM
/run-all-tests |
table/tables/tables.go
Outdated
@@ -916,6 +916,11 @@ func GetColDefaultValue(ctx sessionctx.Context, col *table.Column, defaultVals [ | |||
|
|||
// AllocAutoID implements table.Table AllocAutoID interface. | |||
func (t *tableCommon) AllocAutoID(ctx sessionctx.Context) (int64, error) { |
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.
Maybe AllocAutoIncrementValue
is more accurate.
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.
addressed, thanks! @coocood
10781d1
to
78b6c2a
Compare
78b6c2a
to
872256d
Compare
@bb7133 |
I didn't get your point: If the PK is handle, |
I mean check it in the create table phase. |
addressed, PTAL @coocood @crazycs520 |
ddl/ddl_api.go
Outdated
@@ -1219,6 +1219,9 @@ func buildTableInfoWithCheck(ctx sessionctx.Context, d *ddl, s *ast.CreateTableS | |||
if err = handleTableOptions(s.Options, tbInfo); err != nil { | |||
return nil, errors.Trace(err) | |||
} | |||
if tbInfo.ShardRowIDBits > 0 && tbInfo.PKIsHandle { |
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.
Why not put it in handleTableOptions
?
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.
addressed, thanks!
239da3a
to
7f7ad56
Compare
LGTM |
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.
LGTM
LGTM |
/run-all-tests |
What problem does this PR solve?
This PR allows using
SHARD_ROW_ID_BITS
for tables withAUTO_INCREMENT
columns.Before this PR,
SHARD_ROW_ID_BITS
cannot work withAUTO_INCREMENT
:This restriction leads to inconveniences to many TiDB users, this PR gives a quick way to remove it by:
row_id
(orhandle
), TiDB still tries to make sharding ifSHARD_ROW_ID_BITS
is defined.auto_increment_id
(orautoid
), TiDB doesn't make sharding to keep it incremental always.What is changed and how it works?
A new
AllocHandle()
is added totable.Table
, which is used for the allocation ofhandle
. NowAllocAutoID()
will not try to do sharding for the allocated ids.Check List
Tests
Code changes
Side effects
Related changes