-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[13.0] Cherry Pick: only use the special NoRoute handling mode when n…
…eeded (#11020) * fix V3: only use the special NoRoute handling mode when needed (#10422) Signed-off-by: Andres Taylor <andres@planetscale.com> * fix: build Signed-off-by: Harshit Gangal <harshit@planetscale.com> * Fix failure when Unowned lookup IS NULL (#10346) * Add a failing test case showing Gen4 planner failure. This test case shows a regression in the query planner for queries that use `IS NULL` condition on an unowned lookup vindex column. Signed-off-by: Arthur Schreiber <arthurschreiber@github.com> Co-authored-by: Elisa Vaccaro <30807261+evaccaro@users.noreply.github.com> Co-authored-by: Jakob Class <mikrobi@github.com> * bugfix: Limit the use of NoRoutesSpecialHandling to when it's needed Signed-off-by: Andres Taylor <andres@planetscale.com> Co-authored-by: Arthur Schreiber <arthurschreiber@github.com> Co-authored-by: Elisa Vaccaro <30807261+evaccaro@users.noreply.github.com> Co-authored-by: Jakob Class <mikrobi@github.com> Signed-off-by: Harshit Gangal <harshit@planetscale.com> Signed-off-by: Andres Taylor <andres@planetscale.com> Signed-off-by: Harshit Gangal <harshit@planetscale.com> Signed-off-by: deepthi <deepthi@planetscale.com> Co-authored-by: Andres Taylor <andres@planetscale.com> Co-authored-by: Arthur Schreiber <arthurschreiber@github.com> Co-authored-by: Elisa Vaccaro <30807261+evaccaro@users.noreply.github.com> Co-authored-by: Jakob Class <mikrobi@github.com> Co-authored-by: deepthi <deepthi@planetscale.com>
- Loading branch information
1 parent
19071b6
commit 87c8549
Showing
10 changed files
with
245 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
Copyright 2022 The Vitess Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package vtgate | ||
|
||
import ( | ||
"context" | ||
_ "embed" | ||
"flag" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"vitess.io/vitess/go/mysql" | ||
"vitess.io/vitess/go/test/endtoend/cluster" | ||
"vitess.io/vitess/go/test/endtoend/vtgate/utils" | ||
) | ||
|
||
var ( | ||
clusterInstance *cluster.LocalProcessCluster | ||
vtParams mysql.ConnParams | ||
KeyspaceName = "ks" | ||
Cell = "test" | ||
//go:embed schema.sql | ||
SchemaSQL string | ||
|
||
//go:embed vschema.json | ||
VSchema string | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
defer cluster.PanicHandler(nil) | ||
flag.Parse() | ||
|
||
exitCode := func() int { | ||
clusterInstance = cluster.NewCluster(Cell, "localhost") | ||
defer clusterInstance.Teardown() | ||
|
||
// Start topo server | ||
err := clusterInstance.StartTopo() | ||
if err != nil { | ||
return 1 | ||
} | ||
|
||
// Start keyspace | ||
keyspace := &cluster.Keyspace{ | ||
Name: KeyspaceName, | ||
SchemaSQL: SchemaSQL, | ||
VSchema: VSchema, | ||
} | ||
err = clusterInstance.StartKeyspace(*keyspace, []string{"-80", "80-"}, 1, true) | ||
if err != nil { | ||
return 1 | ||
} | ||
|
||
// Start vtgate | ||
err = clusterInstance.StartVtgate() | ||
if err != nil { | ||
return 1 | ||
} | ||
vtParams = mysql.ConnParams{ | ||
Host: clusterInstance.Hostname, | ||
Port: clusterInstance.VtgateMySQLPort, | ||
} | ||
return m.Run() | ||
}() | ||
os.Exit(exitCode) | ||
} | ||
|
||
func start(t *testing.T) (*mysql.Conn, func()) { | ||
ctx := context.Background() | ||
conn, err := mysql.Connect(ctx, &vtParams) | ||
require.Nil(t, err) | ||
|
||
deleteAll := func() { | ||
_, _ = utils.ExecAllowError(t, conn, "set workload = oltp") | ||
|
||
tables := []string{"t1", "lookup_t1"} | ||
for _, table := range tables { | ||
_, _ = utils.ExecAllowError(t, conn, "delete from "+table) | ||
} | ||
} | ||
|
||
deleteAll() | ||
|
||
return conn, func() { | ||
deleteAll() | ||
conn.Close() | ||
cluster.PanicHandler(t) | ||
} | ||
} | ||
|
||
func TestInAgainstSecondaryVindex(t *testing.T) { | ||
conn, closer := start(t) | ||
defer closer() | ||
|
||
utils.AssertMatches(t, conn, `select 1 from t1 where c2 in ("abc")`, "[]") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE TABLE t1 ( | ||
c1 bigint unsigned NOT NULL, | ||
c2 varchar(16) NOT NULL, | ||
PRIMARY KEY (c1) | ||
) ENGINE InnoDB; | ||
|
||
CREATE TABLE lookup_t1 ( | ||
c2 varchar(16) NOT NULL, | ||
keyspace_id varbinary(16) NOT NULL, | ||
PRIMARY KEY (c2) | ||
) ENGINE InnoDB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"sharded": true, | ||
"vindexes": { | ||
"lookup_idx": { | ||
"type": "lookup", | ||
"params": { | ||
"from": "c2", | ||
"to": "keyspace_id", | ||
"table": "lookup_t1" | ||
}, | ||
"owner": "t1" | ||
}, | ||
"xxhash": { | ||
"type": "xxhash" | ||
} | ||
}, | ||
"tables": { | ||
"t1": { | ||
"columnVindexes": [ | ||
{ | ||
"column": "c1", | ||
"name": "xxhash" | ||
}, | ||
{ | ||
"column": "c2", | ||
"name": "lookup_idx" | ||
} | ||
] | ||
}, | ||
"lookup_t1": { | ||
"columnVindexes": [ | ||
{ | ||
"column": "c2", | ||
"name": "xxhash" | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters