Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into morgo-matrix-unit
Browse files Browse the repository at this point in the history
Signed-off-by: Morgan Tocker <[email protected]>
  • Loading branch information
morgo committed Dec 13, 2019
2 parents eab9ef2 + 9471739 commit c3dbe25
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check_make_parser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Get dependencies
run: |
sudo apt-get update
sudo apt-get update || echo "update failed"
sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget
sudo service mysql stop
sudo service etcd stop
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Get dependencies
run: |
sudo apt-get update
sudo apt-get update || echo "update failed"
sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget
sudo service mysql stop
sudo service etcd stop
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_race.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Get dependencies
run: |
sudo apt-get update
sudo apt-get update || echo "update failed"
sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget
sudo service mysql stop
sudo service etcd stop
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/endtoend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Get dependencies
run: |
sudo apt-get update
sudo apt-get update || echo "update failed"
sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget
sudo service mysql stop
sudo service etcd stop
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/local_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Get dependencies
run: |
sudo apt-get update
sudo apt-get update || echo "update failed"
sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget
sudo service mysql stop
sudo service etcd stop
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- name: Get dependencies
run: |
sudo apt-get update
sudo apt-get update || echo "update failed"
if [ ${{matrix.name}} = "mysql57" ]; then
sudo apt-get install -y mysql-server mysql-client
Expand All @@ -29,7 +29,7 @@ jobs:
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
sudo apt-get update
sudo apt-get update || echo "update failed"
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server mysql-client
elif [ ${{matrix.name}} = "mariadb101" ]; then
sudo apt-get remove -y mysql-server mysql-client
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_race.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Get dependencies
run: |
sudo apt-get update
sudo apt-get update || echo "update failed"
sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget
sudo service mysql stop
sudo service etcd stop
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/evanphx/json-patch v4.5.0+incompatible
github.com/ghodss/yaml v0.0.0-20161207003320-04f313413ffd // indirect
github.com/go-ini/ini v1.12.0 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
Expand Down Expand Up @@ -45,7 +45,7 @@ require (
github.com/klauspost/crc32 v1.2.0 // indirect
github.com/klauspost/pgzip v1.2.0
github.com/kr/pretty v0.1.0 // indirect
github.com/krishicks/yaml-patch v0.0.10 // indirect
github.com/krishicks/yaml-patch v0.0.10
github.com/mattn/go-runewidth v0.0.1 // indirect
github.com/minio/minio-go v0.0.0-20190131015406-c8a261de75c1
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
Expand Down
14 changes: 14 additions & 0 deletions go/mysql/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,17 @@ func readLenEncStringAsBytes(data []byte, pos int) ([]byte, int, bool) {
}
return data[pos : pos+s], pos + s, true
}

func readLenEncStringAsBytesCopy(data []byte, pos int) ([]byte, int, bool) {
size, pos, ok := readLenEncInt(data, pos)
if !ok {
return nil, 0, false
}
s := int(size)
if pos+s-1 >= len(data) {
return nil, 0, false
}
result := make([]byte, size)
copy(result, data[pos:pos+s])
return result, pos + s, true
}
18 changes: 18 additions & 0 deletions go/mysql/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,24 @@ func TestEncString(t *testing.T) {
t.Errorf("readLenEncStringAsBytes returned ok=true for empty value %v", test.value)
}

// Check successful decoding as bytes.
gotbcopy, posCopy, ok := readLenEncStringAsBytesCopy(test.lenEncoded, 0)
if !ok || string(gotb) != test.value || pos != len(test.lenEncoded) {
t.Errorf("readLenEncString returned %v/%v/%v but expected %v/%v/%v", gotbcopy, posCopy, ok, test.value, len(test.lenEncoded), true)
}

// Check failed decoding as bytes with shorter data.
_, _, ok = readLenEncStringAsBytesCopy(test.lenEncoded[:len(test.lenEncoded)-1], 0)
if ok {
t.Errorf("readLenEncStringAsBytes returned ok=true for shorter value %v", test.value)
}

// Check failed decoding as bytes with no data.
_, _, ok = readLenEncStringAsBytesCopy([]byte{}, 0)
if ok {
t.Errorf("readLenEncStringAsBytes returned ok=true for empty value %v", test.value)
}

// null encoded tests.

// Check successful encoding.
Expand Down
4 changes: 2 additions & 2 deletions go/mysql/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (c *Conn) parseRow(data []byte, fields []*querypb.Field) ([]sqltypes.Value,
}
var s []byte
var ok bool
s, pos, ok = readLenEncStringAsBytes(data, pos)
s, pos, ok = readLenEncStringAsBytesCopy(data, pos)
if !ok {
return nil, NewSQLError(CRMalformedPacket, SSUnknownSQLState, "decoding string failed")
}
Expand Down Expand Up @@ -823,7 +823,7 @@ func (c *Conn) parseStmtArgs(data []byte, typ querypb.Type, pos int) (sqltypes.V
}
case sqltypes.Decimal, sqltypes.Text, sqltypes.Blob, sqltypes.VarChar, sqltypes.VarBinary, sqltypes.Char,
sqltypes.Bit, sqltypes.Enum, sqltypes.Set, sqltypes.Geometry, sqltypes.Binary, sqltypes.TypeJSON:
val, pos, ok := readLenEncStringAsBytes(data, pos)
val, pos, ok := readLenEncStringAsBytesCopy(data, pos)
return sqltypes.MakeTrusted(sqltypes.VarBinary, val), pos, ok
default:
return sqltypes.NULL, pos, false
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,14 @@ func (e *Executor) handleShow(ctx context.Context, safeSession *SafeSession, sql
}
}
}
case sqlparser.KeywordString(sqlparser.COLUMNS):
if !show.OnTable.Qualifier.IsEmpty() {
destKeyspace = show.OnTable.Qualifier.String()
show.OnTable.Qualifier = sqlparser.NewTableIdent("")
} else {
break
}
sql = sqlparser.String(show)
case sqlparser.KeywordString(sqlparser.TABLES):
if show.ShowTablesOpt != nil && show.ShowTablesOpt.DbName != "" {
if destKeyspace == "" {
Expand Down
7 changes: 7 additions & 0 deletions go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,13 @@ func TestExecutorShow(t *testing.T) {
if err != nil {
t.Error(err)
}

// Test SHOW FULL COLUMNS FROM where query has a qualifier
_, err = executor.Execute(context.Background(), "TestExecute", session, fmt.Sprintf("show full columns from %v.table1", KsTestUnsharded), nil)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}

// Just test for first & last.
qr.Rows = [][]sqltypes.Value{qr.Rows[0], qr.Rows[len(qr.Rows)-1]}
wantqr = &sqltypes.Result{
Expand Down
2 changes: 2 additions & 0 deletions tools/unit_test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ if [ $? -ne 0 ]; then
exit 1
fi

echo '# Flaky tests (3 attempts permitted)'

# Run flaky tests sequentially. Retry when necessary.
for pkg in $flaky_tests; do
max_attempts=3
Expand Down

0 comments on commit c3dbe25

Please sign in to comment.