Skip to content

Commit 37dd649

Browse files
committed
Test for alter NULL enum value
1 parent 8a3476a commit 37dd649

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

enginetest/queries/script_queries.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@ var ScriptTests = []ScriptTest{
120120
},
121121
},
122122
},
123+
{
124+
Name: "alter nil enum",
125+
SetUpScript: []string{
126+
"create table xy (x int primary key, y enum ('a', 'b'));",
127+
"insert into xy values (0, NULL),(1, 'b')",
128+
},
129+
Assertions: []ScriptTestAssertion{
130+
{
131+
Query: "alter table xy modify y enum('a','b','c')",
132+
},
133+
//{
134+
// Query: "alter table xy modify y enum('a')",
135+
//},
136+
},
137+
},
123138
{
124139
Name: "issue 7958, update join uppercase table name validation",
125140
SetUpScript: []string{

sql/rowexec/ddl_iters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ func (i *modifyColumnIter) rewriteTable(ctx *sql.Context, rwt sql.RewritableTabl
565565
}
566566

567567
// remap old enum values to new enum values
568-
if isOldEnum && isNewEnum {
568+
if isOldEnum && isNewEnum && newRow[newColIdx] != nil {
569569
oldIdx := int(newRow[newColIdx].(uint16))
570570
oldStr, _ := oldEnum.At(oldIdx)
571571
newIdx := newEnum.IndexOf(oldStr)

sql/rowexec/merge_join.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (i *mergeJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
180180
// We use two variables to manage the lookahead state management.
181181
// |matchedleft| is a forward-looking indicator of whether the current left
182182
// row has satisfied a join condition. It is reset to false when we
183-
// increment left. |matchincleft| is true when the most recent call to
183+
// increment left. |matchingleft| is true when the most recent call to
184184
// |incmatch| incremented the left row. The two vars combined let us
185185
// lookahead during msSelect to 1) identify proper nullified row matches,
186186
// and 2) maintain forward-looking state for the next |i.fullrow|.

sql/rows_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package sql
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
)
7+
8+
var result_ []interface{}
9+
10+
func BenchmarkSliceCopy(b *testing.B) {
11+
var res []interface{}
12+
13+
r := []interface{}{1, 2, 3}
14+
for i := 0; i < b.N; i++ {
15+
res = make([]interface{}, len(r))
16+
copy(res, r)
17+
}
18+
result_ = res
19+
}
20+
21+
func TestRowCopy2(t *testing.T) {
22+
r1 := UntypedSqlRow{1, 2, 3}
23+
r2 := r1.Copy()
24+
r1[0] = 4
25+
fmt.Println(r1, r2)
26+
}
27+
28+
func BenchmarkRowCopy(b *testing.B) {
29+
var res Row
30+
31+
r := UntypedSqlRow{1, 2, 3}
32+
for i := 0; i < b.N; i++ {
33+
res = r.Copy()
34+
}
35+
result_ = res.Values()
36+
}
37+
38+
func BenchmarkUntypedRowCopyToRow(b *testing.B) {
39+
var res Row
40+
r := UntypedSqlRow{1, 2, 3}
41+
for i := 0; i < b.N; i++ {
42+
r2 := make(UntypedSqlRow, len(r))
43+
copy(r2, r)
44+
res = r2
45+
}
46+
result_ = res.Values()
47+
}
48+
49+
func BenchmarkUntypedRowCopy(b *testing.B) {
50+
var res UntypedSqlRow
51+
r := UntypedSqlRow{1, 2, 3}
52+
for i := 0; i < b.N; i++ {
53+
r2 := make(UntypedSqlRow, len(r))
54+
copy(r2, r)
55+
res = r2
56+
}
57+
result_ = res.Values()
58+
}

0 commit comments

Comments
 (0)