diff --git a/table/tables/tables.go b/table/tables/tables.go
index <HASH>..<HASH> 100644
--- a/table/tables/tables.go
+++ b/table/tables/tables.go
@@ -681,7 +681,7 @@ func (t *TableCommon) AddRecord(sctx sessionctx.Context, r []types.Datum, opts .
 			pkIdx := FindPrimaryIndex(tblInfo)
 			pkDts := make([]types.Datum, 0, len(pkIdx.Columns))
 			for _, idxCol := range pkIdx.Columns {
-				pkDts = append(pkDts, r[tblInfo.Columns[idxCol.Offset].Offset])
+				pkDts = append(pkDts, r[idxCol.Offset])
 			}
 			tablecodec.TruncateIndexValues(tblInfo, pkIdx, pkDts)
 			var handleBytes []byte
table: fix redundant and misleading conditions (#<I>)