Skip to content

Commit

Permalink
expression: fix date format identifies '\n' as invalid separator (#32… (
Browse files Browse the repository at this point in the history
#32391)

* expression: fix date format identifies '\n' as invalid separator (#32358)
  • Loading branch information
mengxin9014 authored Feb 17, 2022
1 parent eefba66 commit b854b4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,8 @@ func isValidSeparator(c byte, prevParts int) bool {
return true
}

if prevParts == 2 && (c == ' ' || c == 'T') {
// for https://github.com/pingcap/tidb/issues/32232
if prevParts == 2 && (c == 'T' || c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r') {
return true
}

Expand Down
5 changes: 5 additions & 0 deletions types/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,11 @@ func (s *testTimeSuite) TestParseDateFormat(c *C) {
{"T10:10:10", nil},
{"2011-11-11x", []string{"2011", "11", "11x"}},
{"xxx 10:10:10", nil},
{"2022-02-01\n16:33:00", []string{"2022", "02", "01", "16", "33", "00"}},
{"2022-02-01\f16:33:00", []string{"2022", "02", "01", "16", "33", "00"}},
{"2022-02-01\v16:33:00", []string{"2022", "02", "01", "16", "33", "00"}},
{"2022-02-01\r16:33:00", []string{"2022", "02", "01", "16", "33", "00"}},
{"2022-02-01\t16:33:00", []string{"2022", "02", "01", "16", "33", "00"}},
}

for _, t := range tbl {
Expand Down
6 changes: 3 additions & 3 deletions util/stmtsummary/statement_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,9 +980,9 @@ func (ssElement *stmtSummaryByDigestElement) toDatum(ssbd *stmtSummaryByDigest)
avgInt(int64(ssElement.sumPDTotal), ssElement.commitCount),
avgInt(int64(ssElement.sumBackoffTotal), ssElement.commitCount),
avgInt(int64(ssElement.sumWriteSQLRespTotal), ssElement.commitCount),
int64(ssElement.maxResultRows),
int64(ssElement.minResultRows),
avgInt(int64(ssElement.sumResultRows), ssElement.execCount),
ssElement.maxResultRows,
ssElement.minResultRows,
avgInt(ssElement.sumResultRows, ssElement.execCount),
ssElement.prepared,
avgFloat(int64(ssElement.sumAffectedRows), ssElement.execCount),
types.NewTime(types.FromGoTime(ssElement.firstSeen), mysql.TypeTimestamp, 0),
Expand Down

0 comments on commit b854b4f

Please sign in to comment.