Skip to content

Commit

Permalink
Merge pull request pingcap#5 from rebelice/feat/default-expr
Browse files Browse the repository at this point in the history
feat: let column default support more expressions
  • Loading branch information
d-bytebase authored Mar 28, 2023
2 parents 81c8ec0 + 7149802 commit 75f6648
Show file tree
Hide file tree
Showing 10 changed files with 7,884 additions and 7,757 deletions.
32 changes: 19 additions & 13 deletions parser/ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,31 @@ func (*Join) resultSet() {}
// NewCrossJoin builds a cross join without `on` or `using` clause.
// If the right child is a join tree, we need to handle it differently to make the precedence get right.
// Here is the example: t1 join t2 join t3
// JOIN ON t2.a = t3.a
// t1 join / \
// t2 t3
//
// JOIN ON t2.a = t3.a
// t1 join / \
// t2 t3
//
// (left) (right)
//
// We can not build it directly to:
// JOIN
// / \
// t1 JOIN ON t2.a = t3.a
// / \
// t2 t3
//
// JOIN
// / \
// t1 JOIN ON t2.a = t3.a
// / \
// t2 t3
//
// 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
// We need to find the left-most child of the right child, and build a cross join of the left-hand side
// of the left child(t1), and the right hand side with the original left-most child of the right child(t2).
// JOIN t2.a = t3.a
// / \
// JOIN t3
// / \
// t1 t2
//
// JOIN t2.a = t3.a
// / \
// JOIN t3
// / \
// t1 t2
//
// 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.
// So t1 join t2 right join t3 would be rewrite to t1 join t3 left join t2.
// If not, t1 join (t2 right join t3) would be (t1 join t2) right join t3. After rewrite the right join to left join.
Expand Down
11 changes: 7 additions & 4 deletions parser/ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1885,9 +1885,10 @@ type StatisticsSpec struct {

// CreateStatisticsStmt is a statement to create extended statistics.
// Examples:
// CREATE STATISTICS stats1 (cardinality) ON t(a, b, c);
// CREATE STATISTICS stats2 (dependency) ON t(a, b);
// CREATE STATISTICS stats3 (correlation) ON t(a, b);
//
// CREATE STATISTICS stats1 (cardinality) ON t(a, b, c);
// CREATE STATISTICS stats2 (dependency) ON t(a, b);
// CREATE STATISTICS stats3 (correlation) ON t(a, b);
type CreateStatisticsStmt struct {
stmtNode

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

// DropStatisticsStmt is a statement to drop extended statistics.
// Examples:
// DROP STATISTICS stats1;
//
// DROP STATISTICS stats1;
type DropStatisticsStmt struct {
stmtNode

Expand Down Expand Up @@ -2087,6 +2089,7 @@ const (
)

// ShowSlow is used for the following command:
//
// admin show slow top [ internal | all] N
// admin show slow recent N
type ShowSlow struct {
Expand Down
27 changes: 14 additions & 13 deletions parser/auth/mysql_native_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ import (

// CheckScrambledPassword check scrambled password received from client.
// The new authentication is performed in following manner:
// SERVER: public_seed=create_random_string()
// send(public_seed)
// CLIENT: recv(public_seed)
// hash_stage1=sha1("password")
// hash_stage2=sha1(hash_stage1)
// reply=xor(hash_stage1, sha1(public_seed,hash_stage2)
// // this three steps are done in scramble()
// send(reply)
// SERVER: recv(reply)
// hash_stage1=xor(reply, sha1(public_seed,hash_stage2))
// candidate_hash2=sha1(hash_stage1)
// check(candidate_hash2==hash_stage2)
// // this three steps are done in check_scramble()
//
// SERVER: public_seed=create_random_string()
// send(public_seed)
// CLIENT: recv(public_seed)
// hash_stage1=sha1("password")
// hash_stage2=sha1(hash_stage1)
// reply=xor(hash_stage1, sha1(public_seed,hash_stage2)
// // this three steps are done in scramble()
// send(reply)
// SERVER: recv(reply)
// hash_stage1=xor(reply, sha1(public_seed,hash_stage2))
// candidate_hash2=sha1(hash_stage1)
// check(candidate_hash2==hash_stage2)
// // this three steps are done in check_scramble()
func CheckScrambledPassword(salt, hpwd, auth []byte) bool {
//nolint: gosec
crypt := sha1.New()
Expand Down
20 changes: 9 additions & 11 deletions parser/goyacc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

// Goyacc is a version of yacc generating Go parsers.
//
// Usage
// # Usage
//
// Note: If no non flag arguments are given, goyacc reads standard input.
//
Expand All @@ -42,9 +42,7 @@
// -xegen examplesFile Generate a file suitable for -xe automatically from the grammar.
// The file must not exist. ("")
//
//
//
// Changelog
// # Changelog
//
// 2015-03-24: The search for a custom error message is now extended to include
// also the last state that was shifted into, if any. This change resolves a
Expand All @@ -70,7 +68,7 @@
// by parsing code fragments. If it returns true the parser exits immediately
// with return value -1.
//
// Overview
// # Overview
//
// The generated parser is reentrant and mostly backwards compatible with
// parsers generated by go tool yacc[0]. yyParse expects to be given an
Expand Down Expand Up @@ -104,7 +102,7 @@
// generated code. Setting it to distinct values allows multiple grammars to be
// placed in a single package.
//
// Differences wrt go tool yacc
// # Differences wrt go tool yacc
//
// - goyacc implements ideas from "Generating LR Syntax Error Messages from
// Examples"[1]. Use the -xe flag to pass a name of the example file. For more
Expand All @@ -115,14 +113,14 @@
//
// - Minor changes in parser debug output.
//
// Links
// # Links
//
// Referenced from elsewhere:
//
// [0]: http://golang.org/cmd/yacc/
// [1]: http://people.via.ecp.fr/~stilgar/doc/compilo/parser/Generating%20LR%20Syntax%20Error%20Messages.pdf
// [2]: http://godoc.org/github.com/cznic/y#hdr-Error_Examples
// [3]: http://www.gnu.org/software/bison/manual/html_node/Precedence-Only.html#Precedence-Only
// [0]: http://golang.org/cmd/yacc/
// [1]: http://people.via.ecp.fr/~stilgar/doc/compilo/parser/Generating%20LR%20Syntax%20Error%20Messages.pdf
// [2]: http://godoc.org/github.com/cznic/y#hdr-Error_Examples
// [3]: http://www.gnu.org/software/bison/manual/html_node/Precedence-Only.html#Precedence-Only
package main

import (
Expand Down
5 changes: 3 additions & 2 deletions parser/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,9 @@ func (v *ViewCheckOption) String() string {
}
}

//revive:disable:exported
// ViewInfo provides meta data describing a DB view.
//
//revive:disable:exported
type ViewInfo struct {
Algorithm ViewAlgorithm `json:"view_algorithm"`
Definer *auth.UserIdentity `json:"view_definer"`
Expand Down Expand Up @@ -1260,7 +1261,7 @@ func (i *IndexColumn) Clone() *IndexColumn {
}

// PrimaryKeyType is the type of primary key.
// Available values are 'clustered', 'nonclustered', and ''(default).
// Available values are 'clustered', 'nonclustered', and (default).
type PrimaryKeyType int8

func (p PrimaryKeyType) String() string {
Expand Down
Loading

0 comments on commit 75f6648

Please sign in to comment.