Closed kolbe closed 5 years ago
The issue is that there's no case
for model.ActionCreateView in the switch inside drainer/schema.go:handleDDL(). The fix is pretty simple:
index dd84b5b..d67cf6b 100644
--- a/drainer/schema.go
+++ b/drainer/schema.go
@@ -315,7 +315,7 @@ func (s *Schema) handleDDL(job *model.Job) (schemaName string, tableName string,
schemaName = schema.Name.O
tableName = table.Name.O
- case model.ActionCreateTable:
+ case model.ActionCreateTable, model.ActionCreateView:
table := job.BinlogInfo.TableInfo
if table == nil {
return "", "", "", errors.NotFoundf("table %d", job.TableID)
@@ -336,7 +336,7 @@ func (s *Schema) handleDDL(job *model.Job) (schemaName string, tableName string,
schemaName = schema.Name.O
tableName = table.Name.O
- case model.ActionDropTable:
+ case model.ActionDropTable, model.ActionDropView:
schema, ok := s.SchemaByID(job.SchemaID)
if !ok {
return "", "", "", errors.NotFoundf("schema %d", job.SchemaID)```
... however, that relies on commit 20bc24aef58addbd906513ec13424e5755e6d97a to github.com/pingcap/parser, which adds ActionDropView to the parser model.
For some reason commit 20bc24aef58addbd906513ec13424e5755e6d97a was never pulled into the release-2.1 branch. I cherry-picked it locally and everything built fine, so I'll file a PR for that in github.com/pingcap/parser.
This is the PR to get 20bc24aef58addbd906513ec13424e5755e6d97a cherry-picked to github.com/pingcap/parser: https://github.com/pingcap/parser/pull/276
If the drainer encounters a
CREATE VIEW
statement, it crashes: