Commit af19fa46 authored by unknown's avatar unknown

Fixed bug in UNION

Fixed replication bug in load_master_data


BitKeeper/deleted/.del-global.h~e80d28157acfdcb5:
  Delete: include/global.h
Docs/manual.texi:
  Cleaned up "Things to do in 4.0"
mysql-test/r/union.result:
  New test
mysql-test/t/union.test:
  New test
mysys/my_lib.c:
  Cleanup
sql/mysql_priv.h:
  Fixed replication bug load_master_data
sql/sql_base.cc:
  Fixed bug in UNION
sql/sql_db.cc:
  Fixed replication bug load_master_data
sql/sql_parse.cc:
  Fixed replication bug load_master_data
sql/sql_repl.cc:
  Fixed replication bug load_master_data
sql/sql_union.cc:
  Fixed bug in UNION
tools/mysqlmanager.c:
  Portability fix
parent cca50665
......@@ -5680,11 +5680,10 @@ this without sacrifying the speed or compromise the code.
@node TODO MySQL 4.0, TODO future, TODO, TODO
@subsection Things that should be in 4.0
We plan to make MySQL Version 4.0 a ``quick'' release where we only
add some new stuff to enable others to help us with developing new features
into Version 4.1. The MySQL 4.0 version should only take us about
a month to make after which we want to stabilize it and start working on
Version 4.1. Version 4.0 should have the following new features:
We have now shifted development to MySQL Version 4.0. Most of the basic
things we want to have in 4.0 is already done. The target is to quickly
implement the rest of the following features and then shift development
to MySQL 4.1.
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}.
......@@ -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
make it easy to add a new replication slave without taking down the
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.
To do this, we need to update the threads record cache when we update
the @code{.MYD} file.
......@@ -5741,9 +5733,6 @@ Help for all commands from the client.
@item
Secure connections (with SSL).
@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
expansions of column names) should not open the table, but only the
definition file. This will require less memory and be much faster.
This diff is collapsed.
......@@ -59,3 +59,6 @@ t2 f 1
table type possible_keys key key_len ref rows Extra
t1 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
# Test some error conditions with UNION
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;
--error 1215
--error 1216
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;
--error 1215
--error 1216
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;
# Test CREATE, INSERT and REPLACE
......@@ -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;
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)
my_errno=errno;
if (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);
DBUG_RETURN((MY_DIR *) NULL);
} /* my_dir */
......
......@@ -237,7 +237,8 @@ inline THD *_current_thd(void)
#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);
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,
......@@ -262,7 +263,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char* packet, uint packet_length);
bool check_stack_overrun(THD *thd,char *dummy);
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_free(void);
uint cached_tables(void);
......
......@@ -1780,27 +1780,34 @@ bool setup_tables(TABLE_LIST *tables)
{
DBUG_ENTER("setup_tables");
uint tablenr=0;
for (TABLE_LIST *table=tables ; table ; table=table->next,tablenr++)
{
table->table->tablenr=tablenr;
table->table->map= (table_map) 1 << tablenr;
if ((table->table->outer_join=table->outer_join))
table->table->maybe_null=1; // LEFT OUTER JOIN ...
if (table->use_index)
for (TABLE_LIST *table_list=tables ; table_list ;
table_list=table_list->next,tablenr++)
{
TABLE *table=table_list->table;
table->used_fields=0;
table->const_table=0;
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,
table->use_index);
key_map map= get_key_map_from_key_list(table,
table_list->use_index);
if (map == ~(key_map) 0)
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,
table->ignore_index);
key_map map= get_key_map_from_key_list(table,
table_list->ignore_index);
if (map == ~(key_map) 0)
DBUG_RETURN(1);
table->table->keys_in_use_for_query &= ~map;
table->keys_in_use_for_query &= ~map;
}
}
if (tablenr > MAX_TABLES)
......
......@@ -31,7 +31,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
/* 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];
MY_DIR *dirp;
......@@ -56,9 +56,8 @@ int mysql_create_db(THD *thd, char *db, uint create_options)
my_dirend(dirp);
if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS))
{
if (thd)
net_printf(&thd->net,ER_DB_CREATE_EXISTS,db);
error = 1;
my_error(ER_DB_CREATE_EXISTS,MYF(0),db);
error = -1;
goto exit;
}
result = 0;
......@@ -68,14 +67,13 @@ int mysql_create_db(THD *thd, char *db, uint create_options)
strend(path)[-1]=0; // Remove last '/' from path
if (my_mkdir(path,0777,MYF(0)) < 0)
{
if (thd)
net_printf(&thd->net,ER_CANT_CREATE_DB,db,my_errno);
error = 1;
my_error(ER_CANT_CREATE_DB,MYF(0),db,my_errno);
error = -1;
goto exit;
}
}
if (thd)
if (!silent)
{
if (!thd->query)
{
......@@ -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;
int error = 0;
......@@ -144,16 +142,15 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists)
(void) sprintf(path,"%s/%s",mysql_data_home,db);
unpack_dirname(path,path); // Convert if not unix
/* 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
send_ok(&thd->net,0);
error= -1;
my_error(ER_DB_DROP_EXISTS,MYF(0),db);
}
error = !if_exists;
else if (!silent)
send_ok(&thd->net,0);
goto exit;
}
remove_db_from_cache(db);
......@@ -161,24 +158,27 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists)
error = -1;
if ((deleted=mysql_rm_known_files(thd, dirp, db, path,0)) >= 0 && thd)
{
if (!thd->query)
{
thd->query = path;
thd->query_length = (uint) (strxmov(path,"drop database ", db, NullS)-
path);
}
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
if (!silent)
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
if (thd->query == path)
{
thd->query = 0; // just in case
thd->query_length = 0;
if (!thd->query)
{
thd->query = path;
thd->query_length = (uint) (strxmov(path,"drop database ", db, NullS)-
path);
}
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
if (thd->query == path)
{
thd->query = 0; // just in case
thd->query_length = 0;
}
send_ok(&thd->net,(ulong) deleted);
}
send_ok(&thd->net,(ulong) deleted);
error = 0;
}
......
......@@ -903,7 +903,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (check_access(thd,CREATE_ACL,db,0,1))
break;
mysql_log.write(thd,command,packet);
mysql_create_db(thd,db,0);
mysql_create_db(thd,db,0,0);
break;
}
case COM_DROP_DB: // QQ: To be removed
......@@ -921,7 +921,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
}
mysql_log.write(thd,command,db);
mysql_rm_db(thd,db,0);
mysql_rm_db(thd,db,0,0);
break;
}
case COM_BINLOG_DUMP:
......@@ -1974,7 +1974,7 @@ mysql_execute_command(void)
}
if (check_access(thd,CREATE_ACL,lex->name,0,1))
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;
}
case SQLCOM_DROP_DB:
......@@ -1991,7 +1991,7 @@ mysql_execute_command(void)
send_error(&thd->net,ER_LOCK_OR_ACTIVE_TRANSACTION);
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;
}
case SQLCOM_CREATE_FUNCTION:
......
......@@ -1531,11 +1531,10 @@ int load_master_data(THD* thd)
continue;
}
if ((drop_error = mysql_rm_db(0, db, 1)) ||
mysql_create_db(0, db, 0))
if (mysql_rm_db(thd, db, 1,1) ||
mysql_create_db(thd, db, 0, 1))
{
error = (drop_error) ? ER_DB_DROP_DELETE : ER_CANT_CREATE_DB;
net_printf(&thd->net, error, db, my_error);
send_error(&thd->net, 0, 0);
cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
goto err;
}
......
......@@ -73,10 +73,11 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
(ORDER*) sl->group_list.first,
sl->having,
(ORDER*) NULL,
sl->options | thd->options | SELECT_NO_UNLOCK | SELECT_DESCRIBE,
(sl->options | thd->options | SELECT_NO_UNLOCK |
SELECT_DESCRIBE),
result);
}
return 0;
DBUG_RETURN(0);
}
order = (ORDER *) last_sl->order_list.first;
......
......@@ -22,25 +22,21 @@
#include <my_global.h>
#include <my_sys.h>
#include <my_pthread.h>
#include <m_ctype.h>
#include <m_string.h>
#include <mysql.h>
#include <mysql_version.h>
#include <m_ctype.h>
#include <my_config.h>
#include <mysqld_error.h>
#include <my_dir.h>
#include <hash.h>
#include <mysqld_error.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <stdarg.h>
#include <violite.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
#include <violite.h>
#include <my_pthread.h>
#define MANAGER_VERSION "1.0"
#define MANAGER_GREETING "MySQL Server Management Daemon v." ## \
......@@ -827,7 +823,7 @@ LOG_MSG_FUNC(info,INFO)
#ifndef DBUG_OFF
LOG_MSG_FUNC(debug,DEBUG)
#else
inline void log_debug(char* __attribute__((unused)) fmt,...) {}
void log_debug(char* __attribute__((unused)) fmt,...) {}
#endif
static pthread_handler_decl(process_launcher_messages,
......@@ -905,6 +901,7 @@ static pthread_handler_decl(process_connection,arg)
}
manager_thd_free(thd);
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,
......@@ -1151,13 +1148,15 @@ static int run_server_loop()
{
pthread_t th;
struct manager_thd *thd;
int client_sock,len;
int client_sock;
uint len;
Vio* vio;
for (;!shutdown_requested;)
{
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)
break;
......@@ -1531,7 +1530,7 @@ static int daemonize()
int main(int argc, char** argv)
{
char c;
stack_bottom=&c;
stack_bottom= (uchar *) &c;
MY_INIT(argv[0]);
errfp = stderr;
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