-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathcommon.go
More file actions
40 lines (35 loc) · 790 Bytes
/
common.go
File metadata and controls
40 lines (35 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Radon
*
* Copyright 2018 The Radon Authors.
* Code is licensed under the GPLv3.
*
*/
package planner
import (
"errors"
"github.com/xelabs/go-mysqlstack/sqlparser"
)
func hasSubquery(node sqlparser.SQLNode) bool {
has := false
_ = sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) {
if _, ok := node.(*sqlparser.Subquery); ok {
has = true
return false, errors.New("dummy")
}
return true, nil
}, node)
return has
}
// isUpdateShardKey returns true if any of the update
// expressions modify a shardkey column.
func isUpdateShardKey(exprs sqlparser.UpdateExprs, shardkey string) bool {
if shardkey != "" {
for _, assignment := range exprs {
if shardkey == assignment.Name.Name.String() {
return true
}
}
}
return false
}