beads/internal/storage/dberrors/errors.go
Julian Knutsen 09a3890877
fix(storage): preserve mixed issue and wisp reads (#3991)
* 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
2026-05-21 06:50:42 -07:00

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)
}