Commit f1635f64 authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

Merge with 3.23 to get fixes for --user and BACKUP TABLE

parents e98a4473 c231b747
......@@ -206,6 +206,7 @@ config.h.in
config.log
config.status
configure
configure.lineno
core
core.2430
db-*.*.*
......@@ -214,6 +215,7 @@ depcomp
extra/comp_err
extra/my_print_defaults
extra/mysql_install
extra/mysql_waitpid
extra/perror
extra/replace
extra/resolve_stack_dump
......@@ -232,6 +234,7 @@ innobase/autom4te.cache/*
innobase/autom4te.cache/output.0
innobase/autom4te.cache/requests
innobase/autom4te.cache/traces.0
innobase/configure.lineno
innobase/conftest.s1
innobase/conftest.subs
innobase/ib_config.h
......@@ -499,6 +502,11 @@ stamp-h1
strings/conf_to_src
strings/ctype_autoconf.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/my-huge.cnf
support-files/my-large.cnf
......@@ -522,9 +530,3 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
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
......@@ -27,7 +27,7 @@
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
char server_version[SERVER_VERSION_LENGTH];
uint32 server_id = 0;
ulong server_id = 0;
// needed by net_serv.c
ulong bytes_sent = 0L, bytes_received = 0L;
......
......@@ -73,6 +73,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */
#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */
#define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */
#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy; Don't overwrite file */
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
#define MY_GIVE_INFO 2 /* Give time info about process*/
......
......@@ -170,9 +170,10 @@ int my_connect(my_socket s, const struct sockaddr *name, uint namelen,
struct timeval tv;
time_t start_time, now_time;
/* If they passed us a timeout of zero, we should behave
* exactly like the normal connect() call does.
*/
/*
If they passed us a timeout of zero, we should behave
exactly like the normal connect() call does.
*/
if (timeout == 0)
return connect(s, (struct sockaddr*) name, namelen);
......@@ -193,30 +194,31 @@ int my_connect(my_socket s, const struct sockaddr *name, uint namelen,
if (res == 0) /* Connected quickly! */
return(0);
/* Otherwise, our connection is "in progress." We can use
* the select() call to wait up to a specified period of time
* for the connection to suceed. If select() returns 0
* (after waiting howevermany seconds), our socket never became
* writable (host is probably unreachable.) Otherwise, if
* select() returns 1, then one of two conditions exist:
*
* 1. An error occured. We use getsockopt() to check for this.
* 2. The connection was set up sucessfully: getsockopt() will
* return 0 as an error.
*
* Thanks goes to Andrew Gierth <andrew@erlenstar.demon.co.uk>
* who posted this method of timing out a connect() in
* comp.unix.programmer on August 15th, 1997.
*/
/*
Otherwise, our connection is "in progress." We can use
the select() call to wait up to a specified period of time
for the connection to suceed. If select() returns 0
(after waiting howevermany seconds), our socket never became
writable (host is probably unreachable.) Otherwise, if
select() returns 1, then one of two conditions exist:
1. An error occured. We use getsockopt() to check for this.
2. The connection was set up sucessfully: getsockopt() will
return 0 as an error.
Thanks goes to Andrew Gierth <andrew@erlenstar.demon.co.uk>
who posted this method of timing out a connect() in
comp.unix.programmer on August 15th, 1997.
*/
FD_ZERO(&sfds);
FD_SET(s, &sfds);
/*
* select could be interrupted by a signal, and if it is,
* the timeout should be adjusted and the select restarted
* to work around OSes that don't restart select and
* implementations of select that don't adjust tv upon
* failure to reflect the time remaining
select could be interrupted by a signal, and if it is,
the timeout should be adjusted and the select restarted
to work around OSes that don't restart select and
implementations of select that don't adjust tv upon
failure to reflect the time remaining
*/
start_time = time(NULL);
for (;;)
......@@ -224,22 +226,25 @@ int my_connect(my_socket s, const struct sockaddr *name, uint namelen,
tv.tv_sec = (long) timeout;
tv.tv_usec = 0;
#if defined(HPUX10) && defined(THREAD)
if ((res = select(s+1, NULL, (int*) &sfds, NULL, &tv)) >= 0)
if ((res = select(s+1, NULL, (int*) &sfds, NULL, &tv)) > 0)
break;
#else
if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0)
if ((res = select(s+1, NULL, &sfds, NULL, &tv)) > 0)
break;
#endif
if (res == 0) /* timeout */
return -1;
now_time=time(NULL);
timeout-= (uint) (now_time - start_time);
if (errno != EINTR || (int) timeout <= 0)
return -1;
}
/* select() returned something more interesting than zero, let's
* see if we have any errors. If the next two statements pass,
* we've got an open socket!
*/
/*
select() returned something more interesting than zero, let's
see if we have any errors. If the next two statements pass,
we've got an open socket!
*/
s_err=0;
if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*) &s_err, &s_err_size) != 0)
......@@ -250,7 +255,8 @@ int my_connect(my_socket s, const struct sockaddr *name, uint namelen,
errno = s_err;
return(-1); /* but return an error... */
}
return(0); /* It's all good! */
return (0); /* ok */
#endif
}
......
......@@ -1160,7 +1160,7 @@ run_testcase ()
echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
start_master
else
if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] ;
if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] || [ -f $master_init_script ]
then
EXTRA_MASTER_OPT=""
stop_master
......
......@@ -251,3 +251,7 @@ t1_id t2_id type cost_unit min_value max_value t3_id item_id id name
22 1 Percent Cost 100 -1 6 291 1 s1
23 1 Percent Cost 100 -1 21 291 1 s1
drop table t1,t2;
rate_code base_rate
cust 20
rate_code base_rate
cust 20
#!/bin/sh
if [ "$MYSQL_TEST_DIR" ]
then
rm -f $MYSQL_TEST_DIR/var/tmp/*.frm $MYSQL_TEST_DIR/var/tmp/*.MY?
fi
#
# This test is a bit tricky as we can't use backup table to overwrite an old
# table
#
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
set SQL_LOG_BIN=0;
drop table if exists t1;
create table t4(n int);
--replace_result "errno: 2" "errno: X" "errno: 22" "errno: X" "errno: 23" "errno: X"
backup table t4 to '../bogus';
backup table t4 to '../tmp';
--replace_result "errno: 17" "errno: X"
backup table t4 to '../tmp';
drop table t4;
restore table t4 from '../tmp';
select count(*) from t4;
create table t1(n int);
--replace_result "errno = 1" "errno = X" "errno = 2" "errno = X" "errno = 22" "errno = X" "errno = 23" "errno = X"
backup table t1 to '../bogus';
backup table t1 to '../tmp';
drop table t1;
restore table t1 from '../tmp';
select count(*) from t1;
insert into t1 values (23),(45),(67);
backup table t1 to '../tmp';
drop table t1;
......@@ -20,23 +27,24 @@ create table t2(m int not null primary key);
create table t3(k int not null primary key);
insert into t2 values (123),(145),(167);
insert into t3 values (223),(245),(267);
backup table t1,t2,t3 to '../tmp';
backup table t2,t3 to '../tmp';
drop table t1,t2,t3;
restore table t1,t2,t3 from '../tmp';
select n from t1;
select m from t2;
select k from t3;
drop table t1,t2,t3;
drop table t1,t2,t3,t4;
restore table t1 from '../tmp';
connection con2;
rename table t1 to t5;
--send
lock tables t1 write;
lock tables t5 write;
connection con1;
--send
backup table t1 to '../tmp';
backup table t5 to '../tmp';
connection con2;
reap;
unlock tables;
connection con1;
reap;
drop table t1;
drop table t5;
......@@ -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);
delete from t1 where a=27;
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;
......@@ -247,3 +247,27 @@ CREATE TABLE t2 (
INSERT INTO t2 VALUES (1,'s1'),(2,'s2'),(3,'s3'),(4,'s4'),(5,'s5');
select t1.*, t2.* from t1, t2 where t2.id=t1.t2_id limit 2;
drop table t1,t2;
#
# Bug in range optimiser with MAYBE_KEY
#
CREATE TABLE t1 (
siteid varchar(25) NOT NULL default '',
emp_id varchar(30) NOT NULL default '',
rate_code varchar(10) default NULL,
UNIQUE KEY site_emp (siteid,emp_id),
KEY siteid (siteid)
) TYPE=MyISAM;
INSERT INTO t1 VALUES ('rivercats','psmith','cust'), ('rivercats','KWalker','cust');
CREATE TABLE t2 (
siteid varchar(25) NOT NULL default '',
rate_code varchar(10) NOT NULL default '',
base_rate float NOT NULL default '0',
PRIMARY KEY (siteid,rate_code),
FULLTEXT KEY rate_code (rate_code)
) TYPE=MyISAM;
INSERT INTO t2 VALUES ('rivercats','cust',20);
SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND lr.siteid = 'rivercats';
SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE lr.siteid = 'rivercats' AND emp.emp_id = 'psmith';
drop table t1,t2;
......@@ -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';
EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
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;
......@@ -31,17 +31,29 @@ struct utimbuf {
#endif
/*
Ordinary ownership and accesstimes are copied from 'from-file'
if MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then
the modes of to-file isn't changed
Dont set MY_FNABP or MY_NABP bits on when calling this function !
*/
/*
int my_copy(const char *from, const char *to, myf MyFlags)
NOTES
Ordinary ownership and accesstimes are copied from 'from-file'
If MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then
the modes of to-file isn't changed
If MyFlags & MY_DONT_OVERWRITE_FILE is set, we will give an error
if the file existed.
WARNING
Don't set MY_FNABP or MY_NABP bits on when calling this function !
RETURN
0 ok
# Error
*/
int my_copy(const char *from, const char *to, myf MyFlags)
{
uint Count;
int new_file_stat;
int new_file_stat, create_flag;
File from_file,to_file;
char buff[IO_SIZE];
struct stat stat_buff,new_stat_buff;
......@@ -62,8 +74,10 @@ int my_copy(const char *from, const char *to, myf MyFlags)
}
if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
stat_buff=new_stat_buff;
create_flag= (MyFlags & MY_DONT_OVERWRITE_FILE) ? O_EXCL : O_TRUNC;
if ((to_file= my_create(to,(int) stat_buff.st_mode,
O_WRONLY | O_TRUNC | O_BINARY | O_SHARE,
O_WRONLY | create_flag | O_BINARY | O_SHARE,
MyFlags)) < 0)
goto err;
......
......@@ -38,7 +38,12 @@ parse_arguments() {
--basedir=*) MY_BASEDIR_VERSION=`echo "$arg" | sed -e "s;--basedir=;;"` ;;
--datadir=*) DATADIR=`echo "$arg" | sed -e "s;--datadir=;;"` ;;
--pid-file=*) pid_file=`echo "$arg" | sed -e "s;--pid-file=;;"` ;;
--user=*) user=`echo "$arg" | sed -e "s;--[^=]*=;;"` ; SET_USER=1 ;;
--user=*)
if [ $SET_USER == 0 ]
then
user=`echo "$arg" | sed -e "s;--[^=]*=;;"` ; SET_USER=1
fi
;;
# these two might have been set in a [mysqld_safe] section of my.cnf
# they get passed via environment variables to mysqld_safe
......
......@@ -65,7 +65,7 @@ public:
virtual String *val_str(String*,String *)=0;
virtual Item_result result_type () const=0;
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 uint32 pack_length() const { return (uint32) field_length; }
virtual void reset(void) { bzero(ptr,pack_length()); }
......
......@@ -407,7 +407,7 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
param.db_name = table->table_cache_key;
param.table_name = table->table_name;
param.testflag = 0;
mi_check_print_error(&param,errmsg, my_errno);
mi_check_print_error(&param, errmsg, my_errno);
DBUG_RETURN(error);
}
}
......@@ -425,17 +425,17 @@ int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt)
if (fn_format_relative_to_data_home(dst_path, table_name, backup_dir,
reg_ext))
{
errmsg = "Failed in fn_format() for .frm file: errno = %d";
errmsg = "Failed in fn_format() for .frm file (errno: %d)";
error = HA_ADMIN_INVALID;
goto err;
}
if (my_copy(fn_format(src_path, table->path,"", reg_ext, MY_UNPACK_FILENAME),
dst_path,
MYF(MY_WME | MY_HOLD_ORIGINAL_MODES)))
MYF(MY_WME | MY_HOLD_ORIGINAL_MODES | MY_DONT_OVERWRITE_FILE)))
{
error = HA_ADMIN_FAILED;
errmsg = "Failed copying .frm file: errno = %d";
errmsg = "Failed copying .frm file (errno: %d)";
goto err;
}
......@@ -443,7 +443,7 @@ int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt)
if (!fn_format(dst_path, dst_path, "", MI_NAME_DEXT,
MY_REPLACE_EXT | MY_UNPACK_FILENAME | MY_SAFE_PATH))
{
errmsg = "Failed in fn_format() for .MYD file: errno = %d";
errmsg = "Failed in fn_format() for .MYD file (errno: %d)";
error = HA_ADMIN_INVALID;
goto err;
}
......@@ -451,9 +451,9 @@ int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt)
if (my_copy(fn_format(src_path, table->path,"", MI_NAME_DEXT,
MY_UNPACK_FILENAME),
dst_path,
MYF(MY_WME | MY_HOLD_ORIGINAL_MODES)))
MYF(MY_WME | MY_HOLD_ORIGINAL_MODES | MY_DONT_OVERWRITE_FILE)))
{
errmsg = "Failed copying .MYD file: errno = %d";
errmsg = "Failed copying .MYD file (errno: %d)";
error= HA_ADMIN_FAILED;
goto err;
}
......
......@@ -3596,7 +3596,7 @@ struct my_option my_long_options[] =
IF_PURIFY(0,1), 0, 0, 0, 0, 0},
#endif
{"user", 'u', "Run mysqld daemon as user", (gptr*) &mysqld_user,
(gptr*) &mysqld_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
(gptr*) &mysqld_user, 0, 0, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'v', "Synonym for option -v", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
......@@ -4219,6 +4219,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
/* Correct pointer set by my_getopt (for embedded library) */
mysql_data_home= mysql_real_data_home;
break;
case 'u':
if (!mysqld_user)
mysqld_user=optarg;
else
fprintf(stderr, "Warning: Ignoring user change to '%s' becasue the user is set to '%s' earlier on the command line\n", optarg, mysqld_user);
break;
case 'L':
strmake(language, argument, sizeof(language)-1);
break;
......
......@@ -1340,7 +1340,8 @@ key_and(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag)
}
if (((clone_flag & CLONE_KEY2_MAYBE) &&
!(clone_flag & CLONE_KEY1_MAYBE)) ||
!(clone_flag & CLONE_KEY1_MAYBE) &&
key2->type != SEL_ARG::MAYBE_KEY) ||
key1->type == SEL_ARG::MAYBE_KEY)
{ // Put simple key in key2
swap(SEL_ARG *,key1,key2);
......@@ -1368,7 +1369,10 @@ key_and(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag)
{
key1->maybe_smaller();
if (key2->next_key_part)
{
key1->use_count--; // Incremented in and_all_keys
return and_all_keys(key1,key2,clone_flag);
}
key2->use_count--; // Key2 doesn't have a tree
}
return key1;
......@@ -2067,7 +2071,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root)
{
if (this == root && use_count != 1)
{
sql_print_error("Use_count: Wrong count %lu for root",use_count);
sql_print_error("Note: Use_count: Wrong count %lu for root",use_count);
return;
}
if (this->type != SEL_ARG::KEY_RANGE)
......@@ -2081,7 +2085,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root)
ulong count=count_key_part_usage(root,pos->next_key_part);
if (count > pos->next_key_part->use_count)
{
sql_print_error("Use_count: Wrong count for key at %lx, %lu should be %lu",
sql_print_error("Note: Use_count: Wrong count for key at %lx, %lu should be %lu",
pos,pos->next_key_part->use_count,count);
return;
}
......@@ -2089,7 +2093,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root)
}
}
if (e_count != elements)
sql_print_error("Wrong use count: %u for tree at %lx", e_count,
sql_print_error("Warning: Wrong use count: %u for tree at %lx", e_count,
(gptr) this);
}
......
......@@ -7,8 +7,8 @@
"hashchk",
"isamchk",
"TAK",
"NIE",
"TAK",
"Nie mona stworzy pliku '%-.64s' (Kod bdu: %d)",
"Nie mona stworzy tabeli '%-.64s' (Kod bdu: %d)",
"Nie mona stworzy bazy danych '%-.64s'. B?d %d",
......
......@@ -3330,6 +3330,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
== Item_func::COND_AND_FUNC;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
Item::cond_result tmp_cond_value;
bool should_fix_fields=0;
*cond_value=Item::COND_UNDEF;
Item *item;
......@@ -3349,6 +3350,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
delete item; // This may be shared
#endif
VOID(li.replace(new_item));
should_fix_fields=1;
}
if (*cond_value == Item::COND_UNDEF)
*cond_value=tmp_cond_value;
......@@ -3375,6 +3377,9 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
break; /* purecov: deadcode */
}
}
if (should_fix_fields)
cond->fix_fields(current_thd,0);
if (!((Item_cond*) cond)->argument_list()->elements ||
*cond_value != Item::COND_OK)
return (COND*) 0;
......
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