Commit 88a59c50 authored by unknown's avatar unknown

Merge mysql.com:/usr_rh9/home/elkin.rh9/MySQL/BARE/5.1

into  mysql.com:/usr_rh9/home/elkin.rh9/MySQL/Merge/5.1

parents 326f7175 a264a79e
...@@ -1482,7 +1482,7 @@ static uint dump_routines_for_db(char *db) ...@@ -1482,7 +1482,7 @@ static uint dump_routines_for_db(char *db)
query_str_tail= strnmov(query_str, row[2], query_str_tail= strnmov(query_str, row[2],
definer_begin - row[2]); definer_begin - row[2]);
query_str_tail= strmov(query_str_tail, "*/ /*!50019"); query_str_tail= strmov(query_str_tail, "*/ /*!50020");
query_str_tail= strnmov(query_str_tail, definer_begin, query_str_tail= strnmov(query_str_tail, definer_begin,
definer_end - definer_begin); definer_end - definer_begin);
query_str_tail= strxmov(query_str_tail, "*/ /*!50003", query_str_tail= strxmov(query_str_tail, "*/ /*!50003",
......
...@@ -295,9 +295,9 @@ int main(int argc, char **argv) ...@@ -295,9 +295,9 @@ int main(int argc, char **argv)
client_flag|= CLIENT_MULTI_RESULTS; client_flag|= CLIENT_MULTI_RESULTS;
if (!opt_only_print) if (!opt_only_print)
{ {
if (!(mysql_real_connect(&mysql,host,user,opt_password, if (!(mysql_real_connect(&mysql, host, user, opt_password,
argv[0],opt_mysql_port,opt_mysql_unix_port, NULL, opt_mysql_port,
client_flag))) opt_mysql_unix_port, client_flag)))
{ {
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql)); fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));
free_defaults(defaults_argv); free_defaults(defaults_argv);
......
...@@ -423,7 +423,7 @@ enum ha_base_keytype { ...@@ -423,7 +423,7 @@ enum ha_base_keytype {
#define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */ #define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */
#define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */ #define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */
#define HA_STATE_EXTEND_BLOCK 2048 #define HA_STATE_EXTEND_BLOCK 2048
#define HA_STATE_RNEXT_SAME 4096 /* rnext_same was called */ #define HA_STATE_RNEXT_SAME 4096 /* rnext_same occupied lastkey2 */
/* myisampack expects no more than 32 field types. */ /* myisampack expects no more than 32 field types. */
enum en_fieldtype { enum en_fieldtype {
......
...@@ -14,15 +14,34 @@ ...@@ -14,15 +14,34 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#if !defined(_my_no_pthread_h) && !defined(THREAD)
#define _my_no_pthread_h
/*
This block is to access some thread-related type definitions
even in builds which do not need thread functions,
as some variables (based on these types) are declared
even in non-threaded builds.
Case in point: 'mf_keycache.c'
*/
#if defined(__WIN__) || defined(OS2)
#elif defined(HAVE_UNIXWARE7_THREADS)
/* #include <thread.h> Currently, not relevant. Enable if needed. */
#else /* Normal threads */
#include <pthread.h>
#endif /* defined(__WIN__) */
/* /*
This undefs some pthread mutex locks when one isn't using threads This undefs some pthread mutex locks when one isn't using threads
to make thread safe code, that should also work in single thread to make thread safe code, that should also work in single thread
environment, easier to use. environment, easier to use.
*/ */
#if !defined(_my_no_pthread_h) && !defined(THREAD)
#define _my_no_pthread_h
#define pthread_mutex_init(A,B) #define pthread_mutex_init(A,B)
#define pthread_mutex_lock(A) #define pthread_mutex_lock(A)
#define pthread_mutex_unlock(A) #define pthread_mutex_unlock(A)
...@@ -32,4 +51,5 @@ ...@@ -32,4 +51,5 @@
#define rw_wrlock(A) #define rw_wrlock(A)
#define rw_unlock(A) #define rw_unlock(A)
#define rwlock_destroy(A) #define rwlock_destroy(A)
#endif #endif
...@@ -2816,7 +2816,6 @@ my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt, ...@@ -2816,7 +2816,6 @@ my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
{ {
switch (attr_type) { switch (attr_type) {
case STMT_ATTR_UPDATE_MAX_LENGTH: case STMT_ATTR_UPDATE_MAX_LENGTH:
*(my_bool*) value= stmt->update_max_length;
break; break;
case STMT_ATTR_CURSOR_TYPE: case STMT_ATTR_CURSOR_TYPE:
*(ulong*) value= stmt->flags; *(ulong*) value= stmt->flags;
......
...@@ -155,11 +155,24 @@ sub collect_test_cases ($) { ...@@ -155,11 +155,24 @@ sub collect_test_cases ($) {
if ( $::opt_reorder ) if ( $::opt_reorder )
{ {
@$cases = sort { @$cases = sort {
if ( $a->{'master_restart'} and $b->{'master_restart'} or if ( ! $a->{'master_restart'} and ! $b->{'master_restart'} )
! $a->{'master_restart'} and ! $b->{'master_restart'} )
{ {
return $a->{'name'} cmp $b->{'name'}; return $a->{'name'} cmp $b->{'name'};
} }
if ( $a->{'master_restart'} and $b->{'master_restart'} )
{
my $cmp= mtr_cmp_opts($a->{'master_opt'}, $b->{'master_opt'});
if ( $cmp == 0 )
{
return $a->{'name'} cmp $b->{'name'};
}
else
{
return $cmp;
}
}
if ( $a->{'master_restart'} ) if ( $a->{'master_restart'} )
{ {
return 1; # Is greater return 1; # Is greater
......
...@@ -13,6 +13,9 @@ sub mtr_add_arg ($$@); ...@@ -13,6 +13,9 @@ sub mtr_add_arg ($$@);
sub mtr_path_exists(@); sub mtr_path_exists(@);
sub mtr_script_exists(@); sub mtr_script_exists(@);
sub mtr_exe_exists(@); sub mtr_exe_exists(@);
sub mtr_copy_dir($$);
sub mtr_same_opts($$);
sub mtr_cmp_opts($$);
############################################################################## ##############################################################################
# #
...@@ -108,5 +111,44 @@ sub mtr_exe_exists (@) { ...@@ -108,5 +111,44 @@ sub mtr_exe_exists (@) {
} }
} }
sub mtr_copy_dir($$) {
my $srcdir= shift;
my $dstdir= shift;
# Create destination directory
mkpath($dstdir);
find(\&mtr_copy_one_file, $dstdir);
}
sub mtr_copy_one_file {
print $File::Find::name, "\n";
}
sub mtr_same_opts ($$) {
my $l1= shift;
my $l2= shift;
return mtr_cmp_opts($l1,$l2) == 0;
}
sub mtr_cmp_opts ($$) {
my $l1= shift;
my $l2= shift;
my @l1= @$l1;
my @l2= @$l2;
return -1 if @l1 < @l2;
return 1 if @l1 > @l2;
while ( @l1 ) # Same length
{
my $e1= shift @l1;
my $e2= shift @l2;
my $cmp= ($e1 cmp $e2);
return $cmp if $cmp != 0;
}
return 0; # They are the same
}
1; 1;
...@@ -481,9 +481,9 @@ sub initial_setup () { ...@@ -481,9 +481,9 @@ sub initial_setup () {
if ( $glob_cygwin_perl ) if ( $glob_cygwin_perl )
{ {
# Windows programs like 'mysqld' needs Windows paths # Windows programs like 'mysqld' needs Windows paths
$glob_mysql_test_dir= `cygpath -m $glob_mysql_test_dir`; $glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`;
my $shell= $ENV{'SHELL'} || "/bin/bash"; my $shell= $ENV{'SHELL'} || "/bin/bash";
$glob_cygwin_shell= `cygpath -w $shell`; # The Windows path c:\... $glob_cygwin_shell= `cygpath -w "$shell"`; # The Windows path c:\...
chomp($glob_mysql_test_dir); chomp($glob_mysql_test_dir);
chomp($glob_cygwin_shell); chomp($glob_cygwin_shell);
} }
...@@ -2031,13 +2031,37 @@ sub run_testcase ($) { ...@@ -2031,13 +2031,37 @@ sub run_testcase ($) {
if ( ! $glob_use_running_server and ! $glob_use_embedded_server ) if ( ! $glob_use_running_server and ! $glob_use_embedded_server )
{ {
if ( $tinfo->{'master_restart'} or # We try to find out if we are to restart the server
$master->[0]->{'running_master_is_special'} or my $do_restart= 0; # Assumes we don't have to
# Stop if cluster is started but test cases does not need cluster
( $opt_with_ndbcluster && $tinfo->{'ndb_test'} != $using_ndbcluster_master ) ) if ( $tinfo->{'master_sh'} )
{
$do_restart= 1; # Always restart if script to run
}
elsif ( $opt_with_ndbcluster and $tinfo->{'ndb_test'} != $using_ndbcluster_master )
{
$do_restart= 1; # Restart without cluster
}
elsif ( $master->[0]->{'running_master_is_special'} and
$master->[0]->{'running_master_is_special'}->{'timezone'} eq
$tinfo->{'timezone'} and
mtr_same_opts($master->[0]->{'running_master_is_special'}->{'master_opt'},
$tinfo->{'master_opt'}) )
{
# If running master was started with special settings, but
# the current test requuires the same ones, we *don't* restart.
$do_restart= 0;
}
elsif ( $tinfo->{'master_restart'} or
$master->[0]->{'running_master_is_special'} )
{
$do_restart= 1;
}
if ( $do_restart )
{ {
stop_masters(); stop_masters();
$master->[0]->{'running_master_is_special'}= 0; # Forget why we stopped delete $master->[0]->{'running_master_is_special'}; # Forget history
} }
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -2129,7 +2153,8 @@ sub run_testcase ($) { ...@@ -2129,7 +2153,8 @@ sub run_testcase ($) {
if ( $tinfo->{'master_restart'} ) if ( $tinfo->{'master_restart'} )
{ {
$master->[0]->{'running_master_is_special'}= 1; # Save this test case information, so next can examine it
$master->[0]->{'running_master_is_special'}= $tinfo;
} }
} }
elsif ( ! $opt_skip_im and $tinfo->{'component_id'} eq 'im' ) elsif ( ! $opt_skip_im and $tinfo->{'component_id'} eq 'im' )
......
...@@ -729,6 +729,24 @@ select * from t1 where bob is null and cip=1; ...@@ -729,6 +729,24 @@ select * from t1 where bob is null and cip=1;
cip time score bob cip time score bob
1 00:01:00 0 NULL 1 00:01:00 0 NULL
drop table t1; drop table t1;
create table t1 (
id1 int not null auto_increment,
id2 int not null default '0',
t text not null,
primary key (id1),
key x (id2, t(32))
) engine=myisam;
insert into t1 (id2, t) values
(10, 'abc'), (10, 'abc'), (10, 'abc'),
(20, 'abc'), (20, 'abc'), (20, 'def'),
(10, 'abc'), (10, 'abc');
select count(*) from t1 where id2 = 10;
count(*)
5
select count(id1) from t1 where id2 = 10;
count(id1)
5
drop table t1;
set storage_engine=MyISAM; set storage_engine=MyISAM;
drop table if exists t1,t2,t3; drop table if exists t1,t2,t3;
--- Testing varchar --- --- Testing varchar ---
......
...@@ -2279,12 +2279,12 @@ UNLOCK TABLES; ...@@ -2279,12 +2279,12 @@ UNLOCK TABLES;
DELIMITER ;; DELIMITER ;;
/*!50003 DROP FUNCTION IF EXISTS `bug9056_func1` */;; /*!50003 DROP FUNCTION IF EXISTS `bug9056_func1` */;;
/*!50003 SET SESSION SQL_MODE=""*/;; /*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE*/ /*!50019 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11) /*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11)
RETURN a+b */;; RETURN a+b */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;; /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `bug9056_func2` */;; /*!50003 DROP FUNCTION IF EXISTS `bug9056_func2` */;;
/*!50003 SET SESSION SQL_MODE=""*/;; /*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE*/ /*!50019 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1) /*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1)
begin begin
set f1= concat( 'hello', f1 ); set f1= concat( 'hello', f1 );
return f1; return f1;
...@@ -2292,17 +2292,17 @@ end */;; ...@@ -2292,17 +2292,17 @@ end */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;; /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `a'b` */;; /*!50003 DROP PROCEDURE IF EXISTS `a'b` */;;
/*!50003 SET SESSION SQL_MODE="REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI"*/;; /*!50003 SET SESSION SQL_MODE="REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI"*/;;
/*!50003 CREATE*/ /*!50019 DEFINER="root"@"localhost"*/ /*!50003 PROCEDURE "a'b"() /*!50003 CREATE*/ /*!50020 DEFINER="root"@"localhost"*/ /*!50003 PROCEDURE "a'b"()
select 1 */;; select 1 */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;; /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc1` */;; /*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc1` */;;
/*!50003 SET SESSION SQL_MODE=""*/;; /*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE*/ /*!50019 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT) /*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT)
BEGIN SELECT a+b INTO c; end */;; BEGIN SELECT a+b INTO c; end */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;; /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc2` */;; /*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc2` */;;
/*!50003 SET SESSION SQL_MODE=""*/;; /*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE*/ /*!50019 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `bug9056_proc2`(OUT a INT) /*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `bug9056_proc2`(OUT a INT)
BEGIN BEGIN
select sum(id) from t1 into a; select sum(id) from t1 into a;
END */;; END */;;
......
...@@ -678,6 +678,25 @@ select * from t1 where bob is null and cip=1; ...@@ -678,6 +678,25 @@ select * from t1 where bob is null and cip=1;
create index bug on t1 (bob(22), cip, time); create index bug on t1 (bob(22), cip, time);
select * from t1 where bob is null and cip=1; select * from t1 where bob is null and cip=1;
drop table t1; drop table t1;
#
# Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
#
create table t1 (
id1 int not null auto_increment,
id2 int not null default '0',
t text not null,
primary key (id1),
key x (id2, t(32))
) engine=myisam;
insert into t1 (id2, t) values
(10, 'abc'), (10, 'abc'), (10, 'abc'),
(20, 'abc'), (20, 'abc'), (20, 'def'),
(10, 'abc'), (10, 'abc');
select count(*) from t1 where id2 = 10;
select count(id1) from t1 where id2 = 10;
drop table t1;
# End of 4.1 tests # End of 4.1 tests
# #
......
...@@ -12,3 +12,5 @@ ...@@ -12,3 +12,5 @@
--exec $MYSQL_SLAP --only-print --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" --engine="heap,myisam" --exec $MYSQL_SLAP --only-print --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" --engine="heap,myisam"
--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')"
--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --create-schema=test_env
...@@ -88,6 +88,8 @@ int mi_delete(MI_INFO *info,const byte *record) ...@@ -88,6 +88,8 @@ int mi_delete(MI_INFO *info,const byte *record)
_mi_make_key(info,i,old_key,record,info->lastpos))) _mi_make_key(info,i,old_key,record,info->lastpos)))
goto err; goto err;
} }
/* The above changed info->lastkey2. Inform mi_rnext_same(). */
info->update&= ~HA_STATE_RNEXT_SAME;
} }
} }
......
...@@ -444,6 +444,10 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, ...@@ -444,6 +444,10 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
(char*) &blob_ptr,sizeof(char*)); (char*) &blob_ptr,sizeof(char*));
memcpy(blob_ptr,key,length); memcpy(blob_ptr,key,length);
blob_ptr+=length; blob_ptr+=length;
/* The above changed info->lastkey2. Inform mi_rnext_same(). */
info->update&= ~HA_STATE_RNEXT_SAME;
_my_store_blob_length(record+keyseg->start, _my_store_blob_length(record+keyseg->start,
(uint) keyseg->bit_start,length); (uint) keyseg->bit_start,length);
key+=length; key+=length;
......
...@@ -40,7 +40,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf) ...@@ -40,7 +40,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf)
if (info->s->concurrent_insert) if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]); rw_rdlock(&info->s->key_root_lock[inx]);
switch (keyinfo->key_alg) switch (keyinfo->key_alg)
{ {
#ifdef HAVE_RTREE_KEYS #ifdef HAVE_RTREE_KEYS
...@@ -102,4 +102,4 @@ int mi_rnext_same(MI_INFO *info, byte *buf) ...@@ -102,4 +102,4 @@ int mi_rnext_same(MI_INFO *info, byte *buf)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
} /* mi_rnext */ } /* mi_rnext_same */
...@@ -30,6 +30,9 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, ...@@ -30,6 +30,9 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record,
mi_unique_store(record+key->seg->start, unique_hash); mi_unique_store(record+key->seg->start, unique_hash);
_mi_make_key(info,def->key,key_buff,record,0); _mi_make_key(info,def->key,key_buff,record,0);
/* The above changed info->lastkey2. Inform mi_rnext_same(). */
info->update&= ~HA_STATE_RNEXT_SAME;
if (_mi_search(info,info->s->keyinfo+def->key,key_buff,MI_UNIQUE_HASH_LENGTH, if (_mi_search(info,info->s->keyinfo+def->key,key_buff,MI_UNIQUE_HASH_LENGTH,
SEARCH_FIND,info->s->state.key_root[def->key])) SEARCH_FIND,info->s->state.key_root[def->key]))
{ {
......
...@@ -111,6 +111,10 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec) ...@@ -111,6 +111,10 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec)
{ {
uint new_length=_mi_make_key(info,i,new_key,newrec,pos); uint new_length=_mi_make_key(info,i,new_key,newrec,pos);
uint old_length=_mi_make_key(info,i,old_key,oldrec,pos); uint old_length=_mi_make_key(info,i,old_key,oldrec,pos);
/* The above changed info->lastkey2. Inform mi_rnext_same(). */
info->update&= ~HA_STATE_RNEXT_SAME;
if (new_length != old_length || if (new_length != old_length ||
memcmp((byte*) old_key,(byte*) new_key,new_length)) memcmp((byte*) old_key,(byte*) new_key,new_length))
{ {
......
...@@ -132,6 +132,10 @@ int mi_write(MI_INFO *info, byte *record) ...@@ -132,6 +132,10 @@ int mi_write(MI_INFO *info, byte *record)
goto err; goto err;
} }
} }
/* The above changed info->lastkey2. Inform mi_rnext_same(). */
info->update&= ~HA_STATE_RNEXT_SAME;
if (local_lock_tree) if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]); rw_unlock(&share->key_root_lock[i]);
} }
......
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