* fix(schema): avoid sweeping dirty data during migrations * fix: guard schema migration dirty commits (bd-wisp-g6c0g) * fix(storage): preserve mixed issue and wisp reads * fix(schema): unstage old tables before migrations * test(dolt): add generated column cascade repro * Repair PR 3991 rebase against current storage schema
33 lines
890 B
Go
33 lines
890 B
Go
package dberrors
|
|
|
|
import (
|
|
"errors"
|
|
"regexp"
|
|
"strings"
|
|
|
|
mysql "github.com/go-sql-driver/mysql"
|
|
)
|
|
|
|
var (
|
|
quotedTableMissingPattern = regexp.MustCompile(`(?i)\btable\s+'[^']+'\s+(doesn't exist|does not exist)\b`)
|
|
unquotedTableMissingPattern = regexp.MustCompile("(?i)^table\\s+`?[^\\s'`]+`?\\s+(doesn't exist|does not exist)\\b")
|
|
)
|
|
|
|
// IsTableNotExist reports whether err is specifically a MySQL/Dolt
|
|
// table-not-found error. It intentionally does not classify missing columns,
|
|
// schemas, or other objects as optional-table absence.
|
|
func IsTableNotExist(err error) bool {
|
|
if err == nil {
|
|
return false
|
|
}
|
|
|
|
var mysqlErr *mysql.MySQLError
|
|
if errors.As(err, &mysqlErr) {
|
|
return mysqlErr.Number == 1146
|
|
}
|
|
|
|
s := strings.ToLower(err.Error())
|
|
return strings.Contains(s, "error 1146") ||
|
|
quotedTableMissingPattern.MatchString(s) ||
|
|
unquotedTableMissingPattern.MatchString(s)
|
|
}
|