From e0f96d31deb8e1d4b9e0e0fbc4f4dce257526a9c Mon Sep 17 00:00:00 2001 From: "vitess-bot[bot]" <108069721+vitess-bot[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:49:00 +0200 Subject: [PATCH] [release-18.0] Rename Foreign Key enum values in VSchema and drop `FK_` prefix (#14274) (#14299) Signed-off-by: Manan Gupta Co-authored-by: Manan Gupta <35839558+GuptaManan100@users.noreply.github.com> Co-authored-by: Manan Gupta --- changelog/18.0/18.0.0/release_notes.md | 6 +- changelog/18.0/18.0.0/summary.md | 6 +- .../vtgate/foreignkey/sharded_vschema.json | 2 +- .../foreignkey/stress/fk_stress_test.go | 2 +- .../vtgate/foreignkey/unsharded_vschema.json | 2 +- go/test/vschemawrapper/vschema_wrapper.go | 4 +- go/vt/proto/vschema/vschema.pb.go | 192 +++++++++--------- go/vt/vtgate/planbuilder/ddl.go | 2 +- go/vt/vtgate/planbuilder/delete.go | 2 +- go/vt/vtgate/planbuilder/insert.go | 2 +- go/vt/vtgate/planbuilder/operators/delete.go | 2 +- go/vt/vtgate/planbuilder/operators/insert.go | 2 +- go/vt/vtgate/planbuilder/operators/update.go | 2 +- .../planbuilder/testdata/vschemas/schema.json | 4 +- go/vt/vtgate/planbuilder/update.go | 2 +- go/vt/vtgate/vcursor_impl.go | 2 +- go/vt/vtgate/vindexes/vschema.go | 10 +- go/vt/vtgate/vindexes/vschema_test.go | 76 +++---- go/vt/vtgate/vschema_manager_test.go | 8 +- .../tabletserver/vstreamer/engine_test.go | 2 +- proto/vschema.proto | 8 +- web/vtadmin/src/proto/vtadmin.d.ts | 8 +- web/vtadmin/src/proto/vtadmin.js | 26 +-- 23 files changed, 186 insertions(+), 186 deletions(-) diff --git a/changelog/18.0/18.0.0/release_notes.md b/changelog/18.0/18.0.0/release_notes.md index c6cab829d3a..026c0363b22 100644 --- a/changelog/18.0/18.0.0/release_notes.md +++ b/changelog/18.0/18.0.0/release_notes.md @@ -85,14 +85,14 @@ It is disabled by default. A new field `foreignKeyMode` has been added to the VSchema. This field can be provided for each keyspace. The VTGate flag `--foreign_key_mode` has been deprecated in favour of this field. There are 3 foreign key modes now supported in Vitess - -1. `FK_UNMANAGED` - +1. `unmanaged` - This mode represents the default behaviour in Vitess, where it does not manage foreign keys column references. Users are responsible for configuring foreign keys in MySQL in such a way that related rows, as determined by foreign keys, reside within the same shard. -2. `FK_MANAGED` [EXPERIMENTAL] - +2. `managed` [EXPERIMENTAL] - In this experimental mode, Vitess is fully aware of foreign key relationships and actively tracks foreign key constraints using the schema tracker. Vitess takes charge of handling DML operations with foreign keys cascading updates, deletes and verifying restrict. It will also validate parent row existence. This ensures that all the operations are logged in binary logs, unlike MySQL implementation of foreign keys. This enables seamless integration of VReplication with foreign keys. For more details on what operations Vitess takes please refer to the [design document for foreign keys](https://github.com/vitessio/vitess/issues/12967). -3. `FK_DISALLOW` - +3. `disallow` - In this mode Vitess explicitly disallows any DDL statements that try to create a foreign key constraint. This mode is equivalent to running VTGate with the flag `--foreign_key_mode=disallow`. #### Upgrade process diff --git a/changelog/18.0/18.0.0/summary.md b/changelog/18.0/18.0.0/summary.md index 1adf55a8683..9d31410c32b 100644 --- a/changelog/18.0/18.0.0/summary.md +++ b/changelog/18.0/18.0.0/summary.md @@ -85,14 +85,14 @@ It is disabled by default. A new field `foreignKeyMode` has been added to the VSchema. This field can be provided for each keyspace. The VTGate flag `--foreign_key_mode` has been deprecated in favour of this field. There are 3 foreign key modes now supported in Vitess - -1. `FK_UNMANAGED` - +1. `unmanaged` - This mode represents the default behaviour in Vitess, where it does not manage foreign keys column references. Users are responsible for configuring foreign keys in MySQL in such a way that related rows, as determined by foreign keys, reside within the same shard. -2. `FK_MANAGED` [EXPERIMENTAL] - +2. `managed` [EXPERIMENTAL] - In this experimental mode, Vitess is fully aware of foreign key relationships and actively tracks foreign key constraints using the schema tracker. Vitess takes charge of handling DML operations with foreign keys cascading updates, deletes and verifying restrict. It will also validate parent row existence. This ensures that all the operations are logged in binary logs, unlike MySQL implementation of foreign keys. This enables seamless integration of VReplication with foreign keys. For more details on what operations Vitess takes please refer to the [design document for foreign keys](https://github.com/vitessio/vitess/issues/12967). -3. `FK_DISALLOW` - +3. `disallow` - In this mode Vitess explicitly disallows any DDL statements that try to create a foreign key constraint. This mode is equivalent to running VTGate with the flag `--foreign_key_mode=disallow`. #### Upgrade process diff --git a/go/test/endtoend/vtgate/foreignkey/sharded_vschema.json b/go/test/endtoend/vtgate/foreignkey/sharded_vschema.json index b40b10b88e0..688228f8772 100644 --- a/go/test/endtoend/vtgate/foreignkey/sharded_vschema.json +++ b/go/test/endtoend/vtgate/foreignkey/sharded_vschema.json @@ -1,6 +1,6 @@ { "sharded": true, - "foreignKeyMode": "FK_MANAGED", + "foreignKeyMode": "managed", "vindexes": { "xxhash": { "type": "xxhash" diff --git a/go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go b/go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go index c55ce9eef79..5c91fdbb929 100644 --- a/go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go +++ b/go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go @@ -323,7 +323,7 @@ func TestMain(m *testing.M) { Name: keyspaceName, VSchema: `{ "sharded": false, - "foreignKeyMode": "FK_MANAGED" + "foreignKeyMode": "managed" }`, } diff --git a/go/test/endtoend/vtgate/foreignkey/unsharded_vschema.json b/go/test/endtoend/vtgate/foreignkey/unsharded_vschema.json index fbdc3dd7c04..31f02ca41c4 100644 --- a/go/test/endtoend/vtgate/foreignkey/unsharded_vschema.json +++ b/go/test/endtoend/vtgate/foreignkey/unsharded_vschema.json @@ -1,6 +1,6 @@ { "sharded": false, - "foreignKeyMode": "FK_MANAGED", + "foreignKeyMode": "managed", "tables": { "u_t1": {}, "u_t2": {}, diff --git a/go/test/vschemawrapper/vschema_wrapper.go b/go/test/vschemawrapper/vschema_wrapper.go index 11038fd151f..1656fafa41b 100644 --- a/go/test/vschemawrapper/vschema_wrapper.go +++ b/go/test/vschemawrapper/vschema_wrapper.go @@ -129,8 +129,8 @@ func (vw *VSchemaWrapper) PlannerWarning(_ string) { } func (vw *VSchemaWrapper) ForeignKeyMode(keyspace string) (vschemapb.Keyspace_ForeignKeyMode, error) { - defaultFkMode := vschemapb.Keyspace_FK_UNMANAGED - if vw.V.Keyspaces[keyspace] != nil && vw.V.Keyspaces[keyspace].ForeignKeyMode != vschemapb.Keyspace_FK_DEFAULT { + defaultFkMode := vschemapb.Keyspace_unmanaged + if vw.V.Keyspaces[keyspace] != nil && vw.V.Keyspaces[keyspace].ForeignKeyMode != vschemapb.Keyspace_unspecified { return vw.V.Keyspaces[keyspace].ForeignKeyMode, nil } return defaultFkMode, nil diff --git a/go/vt/proto/vschema/vschema.pb.go b/go/vt/proto/vschema/vschema.pb.go index 4783fa51586..a1524e66723 100644 --- a/go/vt/proto/vschema/vschema.pb.go +++ b/go/vt/proto/vschema/vschema.pb.go @@ -41,25 +41,25 @@ const ( type Keyspace_ForeignKeyMode int32 const ( - Keyspace_FK_DEFAULT Keyspace_ForeignKeyMode = 0 - Keyspace_FK_DISALLOW Keyspace_ForeignKeyMode = 1 - Keyspace_FK_UNMANAGED Keyspace_ForeignKeyMode = 2 - Keyspace_FK_MANAGED Keyspace_ForeignKeyMode = 3 + Keyspace_unspecified Keyspace_ForeignKeyMode = 0 + Keyspace_disallow Keyspace_ForeignKeyMode = 1 + Keyspace_unmanaged Keyspace_ForeignKeyMode = 2 + Keyspace_managed Keyspace_ForeignKeyMode = 3 ) // Enum value maps for Keyspace_ForeignKeyMode. var ( Keyspace_ForeignKeyMode_name = map[int32]string{ - 0: "FK_DEFAULT", - 1: "FK_DISALLOW", - 2: "FK_UNMANAGED", - 3: "FK_MANAGED", + 0: "unspecified", + 1: "disallow", + 2: "unmanaged", + 3: "managed", } Keyspace_ForeignKeyMode_value = map[string]int32{ - "FK_DEFAULT": 0, - "FK_DISALLOW": 1, - "FK_UNMANAGED": 2, - "FK_MANAGED": 3, + "unspecified": 0, + "disallow": 1, + "unmanaged": 2, + "managed": 3, } ) @@ -277,7 +277,7 @@ func (x *Keyspace) GetForeignKeyMode() Keyspace_ForeignKeyMode { if x != nil { return x.ForeignKeyMode } - return Keyspace_FK_DEFAULT + return Keyspace_unspecified } // Vindex is the vindex info for a Keyspace. @@ -840,7 +840,7 @@ var file_vschema_proto_rawDesc = []byte{ 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x72, 0x6f, 0x6d, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x08, 0x74, 0x6f, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x22, 0x8c, 0x04, 0x0a, + 0x28, 0x09, 0x52, 0x08, 0x74, 0x6f, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x22, 0x84, 0x04, 0x0a, 0x08, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x65, 0x64, 0x12, 0x3b, 0x0a, 0x08, 0x76, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x18, @@ -868,88 +868,88 @@ var file_vschema_proto_rawDesc = []byte{ 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x53, 0x0a, 0x0e, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, - 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4b, 0x5f, 0x44, - 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x4b, 0x5f, 0x44, - 0x49, 0x53, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x4b, 0x5f, - 0x55, 0x4e, 0x4d, 0x41, 0x4e, 0x41, 0x47, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x46, - 0x4b, 0x5f, 0x4d, 0x41, 0x4e, 0x41, 0x47, 0x45, 0x44, 0x10, 0x03, 0x22, 0xa2, 0x01, 0x0a, 0x06, - 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x70, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x73, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, - 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x22, 0xb1, 0x02, 0x0a, 0x05, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3e, - 0x0a, 0x0f, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x76, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0e, - 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x12, 0x3d, - 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, - 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0d, - 0x61, 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x29, 0x0a, - 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, - 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, - 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x69, 0x6e, 0x6e, - 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, - 0x12, 0x3a, 0x0a, 0x19, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, - 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x17, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x41, - 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, 0x12, 0x16, 0x0a, 0x06, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x22, 0x54, 0x0a, 0x0c, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, - 0x6e, 0x64, 0x65, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x22, 0x43, 0x0a, 0x0d, 0x41, 0x75, - 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63, - 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, - 0x75, 0x6d, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, - 0x3d, 0x0a, 0x06, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x71, 0x75, - 0x65, 0x72, 0x79, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xa7, - 0x02, 0x0a, 0x0a, 0x53, 0x72, 0x76, 0x56, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x40, 0x0a, - 0x09, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x22, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x53, 0x72, 0x76, 0x56, 0x53, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, - 0x3a, 0x0a, 0x0d, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, - 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x0c, 0x72, - 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x4a, 0x0a, 0x13, 0x73, - 0x68, 0x61, 0x72, 0x64, 0x5f, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, - 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, - 0x6d, 0x61, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, - 0x75, 0x6c, 0x65, 0x73, 0x52, 0x11, 0x73, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, - 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x1a, 0x4f, 0x0a, 0x0e, 0x4b, 0x65, 0x79, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x27, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x76, 0x73, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x44, 0x0a, 0x11, 0x53, 0x68, 0x61, 0x72, - 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x2f, 0x0a, - 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x76, - 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, - 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x6e, - 0x0a, 0x10, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, - 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6d, 0x4b, - 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x5f, 0x6b, 0x65, - 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x6f, - 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x68, 0x61, 0x72, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x68, 0x61, 0x72, 0x64, 0x42, 0x26, - 0x5a, 0x24, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6f, 0x2f, 0x76, 0x69, 0x74, 0x65, - 0x73, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, - 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x4b, 0x0a, 0x0e, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, + 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x75, 0x6e, 0x73, 0x70, + 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x64, 0x69, 0x73, + 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x75, 0x6e, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x64, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x64, 0x10, 0x03, 0x22, 0xa2, 0x01, 0x0a, 0x06, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x56, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x1a, 0x39, 0x0a, + 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xb1, 0x02, 0x0a, 0x05, 0x54, 0x61, 0x62, + 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3e, 0x0a, 0x0f, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, + 0x5f, 0x76, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, + 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0e, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x12, 0x3d, 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x69, + 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, + 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, + 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, + 0x12, 0x16, 0x0a, 0x06, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x12, 0x3a, 0x0a, 0x19, 0x63, 0x6f, 0x6c, 0x75, + 0x6d, 0x6e, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, + 0x61, 0x74, 0x69, 0x76, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x17, 0x63, 0x6f, 0x6c, + 0x75, 0x6d, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x61, + 0x74, 0x69, 0x76, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x54, 0x0a, 0x0c, + 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x16, 0x0a, 0x06, + 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, + 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, + 0x6d, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, + 0x6e, 0x73, 0x22, 0x43, 0x0a, 0x0d, 0x41, 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, + 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, + 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x3d, 0x0a, 0x06, 0x43, 0x6f, 0x6c, 0x75, 0x6d, + 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xa7, 0x02, 0x0a, 0x0a, 0x53, 0x72, 0x76, 0x56, 0x53, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x40, 0x0a, 0x09, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x2e, 0x53, 0x72, 0x76, 0x56, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x4b, 0x65, + 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6b, 0x65, + 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x0d, 0x72, 0x6f, 0x75, 0x74, 0x69, + 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, + 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, + 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x0c, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, + 0x6c, 0x65, 0x73, 0x12, 0x4a, 0x0a, 0x13, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x72, 0x6f, 0x75, + 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x64, + 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x11, 0x73, 0x68, + 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x1a, + 0x4f, 0x0a, 0x0e, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x27, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x4b, 0x65, 0x79, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0x44, 0x0a, 0x11, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, + 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x2f, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x53, + 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, + 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x6e, 0x0a, 0x10, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, + 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, + 0x6f, 0x6d, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6d, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, + 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x6f, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x12, 0x14, 0x0a, 0x05, 0x73, 0x68, 0x61, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x73, 0x68, 0x61, 0x72, 0x64, 0x42, 0x26, 0x5a, 0x24, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, + 0x2e, 0x69, 0x6f, 0x2f, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/go/vt/vtgate/planbuilder/ddl.go b/go/vt/vtgate/planbuilder/ddl.go index e7703630bb3..41e5d64346e 100644 --- a/go/vt/vtgate/planbuilder/ddl.go +++ b/go/vt/vtgate/planbuilder/ddl.go @@ -155,7 +155,7 @@ func checkFKError(vschema plancontext.VSchema, ddlStatement sqlparser.DDLStateme if err != nil { return err } - if fkMode == vschemapb.Keyspace_FK_DISALLOW { + if fkMode == vschemapb.Keyspace_disallow { fk := &fkContraint{} _ = sqlparser.Walk(fk.FkWalk, ddlStatement) if fk.found { diff --git a/go/vt/vtgate/planbuilder/delete.go b/go/vt/vtgate/planbuilder/delete.go index b62c35e9bd1..e5e993d50e0 100644 --- a/go/vt/vtgate/planbuilder/delete.go +++ b/go/vt/vtgate/planbuilder/delete.go @@ -100,7 +100,7 @@ func fkManagementNotRequired(ctx *plancontext.PlanningContext, vschema planconte if err != nil { return false } - if ksMode != vschemapb.Keyspace_FK_MANAGED { + if ksMode != vschemapb.Keyspace_managed { continue } childFks := vTable.ChildFKsNeedsHandling(ctx.VerifyAllFKs, vindexes.DeleteAction) diff --git a/go/vt/vtgate/planbuilder/insert.go b/go/vt/vtgate/planbuilder/insert.go index 55ef9148b1a..f66fd5727b1 100644 --- a/go/vt/vtgate/planbuilder/insert.go +++ b/go/vt/vtgate/planbuilder/insert.go @@ -107,7 +107,7 @@ func errOutIfPlanCannotBeConstructed(ctx *plancontext.PlanningContext, vTbl *vin // TODO: Handle all this in semantic analysis. func fkManagementRequiredForInsert(ctx *plancontext.PlanningContext, vTbl *vindexes.Table, updateExprs sqlparser.UpdateExprs, replace bool) bool { ksMode, err := ctx.VSchema.ForeignKeyMode(vTbl.Keyspace.Name) - if err != nil || ksMode != vschemapb.Keyspace_FK_MANAGED { + if err != nil || ksMode != vschemapb.Keyspace_managed { return false } diff --git a/go/vt/vtgate/planbuilder/operators/delete.go b/go/vt/vtgate/planbuilder/operators/delete.go index 3d4d5e40357..11a4ed8b31d 100644 --- a/go/vt/vtgate/planbuilder/operators/delete.go +++ b/go/vt/vtgate/planbuilder/operators/delete.go @@ -99,7 +99,7 @@ func createOperatorFromDelete(ctx *plancontext.PlanningContext, deleteStmt *sqlp } // Unmanaged foreign-key-mode, we don't need to do anything. - if ksMode != vschemapb.Keyspace_FK_MANAGED { + if ksMode != vschemapb.Keyspace_managed { return delOp, nil } diff --git a/go/vt/vtgate/planbuilder/operators/insert.go b/go/vt/vtgate/planbuilder/operators/insert.go index 9853e714c47..1925a0d9518 100644 --- a/go/vt/vtgate/planbuilder/operators/insert.go +++ b/go/vt/vtgate/planbuilder/operators/insert.go @@ -149,7 +149,7 @@ func createOperatorFromInsert(ctx *plancontext.PlanningContext, ins *sqlparser.I if err != nil { return nil, err } - if ksMode != vschemapb.Keyspace_FK_MANAGED { + if ksMode != vschemapb.Keyspace_managed { return insOp, nil } diff --git a/go/vt/vtgate/planbuilder/operators/update.go b/go/vt/vtgate/planbuilder/operators/update.go index c20ce9fa020..5a7716bdbeb 100644 --- a/go/vt/vtgate/planbuilder/operators/update.go +++ b/go/vt/vtgate/planbuilder/operators/update.go @@ -120,7 +120,7 @@ func createOperatorFromUpdate(ctx *plancontext.PlanningContext, updStmt *sqlpars return nil, err } // Unmanaged foreign-key-mode, we don't need to do anything. - if ksMode != vschemapb.Keyspace_FK_MANAGED { + if ksMode != vschemapb.Keyspace_managed { return updOp, nil } diff --git a/go/vt/vtgate/planbuilder/testdata/vschemas/schema.json b/go/vt/vtgate/planbuilder/testdata/vschemas/schema.json index 50a09c97a48..ac88fea498d 100644 --- a/go/vt/vtgate/planbuilder/testdata/vschemas/schema.json +++ b/go/vt/vtgate/planbuilder/testdata/vschemas/schema.json @@ -605,7 +605,7 @@ }, "sharded_fk_allow": { "sharded": true, - "foreignKeyMode": "FK_MANAGED", + "foreignKeyMode": "managed", "vindexes": { "hash_vin": { "type": "hash_test" @@ -746,7 +746,7 @@ } }, "unsharded_fk_allow": { - "foreignKeyMode": "FK_MANAGED", + "foreignKeyMode": "managed", "tables": { "u_tbl1": {}, "u_tbl2": {}, diff --git a/go/vt/vtgate/planbuilder/update.go b/go/vt/vtgate/planbuilder/update.go index b99631f6b55..aed62f2b1d5 100644 --- a/go/vt/vtgate/planbuilder/update.go +++ b/go/vt/vtgate/planbuilder/update.go @@ -95,7 +95,7 @@ func fkManagementNotRequiredForUpdate(ctx *plancontext.PlanningContext, vTables if err != nil { return false } - if ksMode != vschemapb.Keyspace_FK_MANAGED { + if ksMode != vschemapb.Keyspace_managed { continue } childFks := vTable.ChildFKsNeedsHandling(ctx.VerifyAllFKs, vindexes.UpdateAction) diff --git a/go/vt/vtgate/vcursor_impl.go b/go/vt/vtgate/vcursor_impl.go index 7341e3e8c1b..8eca63e11ad 100644 --- a/go/vt/vtgate/vcursor_impl.go +++ b/go/vt/vtgate/vcursor_impl.go @@ -1027,7 +1027,7 @@ func (vc *vcursorImpl) PlannerWarning(message string) { // ForeignKeyMode implements the VCursor interface func (vc *vcursorImpl) ForeignKeyMode(keyspace string) (vschemapb.Keyspace_ForeignKeyMode, error) { if strings.ToLower(foreignKeyMode) == "disallow" { - return vschemapb.Keyspace_FK_DISALLOW, nil + return vschemapb.Keyspace_disallow, nil } ks := vc.vschema.Keyspaces[keyspace] if ks == nil { diff --git a/go/vt/vtgate/vindexes/vschema.go b/go/vt/vtgate/vindexes/vschema.go index 95de008c705..de57908adb9 100644 --- a/go/vt/vtgate/vindexes/vschema.go +++ b/go/vt/vtgate/vindexes/vschema.go @@ -326,7 +326,7 @@ func buildKeyspaces(source *vschemapb.SrvVSchema, vschema *VSchema) { Name: ksname, Sharded: ks.Sharded, }, - ForeignKeyMode: replaceDefaultForeignKeyMode(ks.ForeignKeyMode), + ForeignKeyMode: replaceUnspecifiedForeignKeyMode(ks.ForeignKeyMode), Tables: make(map[string]*Table), Vindexes: make(map[string]Vindex), } @@ -335,10 +335,10 @@ func buildKeyspaces(source *vschemapb.SrvVSchema, vschema *VSchema) { } } -// replaceDefaultForeignKeyMode replaces the default value of the foreign key mode enum with the default we want to keep. -func replaceDefaultForeignKeyMode(fkMode vschemapb.Keyspace_ForeignKeyMode) vschemapb.Keyspace_ForeignKeyMode { - if fkMode == vschemapb.Keyspace_FK_DEFAULT { - return vschemapb.Keyspace_FK_UNMANAGED +// replaceUnspecifiedForeignKeyMode replaces the default value of the foreign key mode enum with the default we want to keep. +func replaceUnspecifiedForeignKeyMode(fkMode vschemapb.Keyspace_ForeignKeyMode) vschemapb.Keyspace_ForeignKeyMode { + if fkMode == vschemapb.Keyspace_unspecified { + return vschemapb.Keyspace_unmanaged } return fkMode } diff --git a/go/vt/vtgate/vindexes/vschema_test.go b/go/vt/vtgate/vindexes/vschema_test.go index 5b66059e25c..a59ec78139d 100644 --- a/go/vt/vtgate/vindexes/vschema_test.go +++ b/go/vt/vtgate/vindexes/vschema_test.go @@ -259,19 +259,19 @@ func TestForeignKeyMode(t *testing.T) { }{ { name: "Default Value", - wantedFkMode: vschemapb.Keyspace_FK_UNMANAGED, + wantedFkMode: vschemapb.Keyspace_unmanaged, }, { name: "Managed Value", - fkMode: vschemapb.Keyspace_FK_MANAGED, - wantedFkMode: vschemapb.Keyspace_FK_MANAGED, + fkMode: vschemapb.Keyspace_managed, + wantedFkMode: vschemapb.Keyspace_managed, }, { name: "Unmanaged Value", - fkMode: vschemapb.Keyspace_FK_UNMANAGED, - wantedFkMode: vschemapb.Keyspace_FK_UNMANAGED, + fkMode: vschemapb.Keyspace_unmanaged, + wantedFkMode: vschemapb.Keyspace_unmanaged, }, { name: "Disallow Value", - fkMode: vschemapb.Keyspace_FK_DISALLOW, - wantedFkMode: vschemapb.Keyspace_FK_DISALLOW, + fkMode: vschemapb.Keyspace_disallow, + wantedFkMode: vschemapb.Keyspace_disallow, }, } @@ -365,7 +365,7 @@ func TestVSchemaViews(t *testing.T) { got := string(out) want := ` { - "foreignKeyMode":"FK_UNMANAGED", + "foreignKeyMode":"unmanaged", "tables": { "t1": { "name": "t1", @@ -423,7 +423,7 @@ func TestVSchemaForeignKeys(t *testing.T) { require.NoError(t, err) want := ` { - "foreignKeyMode": "FK_UNMANAGED", + "foreignKeyMode": "unmanaged", "tables": { "t1": { "name": "t1", @@ -681,7 +681,7 @@ func TestVSchemaRoutingRules(t *testing.T) { Keyspaces: map[string]*vschemapb.Keyspace{ "ks1": { Sharded: true, - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Vindexes: map[string]*vschemapb.Vindex{ "stfu1": { Type: "stfu", @@ -699,7 +699,7 @@ func TestVSchemaRoutingRules(t *testing.T) { }, }, "ks2": { - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Tables: map[string]*vschemapb.Table{ "t2": {}, }, @@ -773,7 +773,7 @@ func TestVSchemaRoutingRules(t *testing.T) { Keyspaces: map[string]*KeyspaceSchema{ "ks1": { Keyspace: ks1, - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Tables: map[string]*Table{ "t1": t1, }, @@ -782,7 +782,7 @@ func TestVSchemaRoutingRules(t *testing.T) { }, }, "ks2": { - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Keyspace: ks2, Tables: map[string]*Table{ "t2": t2, @@ -1108,7 +1108,7 @@ func TestShardedVSchemaMultiColumnVindex(t *testing.T) { Keyspaces: map[string]*vschemapb.Keyspace{ "sharded": { Sharded: true, - ForeignKeyMode: vschemapb.Keyspace_FK_DISALLOW, + ForeignKeyMode: vschemapb.Keyspace_disallow, Vindexes: map[string]*vschemapb.Vindex{ "stfu1": { Type: "stfu", @@ -1155,7 +1155,7 @@ func TestShardedVSchemaMultiColumnVindex(t *testing.T) { }, Keyspaces: map[string]*KeyspaceSchema{ "sharded": { - ForeignKeyMode: vschemapb.Keyspace_FK_DISALLOW, + ForeignKeyMode: vschemapb.Keyspace_disallow, Keyspace: ks, Tables: map[string]*Table{ "t1": t1}, @@ -1173,7 +1173,7 @@ func TestShardedVSchemaNotOwned(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "sharded": { - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Sharded: true, Vindexes: map[string]*vschemapb.Vindex{ "stlu1": { @@ -1231,7 +1231,7 @@ func TestShardedVSchemaNotOwned(t *testing.T) { "stfu1": vindex2}, Keyspaces: map[string]*KeyspaceSchema{ "sharded": { - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Keyspace: ks, Tables: map[string]*Table{ "t1": t1, @@ -1306,12 +1306,12 @@ func TestBuildVSchemaDupSeq(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Tables: map[string]*vschemapb.Table{ "t1": { Type: "sequence"}}}, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Tables: map[string]*vschemapb.Table{ "t1": { Type: "sequence"}}}}} @@ -1336,7 +1336,7 @@ func TestBuildVSchemaDupSeq(t *testing.T) { uniqueVindexes: map[string]Vindex{}, Keyspaces: map[string]*KeyspaceSchema{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Keyspace: ksa, Tables: map[string]*Table{ "t1": t1a, @@ -1344,7 +1344,7 @@ func TestBuildVSchemaDupSeq(t *testing.T) { Vindexes: map[string]Vindex{}, }, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Keyspace: ksb, Tables: map[string]*Table{ "t1": t1b, @@ -1361,13 +1361,13 @@ func TestBuildVSchemaDupTable(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Tables: map[string]*vschemapb.Table{ "t1": {}, }, }, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Tables: map[string]*vschemapb.Table{ "t1": {}, }, @@ -1397,7 +1397,7 @@ func TestBuildVSchemaDupTable(t *testing.T) { uniqueVindexes: map[string]Vindex{}, Keyspaces: map[string]*KeyspaceSchema{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Keyspace: ksa, Tables: map[string]*Table{ "t1": t1a, @@ -1405,7 +1405,7 @@ func TestBuildVSchemaDupTable(t *testing.T) { Vindexes: map[string]Vindex{}, }, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Keyspace: ksb, Tables: map[string]*Table{ "t1": t1b, @@ -1425,7 +1425,7 @@ func TestBuildVSchemaDupVindex(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Sharded: true, Vindexes: map[string]*vschemapb.Vindex{ "stlu1": { @@ -1445,7 +1445,7 @@ func TestBuildVSchemaDupVindex(t *testing.T) { }, }, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Sharded: true, Vindexes: map[string]*vschemapb.Vindex{ "stlu1": { @@ -1528,7 +1528,7 @@ func TestBuildVSchemaDupVindex(t *testing.T) { }, Keyspaces: map[string]*KeyspaceSchema{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Keyspace: ksa, Tables: map[string]*Table{ "t1": t1, @@ -1538,7 +1538,7 @@ func TestBuildVSchemaDupVindex(t *testing.T) { }, }, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Keyspace: ksb, Tables: map[string]*Table{ "t1": t2, @@ -1997,7 +1997,7 @@ func TestSequence(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "unsharded": { - ForeignKeyMode: vschemapb.Keyspace_FK_DISALLOW, + ForeignKeyMode: vschemapb.Keyspace_disallow, Tables: map[string]*vschemapb.Table{ "seq": { Type: "sequence", @@ -2006,7 +2006,7 @@ func TestSequence(t *testing.T) { }, "sharded": { Sharded: true, - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Vindexes: map[string]*vschemapb.Vindex{ "stfu1": { Type: "stfu", @@ -2116,7 +2116,7 @@ func TestSequence(t *testing.T) { }, Keyspaces: map[string]*KeyspaceSchema{ "unsharded": { - ForeignKeyMode: vschemapb.Keyspace_FK_DISALLOW, + ForeignKeyMode: vschemapb.Keyspace_disallow, Keyspace: ksu, Tables: map[string]*Table{ "seq": seq, @@ -2124,7 +2124,7 @@ func TestSequence(t *testing.T) { Vindexes: map[string]Vindex{}, }, "sharded": { - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Keyspace: kss, Tables: map[string]*Table{ "t1": t1, @@ -2555,7 +2555,7 @@ func TestBuildKeyspaceSchema(t *testing.T) { } want := &KeyspaceSchema{ Keyspace: ks, - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Tables: map[string]*Table{ "t1": t1, "t2": t2, @@ -2677,7 +2677,7 @@ func TestVSchemaJSON(t *testing.T) { in := map[string]*KeyspaceSchema{ "unsharded": { - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Keyspace: &Keyspace{ Name: "k1", }, @@ -2698,7 +2698,7 @@ func TestVSchemaJSON(t *testing.T) { }, }, "sharded": { - ForeignKeyMode: vschemapb.Keyspace_FK_DISALLOW, + ForeignKeyMode: vschemapb.Keyspace_disallow, Keyspace: &Keyspace{ Name: "k2", Sharded: true, @@ -2725,7 +2725,7 @@ func TestVSchemaJSON(t *testing.T) { want := `{ "sharded": { "sharded": true, - "foreignKeyMode": "FK_DISALLOW", + "foreignKeyMode": "disallow", "tables": { "t3": { "name": "n3", @@ -2750,7 +2750,7 @@ func TestVSchemaJSON(t *testing.T) { } }, "unsharded": { - "foreignKeyMode": "FK_MANAGED", + "foreignKeyMode": "managed", "tables": { "t1": { "name": "n1", diff --git a/go/vt/vtgate/vschema_manager_test.go b/go/vt/vtgate/vschema_manager_test.go index 5d7af6fe5c6..6e7a9a9a2d1 100644 --- a/go/vt/vtgate/vschema_manager_test.go +++ b/go/vt/vtgate/vschema_manager_test.go @@ -189,7 +189,7 @@ func TestVSchemaUpdate(t *testing.T) { Keyspaces: map[string]*vschemapb.Keyspace{ "ks": { Sharded: false, - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Tables: map[string]*vschemapb.Table{ "t1": { Columns: []*vschemapb.Column{ @@ -237,7 +237,7 @@ func TestVSchemaUpdate(t *testing.T) { Keyspaces: map[string]*vindexes.KeyspaceSchema{ "ks": { Keyspace: ks, - ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, + ForeignKeyMode: vschemapb.Keyspace_managed, Vindexes: map[string]vindexes.Vindex{}, Tables: map[string]*vindexes.Table{ "t1": vindexTable_t1, @@ -379,7 +379,7 @@ func makeTestVSchema(ks string, sharded bool, tbls map[string]*vindexes.Table) * Sharded: sharded, }, // Default foreign key mode - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, Tables: tbls, Vindexes: map[string]vindexes.Vindex{}, } @@ -401,7 +401,7 @@ func makeTestSrvVSchema(ks string, sharded bool, tbls map[string]*vschemapb.Tabl Sharded: sharded, Tables: tbls, // Default foreign key mode - ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, + ForeignKeyMode: vschemapb.Keyspace_unmanaged, } return &vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ks: keyspaceSchema}, diff --git a/go/vt/vttablet/tabletserver/vstreamer/engine_test.go b/go/vt/vttablet/tabletserver/vstreamer/engine_test.go index 7f9a8cdff99..36bcc8f181a 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/engine_test.go +++ b/go/vt/vttablet/tabletserver/vstreamer/engine_test.go @@ -110,7 +110,7 @@ func TestUpdateVSchema(t *testing.T) { "keyspaces": { "vttest": { "sharded": true, - "foreignKeyMode": "FK_UNMANAGED", + "foreignKeyMode": "unmanaged", "tables": { "t1": { "name": "t1", diff --git a/proto/vschema.proto b/proto/vschema.proto index ea6482a4825..1f7122cca5f 100644 --- a/proto/vschema.proto +++ b/proto/vschema.proto @@ -49,10 +49,10 @@ message Keyspace { ForeignKeyMode foreign_key_mode = 5; enum ForeignKeyMode { - FK_DEFAULT = 0; - FK_DISALLOW = 1; - FK_UNMANAGED = 2; - FK_MANAGED = 3; + unspecified = 0; + disallow = 1; + unmanaged = 2; + managed = 3; } } diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index 33e569ddcaa..1d771c49954 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -41120,10 +41120,10 @@ export namespace vschema { /** ForeignKeyMode enum. */ enum ForeignKeyMode { - FK_DEFAULT = 0, - FK_DISALLOW = 1, - FK_UNMANAGED = 2, - FK_MANAGED = 3 + unspecified = 0, + disallow = 1, + unmanaged = 2, + managed = 3 } } diff --git a/web/vtadmin/src/proto/vtadmin.js b/web/vtadmin/src/proto/vtadmin.js index a16dfdeb3eb..e02475e1abf 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -100005,19 +100005,19 @@ export const vschema = $root.vschema = (() => { break; } break; - case "FK_DEFAULT": + case "unspecified": case 0: message.foreign_key_mode = 0; break; - case "FK_DISALLOW": + case "disallow": case 1: message.foreign_key_mode = 1; break; - case "FK_UNMANAGED": + case "unmanaged": case 2: message.foreign_key_mode = 2; break; - case "FK_MANAGED": + case "managed": case 3: message.foreign_key_mode = 3; break; @@ -100045,7 +100045,7 @@ export const vschema = $root.vschema = (() => { if (options.defaults) { object.sharded = false; object.require_explicit_routing = false; - object.foreign_key_mode = options.enums === String ? "FK_DEFAULT" : 0; + object.foreign_key_mode = options.enums === String ? "unspecified" : 0; } if (message.sharded != null && message.hasOwnProperty("sharded")) object.sharded = message.sharded; @@ -100097,17 +100097,17 @@ export const vschema = $root.vschema = (() => { * ForeignKeyMode enum. * @name vschema.Keyspace.ForeignKeyMode * @enum {number} - * @property {number} FK_DEFAULT=0 FK_DEFAULT value - * @property {number} FK_DISALLOW=1 FK_DISALLOW value - * @property {number} FK_UNMANAGED=2 FK_UNMANAGED value - * @property {number} FK_MANAGED=3 FK_MANAGED value + * @property {number} unspecified=0 unspecified value + * @property {number} disallow=1 disallow value + * @property {number} unmanaged=2 unmanaged value + * @property {number} managed=3 managed value */ Keyspace.ForeignKeyMode = (function() { const valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "FK_DEFAULT"] = 0; - values[valuesById[1] = "FK_DISALLOW"] = 1; - values[valuesById[2] = "FK_UNMANAGED"] = 2; - values[valuesById[3] = "FK_MANAGED"] = 3; + values[valuesById[0] = "unspecified"] = 0; + values[valuesById[1] = "disallow"] = 1; + values[valuesById[2] = "unmanaged"] = 2; + values[valuesById[3] = "managed"] = 3; return values; })();