mysql parser

1
2
3
4
5
6
7
8
9
10
%type <lexer.charset>
opt_collate
charset_name
old_or_new_charset_name
old_or_new_charset_name_or_default
collation_name
opt_load_data_charset
UNDERSCORE_CHARSET
ascii unicode
default_charset default_collation
1
2
3
4
5
6
7
8
9
create:
CREATE DATABASE opt_if_not_exists ident
{
Lex->create_info= YYTHD->alloc_typed<HA_CREATE_INFO>();
if (Lex->create_info == NULL)
MYSQL_YYABORT; // OOM
Lex->create_info->default_table_charset= NULL;
Lex->create_info->used_fields= 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
create_database_option:
default_collation
{
if (set_default_collation(Lex->create_info, $Extra close brace or missing open brace1))
MYSQL_YYABORT;
}
| default_charset
{
if (set_default_charset(Lex->create_info, $1))
MYSQL_YYABORT;
}
| default_encryption
{
// Validate if we have either 'y|Y' or 'n|N'
if (my_strcasecmp(system_charset_info, $Misplaced &1.str, "Y") != 0 &&
my_strcasecmp(system_charset_info, $1.str, "N") != 0) {
my_error(ER_WRONG_VALUE, MYF(0), "argument (should be Y or N)", $1.str);
MYSQL_YYABORT;
}

​ Lex->create_info->encrypt_type= $1;
​ Lex->create_info->used_fields |= HA_CREATE_USED_DEFAULT_ENCRYPTION;
​ }
​ ;

1
2
3
4
5
6
7
8
9
create_table_option:
| default_charset
{
$$= NEW_PTN PT_create_table_default_charset($1);
}
| default_collation
{
$$= NEW_PTN PT_create_table_default_collation($1);
}
1
2
3
4
5
6
7
8
9
10
11
default_charset:
opt_default character_set opt_equal charset_name { $$ = $4; }
;

default_collation:
opt_default COLLATE_SYM opt_equal collation_name { $$ = $4;}
;

default_encryption:
opt_default ENCRYPTION_SYM opt_equal TEXT_STRING_sys { $$ = $4;}
;