Skip to content

Commit

Permalink
variable: remove GoSQLDriverTest (pingcap#3361)
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood authored and hanfei1991 committed May 31, 2017
1 parent 64830c9 commit 77b87ed
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 16 deletions.
4 changes: 0 additions & 4 deletions executor/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/terror"
"github.com/pingcap/tidb/util/types"
Expand Down Expand Up @@ -523,9 +522,6 @@ func (e *LoadDataInfo) insertData(cols []string) {

func (e *InsertValues) handleLoadDataWarnings(err error, logInfo string) {
sc := e.ctx.GetSessionVars().StmtCtx
if variable.GoSQLDriverTest {
return
}
sc.AppendWarning(err)
log.Warn(logInfo)
}
Expand Down
5 changes: 1 addition & 4 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
. "github.com/pingcap/check"
"github.com/pingcap/tidb/executor"
tmysql "github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/util/printer"
)

Expand Down Expand Up @@ -250,9 +249,7 @@ func runTestLoadData(c *C) {
c.Assert(err, IsNil)
err = os.Remove(path)
c.Assert(err, IsNil)
variable.GoSQLDriverTest = false
}()
variable.GoSQLDriverTest = true
_, err = fp.WriteString(`
xxx row1_col1 - row1_col2 1abc
xxx row2_col1 - row2_col2
Expand All @@ -262,7 +259,7 @@ xxx row5_col1 - row5_col3`)
c.Assert(err, IsNil)

// support ClientLocalFiles capability
runTests(c, dsn+"&allowAllFiles=true", func(dbt *DBTest) {
runTests(c, dsn+"&allowAllFiles=true&strict=false", func(dbt *DBTest) {
dbt.mustExec("create table test (a varchar(255), b varchar(255) default 'default value', c int not null auto_increment, primary key(c))")
rs, err := dbt.db.Exec("load data local infile '/tmp/load_data_test.csv' into table test")
dbt.Assert(err, IsNil)
Expand Down
4 changes: 0 additions & 4 deletions sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,6 @@ type TableDelta struct {
Count int64
}

// GoSQLDriverTest is used for server testing.
// Because go-sql-driver regards the warnings as errors.
var GoSQLDriverTest = false

// StatementContext contains variables for a statement.
// It should be reset before executing a statement.
type StatementContext struct {
Expand Down
5 changes: 1 addition & 4 deletions tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func Parse(ctx context.Context, src string) ([]ast.StmtNode, error) {
return stmts, nil
}

// resetStmtCtx resets the StmtContext.
// Before every execution, we must clear statement context.
func resetStmtCtx(ctx context.Context, s ast.StmtNode) {
sessVars := ctx.GetSessionVars()
Expand All @@ -150,10 +151,6 @@ func resetStmtCtx(ctx context.Context, s ast.StmtNode) {
sc.IgnoreTruncate = false
sc.TruncateAsWarning = false
case *ast.LoadDataStmt:
if variable.GoSQLDriverTest {
sc.IgnoreTruncate = true
break
}
sc.IgnoreTruncate = false
sc.TruncateAsWarning = !sessVars.StrictSQLMode
default:
Expand Down

0 comments on commit 77b87ed

Please sign in to comment.