|
| 1 | +// Copyright 2018 PingCAP, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// See the License for the specific language governing permissions and |
| 12 | +// limitations under the License. |
| 13 | + |
| 14 | +package ddl_test |
| 15 | + |
| 16 | +import ( |
| 17 | + gofail "github.com/coreos/gofail/runtime" |
| 18 | + . "github.com/pingcap/check" |
| 19 | + "golang.org/x/net/context" |
| 20 | +) |
| 21 | + |
| 22 | +// TestInitializeOffsetAndState tests the case that the column's offset and state don't be initialized in the file of ddl_api.go when |
| 23 | +// doing the operation of 'modify column'. |
| 24 | +func (s *testStateChangeSuite) TestInitializeOffsetAndState(c *C) { |
| 25 | + _, err := s.se.Execute(context.Background(), "use test_db_state") |
| 26 | + c.Assert(err, IsNil) |
| 27 | + _, err = s.se.Execute(context.Background(), "create table t(a int, b int, c int)") |
| 28 | + c.Assert(err, IsNil) |
| 29 | + defer s.se.Execute(context.Background(), "drop table t") |
| 30 | + |
| 31 | + gofail.Enable("github.com/pingcap/tidb/ddl/uninitializedOffsetAndState", `return(true)`) |
| 32 | + _, err = s.se.Execute(context.Background(), "ALTER TABLE t MODIFY COLUMN b int FIRST;") |
| 33 | + c.Assert(err, IsNil) |
| 34 | + gofail.Disable("github.com/pingcap/tidb/ddl/uninitializedOffsetAndState") |
| 35 | +} |
0 commit comments