From c4bd53834d6af8f7c01aefc1659fd28bca4f4fef Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 24 Jan 2024 15:34:53 +0530 Subject: [PATCH] test: add failing one-case test to show the panic Signed-off-by: Manan Gupta --- go/vt/vtgate/planbuilder/plan_test.go | 4 +++- go/vt/vtgate/planbuilder/testdata/onecase.json | 2 +- .../planbuilder/testdata/vschemas/schema.json | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/go/vt/vtgate/planbuilder/plan_test.go b/go/vt/vtgate/planbuilder/plan_test.go index a680af9b7fb..30730f35db7 100644 --- a/go/vt/vtgate/planbuilder/plan_test.go +++ b/go/vt/vtgate/planbuilder/plan_test.go @@ -183,8 +183,10 @@ func setFks(t *testing.T, vschema *vindexes.VSchema) { // FK from tblrefDef referencing tbl20 that is shard scoped of SET-Default types. _ = vschema.AddForeignKey("sharded_fk_allow", "tblrefDef", createFkDefinition([]string{"ref"}, "tbl20", []string{"col2"}, sqlparser.SetDefault, sqlparser.SetDefault)) + // FK from tbl_auth referencing tbl20 that is shard scoped of CASCADE types. + _ = vschema.AddForeignKey("sharded_fk_allow", "tbl_auth", createFkDefinition([]string{"id"}, "tbl20", []string{"col2"}, sqlparser.Cascade, sqlparser.Cascade)) addPKs(t, vschema, "sharded_fk_allow", []string{"tbl1", "tbl2", "tbl3", "tbl4", "tbl5", "tbl6", "tbl7", "tbl9", "tbl10", - "multicol_tbl1", "multicol_tbl2", "tblrefDef", "tbl20"}) + "multicol_tbl1", "multicol_tbl2", "tbl_auth", "tblrefDef", "tbl20"}) } if vschema.Keyspaces["unsharded_fk_allow"] != nil { // u_tbl2(col2) -> u_tbl1(col1) Cascade. diff --git a/go/vt/vtgate/planbuilder/testdata/onecase.json b/go/vt/vtgate/planbuilder/testdata/onecase.json index da7543f706a..7747f1b0d1d 100644 --- a/go/vt/vtgate/planbuilder/testdata/onecase.json +++ b/go/vt/vtgate/planbuilder/testdata/onecase.json @@ -1,7 +1,7 @@ [ { "comment": "Add your test case here for debugging and run go test -run=One.", - "query": "", + "query": "update tbl_auth set unknown_col = 'verified' where id = 1", "plan": { } diff --git a/go/vt/vtgate/planbuilder/testdata/vschemas/schema.json b/go/vt/vtgate/planbuilder/testdata/vschemas/schema.json index 36aa30381e2..34a3d904f4f 100644 --- a/go/vt/vtgate/planbuilder/testdata/vschemas/schema.json +++ b/go/vt/vtgate/planbuilder/testdata/vschemas/schema.json @@ -723,6 +723,20 @@ } ] }, + "tbl_auth": { + "columns": [ + { + "name": "id" + } + ], + "column_vindexes": [ + { + "column": "id", + "name": "hash_vin" + } + ], + "column_list_authoritative": true + }, "tblrefDef": { "column_vindexes": [ {