summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-08-19 16:00:12 +0300
committerunknown <monty@mashka.mysql.fi>2003-08-19 16:00:12 +0300
commit7616d453bd5c96e7d447153814d1cb9c53880028 (patch)
tree7e42515465680bf9479f44de0c710044aa122610 /sql
parent1ad7a65da1f3d6311ae4469ea7c5895f7b178fe2 (diff)
downloadmariadb-git-7616d453bd5c96e7d447153814d1cb9c53880028.tar.gz
After merge fixes + bugs from last merge
mysql-test/mysql-test-run.sh: Use --skip-bdb with valgrind (as bdb tables causes valgrind to hang) Fix --ddd option mysql-test/t/union.test: After merge fix sql/item.cc: Fixed typo sql/log_event.cc: Move current_tablenr to open_tables() sql/protocol.h: Fixed wrong memory reference sql/set_var.cc: After merge fix sql/slave.cc: Reset thd->lex.current_select before execute sql/sql_base.cc: Move current_tablenr to open_tables() sql/sql_class.cc: Move current_tablenr to open_tables() Add missing update_charset() sql/sql_parse.cc: Move current_tablenr to open_tables() Simple cleanup sql/table.cc: Code cleanup
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc2
-rw-r--r--sql/log_event.cc2
-rw-r--r--sql/protocol.h2
-rw-r--r--sql/set_var.cc4
-rw-r--r--sql/slave.cc8
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_parse.cc37
-rw-r--r--sql/table.cc31
9 files changed, 47 insertions, 45 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 17b0519b61c..060aa2b63a1 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -50,7 +50,7 @@ Item::Item():
next= thd->free_list; // Put in free list
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
can be uninitialised)
*/
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 3b04baf7ae7..8a52ad9ebca 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -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))
{
thd->set_time((time_t)when);
- thd->current_tablenr = 0;
thd->query_length= q_len;
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = (char*)query;
@@ -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))
{
thd->set_time((time_t)when);
- thd->current_tablenr = 0;
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id = query_id++;
VOID(pthread_mutex_unlock(&LOCK_thread_count));
diff --git a/sql/protocol.h b/sql/protocol.h
index ffd61b3e848..05aee12d3d9 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -61,7 +61,7 @@ public:
inline bool store(ulonglong from)
{ return store_longlong((longlong) from, 1); }
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)
{
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 499eed132a7..91583759c70 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -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",
max_binlog_size, max_relay_log_size));
mysql_bin_log.set_max_size(max_binlog_size);
-#ifdef REPLICATION
+#ifdef HAVE_REPLICATION
if (!max_relay_log_size)
active_mi->rli.relay_log.set_max_size(max_binlog_size);
#endif
@@ -835,8 +835,10 @@ void fix_max_relay_log_size(THD *thd, enum_var_type type)
DBUG_ENTER("fix_max_relay_log_size");
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
max_binlog_size, max_relay_log_size));
+#ifdef HAVE_REPLICATION
active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
max_relay_log_size: max_binlog_size);
+#endif
DBUG_VOID_RETURN;
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 16d493f1667..d45cf1aa8b9 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1137,7 +1137,6 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
return 1;
}
thd->query= query;
- thd->current_tablenr = 0;
thd->query_error = 0;
thd->net.no_send_ok = 1;
@@ -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_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_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_empty_string("Last_error", 20));
field_list.push_back(new Item_return_int("Skip_counter", 10,
@@ -1838,7 +1838,8 @@ int show_master_info(THD* thd, MASTER_INFO* mi)
protocol->store(mi->master_log_name, &my_charset_bin);
protocol->store((ulonglong) mi->master_log_pos);
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(mi->rli.group_master_log_name, &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)
thd->server_id = ev->server_id; // use the original server id for logging
thd->set_time(); // time the query
+ thd->lex.current_select= 0;
if (!ev->when)
ev->when = time(NULL);
ev->thd = thd;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index fd0768d6ae7..b6c84be5363 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1355,6 +1355,7 @@ int open_tables(THD *thd,TABLE_LIST *start)
int result=0;
DBUG_ENTER("open_tables");
+ thd->current_tablenr= 0;
restart:
thd->proc_info="Opening tables";
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)
DBUG_ENTER("open_ltable");
thd->proc_info="Opening table";
+ thd->current_tablenr= 0;
while (!(table=open_table(thd,table_list->db,
table_list->real_name,table_list->alias,
&refresh)) && refresh) ;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index c29e7ca2213..763408dc5c2 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -96,7 +96,6 @@ THD::THD():user_time(0), is_fatal_error(0),
query_error= tmp_table_used= 0;
next_insert_id=last_insert_id=0;
open_tables= temporary_tables= handler_tables= derived_tables= 0;
- current_tablenr=0;
handler_items=0;
tmp_table=0;
lock=locked_tables=0;
@@ -161,8 +160,6 @@ THD::THD():user_time(0), is_fatal_error(0),
else
bzero((char*) &user_var_events, sizeof(user_var_events));
-
-
/* Prepared statements */
last_prepared_stmt= 0;
init_tree(&prepared_statements, 0, 0, sizeof(PREP_STMT),
@@ -218,6 +215,7 @@ void THD::init(void)
warn_list.empty();
bzero((char*) warn_count, sizeof(warn_count));
total_warn_count= 0;
+ update_charset();
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 694d1148867..fad388dca7f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -982,7 +982,6 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg)
buff[length-1] == ';'))
length--;
buff[length]=0;
- thd->current_tablenr=0;
thd->query_length=length;
thd->query= thd->memdup_w_gap(buff, length+1, thd->db_length+1);
thd->query[length] = '\0';
@@ -1085,7 +1084,6 @@ bool do_command(THD *thd)
DBUG_ENTER("do_command");
net= &thd->net;
- thd->current_tablenr=0;
/*
indicator of uninitialized lex => normal flow of errors handling
(see my_message_sql)
@@ -1172,21 +1170,20 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
#endif
case COM_TABLE_DUMP:
- {
- statistic_increment(com_other, &LOCK_status);
- slow_command = TRUE;
- uint db_len = *(uchar*)packet;
- uint tbl_len = *(uchar*)(packet + db_len + 1);
- char* db = thd->alloc(db_len + tbl_len + 2);
- memcpy(db, packet + 1, db_len);
- char* tbl_name = db + db_len;
- *tbl_name++ = 0;
- memcpy(tbl_name, packet + db_len + 2, tbl_len);
- tbl_name[tbl_len] = 0;
- if (mysql_table_dump(thd, db, tbl_name, -1))
- send_error(thd); // dump to NET
- break;
- }
+ {
+ char *db, *tbl_name;
+ uint db_len= *(uchar*) packet;
+ uint tbl_len= *(uchar*) (packet + db_len + 1);
+
+ statistic_increment(com_other, &LOCK_status);
+ slow_command= TRUE;
+ db= thd->alloc(db_len + tbl_len + 2);
+ tbl_name= strmake(db, packet + 1, db_len)+1;
+ strmake(tbl_name, packet + db_len + 2, tbl_len);
+ if (mysql_table_dump(thd, db, tbl_name, -1))
+ send_error(thd); // dump to NET
+ break;
+ }
#ifndef EMBEDDED_LIBRARY
case COM_CHANGE_USER:
{
@@ -1703,9 +1700,9 @@ mysql_execute_command(THD *thd)
}
#ifndef TO_BE_DELETED
/*
- 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()
- as DO RELEASE_LOCK()
+ 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()
+ as DO RELEASE_LOCK()
*/
if (lex->sql_command == SQLCOM_SELECT)
{
diff --git a/sql/table.cc b/sql/table.cc
index a76bdc84690..9d12de1f6c7 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1173,23 +1173,25 @@ rename_file_ext(const char * from,const char * to,const char * ext)
res result String
RETURN VALUES
- true string is empty
- false all ok
+ 1 string is empty
+ 0 all ok
*/
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);
+ uint length;
+
field->val_str(&str,&str);
- uint length=str.length();
- if (!length)
- return true;
- char *to= strmake_root(mem, str.ptr(), length);
- res->set(to,length,((Field_str*)field)->charset());
- return false;
+ if (!(length= str.length()))
+ return 1;
+ to= strmake_root(mem, str.ptr(), length);
+ res->set(to, length, ((Field_str*)field)->charset());
+ return 0;
}
+
/*
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)
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);
+ uint length;
+
field->val_str(&str,&str);
- uint length=str.length();
- if (!length)
+ if (!(length= str.length()))
return NullS;
- char *to= (char*) alloc_root(mem,length+1);
- memcpy(to,str.ptr(),(uint) length);
+ to= (char*) alloc_root(mem,length+1);
+ memcpy(to, str.ptr(), (uint) length);
to[length]=0;
return to;
}