Commit eb6458cb authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

After merge fixes + bugs from last merge

parent 10c4acfb
...@@ -344,8 +344,8 @@ while test $# -gt 0; do ...@@ -344,8 +344,8 @@ while test $# -gt 0; do
;; ;;
--valgrind) --valgrind)
VALGRIND="valgrind --alignment=8 --leak-check=yes --num-callers=16" VALGRIND="valgrind --alignment=8 --leak-check=yes --num-callers=16"
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc" EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc --skip-bdb"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb"
SLEEP_TIME_AFTER_RESTART=10 SLEEP_TIME_AFTER_RESTART=10
SLEEP_TIME_FOR_DELETE=60 SLEEP_TIME_FOR_DELETE=60
USE_RUNNING_SERVER="" USE_RUNNING_SERVER=""
...@@ -998,7 +998,7 @@ start_slave() ...@@ -998,7 +998,7 @@ start_slave()
if [ x$DO_DDD = x1 ] if [ x$DO_DDD = x1 ]
then then
$ECHO "set args $master_args" > $GDB_SLAVE_INIT $ECHO "set args $slave_args" > $GDB_SLAVE_INIT
manager_launch $slave_ident ddd -display $DISPLAY --debugger \ manager_launch $slave_ident ddd -display $DISPLAY --debugger \
"gdb -x $GDB_SLAVE_INIT" $SLAVE_MYSQLD "gdb -x $GDB_SLAVE_INIT" $SLAVE_MYSQLD
elif [ x$DO_GDB = x1 ] elif [ x$DO_GDB = x1 ]
......
...@@ -23,7 +23,7 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g ...@@ -23,7 +23,7 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g
(select a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 4; (select a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 4;
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1); (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1);
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
--error 1248 --error 1249
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b; (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b;
explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
(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;
......
...@@ -50,7 +50,7 @@ Item::Item(): ...@@ -50,7 +50,7 @@ Item::Item():
next= thd->free_list; // Put in free list next= thd->free_list; // Put in free list
thd->free_list= this; thd->free_list= this;
/* /*
Item constructor can be called during execution other tnen SQL_COM Item constructor can be called during execution other then SQL_COM
command => we should check thd->lex.current_select on zero (thd->lex command => we should check thd->lex.current_select on zero (thd->lex
can be uninitialised) can be uninitialised)
*/ */
......
...@@ -911,7 +911,6 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -911,7 +911,6 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
if (db_ok(thd->db, replicate_do_db, replicate_ignore_db)) if (db_ok(thd->db, replicate_do_db, replicate_ignore_db))
{ {
thd->set_time((time_t)when); thd->set_time((time_t)when);
thd->current_tablenr = 0;
thd->query_length= q_len; thd->query_length= q_len;
VOID(pthread_mutex_lock(&LOCK_thread_count)); VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = (char*)query; thd->query = (char*)query;
...@@ -1617,7 +1616,6 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, ...@@ -1617,7 +1616,6 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
if (db_ok(thd->db, replicate_do_db, replicate_ignore_db)) if (db_ok(thd->db, replicate_do_db, replicate_ignore_db))
{ {
thd->set_time((time_t)when); thd->set_time((time_t)when);
thd->current_tablenr = 0;
VOID(pthread_mutex_lock(&LOCK_thread_count)); VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id = query_id++; thd->query_id = query_id++;
VOID(pthread_mutex_unlock(&LOCK_thread_count)); VOID(pthread_mutex_unlock(&LOCK_thread_count));
......
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
inline bool store(ulonglong from) inline bool store(ulonglong from)
{ return store_longlong((longlong) from, 1); } { return store_longlong((longlong) from, 1); }
inline bool store(String *str) inline bool store(String *str)
{ return store(str->c_ptr(),str->length(),str->charset()); } { return store((char*) str->ptr(), str->length(), str->charset()); }
virtual bool prepare_for_send(List<Item> *item_list) virtual bool prepare_for_send(List<Item> *item_list)
{ {
......
...@@ -823,7 +823,7 @@ void fix_max_binlog_size(THD *thd, enum_var_type type) ...@@ -823,7 +823,7 @@ void fix_max_binlog_size(THD *thd, enum_var_type type)
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu", DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
max_binlog_size, max_relay_log_size)); max_binlog_size, max_relay_log_size));
mysql_bin_log.set_max_size(max_binlog_size); mysql_bin_log.set_max_size(max_binlog_size);
#ifdef REPLICATION #ifdef HAVE_REPLICATION
if (!max_relay_log_size) if (!max_relay_log_size)
active_mi->rli.relay_log.set_max_size(max_binlog_size); active_mi->rli.relay_log.set_max_size(max_binlog_size);
#endif #endif
...@@ -835,8 +835,10 @@ void fix_max_relay_log_size(THD *thd, enum_var_type type) ...@@ -835,8 +835,10 @@ void fix_max_relay_log_size(THD *thd, enum_var_type type)
DBUG_ENTER("fix_max_relay_log_size"); DBUG_ENTER("fix_max_relay_log_size");
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu", DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
max_binlog_size, max_relay_log_size)); max_binlog_size, max_relay_log_size));
#ifdef HAVE_REPLICATION
active_mi->rli.relay_log.set_max_size(max_relay_log_size ? active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
max_relay_log_size: max_binlog_size); max_relay_log_size: max_binlog_size);
#endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -1137,7 +1137,6 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, ...@@ -1137,7 +1137,6 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
return 1; return 1;
} }
thd->query= query; thd->query= query;
thd->current_tablenr = 0;
thd->query_error = 0; thd->query_error = 0;
thd->net.no_send_ok = 1; thd->net.no_send_ok = 1;
...@@ -1811,7 +1810,8 @@ int show_master_info(THD* thd, MASTER_INFO* mi) ...@@ -1811,7 +1810,8 @@ int show_master_info(THD* thd, MASTER_INFO* mi)
field_list.push_back(new Item_empty_string("Replicate_do_table", 20)); field_list.push_back(new Item_empty_string("Replicate_do_table", 20));
field_list.push_back(new Item_empty_string("Replicate_ignore_table", 23)); field_list.push_back(new Item_empty_string("Replicate_ignore_table", 23));
field_list.push_back(new Item_empty_string("Replicate_wild_do_table", 24)); field_list.push_back(new Item_empty_string("Replicate_wild_do_table", 24));
field_list.push_back(new Item_empty_string("Replicate_wild_ignore_table", 28)); field_list.push_back(new Item_empty_string("Replicate_wild_ignore_table",
28));
field_list.push_back(new Item_return_int("Last_errno", 4, MYSQL_TYPE_LONG)); field_list.push_back(new Item_return_int("Last_errno", 4, MYSQL_TYPE_LONG));
field_list.push_back(new Item_empty_string("Last_error", 20)); field_list.push_back(new Item_empty_string("Last_error", 20));
field_list.push_back(new Item_return_int("Skip_counter", 10, field_list.push_back(new Item_return_int("Skip_counter", 10,
...@@ -1838,7 +1838,8 @@ int show_master_info(THD* thd, MASTER_INFO* mi) ...@@ -1838,7 +1838,8 @@ int show_master_info(THD* thd, MASTER_INFO* mi)
protocol->store(mi->master_log_name, &my_charset_bin); protocol->store(mi->master_log_name, &my_charset_bin);
protocol->store((ulonglong) mi->master_log_pos); protocol->store((ulonglong) mi->master_log_pos);
protocol->store(mi->rli.group_relay_log_name + protocol->store(mi->rli.group_relay_log_name +
dirname_length(mi->rli.group_relay_log_name), &my_charset_bin); dirname_length(mi->rli.group_relay_log_name),
&my_charset_bin);
protocol->store((ulonglong) mi->rli.group_relay_log_pos); protocol->store((ulonglong) mi->rli.group_relay_log_pos);
protocol->store(mi->rli.group_master_log_name, &my_charset_bin); protocol->store(mi->rli.group_master_log_name, &my_charset_bin);
protocol->store(mi->slave_running ? "Yes":"No", &my_charset_bin); protocol->store(mi->slave_running ? "Yes":"No", &my_charset_bin);
...@@ -2384,6 +2385,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ...@@ -2384,6 +2385,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
thd->server_id = ev->server_id; // use the original server id for logging thd->server_id = ev->server_id; // use the original server id for logging
thd->set_time(); // time the query thd->set_time(); // time the query
thd->lex.current_select= 0;
if (!ev->when) if (!ev->when)
ev->when = time(NULL); ev->when = time(NULL);
ev->thd = thd; ev->thd = thd;
......
...@@ -1355,6 +1355,7 @@ int open_tables(THD *thd,TABLE_LIST *start) ...@@ -1355,6 +1355,7 @@ int open_tables(THD *thd,TABLE_LIST *start)
int result=0; int result=0;
DBUG_ENTER("open_tables"); DBUG_ENTER("open_tables");
thd->current_tablenr= 0;
restart: restart:
thd->proc_info="Opening tables"; thd->proc_info="Opening tables";
for (tables=start ; tables ; tables=tables->next) for (tables=start ; tables ; tables=tables->next)
...@@ -1473,6 +1474,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type) ...@@ -1473,6 +1474,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
DBUG_ENTER("open_ltable"); DBUG_ENTER("open_ltable");
thd->proc_info="Opening table"; thd->proc_info="Opening table";
thd->current_tablenr= 0;
while (!(table=open_table(thd,table_list->db, while (!(table=open_table(thd,table_list->db,
table_list->real_name,table_list->alias, table_list->real_name,table_list->alias,
&refresh)) && refresh) ; &refresh)) && refresh) ;
......
...@@ -96,7 +96,6 @@ THD::THD():user_time(0), is_fatal_error(0), ...@@ -96,7 +96,6 @@ THD::THD():user_time(0), is_fatal_error(0),
query_error= tmp_table_used= 0; query_error= tmp_table_used= 0;
next_insert_id=last_insert_id=0; next_insert_id=last_insert_id=0;
open_tables= temporary_tables= handler_tables= derived_tables= 0; open_tables= temporary_tables= handler_tables= derived_tables= 0;
current_tablenr=0;
handler_items=0; handler_items=0;
tmp_table=0; tmp_table=0;
lock=locked_tables=0; lock=locked_tables=0;
...@@ -161,8 +160,6 @@ THD::THD():user_time(0), is_fatal_error(0), ...@@ -161,8 +160,6 @@ THD::THD():user_time(0), is_fatal_error(0),
else else
bzero((char*) &user_var_events, sizeof(user_var_events)); bzero((char*) &user_var_events, sizeof(user_var_events));
/* Prepared statements */ /* Prepared statements */
last_prepared_stmt= 0; last_prepared_stmt= 0;
init_tree(&prepared_statements, 0, 0, sizeof(PREP_STMT), init_tree(&prepared_statements, 0, 0, sizeof(PREP_STMT),
...@@ -218,6 +215,7 @@ void THD::init(void) ...@@ -218,6 +215,7 @@ void THD::init(void)
warn_list.empty(); warn_list.empty();
bzero((char*) warn_count, sizeof(warn_count)); bzero((char*) warn_count, sizeof(warn_count));
total_warn_count= 0; total_warn_count= 0;
update_charset();
} }
......
...@@ -982,7 +982,6 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg) ...@@ -982,7 +982,6 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg)
buff[length-1] == ';')) buff[length-1] == ';'))
length--; length--;
buff[length]=0; buff[length]=0;
thd->current_tablenr=0;
thd->query_length=length; thd->query_length=length;
thd->query= thd->memdup_w_gap(buff, length+1, thd->db_length+1); thd->query= thd->memdup_w_gap(buff, length+1, thd->db_length+1);
thd->query[length] = '\0'; thd->query[length] = '\0';
...@@ -1085,7 +1084,6 @@ bool do_command(THD *thd) ...@@ -1085,7 +1084,6 @@ bool do_command(THD *thd)
DBUG_ENTER("do_command"); DBUG_ENTER("do_command");
net= &thd->net; net= &thd->net;
thd->current_tablenr=0;
/* /*
indicator of uninitialized lex => normal flow of errors handling indicator of uninitialized lex => normal flow of errors handling
(see my_message_sql) (see my_message_sql)
...@@ -1172,21 +1170,20 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1172,21 +1170,20 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
} }
#endif #endif
case COM_TABLE_DUMP: case COM_TABLE_DUMP:
{ {
statistic_increment(com_other, &LOCK_status); char *db, *tbl_name;
slow_command = TRUE; uint db_len= *(uchar*) packet;
uint db_len = *(uchar*)packet; uint tbl_len= *(uchar*) (packet + db_len + 1);
uint tbl_len = *(uchar*)(packet + db_len + 1);
char* db = thd->alloc(db_len + tbl_len + 2); statistic_increment(com_other, &LOCK_status);
memcpy(db, packet + 1, db_len); slow_command= TRUE;
char* tbl_name = db + db_len; db= thd->alloc(db_len + tbl_len + 2);
*tbl_name++ = 0; tbl_name= strmake(db, packet + 1, db_len)+1;
memcpy(tbl_name, packet + db_len + 2, tbl_len); strmake(tbl_name, packet + db_len + 2, tbl_len);
tbl_name[tbl_len] = 0; if (mysql_table_dump(thd, db, tbl_name, -1))
if (mysql_table_dump(thd, db, tbl_name, -1)) send_error(thd); // dump to NET
send_error(thd); // dump to NET break;
break; }
}
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
case COM_CHANGE_USER: case COM_CHANGE_USER:
{ {
...@@ -1703,9 +1700,9 @@ mysql_execute_command(THD *thd) ...@@ -1703,9 +1700,9 @@ mysql_execute_command(THD *thd)
} }
#ifndef TO_BE_DELETED #ifndef TO_BE_DELETED
/* /*
This is a workaround to deal with the shortcoming in 3.23.44-3.23.46 This is a workaround to deal with the shortcoming in 3.23.44-3.23.46
masters in RELEASE_LOCK() logging. We re-write SELECT RELEASE_LOCK() masters in RELEASE_LOCK() logging. We re-write SELECT RELEASE_LOCK()
as DO RELEASE_LOCK() as DO RELEASE_LOCK()
*/ */
if (lex->sql_command == SQLCOM_SELECT) if (lex->sql_command == SQLCOM_SELECT)
{ {
......
...@@ -1173,23 +1173,25 @@ rename_file_ext(const char * from,const char * to,const char * ext) ...@@ -1173,23 +1173,25 @@ rename_file_ext(const char * from,const char * to,const char * ext)
res result String res result String
RETURN VALUES RETURN VALUES
true string is empty 1 string is empty
false all ok 0 all ok
*/ */
bool get_field(MEM_ROOT *mem, Field *field, String *res) bool get_field(MEM_ROOT *mem, Field *field, String *res)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH], *to;
String str(buff,sizeof(buff),&my_charset_bin); String str(buff,sizeof(buff),&my_charset_bin);
uint length;
field->val_str(&str,&str); field->val_str(&str,&str);
uint length=str.length(); if (!(length= str.length()))
if (!length) return 1;
return true; to= strmake_root(mem, str.ptr(), length);
char *to= strmake_root(mem, str.ptr(), length); res->set(to, length, ((Field_str*)field)->charset());
res->set(to,length,((Field_str*)field)->charset()); return 0;
return false;
} }
/* /*
Allocate string field in MEM_ROOT and return it as NULL-terminated string Allocate string field in MEM_ROOT and return it as NULL-terminated string
...@@ -1205,14 +1207,15 @@ bool get_field(MEM_ROOT *mem, Field *field, String *res) ...@@ -1205,14 +1207,15 @@ bool get_field(MEM_ROOT *mem, Field *field, String *res)
char *get_field(MEM_ROOT *mem, Field *field) char *get_field(MEM_ROOT *mem, Field *field)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH], *to;
String str(buff,sizeof(buff),&my_charset_bin); String str(buff,sizeof(buff),&my_charset_bin);
uint length;
field->val_str(&str,&str); field->val_str(&str,&str);
uint length=str.length(); if (!(length= str.length()))
if (!length)
return NullS; return NullS;
char *to= (char*) alloc_root(mem,length+1); to= (char*) alloc_root(mem,length+1);
memcpy(to,str.ptr(),(uint) length); memcpy(to, str.ptr(), (uint) length);
to[length]=0; to[length]=0;
return to; return to;
} }
......
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