Skip to content

When lightning is less capabile than downstream, USE <database> may miss so failed with "no database selected" #51800

Closed
@lance6716

Description

The source schema files may contain some unsupported feature, like unsupported chatset. When lightning failed to rewrite the statement, it directly uses the source file content. However, USE <database> is missing

func (worker *restoreSchemaWorker) addJob(sqlStr string, job *schemaJob) error {
stmts, err := createIfNotExistsStmt(worker.parser, sqlStr, job.dbName, job.tblName)
if err != nil {
worker.logger.Warn("failed to rewrite statement, will use raw input instead",
zap.String("db", job.dbName),
zap.String("table", job.tblName),
zap.String("statement", sqlStr),
zap.Error(err))
job.stmts = []string{sqlStr}
} else {
job.stmts = stmts
}
return worker.appendJob(job)
}

Metadata

Assignees

No one assigned

    Labels

    affects-5.4This bug affects the 5.4.x(LTS) versions.affects-6.1This bug affects the 6.1.x(LTS) versions.affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.component/lightningThis issue is related to Lightning of TiDB.severity/majortype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions