Skip to content

Commit

Permalink
parser: support hints in 'REPLACE INTO' statement (#50007) (#50678)
Browse files Browse the repository at this point in the history
close #34325
  • Loading branch information
ti-chi-bot authored Jan 24, 2024
1 parent 15855e0 commit a880be2
Show file tree
Hide file tree
Showing 6 changed files with 1,565 additions and 1,538 deletions.
11 changes: 11 additions & 0 deletions bindinfo/session_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,14 @@ func TestPreparedStmt(t *testing.T) {
require.Len(t, tk.Session().GetSessionVars().StmtCtx.IndexNames, 1)
require.Equal(t, "t:idx_c", tk.Session().GetSessionVars().StmtCtx.IndexNames[0])
}

func TestSetVarBinding(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t1 (a int, b varchar(20))")
tk.MustExec("insert into t1 values (1, '111111111111111')")
tk.MustExec("insert into t1 values (2, '222222222222222')")
tk.MustExec("create binding for select group_concat(b) from test.t1 using select /*+ SET_VAR(group_concat_max_len = 4) */ group_concat(b) from test.t1 ;")
tk.MustQuery("select group_concat(b) from test.t1").Check(testkit.Rows("1111"))
}
6 changes: 3 additions & 3 deletions parser/ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3779,9 +3779,9 @@ func (n *TableOptimizerHint) Restore(ctx *format.RestoreCtx) error {
ctx.WriteString(hintData.To)
case "set_var":
hintData := n.HintData.(HintSetVar)
ctx.WriteString(hintData.VarName)
ctx.WritePlain(", ")
ctx.WriteString(hintData.Value)
ctx.WritePlain(hintData.VarName)
ctx.WritePlain(" = ")
ctx.WritePlain(hintData.Value)
}
ctx.WritePlain(")")
return nil
Expand Down
Loading

0 comments on commit a880be2

Please sign in to comment.