Commit 04fd9031 authored by ram@gw.mysql.r18.ru's avatar ram@gw.mysql.r18.ru

Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.0

into gw.mysql.r18.ru:/usr/home/ram/work/4.0.b2631
parents 3c85a363 de5d1e78
...@@ -545,3 +545,4 @@ vio/test-sslserver ...@@ -545,3 +545,4 @@ vio/test-sslserver
vio/viotest-ssl vio/viotest-ssl
scripts/make_win_binary_distribution scripts/make_win_binary_distribution
EXCEPTIONS-CLIENT EXCEPTIONS-CLIENT
support-files/my-innodb-heavy-4G.cnf
...@@ -34,14 +34,17 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -34,14 +34,17 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
{ {
int save_errno,errpos=0; int save_errno,errpos=0;
uint files=0,i,dir_length,length,key_parts; uint files=0,i,dir_length,length,key_parts;
ulonglong file_offset; ulonglong file_offset=0;
char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end;
MYRG_INFO *m_info=0; MYRG_INFO *m_info=0;
File fd; File fd;
IO_CACHE file; IO_CACHE file;
MI_INFO *isam=0; MI_INFO *isam=0;
uint found_merge_insert_method= 0;
DBUG_ENTER("myrg_open"); DBUG_ENTER("myrg_open");
LINT_INIT(key_parts);
bzero((char*) &file,sizeof(file)); bzero((char*) &file,sizeof(file));
if ((fd=my_open(fn_format(name_buff,name,"",MYRG_NAME_EXT,4), if ((fd=my_open(fn_format(name_buff,name,"",MYRG_NAME_EXT,4),
O_RDONLY | O_SHARE,MYF(0))) < 0) O_RDONLY | O_SHARE,MYF(0))) < 0)
...@@ -69,10 +72,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -69,10 +72,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
continue; /* Skip empty lines */ continue; /* Skip empty lines */
if (buff[0] == '#') if (buff[0] == '#')
{ {
if( !strncmp(buff+1,"INSERT_METHOD=",14)) if (!strncmp(buff+1,"INSERT_METHOD=",14))
{ /* Lookup insert method */ { /* Lookup insert method */
int tmp=find_type(buff+15,&merge_insert_method,2); int tmp=find_type(buff+15,&merge_insert_method,2);
m_info->merge_insert_method = (uint) (tmp >= 0 ? tmp : 0); found_merge_insert_method = (uint) (tmp >= 0 ? tmp : 0);
} }
continue; /* Skip comments */ continue; /* Skip comments */
} }
...@@ -84,8 +87,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -84,8 +87,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
VOID(cleanup_dirname(buff,name_buff)); VOID(cleanup_dirname(buff,name_buff));
} }
if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0)))) if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0))))
goto err; goto err;
if (!m_info) if (!m_info) /* First file */
{ {
key_parts=isam->s->base.key_parts; key_parts=isam->s->base.key_parts;
if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO) + if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO) +
...@@ -97,15 +100,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -97,15 +100,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
{ {
m_info->open_tables=(MYRG_TABLE *) (m_info+1); m_info->open_tables=(MYRG_TABLE *) (m_info+1);
m_info->rec_per_key_part=(ulong *) (m_info->open_tables+files); m_info->rec_per_key_part=(ulong *) (m_info->open_tables+files);
m_info->tables= files;
files= 0;
} }
else
{
m_info->open_tables=0;
m_info->rec_per_key_part=0;
}
m_info->tables=files;
m_info->reclength=isam->s->base.reclength; m_info->reclength=isam->s->base.reclength;
file_offset=files=0;
errpos=3; errpos=3;
} }
m_info->open_tables[files].table= isam; m_info->open_tables[files].table= isam;
...@@ -122,14 +120,16 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -122,14 +120,16 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
m_info->del+= isam->state->del; m_info->del+= isam->state->del;
m_info->data_file_length+= isam->state->data_file_length; m_info->data_file_length+= isam->state->data_file_length;
for (i=0; i < key_parts; i++) for (i=0; i < key_parts; i++)
m_info->rec_per_key_part[i]+=isam->s->state.rec_per_key_part[i] / m_info->tables; m_info->rec_per_key_part[i]+= (isam->s->state.rec_per_key_part[i] /
m_info->tables);
} }
if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO), if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO),
MYF(MY_WME|MY_ZEROFILL)))) MYF(MY_WME | MY_ZEROFILL))))
goto err; goto err;
/* Don't mark table readonly, for ALTER TABLE ... UNION=(...) to work */ /* Don't mark table readonly, for ALTER TABLE ... UNION=(...) to work */
m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA); m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA);
m_info->merge_insert_method= found_merge_insert_method;
if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L) if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L)
{ {
......
...@@ -88,7 +88,6 @@ explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a l ...@@ -88,7 +88,6 @@ explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a l
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 Using filesort t2 ALL NULL NULL NULL NULL 4 Using filesort
t1 ALL NULL NULL NULL NULL 4
(select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2; (select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2;
a b a b
1 a 1 a
...@@ -420,6 +419,7 @@ a ...@@ -420,6 +419,7 @@ a
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1; (SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
Wrong usage/placement of 'SQL_CALC_FOUND_ROWS' Wrong usage/placement of 'SQL_CALC_FOUND_ROWS'
create temporary table t1 select a from t1 union select a from t2; create temporary table t1 select a from t1 union select a from t2;
drop table t1;
create table t1 select a from t1 union select a from t2; create table t1 select a from t1 union select a from t2;
INSERT TABLE 't1' isn't allowed in FROM table list INSERT TABLE 't1' isn't allowed in FROM table list
select a from t1 union select a from t2 order by t2.a; select a from t1 union select a from t2 order by t2.a;
...@@ -429,3 +429,10 @@ select length(version()) > 1 as `*` UNION select 2; ...@@ -429,3 +429,10 @@ select length(version()) > 1 as `*` UNION select 2;
* *
1 1
2 2
create table t1 (a int);
insert into t1 values (0), (3), (1), (2);
explain (select * from t1) union (select * from t1) order by a;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 4
t1 ALL NULL NULL NULL NULL 4
drop table t1;
...@@ -224,6 +224,7 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1; ...@@ -224,6 +224,7 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1;
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1; (SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
create temporary table t1 select a from t1 union select a from t2; create temporary table t1 select a from t1 union select a from t2;
drop table t1;
--error 1093 --error 1093
create table t1 select a from t1 union select a from t2; create table t1 select a from t1 union select a from t2;
--error 1054 --error 1054
...@@ -236,3 +237,11 @@ drop table t1,t2; ...@@ -236,3 +237,11 @@ drop table t1,t2;
select length(version()) > 1 as `*` UNION select 2; select length(version()) > 1 as `*` UNION select 2;
#
# Bug #4980: problem with explain
#
create table t1 (a int);
insert into t1 values (0), (3), (1), (2);
explain (select * from t1) union (select * from t1) order by a;
drop table t1;
...@@ -108,7 +108,7 @@ gen_lex_hash.o: gen_lex_hash.cc lex.h ...@@ -108,7 +108,7 @@ gen_lex_hash.o: gen_lex_hash.cc lex.h
sql_yacc.cc: sql_yacc.yy sql_yacc.cc: sql_yacc.yy
sql_yacc.h: sql_yacc.yy sql_yacc.h: sql_yacc.yy
sql_yacc.o: sql_yacc.cc sql_yacc.h sql_yacc.o: sql_yacc.cc sql_yacc.h $(noinst_HEADERS)
@echo "Note: The following compile may take a long time." @echo "Note: The following compile may take a long time."
@echo "If it fails, re-run configure with --with-low-memory" @echo "If it fails, re-run configure with --with-low-memory"
$(CXXCOMPILE) $(LM_CFLAGS) -c $< $(CXXCOMPILE) $(LM_CFLAGS) -c $<
......
...@@ -1221,7 +1221,7 @@ bool MYSQL_LOG::write(Log_event* event_info) ...@@ -1221,7 +1221,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
if (e.write(file)) if (e.write(file))
goto err; goto err;
} }
#if MYSQL_VERSION_ID < 40100 #if MYSQL_VERSION_ID < 40100
if (thd->variables.convert_set) if (thd->variables.convert_set)
{ {
Query_log_event e(thd, "SET CHARACTER SET DEFAULT", 25, 0); Query_log_event e(thd, "SET CHARACTER SET DEFAULT", 25, 0);
...@@ -1682,22 +1682,6 @@ void MYSQL_LOG::set_max_size(ulong max_size_arg) ...@@ -1682,22 +1682,6 @@ void MYSQL_LOG::set_max_size(ulong max_size_arg)
} }
Disable_binlog::Disable_binlog(THD *thd_arg) :
thd(thd_arg),
save_options(thd_arg->options), save_master_access(thd_arg->master_access)
{
thd_arg->options&= ~OPTION_BIN_LOG;
thd_arg->master_access|= SUPER_ACL; // unneeded in 4.1
};
Disable_binlog::~Disable_binlog()
{
thd->options= save_options;
thd->master_access= save_master_access;
}
/* /*
Check if a string is a valid number Check if a string is a valid number
...@@ -1761,15 +1745,21 @@ void print_buffer_to_file(enum loglevel level, const char *buffer) ...@@ -1761,15 +1745,21 @@ void print_buffer_to_file(enum loglevel level, const char *buffer)
skr=time(NULL); skr=time(NULL);
localtime_r(&skr, &tm_tmp); localtime_r(&skr, &tm_tmp);
start=&tm_tmp; start=&tm_tmp;
#if MYSQL_VERSION_ID > 40100
fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n", fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n",
start->tm_year % 100, #else
start->tm_mon+1, fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d %s\n",
start->tm_mday, #endif
start->tm_hour, start->tm_year % 100,
start->tm_min, start->tm_mon+1,
start->tm_sec, start->tm_mday,
start->tm_hour,
start->tm_min,
start->tm_sec,
#if MYSQL_VERSION_ID > 40100
(level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ?
"WARNING" : "INFORMATION"), "WARNING" : "INFORMATION"),
#endif
buffer); buffer);
fflush(stderr); fflush(stderr);
......
...@@ -638,27 +638,6 @@ public: ...@@ -638,27 +638,6 @@ public:
#define SYSTEM_THREAD_SLAVE_IO 2 #define SYSTEM_THREAD_SLAVE_IO 2
#define SYSTEM_THREAD_SLAVE_SQL 4 #define SYSTEM_THREAD_SLAVE_SQL 4
/*
Disables binary logging for one thread, and resets it back to what it was
before being disabled.
Some functions (like the internal mysql_create_table() when it's called by
mysql_alter_table()) must NOT write to the binlog (binlogging is done at the
at a later stage of the command already, and must be, for locking reasons);
so we internally disable it temporarily by creating the Disable_binlog
object and reset the state by destroying the object (don't forget that! or
write code so that the object gets automatically destroyed when leaving a
block, see example in sql_table.cc).
*/
class Disable_binlog {
private:
THD *thd;
ulong save_options;
ulong save_master_access;
public:
Disable_binlog(THD *thd_arg);
~Disable_binlog();
};
/* /*
Used to hold information about file and file structure in exchainge Used to hold information about file and file structure in exchainge
via non-DB file (...INTO OUTFILE..., ...LOAD DATA...) via non-DB file (...INTO OUTFILE..., ...LOAD DATA...)
......
...@@ -30,6 +30,16 @@ ...@@ -30,6 +30,16 @@
#include <io.h> #include <io.h>
#endif #endif
#include "sql_acl.h" // for SUPER_ACL
# define tmp_disable_binlog(A) \
ulong save_options= (A)->options, save_master_access= (A)->master_access; \
(A)->options&= ~OPTION_BIN_LOG; \
(A)->master_access|= SUPER_ACL; /* unneeded in 4.1 */
#define reenable_binlog(A) \
(A)->options= save_options; \
(A)->master_access= save_master_access;
extern HASH open_cache; extern HASH open_cache;
static const char *primary_key_name="PRIMARY"; static const char *primary_key_name="PRIMARY";
...@@ -840,9 +850,8 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, ...@@ -840,9 +850,8 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
MYSQL_LOCK **lock) MYSQL_LOCK **lock)
{ {
TABLE tmp_table; // Used during 'create_field()' TABLE tmp_table; // Used during 'create_field()'
TABLE *table; TABLE *table= 0;
tmp_table.table_name=0; tmp_table.table_name=0;
Disable_binlog disable_binlog(thd);
DBUG_ENTER("create_table_from_items"); DBUG_ENTER("create_table_from_items");
/* Add selected items to field list */ /* Add selected items to field list */
...@@ -872,23 +881,25 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, ...@@ -872,23 +881,25 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
extra_fields->push_back(cr_field); extra_fields->push_back(cr_field);
} }
/* create and lock table */ /* create and lock table */
/* QQ: This should be done atomic ! */ /* QQ: create and open should be done atomic ! */
/* We don't log the statement, it will be logged later */
if (mysql_create_table(thd,db,name,create_info,*extra_fields,
*keys,0))
DBUG_RETURN(0);
/* /*
We don't log the statement, it will be logged later.
If this is a HEAP table, the automatic DELETE FROM which is written to the If this is a HEAP table, the automatic DELETE FROM which is written to the
binlog when a HEAP table is opened for the first time since startup, must binlog when a HEAP table is opened for the first time since startup, must
not be written: 1) it would be wrong (imagine we're in CREATE SELECT: we not be written: 1) it would be wrong (imagine we're in CREATE SELECT: we
don't want to delete from it) 2) it would be written before the CREATE don't want to delete from it) 2) it would be written before the CREATE
TABLE, which is a wrong order. So we keep binary logging disabled. TABLE, which is a wrong order. So we keep binary logging disabled when we
open_table().
*/ */
if (!(table=open_table(thd,db,name,name,(bool*) 0))) tmp_disable_binlog(thd);
if (!mysql_create_table(thd,db,name,create_info,*extra_fields,*keys,0))
{ {
quick_rm_table(create_info->db_type,db,table_case_name(create_info,name)); if (!(table=open_table(thd,db,name,name,(bool*) 0)))
DBUG_RETURN(0); quick_rm_table(create_info->db_type,db,table_case_name(create_info,name));
} }
reenable_binlog(thd);
if (!table)
DBUG_RETURN(0);
table->reginfo.lock_type=TL_WRITE; table->reginfo.lock_type=TL_WRITE;
if (!((*lock)=mysql_lock_tables(thd,&table,1))) if (!((*lock)=mysql_lock_tables(thd,&table,1)))
{ {
...@@ -1925,14 +1936,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -1925,14 +1936,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
else else
create_info->data_file_name=create_info->index_file_name=0; create_info->data_file_name=create_info->index_file_name=0;
{ {
/* /* We don't log the statement, it will be logged later. */
We don't log the statement, it will be logged later. Using a block so tmp_disable_binlog(thd);
that disable_binlog is deleted when we leave it in either way. error= mysql_create_table(thd, new_db, tmp_name,
*/ create_info,create_list,key_list,1);
Disable_binlog disable_binlog(thd); reenable_binlog(thd);
if ((error=mysql_create_table(thd, new_db, tmp_name, if (error)
create_info,
create_list,key_list,1)))
DBUG_RETURN(error); DBUG_RETURN(error);
} }
if (table->tmp_table) if (table->tmp_table)
......
...@@ -148,6 +148,10 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ...@@ -148,6 +148,10 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
{ {
ha_rows records_at_start; ha_rows records_at_start;
lex->select=sl; lex->select=sl;
#if MYSQL_VERSION_ID < 40100
if (describe && sl->linkage == NOT_A_SELECT)
break; // Skip extra item in case of 'explain'
#endif
/* Don't use offset for the last union if there is no braces */ /* Don't use offset for the last union if there is no braces */
if (sl != lex_sl) if (sl != lex_sl)
{ {
......
...@@ -2917,7 +2917,7 @@ show_param: ...@@ -2917,7 +2917,7 @@ show_param:
lex->select->select_limit= lex->thd->variables.select_limit; lex->select->select_limit= lex->thd->variables.select_limit;
lex->select->offset_limit= 0L; lex->select->offset_limit= 0L;
} limit_clause } limit_clause
| keys_or_index FROM table_ident opt_db | keys_or_index from_or_in table_ident opt_db
{ {
Lex->sql_command= SQLCOM_SHOW_KEYS; Lex->sql_command= SQLCOM_SHOW_KEYS;
if ($4) if ($4)
......
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