Skip to content

Commit

Permalink
Merge branch 'master' into dev/fix-pkishandle
Browse files Browse the repository at this point in the history
  • Loading branch information
zz-jason authored Aug 7, 2018
2 parents 07a56ae + f6dbad0 commit 9307768
Show file tree
Hide file tree
Showing 24 changed files with 361 additions and 925 deletions.
1 change: 0 additions & 1 deletion executor/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ func (e *DeleteExec) removeRow(ctx sessionctx.Context, t table.Table, h int64, d
if err != nil {
return errors.Trace(err)
}
ctx.StmtAddDirtyTableOP(DirtyTableDeleteRow, t.Meta().ID, h, nil)
ctx.GetSessionVars().StmtCtx.AddAffectedRows(1)
colSize := make(map[int64]int64)
for id, col := range t.Cols() {
Expand Down
3 changes: 0 additions & 3 deletions executor/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ func (e *InsertExec) insertOneRow(row []types.Datum) (int64, error) {
if err != nil {
return 0, errors.Trace(err)
}
if !e.ctx.GetSessionVars().LightningMode {
e.ctx.StmtAddDirtyTableOP(DirtyTableAddRow, e.Table.Meta().ID, h, row)
}
e.batchInsertRowCount++
return h, nil
}
Expand Down
4 changes: 0 additions & 4 deletions executor/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func (e *ReplaceExec) removeRow(handle int64, newRow []types.Datum) (bool, error
if err != nil {
return false, errors.Trace(err)
}
e.ctx.StmtAddDirtyTableOP(DirtyTableDeleteRow, e.Table.Meta().ID, handle, nil)
e.ctx.GetSessionVars().StmtCtx.AddAffectedRows(1)

// Cleanup keys map, because the record was removed.
Expand All @@ -89,9 +88,6 @@ func (e *ReplaceExec) addRow(row []types.Datum) (int64, error) {
if err != nil {
return 0, errors.Trace(err)
}
if !e.ctx.GetSessionVars().LightningMode {
e.ctx.StmtAddDirtyTableOP(DirtyTableAddRow, e.Table.Meta().ID, h, row)
}
return h, nil
}

Expand Down
2 changes: 1 addition & 1 deletion executor/union_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func GetDirtyDB(ctx sessionctx.Context) *DirtyDB {
return udb
}

// UnionScanExec merges the rows from dirty table and the rows from XAPI request.
// UnionScanExec merges the rows from dirty table and the rows from distsql request.
type UnionScanExec struct {
baseExecutor

Expand Down
17 changes: 0 additions & 17 deletions executor/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ var (
_ Executor = &LoadDataExec{}
)

const (
// DirtyTableAddRow is the constant for dirty table operation type.
DirtyTableAddRow = iota
// DirtyTableDeleteRow is the constant for dirty table operation type.
DirtyTableDeleteRow
// DirtyTableTruncate is the constant for dirty table operation type.
DirtyTableTruncate
)

// updateRecord updates the row specified by the handle `h`, from `oldData` to `newData`.
// `modified` means which columns are really modified. It's used for secondary indices.
// Length of `oldData` and `newData` equals to length of `t.WritableCols()`.
Expand Down Expand Up @@ -170,14 +161,6 @@ func updateRecord(ctx sessionctx.Context, h int64, oldData, newData []types.Datu
return false, handleChanged, newHandle, 0, errors.Trace(err)
}

tid := t.Meta().ID
ctx.StmtAddDirtyTableOP(DirtyTableDeleteRow, tid, h, nil)
if handleChanged {
ctx.StmtAddDirtyTableOP(DirtyTableAddRow, tid, newHandle, newData)
} else {
ctx.StmtAddDirtyTableOP(DirtyTableAddRow, tid, h, newData)
}

if onDup {
sc.AddAffectedRows(2)
} else {
Expand Down
2 changes: 1 addition & 1 deletion expression/builtin_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ func (b *builtinUnHexSig) evalString(row chunk.Row) (string, bool, error) {
return string(bs), false, nil
}

const spaceChars = "\n\t\r "
const spaceChars = " "

type trimFunctionClass struct {
baseFunctionClass
Expand Down
17 changes: 17 additions & 0 deletions expression/builtin_string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,9 @@ func (s *testEvaluatorSuite) TestTrim(c *C) {
res string
}{
{[]interface{}{" bar "}, false, false, "bar"},
{[]interface{}{"\t bar \n"}, false, false, "\t bar \n"},
{[]interface{}{"\r bar \t"}, false, false, "\r bar \t"},
{[]interface{}{" \tbar\n "}, false, false, "\tbar\n"},
{[]interface{}{""}, false, false, ""},
{[]interface{}{nil}, true, false, ""},
{[]interface{}{"xxxbarxxx", "x"}, false, false, "bar"},
Expand Down Expand Up @@ -919,6 +922,14 @@ func (s *testEvaluatorSuite) TestLTrim(c *C) {
res string
}{
{" bar ", false, false, "bar "},
{"\t bar ", false, false, "\t bar "},
{" \tbar ", false, false, "\tbar "},
{"\t bar ", false, false, "\t bar "},
{" \tbar ", false, false, "\tbar "},
{"\r bar ", false, false, "\r bar "},
{" \rbar ", false, false, "\rbar "},
{"\n bar ", false, false, "\n bar "},
{" \nbar ", false, false, "\nbar "},
{"bar", false, false, "bar"},
{"", false, false, ""},
{nil, true, false, ""},
Expand Down Expand Up @@ -954,6 +965,12 @@ func (s *testEvaluatorSuite) TestRTrim(c *C) {
}{
{" bar ", false, false, " bar"},
{"bar", false, false, "bar"},
{"bar \n", false, false, "bar \n"},
{"bar\n ", false, false, "bar\n"},
{"bar \r", false, false, "bar \r"},
{"bar\r ", false, false, "bar\r"},
{"bar \t", false, false, "bar \t"},
{"bar\t ", false, false, "bar\t"},
{"", false, false, ""},
{nil, true, false, ""},
{errors.New("must error"), false, true, ""},
Expand Down
6 changes: 6 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,10 @@ func (s *testIntegrationSuite) TestStringBuiltin(c *C) {
result.Check(testutil.RowsWithSep(",", "bar ,bar,,<nil>"))
result = tk.MustQuery(`select rtrim(' bar '), rtrim('bar'), rtrim(''), rtrim(null)`)
result.Check(testutil.RowsWithSep(",", " bar,bar,,<nil>"))
result = tk.MustQuery(`select ltrim("\t bar "), ltrim(" \tbar"), ltrim("\n bar"), ltrim("\r bar")`)
result.Check(testutil.RowsWithSep(",", "\t bar ,\tbar,\n bar,\r bar"))
result = tk.MustQuery(`select rtrim(" bar \t"), rtrim("bar\t "), rtrim("bar \n"), rtrim("bar \r")`)
result.Check(testutil.RowsWithSep(",", " bar \t,bar\t,bar \n,bar \r"))

// for reverse
tk.MustExec(`DROP TABLE IF EXISTS t;`)
Expand All @@ -776,6 +780,8 @@ func (s *testIntegrationSuite) TestStringBuiltin(c *C) {
// for trim
result = tk.MustQuery(`select trim(' bar '), trim(leading 'x' from 'xxxbarxxx'), trim(trailing 'xyz' from 'barxxyz'), trim(both 'x' from 'xxxbarxxx')`)
result.Check(testkit.Rows("bar barxxx barx bar"))
result = tk.MustQuery(`select trim('\t bar\n '), trim(' \rbar \t')`)
result.Check(testutil.RowsWithSep(",", "\t bar\n,\rbar \t"))
result = tk.MustQuery(`select trim(leading from ' bar'), trim('x' from 'xxxbarxxx'), trim('x' from 'bar'), trim('' from ' bar ')`)
result.Check(testutil.RowsWithSep(",", "bar,bar,bar, bar "))
result = tk.MustQuery(`select trim(''), trim('x' from '')`)
Expand Down
2 changes: 1 addition & 1 deletion mysql/errcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ const (
ErrPathLength = 1680
ErrWarnDeprecatedSyntaxNoReplacement = 1681
ErrWrongNativeTableStructure = 1682
ErrWrongPerfschemaUsage = 1683
ErrWrongPerfSchemaUsage = 1683
ErrWarnISSkippedTable = 1684
ErrInsideTransactionPreventsSwitchBinlogDirect = 1685
ErrStoredFunctionPreventsSwitchBinlogDirect = 1686
Expand Down
2 changes: 1 addition & 1 deletion mysql/errname.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ var MySQLErrName = map[uint16]string{
ErrPathLength: "The path specified for %.64s is too long.",
ErrWarnDeprecatedSyntaxNoReplacement: "'%s' is deprecated and will be removed in a future release.",
ErrWrongNativeTableStructure: "Native table '%-.64s'.'%-.64s' has the wrong structure",
ErrWrongPerfschemaUsage: "Invalid performanceSchema usage.",
ErrWrongPerfSchemaUsage: "Invalid performanceSchema usage.",
ErrWarnISSkippedTable: "Table '%s'.'%s' was skipped since its definition is being modified by concurrent DDL statement",
ErrInsideTransactionPreventsSwitchBinlogDirect: "Cannot modify @@session.binlogDirectNonTransactionalUpdates inside a transaction",
ErrStoredFunctionPreventsSwitchBinlogDirect: "Cannot change the binlog direct flag inside a stored function or trigger",
Expand Down
Loading

0 comments on commit 9307768

Please sign in to comment.