Skip to content

Commit 21e9ef1

Browse files
committed
fix: 移除对单行大小的限制 (#5)
1 parent 526aae6 commit 21e9ef1

2 files changed

Lines changed: 47 additions & 5 deletions

File tree

parser.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,11 +1735,12 @@ func InterpolateParams(query string, args []driver.Value) ([]byte, error) {
17351735
}
17361736

17371737
// 4 << 20 , 4MB
1738-
if len(buf)+4 > 4<<20 {
1739-
// log.Print("%T", v)
1740-
log.Info("解析错误")
1741-
return nil, errors.New("driver: skip fast-path; continue as if unimplemented")
1742-
}
1738+
// 移除对单行大小的判断,不入库不需要该限制
1739+
// if len(buf)+4 > 4<<20 {
1740+
// // log.Print("%T", v)
1741+
// log.Info("解析错误")
1742+
// return nil, errors.New("driver: skip fast-path; continue as if unimplemented")
1743+
// }
17431744
}
17441745
if argPos != len(args) {
17451746
// log.Print("%T", v)

parser_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,41 @@ func (t *testParserSuite) TestMinimalUpdate(c *C) {
701701

702702
}
703703

704+
func (t *testParserSuite) TestTextMax(c *C) {
705+
t.setupTest(c, mysql.MySQLFlavor)
706+
707+
id := 100
708+
709+
// 65536 = 64k
710+
value := strings.Repeat("a", 1024*1024*10)
711+
712+
t.testExecute(c, `RESET MASTER;`,
713+
`DROP TABLE IF EXISTS test_long_text`,
714+
`CREATE TABLE test_long_text (
715+
id BIGINT(64) UNSIGNED NOT NULL AUTO_INCREMENT,
716+
c1 longtext,
717+
PRIMARY KEY (id)
718+
) ENGINE=InnoDB`,
719+
fmt.Sprintf(`INSERT INTO test_long_text (id, c1) VALUES (%d, "")`, id),
720+
fmt.Sprintf(`UPDATE test_long_text SET c1 = '%s' WHERE id = %d`, value, id),
721+
fmt.Sprintf(`DELETE FROM test_long_text WHERE id = %d`, id))
722+
723+
t.checkBinlog(c,
724+
"INSERT INTO `test`.`test_long_text`(`id`,`c1`) VALUES(100,'');",
725+
fmt.Sprintf("UPDATE `test`.`test_long_text` SET `id`=100, `c1`='%s' WHERE `id`=100;", value),
726+
"DELETE FROM `test`.`test_long_text` WHERE `id`=100;",
727+
)
728+
729+
t.SetFlashback(true)
730+
t.SetMinimalUpdate(true)
731+
t.checkBinlog(c,
732+
"DELETE FROM `test`.`test_long_text` WHERE `id`=100;",
733+
"UPDATE `test`.`test_long_text` SET `c1`='' WHERE `id`=100;",
734+
fmt.Sprintf("INSERT INTO `test`.`test_long_text`(`id`,`c1`) VALUES(100,'%s');", value),
735+
)
736+
737+
}
738+
704739
func (t *testParserSuite) TestUpdate2Null(c *C) {
705740
t.setupTest(c, mysql.MySQLFlavor)
706741

@@ -761,6 +796,7 @@ func (t *testParserSuite) TestThreadID(c *C) {
761796
t.setupTest(c, mysql.MySQLFlavor)
762797

763798
t.testExecute(c, `RESET MASTER;`,
799+
`DROP TABLE IF EXISTS test_simple`,
764800
`DROP TABLE IF EXISTS test_simple`,
765801
`CREATE TABLE test_simple (
766802
id BIGINT(64) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -1100,6 +1136,11 @@ func (t *testParserSuite) initTableSchema(tableName ...string) {
11001136
c2 int,
11011137
PRIMARY KEY (id)
11021138
) ENGINE=InnoDB`,
1139+
"test_long_text": `CREATE TABLE test_long_text (
1140+
id BIGINT(64) UNSIGNED NOT NULL AUTO_INCREMENT,
1141+
c1 longtext,
1142+
PRIMARY KEY (id)
1143+
) ENGINE=InnoDB`,
11031144
}
11041145

11051146
var tables []string

0 commit comments

Comments
 (0)