Skip to content

Commit

Permalink
util, executor: fix the problem that GetDatumWithBuffer does set null (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Dec 8, 2022
1 parent 2ab3b2b commit 8d97150
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
54 changes: 54 additions & 0 deletions executor/issuetest/executor_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1283,3 +1283,57 @@ func TestIssue24627(t *testing.T) {
tk.MustExec("drop table test2")
}
}

func TestIssue39618(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1;")
tk.MustExec(`CREATE TABLE t1 (
c_int int(11) NOT NULL,
c_str varbinary(40) NOT NULL,
c_datetime datetime DEFAULT NULL,
c_timestamp timestamp NULL DEFAULT NULL,
c_double double DEFAULT NULL,
c_decimal decimal(12,6) DEFAULT NULL,
c_enum enum('blue','green','red','yellow','white','orange','purple') DEFAULT NULL,
PRIMARY KEY (c_int,c_str) /*T![clustered_index] CLUSTERED */,
KEY c_int_2 (c_int),
KEY c_decimal (c_decimal),
KEY c_datetime (c_datetime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY LIST COLUMNS(c_int)
(PARTITION p0 VALUES IN (1,5,9,13,17,21,25,29,33,37),
PARTITION p1 VALUES IN (2,6,10,14,18,22,26,30,34,38),
PARTITION p2 VALUES IN (3,7,11,15,19,23,27,31,35,39),
PARTITION p3 VALUES IN (4,8,12,16,20,24,28,32,36,40));`)
tk.MustExec("INSERT INTO t1 VALUES (3,'bold goldberg','2020-01-07 12:08:19','2020-06-19 08:13:35',0.941002,5.303000,'yellow'),(1,'crazy wescoff','2020-03-24 21:51:02','2020-06-19 08:13:35',47.565275,6.313000,'orange'),(5,'relaxed gagarin','2020-05-20 11:36:26','2020-06-19 08:13:35',38.948617,3.143000,'green'),(9,'gifted vaughan','2020-04-09 16:19:45','2020-06-19 08:13:35',95.922976,8.708000,'yellow'),(2,'focused taussig','2020-05-17 17:58:34','2020-06-19 08:13:35',4.137803,4.902000,'white'),(6,'fervent yonath','2020-05-26 03:55:25','2020-06-19 08:13:35',72.394272,6.491000,'white'),(18,'mystifying bhaskara','2020-02-19 10:41:48','2020-06-19 08:13:35',10.832397,9.707000,'red'),(4,'goofy saha','2020-03-11 13:24:31','2020-06-19 08:13:35',39.007216,2.446000,'blue'),(20,'mystifying bhaskara','2020-04-03 11:33:27','2020-06-19 08:13:35',85.190386,6.787000,'blue');")

tk.MustExec("DROP TABLE IF EXISTS t2;")
tk.MustExec(`CREATE TABLE t2 (
c_int int(11) NOT NULL,
c_str varbinary(40) NOT NULL,
c_datetime datetime DEFAULT NULL,
c_timestamp timestamp NULL DEFAULT NULL,
c_double double DEFAULT NULL,
c_decimal decimal(12,6) DEFAULT NULL,
c_enum enum('blue','green','red','yellow','white','orange','purple') DEFAULT NULL,
PRIMARY KEY (c_int,c_str) /*T![clustered_index] CLUSTERED */,
KEY c_int_2 (c_int),
KEY c_decimal (c_decimal),
KEY c_datetime (c_datetime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY LIST COLUMNS(c_int)
(PARTITION p0 VALUES IN (1,5,9,13,17,21,25,29,33,37),
PARTITION p1 VALUES IN (2,6,10,14,18,22,26,30,34,38),
PARTITION p2 VALUES IN (3,7,11,15,19,23,27,31,35,39),
PARTITION p3 VALUES IN (4,8,12,16,20,24,28,32,36,40));
`)

tk.MustExec("INSERT INTO t2 VALUES (1,'crazy wescoff','2020-03-24 21:51:02','2020-04-01 12:11:56',47.565275,6.313000,'orange'),(1,'unruffled johnson','2020-06-30 03:42:58','2020-06-14 00:16:50',35.444084,1.090000,'red'),(5,'relaxed gagarin','2020-05-20 11:36:26','2020-02-19 12:25:48',38.948617,3.143000,'green'),(9,'eloquent archimedes','2020-02-16 04:20:21','2020-05-23 15:42:33',32.310878,5.855000,'orange'),(9,'gifted vaughan','2020-04-09 16:19:45','2020-05-15 01:42:16',95.922976,8.708000,'yellow'),(13,'dreamy benz','2020-04-27 17:43:44','2020-03-27 06:33:03',39.539233,4.823000,'red'),(3,'bold goldberg','2020-01-07 12:08:19','2020-03-10 18:37:09',0.941002,5.303000,'yellow'),(3,'youthful yonath','2020-01-12 17:10:39','2020-06-10 15:13:44',66.288511,6.046000,'white'),(7,'upbeat bhabha','2020-04-29 01:17:05','2020-03-11 22:58:43',23.316987,9.026000,'yellow'),(11,'quizzical ritchie','2020-05-16 08:21:36','2020-03-05 19:23:25',75.019379,0.260000,'purple'),(2,'dazzling kepler','2020-04-11 04:38:59','2020-05-06 04:42:32',78.798503,2.274000,'purple'),(2,'focused taussig','2020-05-17 17:58:34','2020-02-25 09:11:03',4.137803,4.902000,'white'),(2,'sharp ptolemy',NULL,'2020-05-17 18:04:19',NULL,5.573000,'purple'),(6,'fervent yonath','2020-05-26 03:55:25','2020-05-06 14:23:44',72.394272,6.491000,'white'),(10,'musing wu','2020-04-03 11:33:27','2020-05-24 06:11:56',85.190386,6.787000,'blue'),(8,'hopeful keller','2020-02-19 10:41:48','2020-04-19 17:10:36',10.832397,9.707000,'red'),(12,'exciting boyd',NULL,'2020-03-28 18:27:23',NULL,9.249000,'blue');")

tk.MustExec("set tidb_txn_assertion_level=strict;")
tk.MustExec("begin")
tk.MustExec("delete t1, t2 from t1, t2 where t1.c_enum in ('blue');")
tk.MustExec("commit")
}
3 changes: 3 additions & 0 deletions util/chunk/row.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ func (r Row) GetDatumWithBuffer(colIdx int, tp *types.FieldType, d *types.Datum)
d.SetMysqlJSON(r.GetJSON(colIdx))
}
}
if r.IsNull(colIdx) {
d.SetNull()
}
return *d
}

Expand Down

0 comments on commit 8d97150

Please sign in to comment.