Commit 36a16ffb authored by mskold@mysql.com's avatar mskold@mysql.com

Merge mskold@bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/usr/local/home/marty/MySQL/test/mysql-4.1
parents 37911701 248a9685
...@@ -924,76 +924,139 @@ SOURCE=.\message.mc ...@@ -924,76 +924,139 @@ SOURCE=.\message.mc
!IF "$(CFG)" == "mysqld - Win32 Release" !IF "$(CFG)" == "mysqld - Win32 Release"
# Begin Custom Build
InputPath=.\message.mc
BuildCmds= \
mc message.mc
"message.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"message.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "mysqld - Win32 Debug" !ELSEIF "$(CFG)" == "mysqld - Win32 Debug"
# Begin Custom Build
InputPath=.\message.mc
BuildCmds= \
mc message.mc
"message.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"message.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "mysqld - Win32 nt" !ELSEIF "$(CFG)" == "mysqld - Win32 nt"
# Begin Custom Build - Compiling messages # Begin Custom Build
InputDir=.
InputPath=.\message.mc InputPath=.\message.mc
InputName=message
BuildCmds= \ BuildCmds= \
mc.exe "$(InputDir)\$(InputName).mc" mc message.mc
"$(InputDir)\$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" "message.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds) $(BuildCmds)
"$(InputDir)\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" "message.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds) $(BuildCmds)
# End Custom Build # End Custom Build
!ELSEIF "$(CFG)" == "mysqld - Win32 Max nt" !ELSEIF "$(CFG)" == "mysqld - Win32 Max nt"
# Begin Custom Build - Compiling messages
InputDir=. # Begin Custom Build
InputPath=.\message.mc InputPath=.\message.mc
InputName=message
BuildCmds= \ BuildCmds= \
mc.exe "$(InputDir)\$(InputName).mc" mc message.mc
"$(InputDir)\$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" "message.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds) $(BuildCmds)
"$(InputDir)\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" "message.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds) $(BuildCmds)
# End Custom Build # End Custom Build
!ELSEIF "$(CFG)" == "mysqld - Win32 Max" !ELSEIF "$(CFG)" == "mysqld - Win32 Max"
# Begin Custom Build
InputPath=.\message.mc
BuildCmds= \
mc message.mc
"message.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"message.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "mysqld - Win32 classic" !ELSEIF "$(CFG)" == "mysqld - Win32 classic"
# Begin Custom Build
InputPath=.\message.mc
BuildCmds= \
mc message.mc
"message.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"message.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "mysqld - Win32 pro" !ELSEIF "$(CFG)" == "mysqld - Win32 pro"
# Begin Custom Build
InputPath=.\message.mc
BuildCmds= \
mc message.mc
"message.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
"message.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "mysqld - Win32 classic nt" !ELSEIF "$(CFG)" == "mysqld - Win32 classic nt"
# Begin Custom Build - Compiling messages
InputDir=. # Begin Custom Build
InputPath=.\message.mc InputPath=.\message.mc
InputName=message
BuildCmds= \ BuildCmds= \
mc.exe "$(InputDir)\$(InputName).mc" mc message.mc
"$(InputDir)\$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" "message.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds) $(BuildCmds)
"$(InputDir)\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" "message.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds) $(BuildCmds)
# End Custom Build # End Custom Build
!ELSEIF "$(CFG)" == "mysqld - Win32 pro nt" !ELSEIF "$(CFG)" == "mysqld - Win32 pro nt"
# Begin Custom Build - Compiling messages
InputDir=. # Begin Custom Build
InputPath=.\message.mc InputPath=.\message.mc
InputName=message
BuildCmds= \ BuildCmds= \
mc.exe "$(InputDir)\$(InputName).mc" mc message.mc
"$(InputDir)\$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" "message.rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds) $(BuildCmds)
"$(InputDir)\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" "message.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds) $(BuildCmds)
# End Custom Build # End Custom Build
!ENDIF !ENDIF
# End Source File # End Source File
......
...@@ -158,7 +158,7 @@ static struct my_option my_long_options[] = ...@@ -158,7 +158,7 @@ static struct my_option my_long_options[] =
(gptr*) &opt_compatible_mode_str, (gptr*) &opt_compatible_mode_str, 0, (gptr*) &opt_compatible_mode_str, (gptr*) &opt_compatible_mode_str, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compact", OPT_COMPACT, {"compact", OPT_COMPACT,
"Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options --skip-add-drop-table --no-set-names --skip-disable-keys --skip-lock-tables", "Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options --skip-add-drop-table --no-set-names --skip-disable-keys --skip-add-locks",
(gptr*) &opt_compact, (gptr*) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (gptr*) &opt_compact, (gptr*) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"complete-insert", 'c', "Use complete insert statements.", (gptr*) &cFlag, {"complete-insert", 'c', "Use complete insert statements.", (gptr*) &cFlag,
......
...@@ -63,3 +63,12 @@ ERROR HY000: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET ...@@ -63,3 +63,12 @@ ERROR HY000: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET
create database d1 default character set latin1 collate latin2_bin; create database d1 default character set latin1 collate latin2_bin;
ERROR 42000: COLLATION 'latin2_bin' is not valid for CHARACTER SET 'latin1' ERROR 42000: COLLATION 'latin2_bin' is not valid for CHARACTER SET 'latin1'
DROP DATABASE mysqltest1; DROP DATABASE mysqltest1;
CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET latin7;
use mysqltest2;
ALTER DATABASE DEFAULT CHARACTER SET latin2;
show create database mysqltest2;
Database Create Database
mysqltest2 CREATE DATABASE `mysqltest2` /*!40100 DEFAULT CHARACTER SET latin2 */
drop database mysqltest2;
ALTER DATABASE DEFAULT CHARACTER SET latin2;
ERROR 3D000: No database selected
...@@ -525,3 +525,59 @@ use test; ...@@ -525,3 +525,59 @@ use test;
SET TIMESTAMP=10000; SET TIMESTAMP=10000;
insert into t2 values (@v); insert into t2 values (@v);
drop table t2; drop table t2;
set names latin1;
create table t1 (a enum('x','y','z') character set ucs2);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` enum('x','y','z') character set ucs2 default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values ('x');
insert into t1 values ('y');
insert into t1 values ('z');
select a, hex(a) from t1 order by a;
a hex(a)
x 0078
y 0079
z 007A
alter table t1 change a a enum('x','y','z','d','e','','','') character set ucs2;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` enum('x','y','z','d','e','','','') character set ucs2 default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values ('D');
insert into t1 values ('E ');
insert into t1 values ('');
insert into t1 values ('');
insert into t1 values ('');
select a, hex(a) from t1 order by a;
a hex(a)
x 0078
y 0079
z 007A
d 0064
e 0065
00E4
00F6
00FC
drop table t1;
create table t1 (a set ('x','y','z','','','') character set ucs2);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` set('x','y','z','','','') character set ucs2 default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values ('x');
insert into t1 values ('y');
insert into t1 values ('z');
insert into t1 values ('x,y');
insert into t1 values ('x,y,z,,,');
select a, hex(a) from t1 order by a;
a hex(a)
x 0078
y 0079
x,y 0078002C0079
z 007A
x,y,z,,, 0078002C0079002C007A002C00E4002C00F6002C00FC
drop table t1;
...@@ -86,3 +86,15 @@ create database d1 default character set latin1 collate latin2_bin; ...@@ -86,3 +86,15 @@ create database d1 default character set latin1 collate latin2_bin;
# #
# #
DROP DATABASE mysqltest1; DROP DATABASE mysqltest1;
#
# Synatx: 'ALTER DATABASE' without db_name
#
CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET latin7;
use mysqltest2;
ALTER DATABASE DEFAULT CHARACTER SET latin2;
show create database mysqltest2;
drop database mysqltest2;
--error 1046
ALTER DATABASE DEFAULT CHARACTER SET latin2;
...@@ -343,3 +343,34 @@ show binlog events from 79; ...@@ -343,3 +343,34 @@ show binlog events from 79;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 --exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001
drop table t2; drop table t2;
#
# Check that ucs2 works with ENUM and SET type
#
set names latin1;
create table t1 (a enum('x','y','z') character set ucs2);
show create table t1;
insert into t1 values ('x');
insert into t1 values ('y');
insert into t1 values ('z');
select a, hex(a) from t1 order by a;
alter table t1 change a a enum('x','y','z','d','e','','','') character set ucs2;
show create table t1;
insert into t1 values ('D');
insert into t1 values ('E ');
insert into t1 values ('');
insert into t1 values ('');
insert into t1 values ('');
select a, hex(a) from t1 order by a;
drop table t1;
create table t1 (a set ('x','y','z','','','') character set ucs2);
show create table t1;
insert into t1 values ('x');
insert into t1 values ('y');
insert into t1 values ('z');
insert into t1 values ('x,y');
insert into t1 values ('x,y,z,,,');
select a, hex(a) from t1 order by a;
drop table t1;
...@@ -294,12 +294,14 @@ execute stmt4; ...@@ -294,12 +294,14 @@ execute stmt4;
prepare stmt4 from ' show table status from test like ''t2%'' '; prepare stmt4 from ' show table status from test like ''t2%'' ';
# egalize date and time values # egalize date and time values
--replace_column 12 # 13 # 14 # --replace_column 12 # 13 # 14 #
--replace_result 2147483647 64424509439
# Bug#4288 : prepared statement 'show table status ..', wrong output on execute # Bug#4288 : prepared statement 'show table status ..', wrong output on execute
execute stmt4; execute stmt4;
# try the same with the big table # try the same with the big table
prepare stmt4 from ' show table status from test like ''t9%'' '; prepare stmt4 from ' show table status from test like ''t9%'' ';
# egalize date and time values # egalize date and time values
--replace_column 12 # 13 # 14 # --replace_column 12 # 13 # 14 #
--replace_result 2147483647 4294967295
# Bug#4288 # Bug#4288
execute stmt4; execute stmt4;
prepare stmt4 from ' show status like ''Threads_running'' '; prepare stmt4 from ' show status like ''Threads_running'' ';
......
...@@ -454,10 +454,12 @@ sub print_verbose_errors ...@@ -454,10 +454,12 @@ sub print_verbose_errors
print STDERR "number of help keywords - ",$count_keywords,"\n"; print STDERR "number of help keywords - ",$count_keywords,"\n";
my $count_without_help= scalar(@without_help); my $count_without_help= scalar(@without_help);
my $percent_without_help= $count_lex ?
int (($count_without_help/$count_lex)*100) :
"100";
print_bad_names(\@without_help,"lexems without help (". print_bad_names(\@without_help,"lexems without help (".
$count_without_help." ~ ". $count_without_help." ~ ".
(int (($count_without_help/$count_lex)*100)). $percent_without_help."%)");
"%)");
print_bad_names(\@description_with_at, print_bad_names(\@description_with_at,
" topics below have symbol \'@\' in their descriptions.\n". " topics below have symbol \'@\' in their descriptions.\n".
"it's probably the litter from 'texi' tags (script needs fixing)"); "it's probably the litter from 'texi' tags (script needs fixing)");
...@@ -467,10 +469,12 @@ sub print_verbose_errors ...@@ -467,10 +469,12 @@ sub print_verbose_errors
print_bad_names(\@without_description,"topics without description"); print_bad_names(\@without_description,"topics without description");
my $count_without_example= scalar(@without_example); my $count_without_example= scalar(@without_example);
my $percent_without_example= $count_topics ?
int (($count_without_example/$count_topics)*100) :
"100";
print_bad_names(\@without_example,"topics without example (". print_bad_names(\@without_example,"topics without example (".
$count_without_example." ~ ". $count_without_example." ~ ".
(int (($count_without_example/$count_topics)*100)). $percent_without_example."%)");
"%)");
} }
print_verbose_errors if ($verbose_option ne 0); print_verbose_errors if ($verbose_option ne 0);
......
...@@ -213,7 +213,7 @@ then ...@@ -213,7 +213,7 @@ then
fi fi
mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \ mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \
--skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \ --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \
--skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M" --skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \ if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \
| eval "$mysqld_install_cmd_line" | eval "$mysqld_install_cmd_line"
then then
......
...@@ -5529,8 +5529,7 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) ...@@ -5529,8 +5529,7 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
} }
/* Remove end space */ /* Remove end space */
while (length > 0 && my_isspace(system_charset_info,from[length-1])) length= field_charset->cset->lengthsp(field_charset, from, length);
length--;
uint tmp=find_type2(typelib, from, length, field_charset); uint tmp=find_type2(typelib, from, length, field_charset);
if (!tmp) if (!tmp)
{ {
...@@ -5632,7 +5631,7 @@ String *Field_enum::val_str(String *val_buffer __attribute__((unused)), ...@@ -5632,7 +5631,7 @@ String *Field_enum::val_str(String *val_buffer __attribute__((unused)),
val_ptr->set("", 0, field_charset); val_ptr->set("", 0, field_charset);
else else
val_ptr->set((const char*) typelib->type_names[tmp-1], val_ptr->set((const char*) typelib->type_names[tmp-1],
(uint) strlen(typelib->type_names[tmp-1]), typelib->type_lengths[tmp-1],
field_charset); field_charset);
return val_ptr; return val_ptr;
} }
...@@ -5669,13 +5668,14 @@ void Field_enum::sql_type(String &res) const ...@@ -5669,13 +5668,14 @@ void Field_enum::sql_type(String &res) const
res.append("enum("); res.append("enum(");
bool flag=0; bool flag=0;
for (const char **pos= typelib->type_names; *pos; pos++) uint *len= typelib->type_lengths;
for (const char **pos= typelib->type_names; *pos; pos++, len++)
{ {
uint dummy_errors; uint dummy_errors;
if (flag) if (flag)
res.append(','); res.append(',');
/* convert to res.charset() == utf8, then quote */ /* convert to res.charset() == utf8, then quote */
enum_item.copy(*pos, strlen(*pos), charset(), res.charset(), &dummy_errors); enum_item.copy(*pos, *len, charset(), res.charset(), &dummy_errors);
append_unescaped(&res, enum_item.ptr(), enum_item.length()); append_unescaped(&res, enum_item.ptr(), enum_item.length());
flag= 1; flag= 1;
} }
...@@ -5760,9 +5760,9 @@ String *Field_set::val_str(String *val_buffer, ...@@ -5760,9 +5760,9 @@ String *Field_set::val_str(String *val_buffer,
if (tmp & 1) if (tmp & 1)
{ {
if (val_buffer->length()) if (val_buffer->length())
val_buffer->append(field_separator); val_buffer->append(&field_separator, 1, &my_charset_latin1);
String str(typelib->type_names[bitnr], String str(typelib->type_names[bitnr],
(uint) strlen(typelib->type_names[bitnr]), typelib->type_lengths[bitnr],
field_charset); field_charset);
val_buffer->append(str); val_buffer->append(str);
} }
...@@ -5782,13 +5782,14 @@ void Field_set::sql_type(String &res) const ...@@ -5782,13 +5782,14 @@ void Field_set::sql_type(String &res) const
res.append("set("); res.append("set(");
bool flag=0; bool flag=0;
for (const char **pos= typelib->type_names; *pos; pos++) uint *len= typelib->type_lengths;
for (const char **pos= typelib->type_names; *pos; pos++, len++)
{ {
uint dummy_errors; uint dummy_errors;
if (flag) if (flag)
res.append(','); res.append(',');
/* convert to res.charset() == utf8, then quote */ /* convert to res.charset() == utf8, then quote */
set_item.copy(*pos, strlen(*pos), charset(), res.charset(), &dummy_errors); set_item.copy(*pos, *len, charset(), res.charset(), &dummy_errors);
append_unescaped(&res, set_item.ptr(), set_item.length()); append_unescaped(&res, set_item.ptr(), set_item.length());
flag= 1; flag= 1;
} }
......
...@@ -2320,17 +2320,6 @@ String *Item_func_hex::val_str(String *str) ...@@ -2320,17 +2320,6 @@ String *Item_func_hex::val_str(String *str)
return &tmp_value; return &tmp_value;
} }
inline int hexchar_to_int(char c)
{
if (c <= '9' && c >= '0')
return c-'0';
c|=32;
if (c <= 'f' && c >= 'a')
return c-'a'+10;
return -1;
}
/* Convert given hex string to a binary string */ /* Convert given hex string to a binary string */
String *Item_func_unhex::val_str(String *str) String *Item_func_unhex::val_str(String *str)
......
...@@ -1200,6 +1200,23 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr) ...@@ -1200,6 +1200,23 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr)
} }
/*
SYNOPSYS
hexchar_to_int()
convert a hex digit into number
*/
inline int hexchar_to_int(char c)
{
if (c <= '9' && c >= '0')
return c-'0';
c|=32;
if (c <= 'f' && c >= 'a')
return c-'a'+10;
return -1;
}
/* /*
Some functions that are different in the embedded library and the normal Some functions that are different in the embedded library and the normal
server server
......
...@@ -165,7 +165,7 @@ my_bool net_realloc(NET *net, ulong length) ...@@ -165,7 +165,7 @@ my_bool net_realloc(NET *net, ulong length)
if (length >= net->max_packet_size) if (length >= net->max_packet_size)
{ {
DBUG_PRINT("error",("Packet too large. Max sixe: %lu", DBUG_PRINT("error", ("Packet too large. Max size: %lu",
net->max_packet_size)); net->max_packet_size));
net->error= 1; net->error= 1;
net->report_error= 1; net->report_error= 1;
......
...@@ -1102,13 +1102,25 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg) ...@@ -1102,13 +1102,25 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg)
thd->init_for_queries(); thd->init_for_queries();
while (fgets(buff, thd->net.max_packet, file)) while (fgets(buff, thd->net.max_packet, file))
{ {
uint length=(uint) strlen(buff); ulong length= (ulong) strlen(buff);
if (buff[length-1]!='\n' && !feof(file)) while (buff[length-1] != '\n' && !feof(file))
{ {
send_error(thd,ER_NET_PACKET_TOO_LARGE, NullS); /*
thd->fatal_error(); We got only a part of the current string. Will try to increase
net buffer then read the rest of the current string.
*/
if (net_realloc(&(thd->net), 2 * thd->net.max_packet))
{
send_error(thd, thd->net.last_errno, NullS);
thd->is_fatal_error= 1;
break; break;
} }
buff= (char*) thd->net.buff;
fgets(buff + length, thd->net.max_packet - length, file);
length+= (ulong) strlen(buff + length);
}
if (thd->is_fatal_error)
break;
while (length && (my_isspace(thd->charset(), buff[length-1]) || while (length && (my_isspace(thd->charset(), buff[length-1]) ||
buff[length-1] == ';')) buff[length-1] == ';'))
length--; length--;
...@@ -3184,9 +3196,15 @@ purposes internal to the MySQL server", MYF(0)); ...@@ -3184,9 +3196,15 @@ purposes internal to the MySQL server", MYF(0));
} }
case SQLCOM_ALTER_DB: case SQLCOM_ALTER_DB:
{ {
if (!strip_sp(lex->name) || check_db_name(lex->name)) char *db= lex->name ? lex->name : thd->db;
if (!db)
{ {
net_printf(thd, ER_WRONG_DB_NAME, lex->name); send_error(thd, ER_NO_DB_ERROR);
goto error;
}
if (!strip_sp(db) || check_db_name(db))
{
net_printf(thd, ER_WRONG_DB_NAME, db);
break; break;
} }
/* /*
...@@ -3198,21 +3216,21 @@ purposes internal to the MySQL server", MYF(0)); ...@@ -3198,21 +3216,21 @@ purposes internal to the MySQL server", MYF(0));
*/ */
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
if (thd->slave_thread && if (thd->slave_thread &&
(!db_ok(lex->name, replicate_do_db, replicate_ignore_db) || (!db_ok(db, replicate_do_db, replicate_ignore_db) ||
!db_ok_with_wild_table(lex->name))) !db_ok_with_wild_table(db)))
{ {
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
break; break;
} }
#endif #endif
if (check_access(thd,ALTER_ACL,lex->name,0,1,0)) if (check_access(thd, ALTER_ACL, db, 0, 1, 0))
break; break;
if (thd->locked_tables || thd->active_transaction()) if (thd->locked_tables || thd->active_transaction())
{ {
send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION);
goto error; goto error;
} }
res=mysql_alter_db(thd,lex->name,&lex->create_info); res= mysql_alter_db(thd, db, &lex->create_info);
break; break;
} }
case SQLCOM_SHOW_CREATE_DB: case SQLCOM_SHOW_CREATE_DB:
......
...@@ -609,7 +609,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -609,7 +609,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <simple_string> %type <simple_string>
remember_name remember_end opt_ident opt_db text_or_password remember_name remember_end opt_ident opt_db text_or_password
opt_constraint constraint opt_constraint constraint ident_or_empty
%type <string> %type <string>
text_string opt_gconcat_separator text_string opt_gconcat_separator
...@@ -1870,7 +1870,7 @@ alter: ...@@ -1870,7 +1870,7 @@ alter:
} }
alter_list alter_list
{} {}
| ALTER DATABASE ident | ALTER DATABASE ident_or_empty
{ {
Lex->create_info.default_table_charset= NULL; Lex->create_info.default_table_charset= NULL;
Lex->create_info.used_fields= 0; Lex->create_info.used_fields= 0;
...@@ -1879,10 +1879,15 @@ alter: ...@@ -1879,10 +1879,15 @@ alter:
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->sql_command=SQLCOM_ALTER_DB; lex->sql_command=SQLCOM_ALTER_DB;
lex->name=$3.str; lex->name= $3;
}; };
ident_or_empty:
/* empty */ { $$= 0; }
| ident { $$= $1.str; };
alter_list: alter_list:
| DISCARD TABLESPACE { Lex->alter_info.tablespace_op= DISCARD_TABLESPACE; } | DISCARD TABLESPACE { Lex->alter_info.tablespace_op= DISCARD_TABLESPACE; }
| IMPORT TABLESPACE { Lex->alter_info.tablespace_op= IMPORT_TABLESPACE; } | IMPORT TABLESPACE { Lex->alter_info.tablespace_op= IMPORT_TABLESPACE; }
......
...@@ -53,7 +53,21 @@ ulonglong find_set(TYPELIB *lib, const char *str, uint length, CHARSET_INFO *cs, ...@@ -53,7 +53,21 @@ ulonglong find_set(TYPELIB *lib, const char *str, uint length, CHARSET_INFO *cs,
{ {
const char *pos= start; const char *pos= start;
uint var_len; uint var_len;
int mblen= 1;
if (cs && cs->mbminlen > 1)
{
for ( ; pos < end; pos+= mblen)
{
my_wc_t wc;
if ((mblen= cs->cset->mb_wc(cs, &wc, (const uchar *) pos,
(const uchar *) end)) < 1)
mblen= 1; // Not to hang on a wrong multibyte sequence
if (wc == (my_wc_t) field_separator)
break;
}
}
else
for (; pos != end && *pos != field_separator; pos++) ; for (; pos != end && *pos != field_separator; pos++) ;
var_len= (uint) (pos - start); var_len= (uint) (pos - start);
uint find= cs ? find_type2(lib, start, var_len, cs) : uint find= cs ? find_type2(lib, start, var_len, cs) :
...@@ -66,9 +80,9 @@ ulonglong find_set(TYPELIB *lib, const char *str, uint length, CHARSET_INFO *cs, ...@@ -66,9 +80,9 @@ ulonglong find_set(TYPELIB *lib, const char *str, uint length, CHARSET_INFO *cs,
} }
else else
found|= ((longlong) 1 << (find - 1)); found|= ((longlong) 1 << (find - 1));
if (pos == end) if (pos >= end)
break; break;
start= pos + 1; start= pos + mblen;
} }
} }
return found; return found;
......
...@@ -485,6 +485,23 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -485,6 +485,23 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
charset= outparam->table_charset; charset= outparam->table_charset;
bzero((char*) &comment, sizeof(comment)); bzero((char*) &comment, sizeof(comment));
} }
if (interval_nr && charset->mbminlen > 1)
{
/* Unescape UCS2 intervals from HEX notation */
TYPELIB *interval= outparam->intervals + interval_nr - 1;
for (uint pos= 0; pos < interval->count; pos++)
{
char *from, *to;
for (from= to= (char*) interval->type_names[pos]; *from; )
{
*to++= (char) (hexchar_to_int(*from++) << 4) +
hexchar_to_int(*from++);
}
interval->type_lengths[pos] /= 2;
}
}
*field_ptr=reg_field= *field_ptr=reg_field=
make_field(record+recpos, make_field(record+recpos,
(uint32) field_length, (uint32) field_length,
......
...@@ -423,6 +423,28 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, ...@@ -423,6 +423,28 @@ static bool pack_header(uchar *forminfo, enum db_type table_type,
if (field->interval) if (field->interval)
{ {
uint old_int_count=int_count; uint old_int_count=int_count;
if (field->charset->mbminlen > 1)
{
/* Escape UCS2 intervals using HEX notation */
for (uint pos= 0; pos < field->interval->count; pos++)
{
char *dst;
uint length= field->interval->type_lengths[pos], hex_length;
const char *src= field->interval->type_names[pos];
const char *srcend= src + length;
hex_length= length * 2;
field->interval->type_lengths[pos]= hex_length;
field->interval->type_names[pos]= dst= sql_alloc(hex_length + 1);
for ( ; src < srcend; src++)
{
*dst++= _dig_vec_upper[((uchar) *src) >> 4];
*dst++= _dig_vec_upper[((uchar) *src) & 15];
}
*dst= '\0';
}
}
field->interval_id=get_interval_id(&int_count,create_fields,field); field->interval_id=get_interval_id(&int_count,create_fields,field);
if (old_int_count != int_count) if (old_int_count != int_count)
{ {
......
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