Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: Ignore FULLTEXT KEYs in CREATE/ALTER TABLE statements #9821

Merged
merged 18 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
94b9027
Ignore FULLTEXT KEYs in CREATE TABLE statements.
kolbe Mar 18, 2019
8ae3d63
Fixed TestSlowQueryZapLogger to work with negative UTC offset timezones
kolbe Mar 18, 2019
a85aad1
Issue ErrTableCantHandleFt warning for ALTER TABLE ADD FULLTEXT KEY
kolbe Mar 19, 2019
7ec0176
Add test case for ignoring FULLTEXT KEY in CREATE and ALTER TABLE
kolbe Mar 20, 2019
13aa6c2
Merge github.com:pingcap/tidb into kolbe-fulltext
kolbe Mar 20, 2019
3b8d0ef
Added test to make sure no indexes exist after attempting to create a…
kolbe Mar 20, 2019
0880e48
Merge github.com:pingcap/tidb into kolbe-fulltext
kolbe Mar 20, 2019
bade342
Improved comments for TestFulltextIndexIgnore
kolbe Mar 20, 2019
c210ff5
Merge branch 'master' into kolbe-fulltext
kolbe Mar 22, 2019
77f3ea2
Merge branch 'master' of github.com:pingcap/tidb into kolbe-fulltext
kolbe Mar 25, 2019
f229ba1
Merge branch 'kolbe-fulltext' of github.com:kolbe/tidb into kolbe-ful…
kolbe Mar 25, 2019
1a91b8a
Merge branch 'master' into kolbe-fulltext
morgo Mar 27, 2019
3c40d95
Merge branch 'master' of github.com:pingcap/tidb into kolbe-fulltext
kolbe Apr 2, 2019
e4cf854
Merge branch 'master' into kolbe-fulltext
morgo Apr 2, 2019
0f654e4
Added codeErrTableCantHandleFt to ddlMySQLErrCodes
kolbe Apr 3, 2019
c34a32e
Merge branch 'master' of github.com:pingcap/tidb into kolbe-fulltext
kolbe Apr 3, 2019
fcecfcf
Merge branch 'master' into kolbe-fulltext
crazycs520 Apr 10, 2019
a82808b
Merge branch 'master' into kolbe-fulltext
morgo Apr 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1282,3 +1282,19 @@ func (s *testIntegrationSuite) TestAlterAlgorithm(c *C) {
s.assertAlterErrorExec(c, "alter table t default charset = utf8mb4, ALGORITHM=INPLACE")
s.tk.MustExec("alter table t default charset = utf8mb4, ALGORITHM=INSTANT")
}

func (s *testIntegrationSuite) TestFulltextIndexIgnore(c *C) {
s.tk = testkit.NewTestKit(c, s.store)
s.tk.MustExec("use test")
s.tk.MustExec("drop table if exists t_ft")
defer s.tk.MustExec("drop table if exists t_ft")
// Make sure that creating and altering to add a fulltext key gives the correct warning
s.assertWarningExec(c, "create table t_ft (a text, fulltext key (a))", ddl.ErrTableCantHandleFt)
s.assertWarningExec(c, "alter table t_ft add fulltext key (a)", ddl.ErrTableCantHandleFt)
kolbe marked this conversation as resolved.
Show resolved Hide resolved

// Make sure table t_ft still has no indexes even after it was created and altered
r := s.tk.MustQuery("show index from t_ft")
c.Assert(r.Rows(), HasLen, 0)
r = s.tk.MustQuery("select * from information_schema.statistics where table_schema='test' and table_name='t_ft'")
c.Assert(r.Rows(), HasLen, 0)
}
3 changes: 3 additions & 0 deletions ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ var (
ErrAlterOperationNotSupported = terror.ClassDDL.New(codeNotSupportedAlterOperation, mysql.MySQLErrName[mysql.ErrAlterOperationNotSupportedReason])
// ErrWrongObject returns for wrong object.
ErrWrongObject = terror.ClassDDL.New(codeErrWrongObject, mysql.MySQLErrName[mysql.ErrWrongObject])
// ErrTableCantHandleFt returns FULLTEXT keys are not supported by table type
ErrTableCantHandleFt = terror.ClassDDL.New(codeErrTableCantHandleFt, mysql.MySQLErrName[mysql.ErrTableCantHandleFt])
)

// DDL is responsible for updating schema in data store and maintaining in-memory InfoSchema cache.
Expand Down Expand Up @@ -699,6 +701,7 @@ const (
codePrimaryCantHaveNull = terror.ErrCode(mysql.ErrPrimaryCantHaveNull)
codeWrongExprInPartitionFunc = terror.ErrCode(mysql.ErrWrongExprInPartitionFunc)
codeWarnDataTruncated = terror.ErrCode(mysql.WarnDataTruncated)
codeErrTableCantHandleFt = terror.ErrCode(mysql.ErrTableCantHandleFt)
kolbe marked this conversation as resolved.
Show resolved Hide resolved
codeCoalesceOnlyOnHashPartition = terror.ErrCode(mysql.ErrCoalesceOnlyOnHashPartition)
codeUnknownPartition = terror.ErrCode(mysql.ErrUnknownPartition)
codeErrGeneratedColumnRefAutoInc = terror.ErrCode(mysql.ErrGeneratedColumnRefAutoInc)
Expand Down
9 changes: 8 additions & 1 deletion ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func columnDefToCol(ctx sessionctx.Context, offset int, colDef *ast.ColumnDef, o
_, dependColNames := findDependedColumnNames(colDef)
col.Dependences = dependColNames
case ast.ColumnOptionFulltext:
// TODO: Support this type.
ctx.GetSessionVars().StmtCtx.AppendWarning(ErrTableCantHandleFt)
}
}
}
Expand Down Expand Up @@ -949,6 +949,11 @@ func buildTableInfo(ctx sessionctx.Context, d *ddl, tableName model.CIStr, cols
}
}
}
if constr.Tp == ast.ConstraintFulltext {
kolbe marked this conversation as resolved.
Show resolved Hide resolved
sc := ctx.GetSessionVars().StmtCtx
sc.AppendWarning(ErrTableCantHandleFt)
continue
}
// build index info.
idxInfo, err := buildIndexInfo(tbInfo, model.NewCIStr(constr.Name), constr.Keys, model.StatePublic)
if err != nil {
Expand Down Expand Up @@ -1579,6 +1584,8 @@ func (d *ddl) AlterTable(ctx sessionctx.Context, ident ast.Ident, specs []*ast.A
err = d.CreateForeignKey(ctx, ident, model.NewCIStr(constr.Name), spec.Constraint.Keys, spec.Constraint.Refer)
case ast.ConstraintPrimaryKey:
err = ErrUnsupportedModifyPrimaryKey.GenWithStackByArgs("add")
case ast.ConstraintFulltext:
ctx.GetSessionVars().StmtCtx.AppendWarning(ErrTableCantHandleFt)
default:
// Nothing to do now.
}
Expand Down