Below is the list of changes that have just been committed into a local
5.1 repository of andrey. When andrey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1992 05/12/08 20:37:54 andrey@lmy004. +4 -0
WL #1034 update
- handle better non-latin1 identifiers
sql/share/errmsg.txt
1.62 05/12/08 20:37:48 andrey@lmy004. +2 -0
add new error message
sql/event_timed.cc
1.8 05/12/08 20:37:48 andrey@lmy004. +26 -2
- fix a problem when event name is not latin1. a cyrillic event name
was crashing the parser so the I emulate SET NAMES utf8. The data is
already in utf8, being loaded from the disk.
sql/event_executor.cc
1.6 05/12/08 20:37:48 andrey@lmy004. +10 -1
- comment about DBUG_FAULTY_THR
- indent fix
sql/event.cc
1.9 05/12/08 20:37:48 andrey@lmy004. +49 -37
- introduce a wrapper to compare easily and correctly
LEX_STRINGs
- remove few unneeded variables
- remove need_second_pass by restructuring the code. this brings
performance boost because the code bails out from the loop once
it hits what it looks for
- handle ALTER EVENT name RENAME TO name (throw an error message).
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: andrey
# Host: lmy004.
# Root: /work/mysql-5.1-tt-copy-works
--- 1.8/sql/event.cc 2005-12-08 15:34:03 +01:00
+++ 1.9/sql/event.cc 2005-12-08 20:37:48 +01:00
@@ -89,6 +89,15 @@
a < b -> -1
*/
+static
+int sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs)
+{
+ return cs->coll->strnncollsp(cs,
+ (unsigned char *) s.str,s.length,
+ (unsigned char *) t.str,t.length, 0);
+}
+
+
inline int
my_time_compare(TIME *a, TIME *b)
{
@@ -472,11 +481,20 @@
}
// first look whether we overwrite
- if (new_name && !evex_db_find_event_aux(thd, new_name->m_db,
new_name->m_name,
- table))
+ if (new_name)
{
- my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), new_name->m_name.str);
- goto err;
+ if (!sortcmp_lex_string(et->name, new_name->m_name, system_charset_info)
&&
+ !sortcmp_lex_string(et->dbname, new_name->m_db, system_charset_info))
+ {
+ my_error(ER_EVENT_SAME_NAME, MYF(0), et->name.str);
+ goto err;
+ }
+
+ if (!evex_db_find_event_aux(thd, new_name->m_db, new_name->m_name, table))
+ {
+ my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), new_name->m_name.str);
+ goto err;
+ }
}
/*
...and then whether there is such an event. don't exchange the blocks
@@ -676,7 +694,6 @@
evex_remove_from_cache(LEX_STRING *db, LEX_STRING *name, bool use_lock)
{
uint i;
- bool need_second_pass= true;
DBUG_ENTER("evex_remove_from_cache");
/*
@@ -689,37 +706,31 @@
for (i= 0; i < evex_executing_queue.elements; ++i)
{
- event_timed **p_et= dynamic_element(&evex_executing_queue, i, event_timed**);
- event_timed *ett= *p_et;
- DBUG_PRINT("info", ("[%s.%s]==[%s.%s]?",db->str,name->str,
- ett->dbname.str, ett->name.str));
- if (name->length == ett->name.length &&
- db->length == ett->dbname.length &&
- 0 == strncmp(db->str, ett->dbname.str, db->length) &&
- 0 == strncmp(name->str, ett->name.str, name->length)
- )
+ event_timed *et= *dynamic_element(&evex_executing_queue, i, event_timed**);
+ DBUG_PRINT("info", ("[%s.%s]==[%s.%s]?",db->str,name->str, et->dbname.str,
+ et->name.str));
+ if (!sortcmp_lex_string(*name, et->name, system_charset_info) &&
+ !sortcmp_lex_string(*db, et->dbname, system_charset_info))
{
- int idx;
+ int idx= get_index_dynamic(&events_array, (gptr) et);
//we are lucky the event is in the executing queue, no need of second pass
- need_second_pass= false;
- idx= get_index_dynamic(&events_array, (gptr) ett);
if (idx == -1)
{
//this should never happen
DBUG_PRINT("error", (" get_index_dynamic problem. %d."
- "i=%d idx=%d evex_ex_queue.buf=%p evex_ex_queue.elements=%d ett=%p\n"
- "events_array=%p events_array.elements=%d events_array.buf=%p\n"
- "p_et=%p ett=%p",
- __LINE__, i, idx, &evex_executing_queue.buffer,
- evex_executing_queue.elements, ett, &events_array,
- events_array.elements, events_array.buffer, p_et, ett));
+ "i=%d idx=%d evex_ex_queue.buf=%p evex_ex_queue.elements=%d et=%p\n"
+ "events_array=%p events_array.elements=%d events_array.buf=%p et=%p\n",
+ __LINE__, i, idx, &evex_executing_queue.buffer,
+ evex_executing_queue.elements, et, &events_array,
+ events_array.elements, events_array.buffer, et));
DBUG_ASSERT(0);
}
//destruct first and then remove. the destructor will delete sp_head
- ett->free_sp();
+ et->free_sp();
delete_dynamic_element(&events_array, idx);
delete_dynamic_element(&evex_executing_queue, i);
// ok, we have cleaned
+ goto done;
}
}
@@ -733,20 +744,21 @@
For instance, second_pass is needed when an event
was created as DISABLED but then altered as ENABLED.
*/
- if (need_second_pass)
- //we haven't found the event in the executing queue. This is nice! :)
- //Look for it in the events_array.
- for (i= 0; i < events_array.elements; ++i)
+ /*
+ we haven't found the event in the executing queue. This is nice! :)
+ Look for it in the events_array.
+ */
+ for (i= 0; i < events_array.elements; ++i)
+ {
+ event_timed *et= dynamic_element(&events_array, i, event_timed*);
+
+ if (!sortcmp_lex_string(*name, et->name, system_charset_info) &&
+ !sortcmp_lex_string(*db, et->dbname, system_charset_info))
{
- event_timed *ett= dynamic_element(&events_array, i, event_timed*);
-
- if (name->length == ett->name.length &&
- db->length == ett->dbname.length &&
- 0 == strncmp(db->str, ett->dbname.str, db->length) &&
- 0 == strncmp(name->str, ett->name.str, name->length)
- )
- delete_dynamic_element(&events_array, i);
- }
+ delete_dynamic_element(&events_array, i);
+ break;
+ }
+ }
done:
if (use_lock)
--- 1.5/sql/event_executor.cc 2005-12-08 00:16:58 +01:00
+++ 1.6/sql/event_executor.cc 2005-12-08 20:37:48 +01:00
@@ -19,6 +19,15 @@
#include "event_priv.h"
#include "sp.h"
+
+/*
+ Make this define DBUG_FAULTY_THR to be able to put breakpoints inside
+ code used by the scheduler's thread(s). In this case user connections
+ are not possible because the scheduler thread code is ran inside the
+ main thread (no spawning takes place. If you want to debug client
+ connection then start with --one-thread and make the define
+ DBUG_FAULTY_THR2 !
+*/
#define DBUG_FAULTY_THR2
extern ulong thread_created;
@@ -204,7 +213,7 @@
VOID(pthread_mutex_unlock(&LOCK_evex_running));
if (evex_load_events_from_db(thd))
- goto err;
+ goto err;
THD_CHECK_SENTRY(thd);
/* Read queries from the IO/THREAD until this thread is killed */
--- 1.7/sql/event_timed.cc 2005-12-08 15:34:04 +01:00
+++ 1.8/sql/event_timed.cc 2005-12-08 20:37:48 +01:00
@@ -904,6 +904,7 @@
int
event_timed::compile(THD *thd, MEM_ROOT *mem_root)
{
+ int ret= 0;
MEM_ROOT *tmp_mem_root= 0;
LEX *old_lex= thd->lex, lex;
char *old_db;
@@ -912,6 +913,19 @@
char *old_query;
uint old_query_len;
st_sp_chistics *p;
+ CHARSET_INFO *old_character_set_client, *old_collation_connection,
+ *old_character_set_results;
+
+ old_character_set_client= thd->variables.character_set_client;
+ old_character_set_results= thd->variables.character_set_results;
+ old_collation_connection= thd->variables.collation_connection;
+
+ thd->variables.character_set_client=
+ thd->variables.character_set_results=
+ thd->variables.collation_connection=
+ get_charset_by_csname("utf8", MY_CS_PRIMARY, MYF(MY_WME));
+
+ thd->update_charset();
DBUG_ENTER("event_timed::compile");
// change the memory root for the execution time
@@ -944,7 +958,9 @@
// QQ: anything else ?
lex_end(&lex);
thd->lex= old_lex;
- DBUG_RETURN(EVEX_COMPILE_ERROR);
+
+ ret= EVEX_COMPILE_ERROR;
+ goto done;
}
sphead= lex.sphead;
@@ -954,17 +970,25 @@
sphead->set_definer(definer.str, definer.length);
sphead->set_info(0, 0, &lex.sp_chistics, 0/*sql_mode*/);
sphead->optimize();
+ ret= 0;
+done:
lex_end(&lex);
thd->lex= old_lex;
thd->query= old_query;
thd->query_length= old_query_len;
thd->db= old_db;
+
+ thd->variables.character_set_client= old_character_set_client;
+ thd->variables.character_set_results= old_character_set_results;
+ thd->variables.collation_connection= old_collation_connection;
+ thd->update_charset();
+
/*
Change the memory root for the execution time.
*/
if (mem_root)
thd->mem_root= tmp_mem_root;
- DBUG_RETURN(0);
+ DBUG_RETURN(ret);
}
--- 1.61/sql/share/errmsg.txt 2005-12-08 15:34:04 +01:00
+++ 1.62/sql/share/errmsg.txt 2005-12-08 20:37:48 +01:00
@@ -5749,3 +5749,5 @@
eng "Failed to delete the event from mysql.event"
ER_EVENT_COMPILE_ERROR
eng "Error during compilation of event's body"
+ER_EVENT_SAME_NAME
+ eng "Same old and new event name"
| Thread |
|---|
| • bk commit into 5.1 tree (andrey:1.1992) | ahristov | 8 Dec |