Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions go/vt/sqlparser/ast_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,16 +416,6 @@ func (node TableName) IsEmpty() bool {
return node.Name.IsEmpty()
}

// ToViewName returns a TableName acceptable for use as a VIEW. VIEW names are
// always lowercase, so ToViewName lowercasese the name. Databases are case-sensitive
// so Qualifier is left untouched.
func (node TableName) ToViewName() TableName {
return TableName{
Qualifier: node.Qualifier,
Name: NewIdentifierCS(strings.ToLower(node.Name.v)),
}
}

// NewWhere creates a WHERE or HAVING clause out
// of a Expr. If the expression is nil, it returns nil.
func NewWhere(typ WhereType, expr Expr) *Where {
Expand Down
15 changes: 5 additions & 10 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,7 @@ var (
output: "rename table x.a to b, b to c",
}, {
input: "drop view a,B,c",
output: "drop view a, b, c",
output: "drop view a, B, c",
}, {
input: "drop /*vt+ strategy=online */ view if exists v",
}, {
Expand Down Expand Up @@ -4008,9 +4008,7 @@ func TestCaseSensitivity(t *testing.T) {
input: "alter table A convert unparsable",
output: "alter table A",
}, {
// View names get lower-cased.
input: "alter view A as select * from t",
output: "alter view a as select * from t",
input: "alter view A as select * from t",
}, {
input: "alter table A rename to B",
output: "alter table A rename B",
Expand Down Expand Up @@ -4060,14 +4058,11 @@ func TestCaseSensitivity(t *testing.T) {
input: "CREATE TABLE A (\n\t`A` int\n)",
output: "create table A (\n\tA int\n)",
}, {
input: "create view A as select * from b",
output: "create view a as select * from b",
input: "create view A as select * from b",
}, {
input: "drop view A",
output: "drop view a",
input: "drop view A",
}, {
input: "drop view if exists A",
output: "drop view if exists a",
input: "drop view if exists A",
}, {
input: "select /* lock in SHARE MODE */ 1 from t lock in SHARE MODE",
output: "select /* lock in SHARE MODE */ 1 from t lock in share mode",
Expand Down
8 changes: 4 additions & 4 deletions go/vt/sqlparser/sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions go/vt/sqlparser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,11 @@ from_or_using:
view_name_list:
table_name
{
$$ = TableNames{$1.ToViewName()}
$$ = TableNames{$1}
}
| view_name_list ',' table_name
{
$$ = append($$, $3.ToViewName())
$$ = append($$, $3)
}

table_name_list:
Expand Down Expand Up @@ -1154,7 +1154,7 @@ create_statement:
}
| CREATE comment_opt replace_opt algorithm_view definer_opt security_view_opt VIEW table_name column_list_opt AS select_statement check_option_opt
{
$$ = &CreateView{ViewName: $8.ToViewName(), Comments: Comments($2).Parsed(), IsReplace:$3, Algorithm:$4, Definer: $5 ,Security:$6, Columns:$9, Select: $11, CheckOption: $12 }
$$ = &CreateView{ViewName: $8, Comments: Comments($2).Parsed(), IsReplace:$3, Algorithm:$4, Definer: $5 ,Security:$6, Columns:$9, Select: $11, CheckOption: $12 }
}
| create_database_prefix create_options_opt
{
Expand Down Expand Up @@ -3180,7 +3180,7 @@ alter_statement:
}
| ALTER comment_opt algorithm_view definer_opt security_view_opt VIEW table_name column_list_opt AS select_statement check_option_opt
{
$$ = &AlterView{ViewName: $7.ToViewName(), Comments: Comments($2).Parsed(), Algorithm:$3, Definer: $4 ,Security:$5, Columns:$8, Select: $10, CheckOption: $11 }
$$ = &AlterView{ViewName: $7, Comments: Comments($2).Parsed(), Algorithm:$3, Definer: $4 ,Security:$5, Columns:$8, Select: $10, CheckOption: $11 }
}
// The syntax here causes a shift / reduce issue, because ENCRYPTION is a non reserved keyword
// and the database identifier is optional. When no identifier is given, the current database
Expand Down