diff --git a/pkg/constant/config.go b/pkg/constant/config.go index 9a33e40..2e4b94c 100644 --- a/pkg/constant/config.go +++ b/pkg/constant/config.go @@ -16,7 +16,11 @@ package constant +import "github.com/cectc/dbpack/third_party/parser/format" + const ( ConfigPathKey = "config" TransactionTimeout = "transaction-timeout" + + DBPackRestoreFormat = format.DefaultRestoreFlags | format.RestoreStringWithoutDefaultCharset ) diff --git a/pkg/executor/read_write_splitting.go b/pkg/executor/read_write_splitting.go index 4333856..6136dc6 100644 --- a/pkg/executor/read_write_splitting.go +++ b/pkg/executor/read_write_splitting.go @@ -25,6 +25,7 @@ import ( "github.com/pkg/errors" "github.com/cectc/dbpack/pkg/config" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/filter" "github.com/cectc/dbpack/pkg/group" "github.com/cectc/dbpack/pkg/log" @@ -159,9 +160,7 @@ func (executor *ReadWriteSplittingExecutor) ExecutorComQuery( connectionID := proto.ConnectionID(spanCtx) queryStmt := proto.QueryStmt(spanCtx) - if err := queryStmt.Restore(format.NewRestoreCtx( - format.DefaultRestoreFlags| - format.RestoreStringWithoutDefaultCharset, &sb)); err != nil { + if err := queryStmt.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { return nil, 0, err } newSql := sb.String() diff --git a/pkg/executor/single_db.go b/pkg/executor/single_db.go index 148a2a8..45b2afe 100644 --- a/pkg/executor/single_db.go +++ b/pkg/executor/single_db.go @@ -25,6 +25,7 @@ import ( "github.com/pkg/errors" "github.com/cectc/dbpack/pkg/config" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/filter" "github.com/cectc/dbpack/pkg/log" "github.com/cectc/dbpack/pkg/proto" @@ -154,9 +155,7 @@ func (executor *SingleDBExecutor) ExecutorComQuery( if queryStmt == nil { return nil, 0, errors.New("query stmt should not be nil") } - if err := queryStmt.Restore(format.NewRestoreCtx( - format.DefaultRestoreFlags| - format.RestoreStringWithoutDefaultCharset, &sb)); err != nil { + if err := queryStmt.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { return nil, 0, err } sql := sb.String() diff --git a/pkg/filter/dt/exec/prepare_delete.go b/pkg/filter/dt/exec/prepare_delete.go index 6946c05..4944c0b 100644 --- a/pkg/filter/dt/exec/prepare_delete.go +++ b/pkg/filter/dt/exec/prepare_delete.go @@ -21,6 +21,7 @@ import ( "fmt" "strings" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/driver" "github.com/cectc/dbpack/pkg/dt/schema" "github.com/cectc/dbpack/pkg/log" @@ -89,7 +90,7 @@ func (executor *prepareDeleteExecutor) GetTableMeta(ctx context.Context) (schema func (executor *prepareDeleteExecutor) GetTableName() string { var sb strings.Builder - if err := executor.stmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.stmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() @@ -115,7 +116,7 @@ func (executor *prepareDeleteExecutor) buildBeforeImageSql(tableMeta schema.Tabl func (executor *prepareDeleteExecutor) GetWhereCondition() string { var sb strings.Builder - if err := executor.stmt.Where.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.stmt.Where.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() diff --git a/pkg/filter/dt/exec/prepare_global_lock.go b/pkg/filter/dt/exec/prepare_global_lock.go index 742b262..7a55b15 100644 --- a/pkg/filter/dt/exec/prepare_global_lock.go +++ b/pkg/filter/dt/exec/prepare_global_lock.go @@ -22,6 +22,7 @@ import ( "strings" "time" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/driver" "github.com/cectc/dbpack/pkg/dt" "github.com/cectc/dbpack/pkg/dt/schema" @@ -96,11 +97,11 @@ func (executor *prepareGlobalLockExecutor) GetTableMeta(ctx context.Context) (sc func (executor *prepareGlobalLockExecutor) GetTableName() string { var sb strings.Builder if executor.isUpdate { - if err := executor.updateStmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.updateStmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } } else { - if err := executor.deleteStmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.deleteStmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } } @@ -148,11 +149,11 @@ func (executor *prepareGlobalLockExecutor) buildBeforeImageSql(tableMeta schema. func (executor *prepareGlobalLockExecutor) GetWhereCondition() string { var sb strings.Builder if executor.isUpdate { - if err := executor.updateStmt.Where.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.updateStmt.Where.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } } else { - if err := executor.deleteStmt.Where.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.deleteStmt.Where.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } } diff --git a/pkg/filter/dt/exec/prepare_insert.go b/pkg/filter/dt/exec/prepare_insert.go index d792d5a..fa79795 100644 --- a/pkg/filter/dt/exec/prepare_insert.go +++ b/pkg/filter/dt/exec/prepare_insert.go @@ -22,6 +22,7 @@ import ( "strconv" "strings" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/driver" "github.com/cectc/dbpack/pkg/dt/schema" "github.com/cectc/dbpack/pkg/log" @@ -92,7 +93,7 @@ func (executor *prepareInsertExecutor) GetTableMeta(ctx context.Context) (schema func (executor *prepareInsertExecutor) GetTableName() string { var sb strings.Builder - if err := executor.stmt.Table.TableRefs.Left.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.stmt.Table.TableRefs.Left.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() diff --git a/pkg/filter/dt/exec/prepare_select_for_update.go b/pkg/filter/dt/exec/prepare_select_for_update.go index 46df479..fec698b 100644 --- a/pkg/filter/dt/exec/prepare_select_for_update.go +++ b/pkg/filter/dt/exec/prepare_select_for_update.go @@ -21,6 +21,7 @@ import ( "strings" "time" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/tracing" "github.com/cectc/dbpack/pkg/driver" @@ -101,7 +102,7 @@ func (executor *prepareSelectForUpdateExecutor) GetTableMeta(ctx context.Context func (executor *prepareSelectForUpdateExecutor) GetTableName() string { var sb strings.Builder table := executor.stmt.From.TableRefs.Left.(*ast.TableSource) - if err := table.Source.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := table.Source.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() @@ -109,6 +110,6 @@ func (executor *prepareSelectForUpdateExecutor) GetTableName() string { func (executor *prepareSelectForUpdateExecutor) GetWhereCondition() string { var sb strings.Builder - executor.stmt.Where.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)) + executor.stmt.Where.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)) return sb.String() } diff --git a/pkg/filter/dt/exec/prepare_update.go b/pkg/filter/dt/exec/prepare_update.go index 6e7d5c7..2729194 100644 --- a/pkg/filter/dt/exec/prepare_update.go +++ b/pkg/filter/dt/exec/prepare_update.go @@ -21,6 +21,7 @@ import ( "fmt" "strings" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/driver" "github.com/cectc/dbpack/pkg/dt/schema" "github.com/cectc/dbpack/pkg/log" @@ -113,7 +114,7 @@ func (executor *prepareUpdateExecutor) GetTableMeta(ctx context.Context) (schema func (executor *prepareUpdateExecutor) GetTableName() string { var sb strings.Builder - if err := executor.stmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.stmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() @@ -159,7 +160,7 @@ func (executor *prepareUpdateExecutor) buildAfterImageSql(tableMeta schema.Table func (executor *prepareUpdateExecutor) GetWhereCondition() string { var sb strings.Builder - if err := executor.stmt.Where.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.stmt.Where.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Error(err) } return sb.String() diff --git a/pkg/filter/dt/exec/query_delete.go b/pkg/filter/dt/exec/query_delete.go index 0ef70a2..c4e305a 100644 --- a/pkg/filter/dt/exec/query_delete.go +++ b/pkg/filter/dt/exec/query_delete.go @@ -21,6 +21,7 @@ import ( "fmt" "strings" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/driver" "github.com/cectc/dbpack/pkg/dt/schema" "github.com/cectc/dbpack/pkg/log" @@ -78,7 +79,7 @@ func (executor *queryDeleteExecutor) GetTableMeta(ctx context.Context) (schema.T func (executor *queryDeleteExecutor) GetTableName() string { var sb strings.Builder - if err := executor.stmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.stmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() @@ -104,7 +105,7 @@ func (executor *queryDeleteExecutor) buildBeforeImageSql(tableMeta schema.TableM func (executor *queryDeleteExecutor) GetWhereCondition() string { var sb strings.Builder - if err := executor.stmt.Where.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.stmt.Where.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() diff --git a/pkg/filter/dt/exec/query_global_lock.go b/pkg/filter/dt/exec/query_global_lock.go index fe1b75b..b18c8c9 100644 --- a/pkg/filter/dt/exec/query_global_lock.go +++ b/pkg/filter/dt/exec/query_global_lock.go @@ -22,6 +22,7 @@ import ( "strings" "time" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/driver" "github.com/cectc/dbpack/pkg/dt" "github.com/cectc/dbpack/pkg/dt/schema" @@ -121,11 +122,11 @@ func (executor *queryGlobalLockExecutor) GetTableMeta(ctx context.Context) (sche func (executor *queryGlobalLockExecutor) GetTableName() string { var sb strings.Builder if executor.isUpdate { - if err := executor.updateStmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.updateStmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } } else { - if err := executor.deleteStmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.deleteStmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } } @@ -166,11 +167,11 @@ func (executor *queryGlobalLockExecutor) buildBeforeImageSql(tableMeta schema.Ta func (executor *queryGlobalLockExecutor) GetWhereCondition() string { var sb strings.Builder if executor.isUpdate { - if err := executor.updateStmt.Where.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.updateStmt.Where.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } } else { - if err := executor.deleteStmt.Where.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.deleteStmt.Where.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } } diff --git a/pkg/filter/dt/exec/query_insert.go b/pkg/filter/dt/exec/query_insert.go index 90bdd31..6623d9f 100644 --- a/pkg/filter/dt/exec/query_insert.go +++ b/pkg/filter/dt/exec/query_insert.go @@ -21,6 +21,7 @@ import ( "fmt" "strings" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/driver" "github.com/cectc/dbpack/pkg/dt/schema" "github.com/cectc/dbpack/pkg/log" @@ -124,7 +125,7 @@ func (executor *queryInsertExecutor) GetTableMeta(ctx context.Context) (schema.T func (executor *queryInsertExecutor) GetTableName() string { var sb strings.Builder - if err := executor.stmt.Table.TableRefs.Left.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.stmt.Table.TableRefs.Left.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() @@ -137,7 +138,7 @@ func (executor *queryInsertExecutor) getPKValuesByColumn(ctx context.Context) ([ for i, value := range executor.stmt.Lists[j] { if i == pkIndex { var sb strings.Builder - if err := value.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := value.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } pkValues = append(pkValues, sb.String()) diff --git a/pkg/filter/dt/exec/query_select_for_update.go b/pkg/filter/dt/exec/query_select_for_update.go index e47f0b2..2accf4e 100644 --- a/pkg/filter/dt/exec/query_select_for_update.go +++ b/pkg/filter/dt/exec/query_select_for_update.go @@ -21,6 +21,7 @@ import ( "strings" "time" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/driver" "github.com/cectc/dbpack/pkg/dt" "github.com/cectc/dbpack/pkg/dt/schema" @@ -97,7 +98,7 @@ func (executor *querySelectForUpdateExecutor) GetTableMeta(ctx context.Context) func (executor *querySelectForUpdateExecutor) GetTableName() string { var sb strings.Builder table := executor.stmt.From.TableRefs.Left.(*ast.TableSource) - if err := table.Source.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := table.Source.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() @@ -105,6 +106,6 @@ func (executor *querySelectForUpdateExecutor) GetTableName() string { func (executor *querySelectForUpdateExecutor) GetWhereCondition() string { var sb strings.Builder - executor.stmt.Where.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)) + executor.stmt.Where.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)) return sb.String() } diff --git a/pkg/filter/dt/exec/query_update.go b/pkg/filter/dt/exec/query_update.go index 5ca665d..c0f5c78 100644 --- a/pkg/filter/dt/exec/query_update.go +++ b/pkg/filter/dt/exec/query_update.go @@ -21,6 +21,7 @@ import ( "fmt" "strings" + "github.com/cectc/dbpack/pkg/constant" "github.com/cectc/dbpack/pkg/driver" "github.com/cectc/dbpack/pkg/dt/schema" "github.com/cectc/dbpack/pkg/log" @@ -98,7 +99,7 @@ func (executor *queryUpdateExecutor) GetTableMeta(ctx context.Context) (schema.T func (executor *queryUpdateExecutor) GetTableName() string { var sb strings.Builder - if err := executor.stmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.stmt.TableRefs.TableRefs.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() @@ -156,7 +157,7 @@ func (executor *queryUpdateExecutor) buildAfterImageSql(tableMeta schema.TableMe func (executor *queryUpdateExecutor) GetWhereCondition() string { var sb strings.Builder - if err := executor.stmt.Where.Restore(format.NewRestoreCtx(format.DefaultRestoreFlags, &sb)); err != nil { + if err := executor.stmt.Where.Restore(format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb)); err != nil { log.Panic(err) } return sb.String() diff --git a/pkg/misc/sql.go b/pkg/misc/sql.go index 7be986e..9c6da5d 100644 --- a/pkg/misc/sql.go +++ b/pkg/misc/sql.go @@ -53,7 +53,11 @@ func MysqlAppendInParamWithValue(values []interface{}) string { for i, value := range values { switch val := value.(type) { case string: - sb.WriteString(fmt.Sprintf("'%s'", val)) + if strings.HasPrefix(val, "'") { + sb.WriteString(fmt.Sprintf("%s", val)) + } else { + sb.WriteString(fmt.Sprintf("'%s'", val)) + } case []byte: sb.WriteString(fmt.Sprintf("'%s'", val)) default: diff --git a/pkg/misc/sql_test.go b/pkg/misc/sql_test.go index ecf4dcc..e0db709 100644 --- a/pkg/misc/sql_test.go +++ b/pkg/misc/sql_test.go @@ -77,10 +77,14 @@ func TestMysqlAppendInParamWithValue(t *testing.T) { in []interface{} out string }{ - "1": { + "0": { in: []interface{}{"abc", "xyz"}, out: "('abc','xyz')", }, + "1": { + in: []interface{}{"'abc'", "'xyz'"}, + out: "('abc','xyz')", + }, "2": { in: []interface{}{[]byte("abc"), []byte("xyz")}, out: "('abc','xyz')", diff --git a/pkg/optimize/optimize_insert.go b/pkg/optimize/optimize_insert.go index f49e952..140b7d3 100644 --- a/pkg/optimize/optimize_insert.go +++ b/pkg/optimize/optimize_insert.go @@ -122,7 +122,7 @@ func getPkValue(ctx context.Context, stmt *ast.InsertStmt, pkIndex int, args []i switch commandType { case constant.ComQuery: var sb strings.Builder - ctx := format.NewRestoreCtx(format.DefaultRestoreFlags, &sb) + ctx := format.NewRestoreCtx(constant.DBPackRestoreFormat, &sb) if err := stmt.Lists[0][pkIndex].Restore(ctx); err != nil { log.Panic(err) } diff --git a/pkg/plan/delete.go b/pkg/plan/delete.go index 9ec5ec9..1f0546f 100644 --- a/pkg/plan/delete.go +++ b/pkg/plan/delete.go @@ -103,7 +103,7 @@ func (p *DeletePlan) Execute(ctx context.Context, hints ...*ast.TableOptimizerHi } func (p *DeletePlan) generate(sb *strings.Builder, table string, hints ...*ast.TableOptimizerHint) error { - ctx := format.NewRestoreCtx(format.DefaultRestoreFlags|format.RestoreStringWithoutDefaultCharset, sb) + ctx := format.NewRestoreCtx(constant.DBPackRestoreFormat, sb) ctx.WriteKeyWord("DELETE ") if len(hints) != 0 { diff --git a/pkg/plan/insert.go b/pkg/plan/insert.go index bb96879..197f88b 100644 --- a/pkg/plan/insert.go +++ b/pkg/plan/insert.go @@ -60,7 +60,7 @@ func (p *InsertPlan) Execute(ctx context.Context, hints ...*ast.TableOptimizerHi } func (p *InsertPlan) generate(sb *strings.Builder) (err error) { - ctx := format.NewRestoreCtx(format.DefaultRestoreFlags|format.RestoreStringWithoutDefaultCharset, sb) + ctx := format.NewRestoreCtx(constant.DBPackRestoreFormat, sb) ctx.WriteKeyWord("INSERT ") ctx.WriteKeyWord("INTO ") diff --git a/pkg/plan/query.go b/pkg/plan/query.go index 1ffa117..7ccae8a 100644 --- a/pkg/plan/query.go +++ b/pkg/plan/query.go @@ -136,7 +136,7 @@ func (p *QueryOnSingleDBPlan) generate(ctx context.Context, sb *strings.Builder, } sb.WriteString(") t ") if p.Stmt.OrderBy != nil { - restoreCtx := format.NewRestoreCtx(format.DefaultRestoreFlags|format.RestoreStringWithoutDefaultCharset, sb) + restoreCtx := format.NewRestoreCtx(constant.DBPackRestoreFormat, sb) if err := p.Stmt.OrderBy.Restore(restoreCtx); err != nil { return errors.WithStack(err) } @@ -240,7 +240,7 @@ func (p *QueryOnMultiDBPlan) Execute(ctx context.Context, _ ...*ast.TableOptimiz } func generateSelect(table string, stmt *ast.SelectStmt, sb *strings.Builder, limit *Limit) error { - ctx := format.NewRestoreCtx(format.DefaultRestoreFlags|format.RestoreStringWithoutDefaultCharset, sb) + ctx := format.NewRestoreCtx(constant.DBPackRestoreFormat, sb) ctx.WriteKeyWord(stmt.Kind.String()) ctx.WritePlain(" ") diff --git a/pkg/plan/update.go b/pkg/plan/update.go index d6df7c4..993af62 100644 --- a/pkg/plan/update.go +++ b/pkg/plan/update.go @@ -103,7 +103,7 @@ func (p *UpdatePlan) Execute(ctx context.Context, hints ...*ast.TableOptimizerHi } func (p *UpdatePlan) generate(sb *strings.Builder, table string, hints ...*ast.TableOptimizerHint) error { - ctx := format.NewRestoreCtx(format.DefaultRestoreFlags|format.RestoreStringWithoutDefaultCharset, sb) + ctx := format.NewRestoreCtx(constant.DBPackRestoreFormat, sb) ctx.WriteKeyWord("UPDATE ") if len(hints) != 0 {