Skip to content
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

executor: check ErrRowDoesNotMatchGivenPartitionSet when inserting rows into a partition table (#25484) #25498

Merged
merged 8 commits into from
Jun 18, 2021
2 changes: 1 addition & 1 deletion executor/batch_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func getKeysNeedCheckOneRow(ctx sessionctx.Context, t table.Table, row []types.D
if p, ok := t.(table.PartitionedTable); ok {
t, err = p.GetPartitionByRow(ctx, row)
if err != nil {
if terr, ok := errors.Cause(err).(*terror.Error); ctx.GetSessionVars().StmtCtx.IgnoreNoPartition && ok && terr.Code() == errno.ErrNoPartitionForGivenValue {
if terr, ok := errors.Cause(err).(*terror.Error); ctx.GetSessionVars().StmtCtx.IgnoreNoPartition && ok && (terr.Code() == errno.ErrNoPartitionForGivenValue || terr.Code() == errno.ErrRowDoesNotMatchGivenPartitionSet) {
ctx.GetSessionVars().StmtCtx.AppendWarning(err)
result = append(result, toBeCheckedRow{ignored: true})
return result, nil
Expand Down
31 changes: 31 additions & 0 deletions executor/partition_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,37 @@ func (s *partitionTableSuite) PartitionPruningInTransaction(c *C) {
tk.MustExec(`rollback`)
}

func (s *partitionTableSuite) TestIssue25253(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("create database issue25253")
defer tk.MustExec("drop database issue25253")
tk.MustExec("use issue25253")

tk.MustExec(`CREATE TABLE IDT_HP23902 (
COL1 smallint DEFAULT NULL,
COL2 varchar(20) DEFAULT NULL,
COL4 datetime DEFAULT NULL,
COL3 bigint DEFAULT NULL,
COL5 float DEFAULT NULL,
KEY UK_COL1 (COL1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY HASH( COL1+30 )
PARTITIONS 6`)
tk.MustExec(`insert ignore into IDT_HP23902 partition(p0, p1)(col1, col3) values(-10355, 1930590137900568573), (13810, -1332233145730692137)`)
tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1748 Found a row not matching the given partition set",
"Warning 1748 Found a row not matching the given partition set"))
tk.MustQuery(`select * from IDT_HP23902`).Check(testkit.Rows())

tk.MustExec(`create table t (
a int
) partition by range(a) (
partition p0 values less than (10),
partition p1 values less than (20))`)
tk.MustExec(`insert ignore into t partition(p0)(a) values(12)`)
tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1748 Found a row not matching the given partition set"))
tk.MustQuery(`select * from t`).Check(testkit.Rows())
}

func (s *partitionTableSuite) TestDML(c *C) {
if israce.RaceEnabled {
c.Skip("exhaustive types test, skip race test")
Expand Down