Commit 52b83ea2 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Fixed bug in UNION

Fixed replication bug in load_master_data
parent c87e072b
...@@ -5680,11 +5680,10 @@ this without sacrifying the speed or compromise the code. ...@@ -5680,11 +5680,10 @@ this without sacrifying the speed or compromise the code.
@node TODO MySQL 4.0, TODO future, TODO, TODO @node TODO MySQL 4.0, TODO future, TODO, TODO
@subsection Things that should be in 4.0 @subsection Things that should be in 4.0
We plan to make MySQL Version 4.0 a ``quick'' release where we only We have now shifted development to MySQL Version 4.0. Most of the basic
add some new stuff to enable others to help us with developing new features things we want to have in 4.0 is already done. The target is to quickly
into Version 4.1. The MySQL 4.0 version should only take us about implement the rest of the following features and then shift development
a month to make after which we want to stabilize it and start working on to MySQL 4.1.
Version 4.1. Version 4.0 should have the following new features:
The news section for 4.0 includes a list of the features we have already The news section for 4.0 includes a list of the features we have already
implemented in the 4.0 tree. @xref{News-4.0.x}. implemented in the 4.0 tree. @xref{News-4.0.x}.
...@@ -5717,13 +5716,6 @@ Replication should work with @code{RAND()} and user variables @code{@@var}. ...@@ -5717,13 +5716,6 @@ Replication should work with @code{RAND()} and user variables @code{@@var}.
Online backup with very low performance penalty. The online backup will Online backup with very low performance penalty. The online backup will
make it easy to add a new replication slave without taking down the make it easy to add a new replication slave without taking down the
master. master.
@item
@code{DELETE FROM table_name} will return the number of deleted rows. For
fast execution one should use @code{TRUNCATE table_name}.
@item
Multi-table @code{DELETE} (cascading @code{DELETE} and multi-table
@code{DELETE}.
@item
Allow @code{DELETE} on @code{MyISAM} tables to use the record cache. Allow @code{DELETE} on @code{MyISAM} tables to use the record cache.
To do this, we need to update the threads record cache when we update To do this, we need to update the threads record cache when we update
the @code{.MYD} file. the @code{.MYD} file.
...@@ -5741,9 +5733,6 @@ Help for all commands from the client. ...@@ -5741,9 +5733,6 @@ Help for all commands from the client.
@item @item
Secure connections (with SSL). Secure connections (with SSL).
@item @item
Extend the optimizer to be able to optimize some @code{ORDER BY key_name DESC}
queries.
@item
@code{SHOW COLUMNS FROM table_name} (used by @code{mysql} client to allow @code{SHOW COLUMNS FROM table_name} (used by @code{mysql} client to allow
expansions of column names) should not open the table, but only the expansions of column names) should not open the table, but only the
definition file. This will require less memory and be much faster. definition file. This will require less memory and be much faster.
This diff is collapsed.
...@@ -59,3 +59,6 @@ t2 f 1 ...@@ -59,3 +59,6 @@ t2 f 1
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 4 t1 ALL NULL NULL NULL NULL 4
t2 ALL NULL NULL NULL NULL 4 t2 ALL NULL NULL NULL NULL 4
pseudo
dekad
joce
...@@ -19,19 +19,19 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g ...@@ -19,19 +19,19 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g
# Test some error conditions with UNION # Test some error conditions with UNION
explain select a,b from t1 union all select a,b from t2; explain select a,b from t1 union all select a,b from t2;
--error 1215 --error 1216
select a,b from t1 into outfile 'skr' union select a,b from t2; select a,b from t1 into outfile 'skr' union select a,b from t2;
--error 1215 --error 1216
select a,b from t1 order by a union select a,b from t2; select a,b from t1 order by a union select a,b from t2;
--error 1216 --error 1217
create table t3 select a,b from t1 union select a from t2; create table t3 select a,b from t1 union select a from t2;
--error 1215 --error 1216
insert into t3 select a from t1 order by a union select a from t2; insert into t3 select a from t1 order by a union select a from t2;
--error 1216 --error 1217
select a,b from t1 union select a from t2; select a,b from t1 union select a from t2;
# Test CREATE, INSERT and REPLACE # Test CREATE, INSERT and REPLACE
...@@ -40,3 +40,18 @@ insert into t3 select a,b from t1 union all select a,b from t2; ...@@ -40,3 +40,18 @@ insert into t3 select a,b from t1 union all select a,b from t2;
replace into t3 select a,b as c from t1 union all select a,b from t2; replace into t3 select a,b as c from t1 union all select a,b from t2;
drop table t1,t2,t3; drop table t1,t2,t3;
#
# Test bug reported by joc@presence-pc.com
#
CREATE TABLE t1 (
`pseudo` char(35) NOT NULL default '',
`pseudo1` char(35) NOT NULL default '',
`same` tinyint(1) unsigned NOT NULL default '1',
PRIMARY KEY (`pseudo1`),
KEY `pseudo` (`pseudo`)
) TYPE=MyISAM;
INSERT INTO t1 (pseudo,pseudo1,same) VALUES ('joce', 'testtt', 1),('joce', 'tsestset', 1),('dekad', 'joce', 1);
SELECT pseudo FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo FROM t1 WHERE pseudo='joce';
drop table t1;
...@@ -183,7 +183,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags) ...@@ -183,7 +183,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
my_errno=errno; my_errno=errno;
if (dirp) if (dirp)
(void) closedir(dirp); (void) closedir(dirp);
if (MyFlags & (MY_FAE+MY_WME)) if (MyFlags & (MY_FAE | MY_WME))
my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,my_errno); my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,my_errno);
DBUG_RETURN((MY_DIR *) NULL); DBUG_RETURN((MY_DIR *) NULL);
} /* my_dir */ } /* my_dir */
......
...@@ -237,7 +237,8 @@ inline THD *_current_thd(void) ...@@ -237,7 +237,8 @@ inline THD *_current_thd(void)
#include "opt_range.h" #include "opt_range.h"
int mysql_create_db(THD *thd, char *db, uint create_info); int mysql_create_db(THD *thd, char *db, uint create_info, bool silent);
int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags); void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags);
int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists); int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists);
int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
...@@ -262,7 +263,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -262,7 +263,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char* packet, uint packet_length); char* packet, uint packet_length);
bool check_stack_overrun(THD *thd,char *dummy); bool check_stack_overrun(THD *thd,char *dummy);
bool reload_acl_and_cache(THD *thd, uint options, TABLE_LIST *tables); bool reload_acl_and_cache(THD *thd, uint options, TABLE_LIST *tables);
int mysql_rm_db(THD *thd,char *db,bool if_exists);
void table_cache_init(void); void table_cache_init(void);
void table_cache_free(void); void table_cache_free(void);
uint cached_tables(void); uint cached_tables(void);
......
...@@ -1780,27 +1780,34 @@ bool setup_tables(TABLE_LIST *tables) ...@@ -1780,27 +1780,34 @@ bool setup_tables(TABLE_LIST *tables)
{ {
DBUG_ENTER("setup_tables"); DBUG_ENTER("setup_tables");
uint tablenr=0; uint tablenr=0;
for (TABLE_LIST *table=tables ; table ; table=table->next,tablenr++) for (TABLE_LIST *table_list=tables ; table_list ;
table_list=table_list->next,tablenr++)
{ {
table->table->tablenr=tablenr; TABLE *table=table_list->table;
table->table->map= (table_map) 1 << tablenr;
if ((table->table->outer_join=table->outer_join)) table->used_fields=0;
table->table->maybe_null=1; // LEFT OUTER JOIN ... table->const_table=0;
if (table->use_index) table->outer_join=table->null_row=0;
table->status=STATUS_NO_RECORD;
table->keys_in_use_for_query=table->used_keys= table->keys_in_use;
table->maybe_null=test(table->outer_join=table_list->outer_join);
table->tablenr=tablenr;
table->map= (table_map) 1 << tablenr;
if (table_list->use_index)
{ {
key_map map= get_key_map_from_key_list(table->table, key_map map= get_key_map_from_key_list(table,
table->use_index); table_list->use_index);
if (map == ~(key_map) 0) if (map == ~(key_map) 0)
DBUG_RETURN(1); DBUG_RETURN(1);
table->table->keys_in_use_for_query=map; table->keys_in_use_for_query=map;
} }
if (table->ignore_index) if (table_list->ignore_index)
{ {
key_map map= get_key_map_from_key_list(table->table, key_map map= get_key_map_from_key_list(table,
table->ignore_index); table_list->ignore_index);
if (map == ~(key_map) 0) if (map == ~(key_map) 0)
DBUG_RETURN(1); DBUG_RETURN(1);
table->table->keys_in_use_for_query &= ~map; table->keys_in_use_for_query &= ~map;
} }
} }
if (tablenr > MAX_TABLES) if (tablenr > MAX_TABLES)
......
...@@ -31,7 +31,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, ...@@ -31,7 +31,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
/* db-name is already validated when we come here */ /* db-name is already validated when we come here */
int mysql_create_db(THD *thd, char *db, uint create_options) int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
{ {
char path[FN_REFLEN+16]; char path[FN_REFLEN+16];
MY_DIR *dirp; MY_DIR *dirp;
...@@ -56,9 +56,8 @@ int mysql_create_db(THD *thd, char *db, uint create_options) ...@@ -56,9 +56,8 @@ int mysql_create_db(THD *thd, char *db, uint create_options)
my_dirend(dirp); my_dirend(dirp);
if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS)) if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS))
{ {
if (thd) my_error(ER_DB_CREATE_EXISTS,MYF(0),db);
net_printf(&thd->net,ER_DB_CREATE_EXISTS,db); error = -1;
error = 1;
goto exit; goto exit;
} }
result = 0; result = 0;
...@@ -68,14 +67,13 @@ int mysql_create_db(THD *thd, char *db, uint create_options) ...@@ -68,14 +67,13 @@ int mysql_create_db(THD *thd, char *db, uint create_options)
strend(path)[-1]=0; // Remove last '/' from path strend(path)[-1]=0; // Remove last '/' from path
if (my_mkdir(path,0777,MYF(0)) < 0) if (my_mkdir(path,0777,MYF(0)) < 0)
{ {
if (thd) my_error(ER_CANT_CREATE_DB,MYF(0),db,my_errno);
net_printf(&thd->net,ER_CANT_CREATE_DB,db,my_errno); error = -1;
error = 1;
goto exit; goto exit;
} }
} }
if (thd) if (!silent)
{ {
if (!thd->query) if (!thd->query)
{ {
...@@ -124,7 +122,7 @@ static TYPELIB known_extentions= ...@@ -124,7 +122,7 @@ static TYPELIB known_extentions=
*/ */
int mysql_rm_db(THD *thd,char *db,bool if_exists) int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
{ {
long deleted=0; long deleted=0;
int error = 0; int error = 0;
...@@ -144,22 +142,23 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists) ...@@ -144,22 +142,23 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists)
(void) sprintf(path,"%s/%s",mysql_data_home,db); (void) sprintf(path,"%s/%s",mysql_data_home,db);
unpack_dirname(path,path); // Convert if not unix unpack_dirname(path,path); // Convert if not unix
/* See if the directory exists */ /* See if the directory exists */
if (!(dirp = my_dir(path,MYF(MY_WME | MY_DONT_SORT)))) if (!(dirp = my_dir(path,MYF(MY_DONT_SORT))))
{
if (thd)
{ {
if (!if_exists) if (!if_exists)
net_printf(&thd->net,ER_DB_DROP_EXISTS,db); {
else error= -1;
send_ok(&thd->net,0); my_error(ER_DB_DROP_EXISTS,MYF(0),db);
} }
error = !if_exists; else if (!silent)
send_ok(&thd->net,0);
goto exit; goto exit;
} }
remove_db_from_cache(db); remove_db_from_cache(db);
error = -1; error = -1;
if ((deleted=mysql_rm_known_files(thd, dirp, db, path,0)) >= 0 && thd) if ((deleted=mysql_rm_known_files(thd, dirp, db, path,0)) >= 0 && thd)
{
if (!silent)
{ {
if (!thd->query) if (!thd->query)
{ {
...@@ -179,6 +178,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists) ...@@ -179,6 +178,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists)
thd->query_length = 0; thd->query_length = 0;
} }
send_ok(&thd->net,(ulong) deleted); send_ok(&thd->net,(ulong) deleted);
}
error = 0; error = 0;
} }
......
...@@ -903,7 +903,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -903,7 +903,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (check_access(thd,CREATE_ACL,db,0,1)) if (check_access(thd,CREATE_ACL,db,0,1))
break; break;
mysql_log.write(thd,command,packet); mysql_log.write(thd,command,packet);
mysql_create_db(thd,db,0); mysql_create_db(thd,db,0,0);
break; break;
} }
case COM_DROP_DB: // QQ: To be removed case COM_DROP_DB: // QQ: To be removed
...@@ -921,7 +921,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -921,7 +921,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break; break;
} }
mysql_log.write(thd,command,db); mysql_log.write(thd,command,db);
mysql_rm_db(thd,db,0); mysql_rm_db(thd,db,0,0);
break; break;
} }
case COM_BINLOG_DUMP: case COM_BINLOG_DUMP:
...@@ -1974,7 +1974,7 @@ mysql_execute_command(void) ...@@ -1974,7 +1974,7 @@ mysql_execute_command(void)
} }
if (check_access(thd,CREATE_ACL,lex->name,0,1)) if (check_access(thd,CREATE_ACL,lex->name,0,1))
break; break;
res=mysql_create_db(thd,lex->name,lex->create_info.options); res=mysql_create_db(thd,lex->name,lex->create_info.options,0);
break; break;
} }
case SQLCOM_DROP_DB: case SQLCOM_DROP_DB:
...@@ -1991,7 +1991,7 @@ mysql_execute_command(void) ...@@ -1991,7 +1991,7 @@ mysql_execute_command(void)
send_error(&thd->net,ER_LOCK_OR_ACTIVE_TRANSACTION); send_error(&thd->net,ER_LOCK_OR_ACTIVE_TRANSACTION);
goto error; goto error;
} }
res=mysql_rm_db(thd,lex->name,lex->drop_if_exists); res=mysql_rm_db(thd,lex->name,lex->drop_if_exists,0);
break; break;
} }
case SQLCOM_CREATE_FUNCTION: case SQLCOM_CREATE_FUNCTION:
......
...@@ -1531,11 +1531,10 @@ int load_master_data(THD* thd) ...@@ -1531,11 +1531,10 @@ int load_master_data(THD* thd)
continue; continue;
} }
if ((drop_error = mysql_rm_db(0, db, 1)) || if (mysql_rm_db(thd, db, 1,1) ||
mysql_create_db(0, db, 0)) mysql_create_db(thd, db, 0, 1))
{ {
error = (drop_error) ? ER_DB_DROP_DELETE : ER_CANT_CREATE_DB; send_error(&thd->net, 0, 0);
net_printf(&thd->net, error, db, my_error);
cleanup_mysql_results(db_res, cur_table_res - 1, table_res); cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
goto err; goto err;
} }
......
...@@ -73,10 +73,11 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ...@@ -73,10 +73,11 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
(ORDER*) sl->group_list.first, (ORDER*) sl->group_list.first,
sl->having, sl->having,
(ORDER*) NULL, (ORDER*) NULL,
sl->options | thd->options | SELECT_NO_UNLOCK | SELECT_DESCRIBE, (sl->options | thd->options | SELECT_NO_UNLOCK |
SELECT_DESCRIBE),
result); result);
} }
return 0; DBUG_RETURN(0);
} }
order = (ORDER *) last_sl->order_list.first; order = (ORDER *) last_sl->order_list.first;
......
...@@ -22,25 +22,21 @@ ...@@ -22,25 +22,21 @@
#include <my_global.h> #include <my_global.h>
#include <my_sys.h> #include <my_sys.h>
#include <my_pthread.h>
#include <m_ctype.h>
#include <m_string.h> #include <m_string.h>
#include <mysql.h> #include <mysql.h>
#include <mysql_version.h> #include <mysql_version.h>
#include <m_ctype.h> #include <mysqld_error.h>
#include <my_config.h>
#include <my_dir.h> #include <my_dir.h>
#include <hash.h> #include <hash.h>
#include <mysqld_error.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h> #include <getopt.h>
#include <stdarg.h> #include <stdarg.h>
#include <violite.h>
#include <signal.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h>
#include <errno.h> #include <errno.h>
#include <violite.h>
#include <my_pthread.h>
#define MANAGER_VERSION "1.0" #define MANAGER_VERSION "1.0"
#define MANAGER_GREETING "MySQL Server Management Daemon v." ## \ #define MANAGER_GREETING "MySQL Server Management Daemon v." ## \
...@@ -827,7 +823,7 @@ LOG_MSG_FUNC(info,INFO) ...@@ -827,7 +823,7 @@ LOG_MSG_FUNC(info,INFO)
#ifndef DBUG_OFF #ifndef DBUG_OFF
LOG_MSG_FUNC(debug,DEBUG) LOG_MSG_FUNC(debug,DEBUG)
#else #else
inline void log_debug(char* __attribute__((unused)) fmt,...) {} void log_debug(char* __attribute__((unused)) fmt,...) {}
#endif #endif
static pthread_handler_decl(process_launcher_messages, static pthread_handler_decl(process_launcher_messages,
...@@ -905,6 +901,7 @@ static pthread_handler_decl(process_connection,arg) ...@@ -905,6 +901,7 @@ static pthread_handler_decl(process_connection,arg)
} }
manager_thd_free(thd); manager_thd_free(thd);
pthread_exit(0); pthread_exit(0);
return 0; /* Don't get cc warning */
} }
static void client_msg_raw(Vio* vio, int err_code, int pre, const char* fmt, static void client_msg_raw(Vio* vio, int err_code, int pre, const char* fmt,
...@@ -1151,13 +1148,15 @@ static int run_server_loop() ...@@ -1151,13 +1148,15 @@ static int run_server_loop()
{ {
pthread_t th; pthread_t th;
struct manager_thd *thd; struct manager_thd *thd;
int client_sock,len; int client_sock;
uint len;
Vio* vio; Vio* vio;
for (;!shutdown_requested;) for (;!shutdown_requested;)
{ {
len=sizeof(struct sockaddr_in); len=sizeof(struct sockaddr_in);
if ((client_sock=accept(manager_sock,(struct sockaddr*)&manager_addr,&len))<0) if ((client_sock=accept(manager_sock,(struct sockaddr*)&manager_addr,
&len)) <0)
{ {
if (shutdown_requested) if (shutdown_requested)
break; break;
...@@ -1531,7 +1530,7 @@ static int daemonize() ...@@ -1531,7 +1530,7 @@ static int daemonize()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
char c; char c;
stack_bottom=&c; stack_bottom= (uchar *) &c;
MY_INIT(argv[0]); MY_INIT(argv[0]);
errfp = stderr; errfp = stderr;
parse_args(argc,argv); parse_args(argc,argv);
......
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