Skip to content

Commit 75f6648

Browse files
authored
Merge pull request pingcap#5 from rebelice/feat/default-expr
feat: let column default support more expressions
2 parents 81c8ec0 + 7149802 commit 75f6648

File tree

10 files changed

+7884
-7757
lines changed

10 files changed

+7884
-7757
lines changed

parser/ast/dml.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,31 @@ func (*Join) resultSet() {}
9393
// NewCrossJoin builds a cross join without `on` or `using` clause.
9494
// If the right child is a join tree, we need to handle it differently to make the precedence get right.
9595
// Here is the example: t1 join t2 join t3
96-
// JOIN ON t2.a = t3.a
97-
// t1 join / \
98-
// t2 t3
96+
//
97+
// JOIN ON t2.a = t3.a
98+
// t1 join / \
99+
// t2 t3
100+
//
99101
// (left) (right)
100102
//
101103
// We can not build it directly to:
102-
// JOIN
103-
// / \
104-
// t1 JOIN ON t2.a = t3.a
105-
// / \
106-
// t2 t3
104+
//
105+
// JOIN
106+
// / \
107+
// t1 JOIN ON t2.a = t3.a
108+
// / \
109+
// t2 t3
110+
//
107111
// The precedence would be t1 join (t2 join t3 on t2.a=t3.a), not (t1 join t2) join t3 on t2.a=t3.a
108112
// We need to find the left-most child of the right child, and build a cross join of the left-hand side
109113
// of the left child(t1), and the right hand side with the original left-most child of the right child(t2).
110-
// JOIN t2.a = t3.a
111-
// / \
112-
// JOIN t3
113-
// / \
114-
// t1 t2
114+
//
115+
// JOIN t2.a = t3.a
116+
// / \
117+
// JOIN t3
118+
// / \
119+
// t1 t2
120+
//
115121
// Besides, if the right handle side join tree's join type is right join and has explicit parentheses, we need to rewrite it to left join.
116122
// So t1 join t2 right join t3 would be rewrite to t1 join t3 left join t2.
117123
// If not, t1 join (t2 right join t3) would be (t1 join t2) right join t3. After rewrite the right join to left join.

parser/ast/misc.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,9 +1885,10 @@ type StatisticsSpec struct {
18851885

18861886
// CreateStatisticsStmt is a statement to create extended statistics.
18871887
// Examples:
1888-
// CREATE STATISTICS stats1 (cardinality) ON t(a, b, c);
1889-
// CREATE STATISTICS stats2 (dependency) ON t(a, b);
1890-
// CREATE STATISTICS stats3 (correlation) ON t(a, b);
1888+
//
1889+
// CREATE STATISTICS stats1 (cardinality) ON t(a, b, c);
1890+
// CREATE STATISTICS stats2 (dependency) ON t(a, b);
1891+
// CREATE STATISTICS stats3 (correlation) ON t(a, b);
18911892
type CreateStatisticsStmt struct {
18921893
stmtNode
18931894

@@ -1955,7 +1956,8 @@ func (n *CreateStatisticsStmt) Accept(v Visitor) (Node, bool) {
19551956

19561957
// DropStatisticsStmt is a statement to drop extended statistics.
19571958
// Examples:
1958-
// DROP STATISTICS stats1;
1959+
//
1960+
// DROP STATISTICS stats1;
19591961
type DropStatisticsStmt struct {
19601962
stmtNode
19611963

@@ -2087,6 +2089,7 @@ const (
20872089
)
20882090

20892091
// ShowSlow is used for the following command:
2092+
//
20902093
// admin show slow top [ internal | all] N
20912094
// admin show slow recent N
20922095
type ShowSlow struct {

parser/auth/mysql_native_password.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ import (
2525

2626
// CheckScrambledPassword check scrambled password received from client.
2727
// The new authentication is performed in following manner:
28-
// SERVER: public_seed=create_random_string()
29-
// send(public_seed)
30-
// CLIENT: recv(public_seed)
31-
// hash_stage1=sha1("password")
32-
// hash_stage2=sha1(hash_stage1)
33-
// reply=xor(hash_stage1, sha1(public_seed,hash_stage2)
34-
// // this three steps are done in scramble()
35-
// send(reply)
36-
// SERVER: recv(reply)
37-
// hash_stage1=xor(reply, sha1(public_seed,hash_stage2))
38-
// candidate_hash2=sha1(hash_stage1)
39-
// check(candidate_hash2==hash_stage2)
40-
// // this three steps are done in check_scramble()
28+
//
29+
// SERVER: public_seed=create_random_string()
30+
// send(public_seed)
31+
// CLIENT: recv(public_seed)
32+
// hash_stage1=sha1("password")
33+
// hash_stage2=sha1(hash_stage1)
34+
// reply=xor(hash_stage1, sha1(public_seed,hash_stage2)
35+
// // this three steps are done in scramble()
36+
// send(reply)
37+
// SERVER: recv(reply)
38+
// hash_stage1=xor(reply, sha1(public_seed,hash_stage2))
39+
// candidate_hash2=sha1(hash_stage1)
40+
// check(candidate_hash2==hash_stage2)
41+
// // this three steps are done in check_scramble()
4142
func CheckScrambledPassword(salt, hpwd, auth []byte) bool {
4243
//nolint: gosec
4344
crypt := sha1.New()

parser/goyacc/main.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
// Goyacc is a version of yacc generating Go parsers.
2323
//
24-
// Usage
24+
// # Usage
2525
//
2626
// Note: If no non flag arguments are given, goyacc reads standard input.
2727
//
@@ -42,9 +42,7 @@
4242
// -xegen examplesFile Generate a file suitable for -xe automatically from the grammar.
4343
// The file must not exist. ("")
4444
//
45-
//
46-
//
47-
// Changelog
45+
// # Changelog
4846
//
4947
// 2015-03-24: The search for a custom error message is now extended to include
5048
// also the last state that was shifted into, if any. This change resolves a
@@ -70,7 +68,7 @@
7068
// by parsing code fragments. If it returns true the parser exits immediately
7169
// with return value -1.
7270
//
73-
// Overview
71+
// # Overview
7472
//
7573
// The generated parser is reentrant and mostly backwards compatible with
7674
// parsers generated by go tool yacc[0]. yyParse expects to be given an
@@ -104,7 +102,7 @@
104102
// generated code. Setting it to distinct values allows multiple grammars to be
105103
// placed in a single package.
106104
//
107-
// Differences wrt go tool yacc
105+
// # Differences wrt go tool yacc
108106
//
109107
// - goyacc implements ideas from "Generating LR Syntax Error Messages from
110108
// Examples"[1]. Use the -xe flag to pass a name of the example file. For more
@@ -115,14 +113,14 @@
115113
//
116114
// - Minor changes in parser debug output.
117115
//
118-
// Links
116+
// # Links
119117
//
120118
// Referenced from elsewhere:
121119
//
122-
// [0]: http://golang.org/cmd/yacc/
123-
// [1]: http://people.via.ecp.fr/~stilgar/doc/compilo/parser/Generating%20LR%20Syntax%20Error%20Messages.pdf
124-
// [2]: http://godoc.org/github.com/cznic/y#hdr-Error_Examples
125-
// [3]: http://www.gnu.org/software/bison/manual/html_node/Precedence-Only.html#Precedence-Only
120+
// [0]: http://golang.org/cmd/yacc/
121+
// [1]: http://people.via.ecp.fr/~stilgar/doc/compilo/parser/Generating%20LR%20Syntax%20Error%20Messages.pdf
122+
// [2]: http://godoc.org/github.com/cznic/y#hdr-Error_Examples
123+
// [3]: http://www.gnu.org/software/bison/manual/html_node/Precedence-Only.html#Precedence-Only
126124
package main
127125

128126
import (

parser/model/model.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,9 @@ func (v *ViewCheckOption) String() string {
10291029
}
10301030
}
10311031

1032-
//revive:disable:exported
10331032
// ViewInfo provides meta data describing a DB view.
1033+
//
1034+
//revive:disable:exported
10341035
type ViewInfo struct {
10351036
Algorithm ViewAlgorithm `json:"view_algorithm"`
10361037
Definer *auth.UserIdentity `json:"view_definer"`
@@ -1260,7 +1261,7 @@ func (i *IndexColumn) Clone() *IndexColumn {
12601261
}
12611262

12621263
// PrimaryKeyType is the type of primary key.
1263-
// Available values are 'clustered', 'nonclustered', and ''(default).
1264+
// Available values are 'clustered', 'nonclustered', and (default).
12641265
type PrimaryKeyType int8
12651266

12661267
func (p PrimaryKeyType) String() string {

0 commit comments

Comments
 (0)