Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b64794c
update
daviszhen Jul 31, 2026
68206db
update
daviszhen Jul 31, 2026
d390235
update
daviszhen Jul 31, 2026
3ec76e5
update
daviszhen Jul 31, 2026
6f919cd
update
daviszhen Aug 3, 2026
b8228aa
Merge branch 'main' into 0731-fix-insert-ignore
daviszhen Aug 3, 2026
55d6bcf
update
daviszhen Aug 3, 2026
ca48d92
Merge branch 'main' into 0731-fix-insert-ignore
daviszhen Aug 3, 2026
e9e6272
update
daviszhen Aug 3, 2026
461a9a7
update
daviszhen Aug 3, 2026
3d1a623
update
daviszhen Aug 3, 2026
3570ac3
update
daviszhen Aug 3, 2026
8fc454c
update
daviszhen Aug 3, 2026
b23467f
update
daviszhen Aug 3, 2026
cc8259c
update
daviszhen Aug 3, 2026
7478b88
update
daviszhen Aug 3, 2026
7615549
Merge branch '0731-fix-insert-ignore' of https://github.com/daviszhen…
daviszhen Aug 3, 2026
d1611fe
Merge branch 'main' into 0731-fix-insert-ignore
daviszhen Aug 3, 2026
62a91ec
update
daviszhen Aug 3, 2026
fede392
update
daviszhen Aug 3, 2026
746859c
Merge branch '0731-fix-insert-ignore' of https://github.com/daviszhen…
daviszhen Aug 3, 2026
2f4787c
update
daviszhen Aug 4, 2026
c968c67
update
daviszhen Aug 4, 2026
4497577
Merge branch 'main' into 0731-fix-insert-ignore
daviszhen Aug 4, 2026
39cb6b7
update
daviszhen Aug 4, 2026
acaa808
Merge branch '0731-fix-insert-ignore' of https://github.com/daviszhen…
daviszhen Aug 4, 2026
86ad8fe
Merge branch 'main' into 0731-fix-insert-ignore
daviszhen Aug 4, 2026
fcf5052
update ut
daviszhen Aug 4, 2026
7532437
Merge branch '0731-fix-insert-ignore' of https://github.com/daviszhen…
daviszhen Aug 4, 2026
106af34
update
daviszhen Aug 4, 2026
f1a90e7
update
daviszhen Aug 4, 2026
c716491
Merge branch 'main' into 0731-fix-insert-ignore
daviszhen Aug 4, 2026
50f55a7
Merge branch 'main' into 0731-fix-insert-ignore
mergify[bot] Aug 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
385 changes: 368 additions & 17 deletions pkg/sql/plan/base_binder.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions pkg/sql/plan/bind_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3462,6 +3462,16 @@ func (builder *QueryBuilder) buildValueScan(
funcBinder = defaultFuncBinder
}
for _, r := range stmt.Rows {
if nv, ok := r[i].(*tree.NumVal); ok && builder.isInsertIgnore {
expr, handled, err := makeInsertIgnoreMySQLSpecialTypeConstExpr(builder.GetContext(), nv, col.Typ)
if err != nil {
return 0, err
}
if handled {
rowsetData.Cols[i].Data = append(rowsetData.Cols[i].Data, &plan.RowsetExpr{Expr: expr})
continue
}
}
if nv, ok := r[i].(*tree.NumVal); ok && !isEnumOrSetPlanType(&col.Typ) && !isTypedArrayPlanType(&col.Typ) {
expr, err := MakeInsertValueConstExpr(proc, nv, &colTyp, builder.isInsertIgnore)
if err != nil {
Expand Down
12 changes: 11 additions & 1 deletion pkg/sql/plan/build_constraint_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ func MakeInsertValueConstExpr(proc *process.Process, numVal *tree.NumVal, colTyp
return MakePlan2BoolConstExprWithType(num), err

case types.T_bit:
canInsert, num, err := util.SetInsertValueBit(proc, numVal, colType)
canInsert, num, err := util.SetInsertValueBit(proc, numVal, colType, isIgnore)
if err != nil || !canInsert {
return nil, err
}
Expand Down Expand Up @@ -1730,6 +1730,16 @@ func buildValueScan(
binder := NewDefaultBinder(builder.GetContext(), nil, nil, col.Typ, nil)
binder.builder = builder
for _, r := range slt.Rows {
if nv, ok := r[i].(*tree.NumVal); ok && builder.isInsertIgnore {
expr, handled, err := makeInsertIgnoreMySQLSpecialTypeConstExpr(builder.GetContext(), nv, col.Typ)
if err != nil {
return err
}
if handled {
rowsetData.Cols[i].Data = append(rowsetData.Cols[i].Data, &plan.RowsetExpr{Expr: expr})
continue
}
}
if nv, ok := r[i].(*tree.NumVal); ok && !isEnumOrSetPlanType(&col.Typ) && !isTypedArrayPlanType(&col.Typ) {
expr, err := MakeInsertValueConstExpr(proc, nv, &colTyp, builder.isInsertIgnore)
if err != nil {
Expand Down
60 changes: 60 additions & 0 deletions pkg/sql/plan/build_dml_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,66 @@ func TestMakeInsertValueConstExprBinaryHexPadding(t *testing.T) {
}
}

func TestMakeInsertValueConstExprBitIgnoreTruncates(t *testing.T) {
proc := testutil.NewProcess(t)
colType := types.New(types.T_bit, 4, 0)
numVal := tree.NewNumVal("0b11111", "0b11111", false, tree.P_bit)

_, err := MakeInsertValueConstExpr(proc, numVal, &colType, false)
require.Error(t, err)

expr, err := MakeInsertValueConstExpr(proc, numVal, &colType, true)
require.NoError(t, err)
require.Equal(t, uint64(15), expr.GetLit().GetU64Val())
}

func TestMakeInsertIgnoreMySQLSpecialTypeConstExpr(t *testing.T) {
ctx := context.Background()
tests := []struct {
name string
target plan.Type
value *tree.NumVal
wantType types.T
wantEnum uint32
wantSet uint64
}{
{
name: "invalid enum becomes error member",
target: plan.Type{Id: int32(types.T_enum), Enumvalues: "a,b,"},
value: tree.NewNumVal("bad", "bad", false, tree.P_char),
wantType: types.T_enum,
},
{
name: "invalid set member is dropped",
target: plan.Type{Id: int32(types.T_uint64), Enumvalues: "x,y,z"},
value: tree.NewNumVal("x,bad", "x,bad", false, tree.P_char),
wantType: types.T_uint64,
wantSet: 1,
},
{
name: "invalid year becomes zero",
target: plan.Type{Id: int32(types.T_year)},
value: tree.NewNumVal(int64(2156), "2156", false, tree.P_int64),
wantType: types.T_year,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
expr, handled, err := makeInsertIgnoreMySQLSpecialTypeConstExpr(ctx, tt.value, tt.target)
require.NoError(t, err)
require.True(t, handled)
require.Equal(t, int32(tt.wantType), expr.Typ.Id)
if tt.wantType == types.T_enum {
require.Equal(t, tt.wantEnum, expr.GetLit().GetEnumVal())
}
if tt.wantType == types.T_uint64 {
require.Equal(t, tt.wantSet, expr.GetLit().GetU64Val())
}
})
}
}

func TestAppendIndexPrefixProjection(t *testing.T) {
newBuilder := func(t *testing.T) (*QueryBuilder, *BindContext, int32) {
t.Helper()
Expand Down
Loading
Loading