Commit 7a89041d authored by tomas@poseidon.ndb.mysql.com's avatar tomas@poseidon.ndb.mysql.com

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

into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1
parents 64eb1621 6c4263ed
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Untar a MySQL distribution, change the copyright texts, # Untar a MySQL distribution, change the copyright texts,
# pack it up again to a given directory # pack it up again to a given directory
$VER="1.4"; $VER="1.5";
use Cwd; use Cwd;
use File::Basename; use File::Basename;
...@@ -134,7 +134,6 @@ sub main ...@@ -134,7 +134,6 @@ sub main
# remove temporary directory # remove temporary directory
chdir($WD) or print "$! Unable to move up one dir\n"; chdir($WD) or print "$! Unable to move up one dir\n";
`cd $WD`;
my $cwd = getcwd(); my $cwd = getcwd();
print "current dir is $cwd\n" if $opt_verbose ; print "current dir is $cwd\n" if $opt_verbose ;
if (-e $dir) { if (-e $dir) {
...@@ -231,7 +230,14 @@ sub run_autotools ...@@ -231,7 +230,14 @@ sub run_autotools
# File "configure.in" has already been modified by "trim_the_fat()" # File "configure.in" has already been modified by "trim_the_fat()"
`aclocal && autoheader && aclocal && automake && autoconf`; # It must be ensured that the timestamps of the relevant files are really
# ascending, for otherwise the Makefile may cause a re-run of these
# autotools. Experience shows that deletion is the only safe way.
unlink ("config.h.in") or die "Can't delete $destdir/config.h.in: $!\n";
unlink ("aclocal.m4") or die "Can't delete $destdir/aclocal.m4: $!\n";
# These sleep commands also ensure the ascending order.
`aclocal && sleep 2 && autoheader && sleep 2 && automake && sleep 2 && autoconf`;
die "'./configure' was not produced!" unless (-f "configure"); die "'./configure' was not produced!" unless (-f "configure");
if (-d "autom4te.cache") { if (-d "autom4te.cache") {
......
...@@ -799,3 +799,16 @@ select * from t1 where b like 'foob%'; ...@@ -799,3 +799,16 @@ select * from t1 where b like 'foob%';
a b a b
2 foobar 2 foobar
drop table t1; drop table t1;
create table t1 (
a enum('петя','вася','анюта') character set utf8 not null default 'анюта',
b set('петя','вася','анюта') character set utf8 not null default 'анюта'
);
create table t2 select concat(a,_utf8'') as a, concat(b,_utf8'')as b from t1;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` char(5) character set utf8 NOT NULL default '',
`b` char(15) character set utf8 NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t2;
drop table t1;
...@@ -644,3 +644,15 @@ create table t1 ( ...@@ -644,3 +644,15 @@ create table t1 (
insert into t1 values(1,'foo'),(2,'foobar'); insert into t1 values(1,'foo'),(2,'foobar');
select * from t1 where b like 'foob%'; select * from t1 where b like 'foob%';
drop table t1; drop table t1;
#
# Test for calculate_interval_lengths() function
#
create table t1 (
a enum('петя','вася','анюта') character set utf8 not null default 'анюта',
b set('петя','вася','анюта') character set utf8 not null default 'анюта'
);
create table t2 select concat(a,_utf8'') as a, concat(b,_utf8'')as b from t1;
show create table t2;
drop table t2;
drop table t1;
...@@ -4091,6 +4091,31 @@ bool mysql_test_parse_for_slave(THD *thd, char *inBuf, uint length) ...@@ -4091,6 +4091,31 @@ bool mysql_test_parse_for_slave(THD *thd, char *inBuf, uint length)
#endif #endif
/*
Calculate interval lengths.
Strip trailing spaces from all strings.
After this function call:
- ENUM uses max_length
- SET uses tot_length.
*/
void calculate_interval_lengths(THD *thd, TYPELIB *interval,
uint *max_length, uint *tot_length)
{
const char **pos;
uint *len;
CHARSET_INFO *cs= thd->variables.character_set_client;
*max_length= *tot_length= 0;
for (pos= interval->type_names, len= interval->type_lengths;
*pos ; pos++, len++)
{
*len= (uint) strip_sp((char*) *pos);
uint length= cs->cset->numchars(cs, *pos, *pos + *len);
*tot_length+= length;
set_if_bigger(*max_length, length);
}
}
/***************************************************************************** /*****************************************************************************
** Store field definition for create ** Store field definition for create
** Return 0 if ok ** Return 0 if ok
...@@ -4405,19 +4430,10 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, ...@@ -4405,19 +4430,10 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
if (new_field->pack_length > 4) if (new_field->pack_length > 4)
new_field->pack_length=8; new_field->pack_length=8;
new_field->interval=interval; new_field->interval=interval;
new_field->length=0; uint dummy_max_length;
uint *lengths; calculate_interval_lengths(thd, interval,
const char **pos; &dummy_max_length, &new_field->length);
for (pos=interval->type_names, new_field->length+= (interval->count - 1);
lengths= interval->type_lengths; *pos ; pos++, lengths++)
{
CHARSET_INFO *cs= thd->variables.character_set_client;
uint length= (uint) strip_sp((char*) *pos)+1;
set_if_smaller(*lengths, length);
length= cs->cset->numchars(cs, *pos, *pos+length);
new_field->length+= length;
}
new_field->length--;
set_if_smaller(new_field->length,MAX_FIELD_WIDTH-1); set_if_smaller(new_field->length,MAX_FIELD_WIDTH-1);
if (default_value) if (default_value)
{ {
...@@ -4442,19 +4458,10 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, ...@@ -4442,19 +4458,10 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
{ {
new_field->interval=interval; new_field->interval=interval;
new_field->pack_length=interval->count < 256 ? 1 : 2; // Should be safe new_field->pack_length=interval->count < 256 ? 1 : 2; // Should be safe
new_field->length=(uint) strip_sp((char*) interval->type_names[0]);
set_if_smaller(interval->type_lengths[0], new_field->length); uint dummy_tot_length;
uint *lengths; calculate_interval_lengths(thd, interval,
const char **pos; &new_field->length, &dummy_tot_length);
for (pos= interval->type_names+1,
lengths= interval->type_lengths+1; *pos ; pos++, lengths++)
{
CHARSET_INFO *cs= thd->variables.character_set_client;
uint length=(uint) strip_sp((char*) *pos);
set_if_smaller(*lengths, length);
length= cs->cset->numchars(cs, *pos, *pos+length);
set_if_bigger(new_field->length,length);
}
set_if_smaller(new_field->length,MAX_FIELD_WIDTH-1); set_if_smaller(new_field->length,MAX_FIELD_WIDTH-1);
if (default_value) if (default_value)
{ {
......
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