Commit 76a9aeb7 authored by unknown's avatar unknown

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

into serg.mylan:/usr/home/serg/Abk/mysql-4.1


sql/sql_select.cc:
  Auto merged
parents 89b7c75f 5e85c284
......@@ -14,6 +14,7 @@
*/.pure
*~
.*.swp
./config.h
.defs.mk
.depend
.depend.mk
......@@ -258,7 +259,7 @@ cmd-line-utils/libedit/common.h
cmd-line-utils/libedit/makelist
comon.h
config.cache
./config.h
config.h
config.h.in
config.log
config.status
......@@ -830,6 +831,7 @@ support-files/MacOSX/postinstall
support-files/MacOSX/preinstall
support-files/binary-configure
support-files/my-huge.cnf
support-files/my-innodb-heavy-4G.cnf
support-files/my-large.cnf
support-files/my-medium.cnf
support-files/my-small.cnf
......
......@@ -204,7 +204,7 @@ sub trim_the_fat
open(CONFIGURE,">configure.in") or die "Unable to open configure.in for write: $!\n";
print CONFIGURE $configure;
close(CONFIGURE);
`autoconf`;
`aclocal && autoheader && aclocal && automake && autoconf`;
die "'./configure' was not produced!" unless (-f "configure");
chdir("$cwd");
}
......
......@@ -25,9 +25,12 @@
#define CHECK_KEYS
#define FIX_LENGTH if (length > char_length) \
#define FIX_LENGTH \
do { \
if (length > char_length) \
char_length= my_charpos(cs, pos, pos+length, char_length); \
set_if_smaller(char_length,length); \
} while(0)
static int _mi_put_key_in_record(MI_INFO *info,uint keynr,byte *record);
......@@ -157,7 +160,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
FIX_LENGTH;
memcpy((byte*) key, pos, char_length);
if (length > char_length)
bfill(key+char_length, length-char_length, ' ');
cs->cset->fill(cs, key+char_length, length-char_length, ' ');
key+= length;
}
_mi_dpointer(info,key,filepos);
......@@ -267,7 +270,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
FIX_LENGTH;
memcpy((byte*) key, pos, char_length);
if (length > char_length)
bfill(key+char_length, length-char_length, ' ');
cs->cset->fill(cs,key+char_length, length-char_length, ' ');
key+= length;
k_length-=length;
}
......
......@@ -367,10 +367,12 @@ while test $# -gt 0; do
VALGRIND=`which valgrind` # this will print an error if not found
# Give good warning to the user and stop
if [ -z "$VALGRIND" ] ; then
$ECHO "You need to have the 'valgrind' program in your PATH to run mysql-test-run with option --valgrind. Valgrind's home page is http://developer.kde.org/~sewardj ."
$ECHO "You need to have the 'valgrind' program in your PATH to run mysql-test-run with option --valgrind. Valgrind's home page is http://valgrind.kde.org ."
exit 1
fi
VALGRIND="$VALGRIND --tool=memcheck --alignment=8 --leak-check=yes --num-callers=16"
# >=2.1.2 requires the --tool option, some versions write to stdout, some to stderr
valgrind --help 2>&1 | grep "\-\-tool" > /dev/null && VALGRIND="$VALGRIND --tool=memcheck"
VALGRIND="$VALGRIND --alignment=8 --leak-check=yes --num-callers=16"
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc --skip-bdb"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb"
SLEEP_TIME_AFTER_RESTART=10
......
......@@ -412,6 +412,36 @@ select c as c_a from t1 where c='б';
c_a
б
drop table t1;
create table t1 (
c char(10) character set utf8,
unique key a (c(1))
) engine=bdb;
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
insert into t1 values ('aa');
ERROR 23000: Duplicate entry 'aa' for key 1
insert into t1 values ('aaa');
ERROR 23000: Duplicate entry 'aaa' for key 1
insert into t1 values ('б');
insert into t1 values ('бб');
ERROR 23000: Duplicate entry 'б' for key 1
insert into t1 values ('ббб');
ERROR 23000: Duplicate entry 'б' for key 1
select c as c_all from t1 order by c;
c_all
a
b
c
d
e
f
б
select c as c_a from t1 where c='a';
c_a
a
select c as c_a from t1 where c='б';
c_a
б
drop table t1;
create table t1 (c varchar(30) character set utf8 collate utf8_bin, unique(c(10)));
insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
insert into t1 values ('aaaaaaaaaa');
......@@ -541,6 +571,36 @@ c_a
б
drop table t1;
create table t1 (
c char(10) character set utf8 collate utf8_bin,
unique key a (c(1))
) engine=bdb;
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
insert into t1 values ('aa');
ERROR 23000: Duplicate entry 'aa' for key 1
insert into t1 values ('aaa');
ERROR 23000: Duplicate entry 'aaa' for key 1
insert into t1 values ('б');
insert into t1 values ('бб');
ERROR 23000: Duplicate entry 'б' for key 1
insert into t1 values ('ббб');
ERROR 23000: Duplicate entry 'б' for key 1
select c as c_all from t1 order by c;
c_all
a
b
c
d
e
f
б
select c as c_a from t1 where c='a';
c_a
a
select c as c_a from t1 where c='б';
c_a
б
drop table t1;
create table t1 (
str varchar(255) character set utf8 not null,
key str (str(2))
) engine=myisam;
......@@ -570,3 +630,13 @@ select * from t1 where str='str';
str
str
drop table t1;
create table t1 (
str varchar(255) character set utf8 not null,
key str (str(2))
) engine=bdb;
INSERT INTO t1 VALUES ('str');
INSERT INTO t1 VALUES ('str2');
select * from t1 where str='str';
str
str
drop table t1;
......@@ -41,8 +41,7 @@ interval(null, 1, 10, 100)
-1
drop table if exists t1,t2;
create table t1 (id int(10) not null unique);
create table t2 (id int(10) not null primary key,
val int(10) not null);
create table t2 (id int(10) not null primary key, val int(10) not null);
insert into t1 values (1),(2),(4);
insert into t2 values (1,1),(2,1),(3,1),(4,2);
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
......@@ -56,3 +55,12 @@ id elt(two.val,'one','two')
2 one
4 two
drop table t1,t2;
select find_in_set(binary 'a',binary 'A,B,C');
find_in_set(binary 'a',binary 'A,B,C')
0
select find_in_set('a',binary 'A,B,C');
find_in_set('a',binary 'A,B,C')
0
select find_in_set(binary 'a', 'A,B,C');
find_in_set(binary 'a', 'A,B,C')
0
......@@ -31,4 +31,25 @@ SELECT * from t1;
a
1
2
delete from t1;
insert into t1 (a) values (NULL),(NULL);
SELECT * from t1;
a
3
4
drop table t1;
create temporary table t1 (a integer auto_increment primary key);
insert into t1 (a) values (NULL),(NULL);
truncate table t1;
insert into t1 (a) values (NULL),(NULL);
SELECT * from t1;
a
1
2
delete from t1;
insert into t1 (a) values (NULL),(NULL);
SELECT * from t1;
a
3
4
drop table t1;
......@@ -436,3 +436,19 @@ SELECT @@global.session.key_buffer_size;
ERROR 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 'key_buffer_size' at line 1
SELECT @@global.local.key_buffer_size;
ERROR 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 'key_buffer_size' at line 1
set @tstlw = @@log_warnings;
show global variables like 'log_warnings';
Variable_name Value
log_warnings 1
set global log_warnings = 0;
show global variables like 'log_warnings';
Variable_name Value
log_warnings 0
set global log_warnings = 42;
show global variables like 'log_warnings';
Variable_name Value
log_warnings 42
set global log_warnings = @tstlw;
show global variables like 'log_warnings';
Variable_name Value
log_warnings 1
......@@ -294,6 +294,30 @@ select c as c_a from t1 where c='a';
select c as c_a from t1 where c='б';
drop table t1;
#
# Bug 4531: unique key prefix interacts poorly with utf8
# Check BDB, case insensitive collation
#
--disable_warnings
create table t1 (
c char(10) character set utf8,
unique key a (c(1))
) engine=bdb;
--enable_warnings
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
--error 1062
insert into t1 values ('aa');
--error 1062
insert into t1 values ('aaa');
insert into t1 values ('б');
--error 1062
insert into t1 values ('бб');
--error 1062
insert into t1 values ('ббб');
select c as c_all from t1 order by c;
select c as c_a from t1 where c='a';
select c as c_a from t1 where c='б';
drop table t1;
#
# Bug 4521: unique key prefix interacts poorly with utf8
......@@ -393,6 +417,31 @@ select c as c_a from t1 where c='a';
select c as c_a from t1 where c='б';
drop table t1;
#
# Bug 4531: unique key prefix interacts poorly with utf8
# Check BDB, binary collation
#
--disable_warnings
create table t1 (
c char(10) character set utf8 collate utf8_bin,
unique key a (c(1))
) engine=bdb;
--enable_warnings
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
--error 1062
insert into t1 values ('aa');
--error 1062
insert into t1 values ('aaa');
insert into t1 values ('б');
--error 1062
insert into t1 values ('бб');
--error 1062
insert into t1 values ('ббб');
select c as c_all from t1 order by c;
select c as c_a from t1 where c='a';
select c as c_a from t1 where c='б';
drop table t1;
# Bug#4594: column index make = failed for gbk, but like works
# Check MYISAM
......@@ -429,3 +478,18 @@ INSERT INTO t1 VALUES ('str');
INSERT INTO t1 VALUES ('str2');
select * from t1 where str='str';
drop table t1;
# the same for BDB
#
--disable_warnings
create table t1 (
str varchar(255) character set utf8 not null,
key str (str(2))
) engine=bdb;
--enable_warnings
INSERT INTO t1 VALUES ('str');
INSERT INTO t1 VALUES ('str2');
select * from t1 where str='str';
drop table t1;
......@@ -31,11 +31,19 @@ drop table if exists t1,t2;
--enable_warnings
create table t1 (id int(10) not null unique);
create table t2 (id int(10) not null primary key,
val int(10) not null);
create table t2 (id int(10) not null primary key, val int(10) not null);
insert into t1 values (1),(2),(4);
insert into t2 values (1,1),(2,1),(3,1),(4,2);
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
drop table t1,t2;
#
# Bug4340: find_in_set is case insensitive even on binary operators
#
select find_in_set(binary 'a',binary 'A,B,C');
select find_in_set('a',binary 'A,B,C');
select find_in_set(binary 'a', 'A,B,C');
......@@ -26,7 +26,7 @@ drop table t1;
truncate non_existing_table;
#
# test autoincrement with TRUNCATE
# test autoincrement with TRUNCATE; verifying difference with DELETE
#
create table t1 (a integer auto_increment primary key);
......@@ -34,5 +34,19 @@ insert into t1 (a) values (NULL),(NULL);
truncate table t1;
insert into t1 (a) values (NULL),(NULL);
SELECT * from t1;
delete from t1;
insert into t1 (a) values (NULL),(NULL);
SELECT * from t1;
drop table t1;
# Verifying that temp tables are handled the same way
create temporary table t1 (a integer auto_increment primary key);
insert into t1 (a) values (NULL),(NULL);
truncate table t1;
insert into t1 (a) values (NULL),(NULL);
SELECT * from t1;
delete from t1;
insert into t1 (a) values (NULL),(NULL);
SELECT * from t1;
drop table t1;
......@@ -324,3 +324,14 @@ SELECT @@global.global.key_buffer_size;
SELECT @@global.session.key_buffer_size;
--error 1064
SELECT @@global.local.key_buffer_size;
# BUG#5135: cannot turn on log_warnings with SET in 4.1 (and 4.0)
set @tstlw = @@log_warnings;
show global variables like 'log_warnings';
set global log_warnings = 0;
show global variables like 'log_warnings';
set global log_warnings = 42;
show global variables like 'log_warnings';
set global log_warnings = @tstlw;
show global variables like 'log_warnings';
......@@ -4401,6 +4401,22 @@ char *Field_string::pack(char *to, const char *from, uint max_length)
}
char *Field_string::pack_key(char *to, const char *from, uint max_length)
{
int length=min(field_length,max_length);
uint char_length= (field_charset->mbmaxlen > 1) ?
max_length/field_charset->mbmaxlen : max_length;
if (length > char_length)
char_length= my_charpos(field_charset, from, from+length, char_length);
set_if_smaller(length, char_length);
while (length && from[length-1] == ' ')
length--;
*to= (uchar)length;
memcpy(to+1, from, length);
return to+1+length;
}
const char *Field_string::unpack(char *to, const char *from)
{
uint length= (uint) (uchar) *from++;
......@@ -4564,6 +4580,24 @@ char *Field_varstring::pack(char *to, const char *from, uint max_length)
}
char *Field_varstring::pack_key(char *to, const char *from, uint max_length)
{
uint length=uint2korr(from);
uint char_length= (field_charset->mbmaxlen > 1) ?
max_length/field_charset->mbmaxlen : max_length;
from+=HA_KEY_BLOB_LENGTH;
if (length > char_length)
char_length= my_charpos(field_charset, from, from+length, char_length);
set_if_smaller(length, char_length);
*to++= (char) (length & 255);
if (max_length > 255)
*to++= (char) (length >> 8);
if (length)
memcpy(to, from, length);
return to+length;
}
const char *Field_varstring::unpack(char *to, const char *from)
{
uint length;
......@@ -5139,16 +5173,17 @@ char *Field_blob::pack_key(char *to, const char *from, uint max_length)
char *save=ptr;
ptr=(char*) from;
uint32 length=get_length(); // Length of from string
if (length > max_length)
length=max_length;
uint char_length= (field_charset->mbmaxlen > 1) ?
max_length/field_charset->mbmaxlen : max_length;
if (length)
get_ptr((char**) &from);
if (length > char_length)
char_length= my_charpos(field_charset, from, from+length, char_length);
set_if_smaller(length, char_length);
*to++= (uchar) length;
if (max_length > 255) // 2 byte length
*to++= (uchar) (length >> 8);
if (length)
{
get_ptr((char**) &from);
memcpy(to, from, length);
}
ptr=save; // Restore org row pointer
return to+length;
}
......
......@@ -917,6 +917,7 @@ class Field_string :public Field_str {
void sort_string(char *buff,uint length);
void sql_type(String &str) const;
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
char *pack_key(char *to, const char *from, uint max_length);
const char *unpack(char* to, const char *from);
int pack_cmp(const char *a,const char *b,uint key_length);
int pack_cmp(const char *b,uint key_length);
......@@ -965,6 +966,7 @@ class Field_varstring :public Field_str {
void set_key_image(char *buff,uint length, CHARSET_INFO *cs);
void sql_type(String &str) const;
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
char *pack_key(char *to, const char *from, uint max_length);
const char *unpack(char* to, const char *from);
int pack_cmp(const char *a, const char *b, uint key_length);
int pack_cmp(const char *b, uint key_length);
......
......@@ -1435,30 +1435,43 @@ longlong Item_func_find_in_set::val_int()
int diff;
if ((diff=buffer->length() - find->length()) >= 0)
{
const char *f_pos=find->ptr();
const char *f_end=f_pos+find->length();
const char *str=buffer->ptr();
const char *end=str+diff+1;
const char *real_end=str+buffer->length();
uint position=1;
do
{
const char *pos= f_pos;
while (pos != f_end)
{
if (my_toupper(cmp_collation.collation,*str) !=
my_toupper(cmp_collation.collation,*pos))
goto not_found;
str++;
pos++;
}
if (str == real_end || str[0] == separator)
return (longlong) position;
not_found:
while (str < end && str[0] != separator)
str++;
my_wc_t wc;
CHARSET_INFO *cs= cmp_collation.collation;
const char *str_begin= buffer->ptr();
const char *str_end= buffer->ptr();
const char *real_end= str_end+buffer->length();
const uchar *find_str= (const uchar *) find->ptr();
uint find_str_len= find->length();
int position= 0;
while (1)
{
int symbol_len;
if ((symbol_len= cs->cset->mb_wc(cs, &wc, (uchar*) str_end,
(uchar*) real_end)) > 0)
{
const char *substr_end= str_end + symbol_len;
bool is_last_item= (substr_end == real_end);
if (wc == (my_wc_t) separator || is_last_item)
{
position++;
} while (++str <= end);
if (is_last_item)
str_end= substr_end;
if (!my_strnncoll(cs, (const uchar *) str_begin,
str_end - str_begin,
find_str, find_str_len))
return (longlong) position;
else
str_begin= substr_end;
}
str_end= substr_end;
}
else if (str_end - str_begin == 0 &&
find_str_len == 0 &&
wc == (my_wc_t) separator)
return (longlong) ++position;
else
return (longlong) 0;
}
}
return 0;
}
......
......@@ -4241,7 +4241,7 @@ Disable with --skip-isam.",
OPT_ARG, 0, 0, 0, 0, 0, 0},
{"log-warnings", 'W', "Log some non-critical warnings to the error log file. Use this option twice or --log-warnings=2 if you also want 'Aborted connections' warnings.",
(gptr*) &global_system_variables.log_warnings,
(gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
(gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, ~0L,
0, 0, 0},
{"low-priority-updates", OPT_LOW_PRIORITY_UPDATES,
"INSERT/DELETE/UPDATE has lower priority than selects.",
......@@ -4551,7 +4551,7 @@ replicating a LOAD DATA INFILE command.",
NO_ARG, 0, 0, 0, 0, 0, 0},
{"warnings", 'W', "Deprecated; use --log-warnings instead.",
(gptr*) &global_system_variables.log_warnings,
(gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
(gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, ~0L,
0, 0, 0},
{ "back_log", OPT_BACK_LOG,
"The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.",
......
......@@ -607,17 +607,13 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
int error;
DBUG_ENTER("mysql_truncate");
bzero((char*) &create_info,sizeof(create_info));
/* If it is a temporary table, close and regenerate it */
if (!dont_send_ok && (table_ptr=find_temporary_table(thd,table_list->db,
table_list->real_name)))
{
TABLE *table= *table_ptr;
HA_CREATE_INFO create_info;
table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK);
bzero((char*) &create_info,sizeof(create_info));
create_info.auto_increment_value= table->file->auto_increment_value;
create_info.default_table_charset= table->table_charset;
db_type table_type=table->db_type;
strmov(path,table->path);
*table_ptr= table->next; // Unlink table from list
......@@ -659,8 +655,6 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
DBUG_RETURN(-1);
}
bzero((char*) &create_info,sizeof(create_info));
*fn_ext(path)=0; // Remove the .frm extension
error= ha_create_table(path,&create_info,1) ? -1 : 0;
query_cache_invalidate3(thd, table_list, 0);
......
......@@ -33,17 +33,6 @@
length of result string
*/
int my_snprintf(char* to, size_t n, const char* fmt, ...)
{
int result;
va_list args;
va_start(args,fmt);
result= my_vsnprintf(to, n, fmt, args);
va_end(args);
return result;
}
int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
{
char *start=to, *end=to+n-1;
......@@ -141,6 +130,15 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
return (uint) (to - start);
}
int my_snprintf(char* to, size_t n, const char* fmt, ...)
{
int result;
va_list args;
va_start(args,fmt);
result= my_vsnprintf(to, n, fmt, args);
va_end(args);
return result;
}
#ifdef MAIN
#define OVERRUN_SENTRY 250
......
......@@ -22,6 +22,7 @@ EXTRA_DIST = mysql.spec.sh \
my-medium.cnf.sh \
my-large.cnf.sh \
my-huge.cnf.sh \
my-innodb-heavy-4G \
mysql-log-rotate.sh \
mysql.server.sh \
binary-configure.sh \
......@@ -34,6 +35,7 @@ pkgdata_DATA = my-small.cnf \
my-medium.cnf \
my-large.cnf \
my-huge.cnf \
my-innodb-heavy-4G.cnf \
mysql-log-rotate \
mysql-@VERSION@.spec \
MySQL-shared-compat.spec
......@@ -44,6 +46,7 @@ CLEANFILES = my-small.cnf \
my-medium.cnf \
my-large.cnf \
my-huge.cnf \
my-innodb-heavy-4G.cnf \
mysql.spec \
mysql-@VERSION@.spec \
mysql-log-rotate \
......
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