diff --git a/go/vt/sqlparser/ast_funcs.go b/go/vt/sqlparser/ast_funcs.go index 992e3dd1648..2a0d53edf16 100644 --- a/go/vt/sqlparser/ast_funcs.go +++ b/go/vt/sqlparser/ast_funcs.go @@ -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 { diff --git a/go/vt/sqlparser/parse_test.go b/go/vt/sqlparser/parse_test.go index f663c9f7b13..d5d34302267 100644 --- a/go/vt/sqlparser/parse_test.go +++ b/go/vt/sqlparser/parse_test.go @@ -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", }, { @@ -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", @@ -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", diff --git a/go/vt/sqlparser/sql.go b/go/vt/sqlparser/sql.go index ec9c479abae..3892101aca8 100644 --- a/go/vt/sqlparser/sql.go +++ b/go/vt/sqlparser/sql.go @@ -10065,7 +10065,7 @@ yydefault: var yyLOCAL TableNames //line sql.y:981 { - yyLOCAL = TableNames{yyDollar[1].tableName.ToViewName()} + yyLOCAL = TableNames{yyDollar[1].tableName} } yyVAL.union = yyLOCAL case 96: @@ -10073,7 +10073,7 @@ yydefault: //line sql.y:985 { yySLICE := (*TableNames)(yyIaddr(yyVAL.union)) - *yySLICE = append(*yySLICE, yyDollar[3].tableName.ToViewName()) + *yySLICE = append(*yySLICE, yyDollar[3].tableName) } case 97: yyDollar = yyS[yypt-1 : yypt+1] @@ -10342,7 +10342,7 @@ yydefault: var yyLOCAL Statement //line sql.y:1156 { - yyLOCAL = &CreateView{ViewName: yyDollar[8].tableName.ToViewName(), Comments: Comments(yyDollar[2].strs).Parsed(), IsReplace: yyDollar[3].booleanUnion(), Algorithm: yyDollar[4].str, Definer: yyDollar[5].definerUnion(), Security: yyDollar[6].str, Columns: yyDollar[9].columnsUnion(), Select: yyDollar[11].selStmtUnion(), CheckOption: yyDollar[12].str} + yyLOCAL = &CreateView{ViewName: yyDollar[8].tableName, Comments: Comments(yyDollar[2].strs).Parsed(), IsReplace: yyDollar[3].booleanUnion(), Algorithm: yyDollar[4].str, Definer: yyDollar[5].definerUnion(), Security: yyDollar[6].str, Columns: yyDollar[9].columnsUnion(), Select: yyDollar[11].selStmtUnion(), CheckOption: yyDollar[12].str} } yyVAL.union = yyLOCAL case 131: @@ -13523,7 +13523,7 @@ yydefault: var yyLOCAL Statement //line sql.y:3182 { - yyLOCAL = &AlterView{ViewName: yyDollar[7].tableName.ToViewName(), Comments: Comments(yyDollar[2].strs).Parsed(), Algorithm: yyDollar[3].str, Definer: yyDollar[4].definerUnion(), Security: yyDollar[5].str, Columns: yyDollar[8].columnsUnion(), Select: yyDollar[10].selStmtUnion(), CheckOption: yyDollar[11].str} + yyLOCAL = &AlterView{ViewName: yyDollar[7].tableName, Comments: Comments(yyDollar[2].strs).Parsed(), Algorithm: yyDollar[3].str, Definer: yyDollar[4].definerUnion(), Security: yyDollar[5].str, Columns: yyDollar[8].columnsUnion(), Select: yyDollar[10].selStmtUnion(), CheckOption: yyDollar[11].str} } yyVAL.union = yyLOCAL case 579: diff --git a/go/vt/sqlparser/sql.y b/go/vt/sqlparser/sql.y index 2a8486b2446..e6644adf79e 100644 --- a/go/vt/sqlparser/sql.y +++ b/go/vt/sqlparser/sql.y @@ -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: @@ -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 { @@ -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