Commit 7e4f1e90 authored by unknown's avatar unknown

Now table and database inhirited a character set from a level above at CREATE time

Some optimization to reduce rules number in sql_yacc.yy


mysql-test/r/create.result:
  Now table and database inhirited a character set from a level above at CREATE time
mysql-test/r/fulltext.result:
  Now table and database inhirited a character set from a level above at CREATE time
mysql-test/r/innodb.result:
  Now table and database inhirited a character set from a level above at CREATE time
mysql-test/r/merge.result:
  Now table and database inhirited a character set from a level above at CREATE time
mysql-test/r/show_check.result:
  Now table and database inhirited a character set from a level above at CREATE time
mysql-test/r/symlink.result:
  Now table and database inhirited a character set from a level above at CREATE time
mysql-test/r/type_enum.result:
  Now table and database inhirited a character set from a level above at CREATE time
mysql-test/r/type_set.result:
  Now table and database inhirited a character set from a level above at CREATE time
sql/sql_yacc.yy:
  Now table and database inhirited a character set from a level above at CREATE time
  Some optimization to reduce rules number
parent c6d7ac6a
......@@ -150,5 +150,5 @@ t1 CREATE TABLE `t1` (
KEY `b_29` (`b`),
KEY `b_30` (`b`),
KEY `b_31` (`b`)
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
drop table t1;
......@@ -139,7 +139,7 @@ t2 CREATE TABLE `t2` (
`inhalt` text character set latin1,
KEY `tig` (`ticket`),
FULLTEXT KEY `tix` (`inhalt`)
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
select * from t2 where MATCH inhalt AGAINST (NULL);
ticket inhalt
select * from t2 where MATCH inhalt AGAINST ('foobar');
......
......@@ -807,7 +807,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` char(20) character set latin1 default NULL,
KEY `a` (`a`)
) TYPE=InnoDB
) TYPE=InnoDB CHARSET=latin1
drop table t1;
create temporary table t1 (a int not null auto_increment, primary key(a)) type=innodb;
insert into t1 values (NULL),(NULL),(NULL);
......
......@@ -174,7 +174,7 @@ t3 CREATE TABLE `t3` (
`a` int(11) NOT NULL default '0',
`b` char(20) character set latin1 default NULL,
KEY `a` (`a`)
) TYPE=MRG_MyISAM UNION=(t1,t2)
) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2)
create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2);
select * from t4;
Can't open file: 't4.MRG'. (errno: 143)
......@@ -249,14 +249,14 @@ t3 CREATE TABLE `t3` (
`incr` int(11) NOT NULL default '0',
`othr` int(11) NOT NULL default '0',
PRIMARY KEY (`incr`)
) TYPE=MRG_MyISAM UNION=(t1,t2)
) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2)
alter table t3 drop primary key;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`incr` int(11) NOT NULL default '0',
`othr` int(11) NOT NULL default '0'
) TYPE=MRG_MyISAM UNION=(t1,t2)
) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2)
drop table t3,t2,t1;
create table t1 (a int not null) type=merge;
select * from t1;
......@@ -287,28 +287,28 @@ t3 CREATE TABLE `t3` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
show create table t4;
Table Create Table
t4 CREATE TABLE `t4` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MRG_MyISAM UNION=(t1,t2)
) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2)
show create table t5;
Table Create Table
t5 CREATE TABLE `t5` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MRG_MyISAM INSERT_METHOD=FIRST UNION=(t1,t2)
) TYPE=MRG_MyISAM CHARSET=latin1 INSERT_METHOD=FIRST UNION=(t1,t2)
show create table t6;
Table Create Table
t6 CREATE TABLE `t6` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1,t2)
) TYPE=MRG_MyISAM CHARSET=latin1 INSERT_METHOD=LAST UNION=(t1,t2)
insert into t1 values (1,1),(1,2),(1,3),(1,4);
insert into t2 values (2,1),(2,2),(2,3),(2,4);
select * from t3 order by b,a limit 3;
......@@ -373,7 +373,7 @@ t4 CREATE TABLE `t4` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MRG_MyISAM UNION=(t1,t2,t3)
) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2,t3)
select * from t4 order by a,b;
a b
1 1
......@@ -399,7 +399,7 @@ t4 CREATE TABLE `t4` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MRG_MyISAM INSERT_METHOD=FIRST UNION=(t1,t2,t3)
) TYPE=MRG_MyISAM CHARSET=latin1 INSERT_METHOD=FIRST UNION=(t1,t2,t3)
insert into t4 values (4,1),(4,2);
select * from t1 order by a,b;
a b
......
......@@ -77,13 +77,13 @@ show create table t1;
Table Create Table
t1 CREATE TEMPORARY TABLE `t1` (
`a` int(11) NOT NULL default '0'
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
alter table t1 rename t2;
show create table t2;
Table Create Table
t2 CREATE TEMPORARY TABLE `t2` (
`a` int(11) NOT NULL default '0'
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
drop table t2;
create table t1 (
test_set set( 'val1', 'val2', 'val3' ) not null default '',
......@@ -96,7 +96,7 @@ t1 CREATE TABLE `t1` (
`test_set` set('val1','val2','val3') NOT NULL default '',
`name` char(20) character set latin1 default 'O''Brien' COMMENT 'O''Brien as default',
`c` int(11) NOT NULL default '0' COMMENT 'int column'
) TYPE=MyISAM COMMENT='it''s a table'
) TYPE=MyISAM CHARSET=latin1 COMMENT='it''s a table'
show full columns from t1;
Field Type Null Key Default Extra Privileges Comment
test_set set('val1','val2','val3') select,insert,update,references
......@@ -109,7 +109,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
UNIQUE KEY `aa` (`a`)
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
drop table t1;
create table t1 (a int not null, primary key (a));
show create table t1;
......@@ -117,7 +117,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
drop table t1;
flush tables;
show open tables;
......@@ -135,7 +135,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
`b` char(10) character set latin1 default NULL,
KEY `b` (`b`)
) TYPE=MyISAM MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test'
) TYPE=MyISAM CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test'
alter table t1 MAX_ROWS=200 ROW_FORMAT=dynamic PACK_KEYS=0;
show create table t1;
Table Create Table
......@@ -143,7 +143,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
`b` varchar(10) character set latin1 default NULL,
KEY `b` (`b`)
) TYPE=MyISAM MIN_ROWS=10 MAX_ROWS=200 AVG_ROW_LENGTH=10 PACK_KEYS=0 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='test'
) TYPE=MyISAM CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=200 AVG_ROW_LENGTH=10 PACK_KEYS=0 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='test'
ALTER TABLE t1 AVG_ROW_LENGTH=0 CHECKSUM=0 COMMENT="" MIN_ROWS=0 MAX_ROWS=0 PACK_KEYS=DEFAULT DELAY_KEY_WRITE=0 ROW_FORMAT=default;
show create table t1;
Table Create Table
......@@ -151,7 +151,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
`b` varchar(10) character set latin1 default NULL,
KEY `b` (`b`)
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
drop table t1;
create table t1 (a decimal(9,2), b decimal (9,0), e double(9,2), f double(5,0), h float(3,2), i float(3,0));
show columns from t1;
......
......@@ -39,7 +39,7 @@ t9 CREATE TABLE `t9` (
`b` char(16) character set latin1 NOT NULL default '',
`c` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
alter table t9 rename t8, add column d int not null;
alter table t8 rename t7;
rename table t7 to t9;
......@@ -61,5 +61,5 @@ t9 CREATE TABLE `t9` (
`c` int(11) NOT NULL default '0',
`d` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
drop database test_mysqltest;
......@@ -1627,12 +1627,12 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` enum('','a','b') NOT NULL default ''
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
drop table t1;
create table t1 (a enum (' ','a','b ') not null default 'b ');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` enum('','a','b') NOT NULL default 'b'
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
drop table t1;
......@@ -3,12 +3,12 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` set('','a','b') NOT NULL default ''
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
drop table t1;
create table t1 (a set (' ','a','b ') not null default 'b ');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` set('','a','b') NOT NULL default 'b'
) TYPE=MyISAM
) TYPE=MyISAM CHARSET=latin1
drop table t1;
......@@ -67,6 +67,7 @@ inline Item *or_or_concat(Item* A, Item* B)
interval_type interval;
LEX_USER *lex_user;
enum Item_udftype udf_type;
CHARSET_INFO *charset;
}
%{
......@@ -600,6 +601,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%type <lex_user> user grant_user
%type <charset>
charset_name
charset_name_or_default
opt_db_default_character_set
%type <NONE>
query verb_clause create change select do drop insert replace insert2
insert_values update delete truncate rename
......@@ -758,6 +764,7 @@ master_def:
create:
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
{
THD *thd=current_thd;
LEX *lex=Lex;
lex->sql_command= SQLCOM_CREATE_TABLE;
if (!add_table_to_list($5,
......@@ -771,7 +778,7 @@ create:
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.options=$2 | $4;
lex->create_info.db_type= default_table_type;
lex->create_info.table_charset=NULL;
lex->create_info.table_charset=thd->db_charset?thd->db_charset:default_charset_info;
}
create2
......@@ -793,13 +800,13 @@ create:
lex->key_list.push_back(new Key($2,$4.str, $5, lex->col_list));
lex->col_list.empty();
}
| CREATE DATABASE opt_if_not_exists ident default_charset
| CREATE DATABASE opt_if_not_exists ident opt_db_default_character_set
{
LEX *lex=Lex;
lex->sql_command=SQLCOM_CREATE_DB;
lex->name=$4.str;
lex->create_info.options=$3;
lex->create_info.table_charset=lex->charset;
lex->create_info.table_charset=$5;
}
| CREATE udf_func_type UDF_SYM ident
{
......@@ -886,9 +893,9 @@ create_table_option:
table_list->next=0;
lex->create_info.used_fields|= HA_CREATE_USED_UNION;
}
| CHARSET EQ charset_or_nocharset
| CHARSET EQ charset_name_or_default
{
Lex->create_info.table_charset=Lex->charset;
Lex->create_info.table_charset= $3;
Lex->create_info.used_fields|= HA_CREATE_USED_CHARSET;
}
| INSERT_METHOD EQ merge_insert_types { Lex->create_info.merge_insert_method= $3; Lex->create_info.used_fields|= HA_CREATE_USED_INSERT_METHOD;}
......@@ -996,7 +1003,7 @@ type:
$$=FIELD_TYPE_TINY; }
| BOOL_SYM { Lex->length=(char*) "1";
$$=FIELD_TYPE_TINY; }
| char '(' NUM ')' opt_binary { Lex->length=$3.str;
| char '(' NUM ')' opt_binary { Lex->length=$3.str;
$$=FIELD_TYPE_STRING; }
| char opt_binary { Lex->length=(char*) "1";
$$=FIELD_TYPE_STRING; }
......@@ -1125,28 +1132,28 @@ attribute:
| UNIQUE_SYM KEY_SYM { Lex->type|= UNIQUE_KEY_FLAG; }
| COMMENT_SYM text_literal { Lex->comment= $2; };
charset:
charset_name:
ident
{
if (!(Lex->charset=get_charset_by_name($1.str,MYF(0))))
if (!($$=get_charset_by_name($1.str,MYF(0))))
{
net_printf(&current_thd->net,ER_UNKNOWN_CHARACTER_SET,$1.str);
YYABORT;
}
};
charset_or_nocharset:
charset
| DEFAULT {Lex->charset=NULL; }
charset_name_or_default:
charset_name { $$=$1; }
| DEFAULT { $$=NULL; } ;
opt_binary:
/* empty */ { Lex->charset=NULL; }
| BINARY { Lex->type|=BINARY_FLAG; Lex->charset=NULL; }
| CHAR_SYM SET charset {/* charset is already in Lex->charset */} ;
opt_db_default_character_set:
/* empty */ { $$=default_charset_info; }
| DEFAULT CHAR_SYM SET charset_name_or_default { $$=$4; };
default_charset:
opt_binary:
/* empty */ { Lex->charset=NULL; }
| DEFAULT CHAR_SYM SET charset_or_nocharset ;
| BINARY { Lex->type|=BINARY_FLAG; Lex->charset=NULL; }
| CHAR_SYM SET charset_name { Lex->charset=$3; } ;
references:
REFERENCES table_ident
......@@ -1247,6 +1254,7 @@ string_list:
alter:
ALTER opt_ignore TABLE_SYM table_ident
{
THD *thd=current_thd;
LEX *lex=Lex;
lex->sql_command = SQLCOM_ALTER_TABLE;
lex->name=0;
......@@ -1264,20 +1272,20 @@ alter:
lex->select->db=lex->name=0;
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.db_type= DB_TYPE_DEFAULT;
lex->create_info.table_charset=thd->db_charset?thd->db_charset:default_charset_info;
lex->create_info.row_type= ROW_TYPE_NOT_USED;
lex->create_info.table_charset=NULL;
lex->alter_keys_onoff=LEAVE_AS_IS;
lex->simple_alter=1;
}
alter_list;
| ALTER DATABASE ident default_charset
| ALTER DATABASE ident opt_db_default_character_set
{
LEX *lex=Lex;
lex->sql_command=SQLCOM_ALTER_DB;
lex->name=$3.str;
lex->create_info.table_charset=lex->charset;
}
lex->create_info.table_charset=$4;
};
alter_list:
......@@ -1660,15 +1668,8 @@ expr_expr:
{ $$= new Item_date_add_interval($1,$4,$5,0); }
| expr '-' INTERVAL_SYM expr interval
{ $$= new Item_date_add_interval($1,$4,$5,1); }
| expr COLLATE_SYM ident
{
if (!(Lex->charset=get_charset_by_name($3.str,MYF(0))))
{
net_printf(&current_thd->net,ER_UNKNOWN_CHARACTER_SET,$3.str);
YYABORT;
}
$$= new Item_func_set_collation($1,Lex->charset);
};
| expr COLLATE_SYM charset_name
{ $$= new Item_func_set_collation($1,$3); };
/* expressions that begin with 'expr' that do NOT follow IN_SYM */
no_in_expr:
......@@ -1783,12 +1784,10 @@ simple_expr:
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
{ $$= new Item_func_case(* $4, $2, $5 ); }
| CONVERT_SYM '(' expr ',' cast_type ')' { $$= create_func_cast($3, $5); }
| CONVERT_SYM '(' expr USING charset ')'
{ $$= new Item_func_conv_charset($3,Lex->charset); }
| CONVERT_SYM '(' expr USING charset_name ')'
{ $$= new Item_func_conv_charset($3,$5); }
| CONVERT_SYM '(' expr ',' expr ',' expr ')'
{
$$= new Item_func_conv_charset3($3,$7,$5);
}
{ $$= new Item_func_conv_charset3($3,$7,$5); }
| FUNC_ARG0 '(' ')'
{ $$= ((Item*(*)(void))($1.symbol->create_func))();}
| FUNC_ARG1 '(' expr ')'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment