Commit 19a5b454 authored by unknown's avatar unknown

Merge work:/my/mysql-4.0 into mashka.mysql.fi:/home/my/mysql-4.0


BitKeeper/etc/ignore:
  auto-union
configure.in:
  Auto merged
parents 8dc4215d efadca64
...@@ -206,6 +206,7 @@ config.h.in ...@@ -206,6 +206,7 @@ config.h.in
config.log config.log
config.status config.status
configure configure
configure.lineno
core core
core.2430 core.2430
db-*.*.* db-*.*.*
...@@ -214,6 +215,7 @@ depcomp ...@@ -214,6 +215,7 @@ depcomp
extra/comp_err extra/comp_err
extra/my_print_defaults extra/my_print_defaults
extra/mysql_install extra/mysql_install
extra/mysql_waitpid
extra/perror extra/perror
extra/replace extra/replace
extra/resolve_stack_dump extra/resolve_stack_dump
...@@ -232,6 +234,7 @@ innobase/autom4te.cache/* ...@@ -232,6 +234,7 @@ innobase/autom4te.cache/*
innobase/autom4te.cache/output.0 innobase/autom4te.cache/output.0
innobase/autom4te.cache/requests innobase/autom4te.cache/requests
innobase/autom4te.cache/traces.0 innobase/autom4te.cache/traces.0
innobase/configure.lineno
innobase/conftest.s1 innobase/conftest.s1
innobase/conftest.subs innobase/conftest.subs
innobase/ib_config.h innobase/ib_config.h
...@@ -499,6 +502,11 @@ stamp-h1 ...@@ -499,6 +502,11 @@ stamp-h1
strings/conf_to_src strings/conf_to_src
strings/ctype_autoconf.c strings/ctype_autoconf.c
strings/ctype_extra_sources.c strings/ctype_extra_sources.c
support-files/MacOSX/Description.plist
support-files/MacOSX/Info.plist
support-files/MacOSX/StartupParameters.plist
support-files/MacOSX/postinstall
support-files/MacOSX/preinstall
support-files/binary-configure support-files/binary-configure
support-files/my-huge.cnf support-files/my-huge.cnf
support-files/my-large.cnf support-files/my-large.cnf
...@@ -522,11 +530,3 @@ vio/test-ssl ...@@ -522,11 +530,3 @@ vio/test-ssl
vio/test-sslclient vio/test-sslclient
vio/test-sslserver vio/test-sslserver
vio/viotest-ssl vio/viotest-ssl
extra/mysql_waitpid
support-files/MacOSX/Description.plist
support-files/MacOSX/Info.plist
support-files/MacOSX/StartupParameters.plist
support-files/MacOSX/postinstall
support-files/MacOSX/preinstall
configure.lineno
innobase/configure.lineno
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES) #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
char server_version[SERVER_VERSION_LENGTH]; char server_version[SERVER_VERSION_LENGTH];
uint32 server_id = 0; ulong server_id = 0;
// needed by net_serv.c // needed by net_serv.c
ulong bytes_sent = 0L, bytes_received = 0L; ulong bytes_sent = 0L, bytes_received = 0L;
......
...@@ -14,7 +14,6 @@ SHARED_LIB_VERSION=12:0:0 ...@@ -14,7 +14,6 @@ SHARED_LIB_VERSION=12:0:0
# Set all version vars based on $VERSION. How do we do this more elegant ? # Set all version vars based on $VERSION. How do we do this more elegant ?
# Remember that regexps needs to quote [ and ] since this is run through m4 # Remember that regexps needs to quote [ and ] since this is run through m4
MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|-.*$||"`
MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|[[a-z]]*-.*$||"` MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|[[a-z]]*-.*$||"`
MYSQL_BASE_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|\.[[^.]]*$||"` MYSQL_BASE_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|\.[[^.]]*$||"`
F_PART=`echo $MYSQL_BASE_VERSION | sed -e "s|\.||g"| sed -e "s|[a-zA-Z]\+||"|sed -e "s|^\(..\)$|\\10|"` F_PART=`echo $MYSQL_BASE_VERSION | sed -e "s|\.||g"| sed -e "s|[a-zA-Z]\+||"|sed -e "s|^\(..\)$|\\10|"`
......
...@@ -218,6 +218,9 @@ int my_connect(my_socket s, const struct sockaddr *name, uint namelen, ...@@ -218,6 +218,9 @@ int my_connect(my_socket s, const struct sockaddr *name, uint namelen,
* implementations of select that don't adjust tv upon * implementations of select that don't adjust tv upon
* failure to reflect the time remaining * failure to reflect the time remaining
*/ */
#ifdef HAVE_POLL
return(0);
#endif
start_time = time(NULL); start_time = time(NULL);
for (;;) for (;;)
{ {
......
drop table if exists t1; drop table if exists t1;
create table t1 (a char (20) not null, b int not null auto_increment, index (a,b),index(b)); create table t1 (a char (20) not null, b int not null auto_increment, index (a,b));
insert into t1 (a) values (''),('ac'),('ae'),('ad'),('c'),('aeb'); insert into t1 (a) values (''),('ac'),('ae'),('ad'),('c'),('aeb');
insert into t1 (a) values ('c'),('uc'),('ue'),('ud'),(''),('ueb'),('uf'); insert into t1 (a) values ('c'),('uc'),('ue'),('ud'),(''),('ueb'),('uf');
insert into t1 (a) values (''),('oc'),('a'),('oe'),('od'),('c'),('oeb'); insert into t1 (a) values (''),('oc'),('a'),('oe'),('od'),('c'),('oeb');
insert into t1 (a) values ('s'),('ss'),(''),('b'),('ssa'),('ssc'),('a'); insert into t1 (a) values ('s'),('ss'),(''),('b'),('ssa'),('ssc'),('a');
insert into t1 (a) values ('e'),('u'),('o'),(''),('a'),('aeae'); insert into t1 (a) values ('e'),('u'),('o'),(''),('a'),('aeae');
insert into t1 (a) values ('q'),('a'),('u'),('o'),(''),(''); insert into t1 (a) values ('q'),('a'),('u'),('o'),(''),(''),('a');
select a,b from t1 order by a,b; select a,b from t1 order by a,b;
a b a b
a 35 a 1
ac 2 a 2
ad 4 ac 1
ad 1
1 1
ae 3 ae 2
31 1
aeae 33 aeae 2
a 32 a 1
aeb 6 aeb 1
c 5 c 1
38 1
39 2
e 28 e 1
o 37 o 1
oc 15 oc 1
od 18 od 1
14 1
oe 17 oe 2
a 16 a 1
oeb 20 oeb 1
c 19 c 1
o 30 o 1
q 34 q 1
s 21 s 1
ss 22 ss 1
23 2
ssa 25 ssa 1
a 27 a 2
b 24 b 1
ssc 26 ssc 1
u 36 u 1
uc 8 uc 1
ud 10 ud 1
ue 9 ue 1
11 2
ueb 12 ueb 1
c 7 c 1
uf 13 uf 1
u 29 u 1
select a,b from t1 order by upper(a),b; select a,b from t1 order by upper(a),b;
a b a b
a 35 a 1
ac 2 a 2
ad 4 ac 1
ad 1
1 1
ae 3 ae 2
31 1
aeae 33 aeae 2
a 32 a 1
aeb 6 aeb 1
c 5 c 1
38 1
39 2
e 28 e 1
o 37 o 1
oc 15 oc 1
od 18 od 1
14 1
oe 17 oe 2
a 16 a 1
oeb 20 oeb 1
c 19 c 1
o 30 o 1
q 34 q 1
s 21 s 1
ss 22 ss 1
23 2
ssa 25 ssa 1
a 27 a 2
b 24 b 1
ssc 26 ssc 1
u 36 u 1
uc 8 uc 1
ud 10 ud 1
ue 9 ue 1
11 2
ueb 12 ueb 1
c 7 c 1
uf 13 uf 1
u 29 u 1
select a from t1 order by a desc; select a from t1 order by a desc;
a a
u u
...@@ -129,44 +131,46 @@ ae ...@@ -129,44 +131,46 @@ ae
ad ad
ac ac
a a
a
check table t1; check table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
select * from t1 where a like "%"; select * from t1 where a like "%";
a b a b
14 1
a 16 a 1
c 19 c 1
o 30 o 1
select * from t1 where a like binary "%%"; select * from t1 where a like binary "%%";
a b a b
39 2
select * from t1 where a like "%%"; select * from t1 where a like "%%";
a b a b
a 35 a 1
ac 2 a 2
ad 4 ac 1
ae 3 ad 1
aeae 33 ae 2
a 32 aeae 2
aeb 6 a 1
a 16 aeb 1
ssa 25 a 1
a 27 ssa 1
a 2
select * from t1 where a like "%U%"; select * from t1 where a like "%U%";
a b a b
u 36 u 1
uc 8 uc 1
ud 10 ud 1
ue 9 ue 1
ueb 12 ueb 1
uf 13 uf 1
u 29 u 1
select * from t1 where a like "%ss%"; select * from t1 where a like "%ss%";
a b a b
ss 22 ss 1
ssa 25 ssa 1
ssc 26 ssc 1
drop table t1; drop table t1;
select strcmp('','ae'),strcmp('ae',''),strcmp('aeq','q'),strcmp('q','aeq'); select strcmp('','ae'),strcmp('ae',''),strcmp('aeq','q'),strcmp('q','aeq');
strcmp('','ae') strcmp('ae','') strcmp('aeq','q') strcmp('q','aeq') strcmp('','ae') strcmp('ae','') strcmp('aeq','q') strcmp('q','aeq')
......
...@@ -24,3 +24,18 @@ create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); ...@@ -24,3 +24,18 @@ create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a));
insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
delete from t1 where a=27; delete from t1 where a=27;
drop table t1; drop table t1;
CREATE TABLE t1 (
bool char(0) default NULL,
not_null varchar(20) binary NOT NULL default '',
misc integer not null,
PRIMARY KEY (not_null)
) TYPE=MyISAM;
INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7);
select * from t1 where misc > 5 and bool is null;
bool not_null misc
NULL c 6
NULL d 7
delete from t1 where misc > 5 and bool is null;
select * from t1 where misc > 5 and bool is null;
bool not_null misc
drop table t1;
use test;
drop table if exists t1,t2,t3,t4; drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 ( CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
......
...@@ -78,3 +78,9 @@ EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; ...@@ -78,3 +78,9 @@ EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref expedition expedition 8 const 1 Using where t1 ref expedition expedition 8 const 1 Using where
drop table t1; drop table t1;
create table t1 (a datetime not null, b datetime not null);
insert into t1 values (now(), now());
insert into t1 values (now(), now());
select * from t1 where a is null or b is null;
a b
drop table t1;
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
# Test latin_de character set # Test latin_de character set
# #
drop table if exists t1; drop table if exists t1;
create table t1 (a char (20) not null, b int not null auto_increment, index (a,b),index(b)); create table t1 (a char (20) not null, b int not null auto_increment, index (a,b));
insert into t1 (a) values (''),('ac'),('ae'),('ad'),('c'),('aeb'); insert into t1 (a) values (''),('ac'),('ae'),('ad'),('c'),('aeb');
insert into t1 (a) values ('c'),('uc'),('ue'),('ud'),(''),('ueb'),('uf'); insert into t1 (a) values ('c'),('uc'),('ue'),('ud'),(''),('ueb'),('uf');
insert into t1 (a) values (''),('oc'),('a'),('oe'),('od'),('c'),('oeb'); insert into t1 (a) values (''),('oc'),('a'),('oe'),('od'),('c'),('oeb');
insert into t1 (a) values ('s'),('ss'),(''),('b'),('ssa'),('ssc'),('a'); insert into t1 (a) values ('s'),('ss'),(''),('b'),('ssa'),('ssc'),('a');
insert into t1 (a) values ('e'),('u'),('o'),(''),('a'),('aeae'); insert into t1 (a) values ('e'),('u'),('o'),(''),('a'),('aeae');
insert into t1 (a) values ('q'),('a'),('u'),('o'),(''),(''); insert into t1 (a) values ('q'),('a'),('u'),('o'),(''),(''),('a');
select a,b from t1 order by a,b; select a,b from t1 order by a,b;
select a,b from t1 order by upper(a),b; select a,b from t1 order by upper(a),b;
select a from t1 order by a desc; select a from t1 order by a desc;
......
...@@ -35,3 +35,23 @@ create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); ...@@ -35,3 +35,23 @@ create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a));
insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
delete from t1 where a=27; delete from t1 where a=27;
drop table t1; drop table t1;
#
# CHAR(0) bug - not actually DELETE bug, but anyway...
#
CREATE TABLE t1 (
bool char(0) default NULL,
not_null varchar(20) binary NOT NULL default '',
misc integer not null,
PRIMARY KEY (not_null)
) TYPE=MyISAM;
INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7);
select * from t1 where misc > 5 and bool is null;
delete from t1 where misc > 5 and bool is null;
select * from t1 where misc > 5 and bool is null;
drop table t1;
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
# Simple select test # Simple select test
# #
use test;
drop table if exists t1,t2,t3,t4; drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 ( CREATE TABLE t1 (
......
...@@ -59,3 +59,8 @@ INSERT INTO t1 (numfacture,expedition) VALUES ('1212','0001-00-00 00:00:00'); ...@@ -59,3 +59,8 @@ INSERT INTO t1 (numfacture,expedition) VALUES ('1212','0001-00-00 00:00:00');
SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
drop table t1; drop table t1;
create table t1 (a datetime not null, b datetime not null);
insert into t1 values (now(), now());
insert into t1 values (now(), now());
select * from t1 where a is null or b is null;
drop table t1;
...@@ -115,13 +115,19 @@ my_string my_tempnam(const char *dir, const char *pfx, ...@@ -115,13 +115,19 @@ my_string my_tempnam(const char *dir, const char *pfx,
old_env=(char**)environ; old_env=(char**)environ;
if (dir) if (dir)
{ /* Don't use TMPDIR if dir is given */ { /* Don't use TMPDIR if dir is given */
((char**) environ)=(char**) temp_env; /*
The following strange cast is required because the IBM compiler on AIX
doesn't allow us to cast the value of environ.
The cast of environ is needed as some systems doesn't allow us to
update environ with a char ** pointer. (const mismatch)
*/
(*(char***) &environ)=(char**) temp_env;
temp_env[0]=0; temp_env[0]=0;
} }
#endif #endif
res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */ res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */
#if !defined(OS2) && !defined(__NETWARE__) #if !defined(OS2) && !defined(__NETWARE__)
((char**) environ)=(char**) old_env; (*(char***) &environ)=(char**) old_env;
#endif #endif
if (!res) if (!res)
DBUG_PRINT("error",("Got error: %d from tempnam",errno)); DBUG_PRINT("error",("Got error: %d from tempnam",errno));
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
# as such, and clarify ones such as "mediumint" with comments such as # as such, and clarify ones such as "mediumint" with comments such as
# "3-byte int" or "same as xxx". # "3-byte int" or "same as xxx".
$version="1.60"; $version="1.61";
use DBI; use DBI;
use Getopt::Long; use Getopt::Long;
...@@ -540,7 +540,7 @@ else ...@@ -540,7 +540,7 @@ else
" Please start it and try again\n"; " Please start it and try again\n";
exit 1; exit 1;
} }
$dbh=safe_connect(); $dbh=retry_connect();
} }
...@@ -2880,9 +2880,10 @@ As all used queries are legal according to some SQL standard. any ...@@ -2880,9 +2880,10 @@ As all used queries are legal according to some SQL standard. any
reasonable SQL server should be able to run this test without any reasonable SQL server should be able to run this test without any
problems. problems.
All questions is cached in $opt_dir/'server_name'.cfg that future runs will use All questions is cached in $opt_dir/'server_name'[-suffix].cfg that
limits found in previous runs. Remove this file if you want to find the future runs will use limits found in previous runs. Remove this file
current limits for your version of the database server. if you want to find the current limits for your version of the
database server.
This program uses some table names while testing things. If you have any This program uses some table names while testing things. If you have any
tables with the name of 'crash_me' or 'crash_qxxxx' where 'x' is a number, tables with the name of 'crash_me' or 'crash_qxxxx' where 'x' is a number,
...@@ -3152,7 +3153,29 @@ sub safe_connect ...@@ -3152,7 +3153,29 @@ sub safe_connect
} }
# #
# Check if the server is upp and running. If not, ask the user to restart it # Test connecting a couple of times before giving an error
# This is needed to get the server time to free old connections
# after the connect test
#
sub retry_connect
{
my ($dbh, $i);
for (i=0 ; $i < 10 ; $i++)
{
if (($dbh=DBI->connect($server->{'data_source'},$opt_user,$opt_password,
{ PrintError => 0, AutoCommit => 1})))
{
$dbh->{LongReadLen}= 16000000; # Set max retrieval buffer
return $dbh;
}
sleep(1);
}
return safe_connect();
}
#
# Check if the server is up and running. If not, ask the user to restart it
# #
sub check_connect sub check_connect
......
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
virtual String *val_str(String*,String *)=0; virtual String *val_str(String*,String *)=0;
virtual Item_result result_type () const=0; virtual Item_result result_type () const=0;
virtual Item_result cmp_type () const { return result_type(); } virtual Item_result cmp_type () const { return result_type(); }
bool eq(Field *field) { return ptr == field->ptr; } bool eq(Field *field) { return ptr == field->ptr && null_ptr == field->null_ptr; }
virtual bool eq_def(Field *field); virtual bool eq_def(Field *field);
virtual uint32 pack_length() const { return (uint32) field_length; } virtual uint32 pack_length() const { return (uint32) field_length; }
virtual void reset(void) { bzero(ptr,pack_length()); } virtual void reset(void) { bzero(ptr,pack_length()); }
......
...@@ -1021,7 +1021,7 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, ...@@ -1021,7 +1021,7 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
{ {
int error; int error;
uint i,j,recpos,minpos,fieldpos,temp_length,length; uint i,j,recpos,minpos,fieldpos,temp_length,length;
bool found_auto_increment=0, found_real_auto_increment=0; bool found_real_auto_increment=0;
enum ha_base_keytype type; enum ha_base_keytype type;
char buff[FN_REFLEN]; char buff[FN_REFLEN];
KEY *pos; KEY *pos;
...@@ -1091,12 +1091,6 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, ...@@ -1091,12 +1091,6 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
keydef[i].seg[j].null_bit=0; keydef[i].seg[j].null_bit=0;
keydef[i].seg[j].null_pos=0; keydef[i].seg[j].null_pos=0;
} }
if (field->flags & AUTO_INCREMENT_FLAG && !found_auto_increment)
{
keydef[i].flag|=HA_AUTO_KEY;
found_auto_increment=1;
found_real_auto_increment=(j==0);
}
if (field->type() == FIELD_TYPE_BLOB) if (field->type() == FIELD_TYPE_BLOB)
{ {
keydef[i].seg[j].flag|=HA_BLOB_PART; keydef[i].seg[j].flag|=HA_BLOB_PART;
...@@ -1108,6 +1102,12 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, ...@@ -1108,6 +1102,12 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
keyseg+=pos->key_parts; keyseg+=pos->key_parts;
} }
if (table_arg->found_next_number_field)
{
keydef[table_arg->next_number_index].flag|= HA_AUTO_KEY;
found_real_auto_increment= table_arg->next_number_key_offset == 0;
}
recpos=0; recinfo_pos=recinfo; recpos=0; recinfo_pos=recinfo;
while (recpos < (uint) table_arg->reclength) while (recpos < (uint) table_arg->reclength)
{ {
......
...@@ -487,11 +487,12 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list) ...@@ -487,11 +487,12 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
{ {
TABLE *table; TABLE *table;
char key[MAX_DBKEY_LENGTH]; char key[MAX_DBKEY_LENGTH];
char *db= table_list->db ? table_list->db : (thd->db ? thd->db : (char*) "");
uint key_length; uint key_length;
DBUG_ENTER("lock_table_name"); DBUG_ENTER("lock_table_name");
safe_mutex_assert_owner(&LOCK_open); safe_mutex_assert_owner(&LOCK_open);
key_length=(uint) (strmov(strmov(key,table_list->db)+1,table_list->real_name) key_length=(uint) (strmov(strmov(key,db)+1,table_list->real_name)
-key)+ 1; -key)+ 1;
/* Only insert the table if we haven't insert it already */ /* Only insert the table if we haven't insert it already */
...@@ -520,7 +521,7 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list) ...@@ -520,7 +521,7 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
my_free((gptr) table,MYF(0)); my_free((gptr) table,MYF(0));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if (remove_table_from_cache(thd, table_list->db, table_list->real_name)) if (remove_table_from_cache(thd, db, table_list->real_name))
DBUG_RETURN(1); // Table is in use DBUG_RETURN(1); // Table is in use
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -564,6 +565,77 @@ bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list) ...@@ -564,6 +565,77 @@ bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list)
DBUG_RETURN(result); DBUG_RETURN(result);
} }
/*
Lock all tables in list with a name lock
SYNOPSIS
lock_table_names()
thd Thread handle
table_list Names of tables to lock
NOTES
One must have a lock on LOCK_open when calling this
RETURN
0 ok
1 Fatal error (end of memory ?)
*/
bool lock_table_names(THD *thd, TABLE_LIST *table_list)
{
bool got_all_locks=1;
TABLE_LIST *lock_table;
for (lock_table=table_list ; lock_table ; lock_table=lock_table->next)
{
int got_lock;
if ((got_lock=lock_table_name(thd,lock_table)) < 0)
goto end; // Fatal error
if (got_lock)
got_all_locks=0; // Someone is using table
}
/* If some table was in use, wait until we got the lock */
if (!got_all_locks && wait_for_locked_table_names(thd, table_list))
goto end;
return 0;
end:
unlock_table_names(thd, table_list, lock_table);
return 1;
}
/*
Unlock all tables in list with a name lock
SYNOPSIS
unlock_table_names()
thd Thread handle
table_list Names of tables to unlock
last_table Don't unlock any tables after this one.
(default 0, which will unlock all tables)
NOTES
One must have a lock on LOCK_open when calling this
This function will send a COND_refresh signal to inform other threads
that the name locks are removed
RETURN
0 ok
1 Fatal error (end of memory ?)
*/
void unlock_table_names(THD *thd, TABLE_LIST *table_list,
TABLE_LIST *last_table)
{
for (TABLE_LIST *table=table_list ; table != last_table ; table=table->next)
unlock_table_name(thd,table);
pthread_cond_broadcast(&COND_refresh);
}
static void print_lock_error(int error) static void print_lock_error(int error)
{ {
int textno; int textno;
......
...@@ -723,6 +723,9 @@ int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list); ...@@ -723,6 +723,9 @@ int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list);
int lock_table_name(THD *thd, TABLE_LIST *table_list); int lock_table_name(THD *thd, TABLE_LIST *table_list);
void unlock_table_name(THD *thd, TABLE_LIST *table_list); void unlock_table_name(THD *thd, TABLE_LIST *table_list);
bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list); bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list);
bool lock_table_names(THD *thd, TABLE_LIST *table_list);
void unlock_table_names(THD *thd, TABLE_LIST *table_list,
TABLE_LIST *last_table= 0);
/* old unireg functions */ /* old unireg functions */
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
"hashchk", "hashchk",
"isamchk", "isamchk",
"TAK",
"NIE", "NIE",
"TAK",
"Nie mona stworzy pliku '%-.64s' (Kod bdu: %d)", "Nie mona stworzy pliku '%-.64s' (Kod bdu: %d)",
"Nie mona stworzy tabeli '%-.64s' (Kod bdu: %d)", "Nie mona stworzy tabeli '%-.64s' (Kod bdu: %d)",
"Nie mona stworzy bazy danych '%-.64s'. B?d %d", "Nie mona stworzy bazy danych '%-.64s'. B?d %d",
......
...@@ -31,8 +31,8 @@ static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list, ...@@ -31,8 +31,8 @@ static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list,
bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list) bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
{ {
bool error=1,got_all_locks=1; bool error=1;
TABLE_LIST *lock_table,*ren_table=0; TABLE_LIST *ren_table=0;
DBUG_ENTER("mysql_rename_tables"); DBUG_ENTER("mysql_rename_tables");
/* /*
...@@ -47,23 +47,11 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list) ...@@ -47,23 +47,11 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
} }
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
for (lock_table=table_list ; lock_table ; lock_table=lock_table->next) if (lock_table_names(thd, table_list))
{ goto err;
int got_lock;
if ((got_lock=lock_table_name(thd,lock_table)) < 0)
goto end;
if (got_lock)
got_all_locks=0;
}
if (!got_all_locks && wait_for_locked_table_names(thd,table_list))
goto end;
if (!(ren_table=rename_tables(thd,table_list,0))) error= 0;
error=0; if ((ren_table=rename_tables(thd,table_list,0)))
end:
if (ren_table)
{ {
/* Rename didn't succeed; rename back the tables in reverse order */ /* Rename didn't succeed; rename back the tables in reverse order */
TABLE_LIST *prev=0,*table; TABLE_LIST *prev=0,*table;
...@@ -85,7 +73,7 @@ end: ...@@ -85,7 +73,7 @@ end:
table=table->next->next; // Skip error table table=table->next->next; // Skip error table
/* Revert to old names */ /* Revert to old names */
rename_tables(thd, table, 1); rename_tables(thd, table, 1);
/* Note that lock_table == 0 here, so the unlock loop will work */ error= 1;
} }
/* Lets hope this doesn't fail as the result will be messy */ /* Lets hope this doesn't fail as the result will be messy */
...@@ -100,9 +88,9 @@ end: ...@@ -100,9 +88,9 @@ end:
send_ok(&thd->net); send_ok(&thd->net);
} }
for (TABLE_LIST *table=table_list ; table != lock_table ; table=table->next) unlock_table_names(thd,table_list);
unlock_table_name(thd,table);
pthread_cond_broadcast(&COND_refresh); err:
pthread_mutex_unlock(&LOCK_open); pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -131,7 +119,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) ...@@ -131,7 +119,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
if (!access(name,F_OK)) if (!access(name,F_OK))
{ {
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),name); my_error(ER_TABLE_EXISTS_ERROR,MYF(0),name);
DBUG_RETURN(ren_table); // This can't be skipped DBUG_RETURN(ren_table); // This can't be skiped
} }
sprintf(name,"%s/%s/%s%s",mysql_data_home, sprintf(name,"%s/%s/%s%s",mysql_data_home,
ren_table->db,ren_table->real_name, ren_table->db,ren_table->real_name,
......
...@@ -3330,6 +3330,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) ...@@ -3330,6 +3330,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
== Item_func::COND_AND_FUNC; == Item_func::COND_AND_FUNC;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
Item::cond_result tmp_cond_value; Item::cond_result tmp_cond_value;
bool should_fix_fields=0;
*cond_value=Item::COND_UNDEF; *cond_value=Item::COND_UNDEF;
Item *item; Item *item;
...@@ -3349,6 +3350,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) ...@@ -3349,6 +3350,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
delete item; // This may be shared delete item; // This may be shared
#endif #endif
VOID(li.replace(new_item)); VOID(li.replace(new_item));
should_fix_fields=1;
} }
if (*cond_value == Item::COND_UNDEF) if (*cond_value == Item::COND_UNDEF)
*cond_value=tmp_cond_value; *cond_value=tmp_cond_value;
...@@ -3375,6 +3377,9 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) ...@@ -3375,6 +3377,9 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
break; /* purecov: deadcode */ break; /* purecov: deadcode */
} }
} }
if (should_fix_fields)
cond->fix_fields(current_thd,0);
if (!((Item_cond*) cond)->argument_list()->elements || if (!((Item_cond*) cond)->argument_list()->elements ||
*cond_value != Item::COND_OK) *cond_value != Item::COND_OK)
return (COND*) 0; return (COND*) 0;
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB /* Copyright (C) 2000-2003 MySQL AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -80,7 +80,6 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) ...@@ -80,7 +80,6 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
{ {
my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0),
tables->real_name); tables->real_name);
error = 1;
goto err; goto err;
} }
while (global_read_lock && ! thd->killed) while (global_read_lock && ! thd->killed)
...@@ -93,7 +92,6 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) ...@@ -93,7 +92,6 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
err: err:
pthread_mutex_unlock(&LOCK_open); pthread_mutex_unlock(&LOCK_open);
VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh
pthread_mutex_lock(&thd->mysys_var->mutex); pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= 0; thd->mysys_var->current_mutex= 0;
...@@ -138,7 +136,6 @@ int mysql_rm_table_part2_with_lock(THD *thd, ...@@ -138,7 +136,6 @@ int mysql_rm_table_part2_with_lock(THD *thd,
error=mysql_rm_table_part2(thd,tables, if_exists, dont_log_query); error=mysql_rm_table_part2(thd,tables, if_exists, dont_log_query);
pthread_mutex_unlock(&LOCK_open); pthread_mutex_unlock(&LOCK_open);
VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh
pthread_mutex_lock(&thd->mysys_var->mutex); pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= 0; thd->mysys_var->current_mutex= 0;
...@@ -171,6 +168,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -171,6 +168,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
bool some_tables_deleted=0, tmp_table_deleted=0; bool some_tables_deleted=0, tmp_table_deleted=0;
DBUG_ENTER("mysql_rm_table_part2"); DBUG_ENTER("mysql_rm_table_part2");
if (lock_table_names(thd, tables))
DBUG_RETURN(1);
for (table=tables ; table ; table=table->next) for (table=tables ; table ; table=table->next)
{ {
char *db=table->db ? table->db : thd->db; char *db=table->db ? table->db : thd->db;
...@@ -242,11 +242,12 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -242,11 +242,12 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
} }
} }
error = 0; unlock_table_names(thd, tables);
error= 0;
if (wrong_tables.length()) if (wrong_tables.length())
{ {
my_error(ER_BAD_TABLE_ERROR,MYF(0),wrong_tables.c_ptr()); my_error(ER_BAD_TABLE_ERROR,MYF(0),wrong_tables.c_ptr());
error=1; error= 1;
} }
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
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