From b463495e112799f7d9928459df044dae05774324 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Wed, 16 Jun 2021 20:58:37 +0800 Subject: [PATCH] cherry pick #25484 to release-5.1 Signed-off-by: ti-srebot --- executor/batch_checker.go | 2 +- executor/partition_table_test.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/executor/batch_checker.go b/executor/batch_checker.go index 713496a6cfb6c..ed454a899bd52 100644 --- a/executor/batch_checker.go +++ b/executor/batch_checker.go @@ -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 diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 11ec1b2a097e3..f696bf9f743ab 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -1680,6 +1680,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")