-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
update clustered index return error message:IntHandle compares to CommonHandle #29520
Comments
The year type is stored as an Int64 in the datum. The row is encoded as a common handle, but decoded as an int handle. A test case to reproduce it: func TestYearTypeCommonHandle(t *testing.T) {
tblInfo := buildTableInfo(t, "CREATE TABLE `tbl_25` (`col_208` int, PRIMARY KEY (`col_208`) CLUSTERED, "+
"KEY `idx_68` (`col_208`));")
store, clean := testkit.CreateMockStore(t)
defer clean()
txn, err := store.Begin()
require.NoError(t, err)
mockCtx := mock.NewContext()
sc := mockCtx.GetSessionVars().StmtCtx
var nonUniqueIdx table.Index
for _, idxInfo := range tblInfo.Indices {
idx := tables.NewIndex(tblInfo.ID, tblInfo, idxInfo)
if !idxInfo.Primary {
nonUniqueIdx = idx
}
}
data := []types.Datum{types.NewIntDatum(2020)}
encodedHandle, err := codec.EncodeKey(sc, nil, data...)
require.NoError(t, err)
commonHandle, err := kv.NewCommonHandle(encodedHandle)
require.NoError(t, err)
key, _, err := nonUniqueIdx.GenIndexKey(sc, data, commonHandle, nil)
_, err = nonUniqueIdx.Create(mockCtx, txn, data, commonHandle, nil)
require.NoError(t, err)
val, err := txn.Get(context.Background(), key)
require.NoError(t, err)
handle, err := tablecodec.DecodeIndexHandle(key, val, 1)
require.NoError(t, err)
require.True(t, handle.IsInt())
} |
Signed-off-by: ekexium <ekexium@gmail.com>
Closed by #29600 |
Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label. |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
dml success;
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: