Repository: vitessio/vitess
Pull request #8675 (2021-08-23 21:41:36)

update MAINTAINERS and CODEOWNERS for deepthi, pH14 and vmg
## Description
Add @deepthi to general vitess and resharding, remove from parser. EDIT: Add @vmg to parser.
Fix link to @vmg's GH profile
Add @ph14 to CODEOWNERS (replacing #6841)

## Related Issue(s)
<!-- List related issues and pull requests. If this PR fixes an issue, please add it using Fixes #????  -->


## Checklist
- [ ] Should this PR be backported? NO
- [x] Tests were added or are not required
- [x] Documentation was added or is not required

## Deployment Notes
<!-- Notes regarding deployment of the contained body of work. These should note any db migrations, etc. -->


Patch:
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 207c765837..f121294edc 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -7,7 +7,7 @@ bootstrap.sh @deepthi
 /examples/local @rohit-nayak-ps
 /examples/operator @askdba
 /examples/region_sharding @deepthi
-/java/ @harshit-gangal
+/java/ @harshit-gangal @pH14
 /go/cache @vmg
 /go/cmd/vtadmin @ajm188 @doeg
 /go/cmd/vtctldclient @ajm188 @doeg
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
index b90be16065..f36e5deb47 100644
--- a/MAINTAINERS.md
+++ b/MAINTAINERS.md
@@ -19,21 +19,21 @@ The following is the full list, alphabetically ordered.
 * Rohit Nayak ([rohit-nayak-ps](https://github.com/rohit-nayak-ps)) rohit@planetscale.com
 * Shlomi Noach ([shlomi-noach](https://github.com/shlomi-noach)) shlomi@planetscale.com
 * Sugu Sougoumarane ([sougou](https://github.com/sougou)) sougou@planetscale.com
-* Vicent Marti ([vmg])(https://github.com/vmg)) vmg@planetscale.com
+* Vicent Marti ([vmg](https://github.com/vmg)) vmg@planetscale.com
 
 ## Areas of expertise
 
 ### General Vitess
-sougou, demmer, rafael, dweitzman, tirsen, askdba, enisoc
+sougou, deepthi, demmer, rafael, dweitzman, tirsen, askdba, enisoc
 
 ### Builds
 dkhenry, shlomi-noach, ajm188, vmg
 
 ### Resharding
-sougou, rafael, tirsen, dweitzman, systay, rohit-nayak-ps
+sougou, rafael, tirsen, dweitzman, systay, rohit-nayak-ps, deepthi
 
 ### Parser
-sougou, dweitzman, deepthi, systay, harshit-gangal
+sougou, dweitzman, systay, harshit-gangal, vmg
 
 ### Performance
 vmg
diff --git a/go/vt/vtgate/planbuilder/route_planning.go b/go/vt/vtgate/planbuilder/route_planning.go
index 0d27063739..2391743b01 100644
--- a/go/vt/vtgate/planbuilder/route_planning.go
+++ b/go/vt/vtgate/planbuilder/route_planning.go
@@ -148,10 +148,6 @@ func newBuildSelectPlan(sel *sqlparser.Select, reservedVars *sqlparser.ReservedV
 		return nil, err
 	}
 
-	if err := setMiscFunc(plan, sel); err != nil {
-		return nil, err
-	}
-
 	if err := plan.WireupGen4(semTable); err != nil {
 		return nil, err
 	}
diff --git a/go/vt/vtgate/semantics/analyzer.go b/go/vt/vtgate/semantics/analyzer.go
index 5309ca0ed3..b64f3dcf47 100644
--- a/go/vt/vtgate/semantics/analyzer.go
+++ b/go/vt/vtgate/semantics/analyzer.go
@@ -205,21 +205,9 @@ func checkForInvalidConstructs(cursor *sqlparser.Cursor) error {
 			return Gen4NotSupportedF("HAVING")
 		}
 	case *sqlparser.Subquery:
-		sel, ok := node.Select.(*sqlparser.Select)
-		if !ok {
+		if _, ok := node.Select.(*sqlparser.Select); !ok {
 			return Gen4NotSupportedF("%T in subquery", node.Select)
 		}
-		if sel.Into != nil {
-			return vterrors.NewErrorf(vtrpcpb.Code_INVALID_ARGUMENT, vterrors.CantUseOptionHere, "Incorrect usage/placement of 'INTO'")
-		}
-	case *sqlparser.DerivedTable:
-		sel, ok := node.Select.(*sqlparser.Select)
-		if !ok {
-			return nil
-		}
-		if sel.Into != nil {
-			return vterrors.NewErrorf(vtrpcpb.Code_INVALID_ARGUMENT, vterrors.CantUseOptionHere, "Incorrect usage/placement of 'INTO'")
-		}
 	case *sqlparser.FuncExpr:
 		if sqlparser.IsLockingFunc(node) {
 			return vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "%v allowed only with dual", sqlparser.String(node))
diff --git a/go/vt/wrangler/materializer.go b/go/vt/wrangler/materializer.go
index 08b5ff75b3..c7576067c5 100644
--- a/go/vt/wrangler/materializer.go
+++ b/go/vt/wrangler/materializer.go
@@ -749,10 +749,7 @@ func (wr *Wrangler) ExternalizeVindex(ctx context.Context, qualifiedVindexName s
 
 	// Remove the write_only param and save the source vschema.
 	delete(sourceVindex.Params, "write_only")
-	if err := wr.ts.SaveVSchema(ctx, sourceKeyspace, sourceVSchema); err != nil {
-		return err
-	}
-	return wr.ts.RebuildSrvVSchema(ctx, nil)
+	return wr.ts.SaveVSchema(ctx, sourceKeyspace, sourceVSchema)
 }
 
 //
diff --git a/misc/git/hooks/govet b/misc/git/hooks/govet
new file mode 100755
index 0000000000..4ca072dbb3
--- /dev/null
+++ b/misc/git/hooks/govet
@@ -0,0 +1,49 @@
+#!/bin/bash
+# Copyright 2019 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.
+
+# git go vet pre-commit hook
+#
+# To use, store as .git/hooks/pre-commit inside your repository and make sure
+# it has execute permissions.
+
+# This script does not handle file names that contain spaces.
+gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '^go/.*\.go$' | grep -v '^go/vt/proto/' | grep -v 'go/vt/sqlparser/sql.go')
+if [ "$gofiles" = "" ]; then
+  exit 0
+fi
+
+# xargs -n1 because dirname on MacOS does not support multiple arguments.
+gopackages=$(echo $gofiles | xargs -n1 dirname | sort -u)
+
+errors=
+
+# If any checks are found to be useless, they can be disabled here.
+# See the output of "go doc cmd/vet" for a list of flags.
+vetflags=""
+
+# Run on one package at a time
+for gopackage in $gopackages
+do
+    if ! go vet $vetflags "vitess.io/vitess/$gopackage" 2>&1; then
+        errors=YES
+    fi
+done
+
+[ -z "$errors" ] && exit 0
+
+echo
+echo "Please fix the go vet warnings above. To disable certain checks, change vetflags in misc/git/hooks/govet."
+exit 1
+


Test patch:
diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.txt b/go/vt/vtgate/planbuilder/testdata/from_cases.txt
index a7ef1afc56..5cac9bb847 100644
--- a/go/vt/vtgate/planbuilder/testdata/from_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/from_cases.txt
@@ -1227,43 +1227,6 @@ Gen4 plan same as above
     ]
   }
 }
-{
-  "QueryType": "SELECT",
-  "Original": "select user.col from user join user_extra on user.id \u003c user_extra.user_id",
-  "Instructions": {
-    "OperatorType": "Join",
-    "Variant": "Join",
-    "JoinColumnIndexes": "-2",
-    "JoinVars": {
-      "user_id": 0
-    },
-    "TableName": "`user`_user_extra",
-    "Inputs": [
-      {
-        "OperatorType": "Route",
-        "Variant": "SelectScatter",
-        "Keyspace": {
-          "Name": "user",
-          "Sharded": true
-        },
-        "FieldQuery": "select `user`.id, `user`.col from `user` where 1 != 1",
-        "Query": "select `user`.id, `user`.col from `user`",
-        "Table": "`user`"
-      },
-      {
-        "OperatorType": "Route",
-        "Variant": "SelectScatter",
-        "Keyspace": {
-          "Name": "user",
-          "Sharded": true
-        },
-        "FieldQuery": "select 1 from user_extra where 1 != 1",
-        "Query": "select 1 from user_extra where :user_id \u003c user_extra.user_id",
-        "Table": "user_extra"
-      }
-    ]
-  }
-}
 
 # sharded join, non-col reference RHS
 "select user.col from user join user_extra on user.id = 5"
@@ -1598,21 +1561,6 @@ Gen4 plan same as above
     "Table": "`user`, ref"
   }
 }
-{
-  "QueryType": "SELECT",
-  "Original": "select ref.col from ref join user",
-  "Instructions": {
-    "OperatorType": "Route",
-    "Variant": "SelectScatter",
-    "Keyspace": {
-      "Name": "user",
-      "Sharded": true
-    },
-    "FieldQuery": "select ref.col from ref, `user` where 1 != 1",
-    "Query": "select ref.col from ref, `user`",
-    "Table": "`user`, ref"
-  }
-}
 
 # reference table can merge with other opcodes left to right and vindex value is in the plan.
 # This tests that route.Merge also copies the condition to the LHS.
diff --git a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt
index 5c3f44e9cf..442ffe8e92 100644
--- a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.txt
@@ -612,51 +612,6 @@ Gen4 plan same as above
     ]
   }
 }
-{
-  "QueryType": "SELECT",
-  "Original": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by null",
-  "Instructions": {
-    "OperatorType": "Join",
-    "Variant": "Join",
-    "JoinColumnIndexes": "-2,-3,1",
-    "JoinVars": {
-      "user_id": 0
-    },
-    "TableName": "`user`_music",
-    "Inputs": [
-      {
-        "OperatorType": "Route",
-        "Variant": "SelectEqualUnique",
-        "Keyspace": {
-          "Name": "user",
-          "Sharded": true
-        },
-        "FieldQuery": "select `user`.id, `user`.col1 as a, `user`.col2 from `user` where 1 != 1",
-        "Query": "select `user`.id, `user`.col1 as a, `user`.col2 from `user` where `user`.id = 1 order by null",
-        "Table": "`user`",
-        "Values": [
-          1
-        ],
-        "Vindex": "user_index"
-      },
-      {
-        "OperatorType": "Route",
-        "Variant": "SelectEqualUnique",
-        "Keyspace": {
-          "Name": "user",
-          "Sharded": true
-        },
-        "FieldQuery": "select music.col3 from music where 1 != 1",
-        "Query": "select music.col3 from music where music.id = :user_id",
-        "Table": "music",
-        "Values": [
-          ":user_id"
-        ],
-        "Vindex": "music_user_map"
-      }
-    ]
-  }
-}
 
 # ORDER BY non-key column for join
 "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by a"
@@ -2049,22 +2004,3 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non
     ]
   }
 }
-
-# Order by has subqueries
-"select id from unsharded order by (select id from unsharded)"
-"unsupported: subqueries disallowed in GROUP or ORDER BY"
-{
-  "QueryType": "SELECT",
-  "Original": "select id from unsharded order by (select id from unsharded)",
-  "Instructions": {
-    "OperatorType": "Route",
-    "Variant": "SelectUnsharded",
-    "Keyspace": {
-      "Name": "main",
-      "Sharded": false
-    },
-    "FieldQuery": "select id from unsharded where 1 != 1",
-    "Query": "select id from unsharded order by (select id from unsharded) asc",
-    "Table": "unsharded"
-  }
-}
diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases.txt b/go/vt/vtgate/planbuilder/testdata/select_cases.txt
index 8fad6083f2..0513d02422 100644
--- a/go/vt/vtgate/planbuilder/testdata/select_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/select_cases.txt
@@ -817,7 +817,6 @@ Gen4 plan same as above
     ]
   }
 }
-Gen4 plan same as above
 
 # Field query should work for joins select bind vars
 "select user.id, (select user.id+outm.m+unsharded.m from unsharded) from user join unsharded outm"
@@ -1678,7 +1677,6 @@ Gen4 plan same as above
     "Table": "unsharded"
   }
 }
-Gen4 plan same as above
 
 # select from unsharded keyspace into outfile
 "select * from main.unsharded into outfile 'x.txt' character set binary fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\\n'"
@@ -1697,7 +1695,6 @@ Gen4 plan same as above
     "Table": "unsharded"
   }
 }
-Gen4 plan same as above
 
 # select from unsharded keyspace into outfile s3
 "select * from main.unsharded into outfile s3 'out_file_name' character set binary format csv header fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n' manifest on overwrite off"
@@ -1716,7 +1713,6 @@ Gen4 plan same as above
     "Table": "unsharded"
   }
 }
-Gen4 plan same as above
 
 # Union after into outfile is incorrect
 "select id from user into outfile 'out_file_name' union all select id from music"
@@ -1726,7 +1722,6 @@ Gen4 plan same as above
 # Into outfile s3 in sub-query is incorrect
 "select id from (select id from user into outfile s3 'inner_outfile') as t2"
 "Incorrect usage/placement of 'INTO'"
-Gen4 plan same as above
 
 "select (select u.id from user as u where u.id = 1), a.id from user as a where a.id = 1"
 {
diff --git a/go/vt/vtgate/planbuilder/testdata/show_cases.txt b/go/vt/vtgate/planbuilder/testdata/show_cases.txt
index 652ff40c8a..11aca628e8 100644
--- a/go/vt/vtgate/planbuilder/testdata/show_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/show_cases.txt
@@ -597,7 +597,7 @@ Gen4 plan same as above
     "OperatorType": "SHOW WARNINGS"
   }
 }
-Gen4 plan same as above
+
 
 # show global status
 "show global status"
diff --git a/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt b/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt
index 20efcd45f2..2bd2aefddc 100644
--- a/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/systemtables_cases.txt
@@ -624,7 +624,6 @@ Gen4 plan same as above
     "Table": "information_schema.a"
   }
 }
-Gen4 plan same as above
 
 # query trying to query two different keyspaces at the same time
 "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'"
diff --git a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt
index 95515d3368..9c9c9d52cc 100644
--- a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt
@@ -147,6 +147,10 @@ Gen4 error: Expression of SELECT list is not in GROUP BY clause and contains non
 "select user.col1 as a from user order by 1 collate utf8_general_ci"
 "unsupported: in scatter query: complex order by expression: 1 collate utf8_general_ci"
 
+# Order by has subqueries
+"select id from unsharded order by (select id from unsharded)"
+"unsupported: subqueries disallowed in GROUP or ORDER BY"
+
 # subqueries in update
 "update user set col = (select id from unsharded)"
 "unsupported: subqueries in sharded DML"