Bug #117130 error occurs when using cast collate binary
Submitted: 8 Jan 7:03 Modified: 8 Jan 7:44
Reporter: ximin liang (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:9.1.0 OS:Any
Assigned to: CPU Architecture:Any

[8 Jan 7:03] ximin liang
Description:
Hello MySQL team:
  This is bug about cast func. Can be repeated in 9.1.0

How to repeat:
If execute:
  select cast('aa' as char charset binary) collate binary;

Then error occurs:
  
  ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'binary' at line 1

Suggested fix:
seems fix in yacc: 

diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 661b38163ef..e70db9e89ab 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -10348,7 +10348,7 @@ simple_expr:
         | function_call_nonkeyword
         | function_call_generic
         | function_call_conflict
-        | simple_expr COLLATE_SYM ident_or_text %prec NEG
+        | simple_expr COLLATE_SYM collation_name %prec NEG
           {
             warn_on_deprecated_user_defined_collation(YYTHD, $3);
             $$= NEW_PTN Item_func_set_collation(@$, $1, $3);
[8 Jan 7:07] ximin liang
in original yacc, `binary` could not be reduced to `ident_or_text`
[8 Jan 7:44] MySQL Verification Team
Hello ximin liang,

Thank you for the report and test case.

regards,
Umesh