summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/event.cc10
-rw-r--r--sql/event.h1
-rw-r--r--sql/event_executor.cc2
-rw-r--r--sql/event_timed.cc25
-rw-r--r--sql/ha_ndbcluster.cc4
-rw-r--r--sql/ha_ndbcluster_binlog.cc42
-rw-r--r--sql/opt_range.cc9
-rw-r--r--sql/share/errmsg.txt2
-rw-r--r--sql/sql_show.cc14
-rw-r--r--sql/sql_yacc.yy18
10 files changed, 88 insertions, 39 deletions
diff --git a/sql/event.cc b/sql/event.cc
index 93f7e9c41d0..3fa41996995 100644
--- a/sql/event.cc
+++ b/sql/event.cc
@@ -623,10 +623,18 @@ evex_fill_row(THD *thd, TABLE *table, event_timed *et, my_bool is_update)
table->field[EVEX_FIELD_STATUS]->store((longlong)et->status);
+ /*
+ Change the SQL_MODE only if body was present in an ALTER EVENT and of course
+ always during CREATE EVENT.
+ */
if (et->body.str)
+ {
+ table->field[EVEX_FIELD_SQL_MODE]->store((longlong)thd->variables.sql_mode);
+
if (table->field[field_num= EVEX_FIELD_BODY]->
store(et->body.str, et->body.length, system_charset_info))
goto trunc_err;
+ }
if (et->starts.year)
{
@@ -1376,7 +1384,7 @@ evex_show_create_event(THD *thd, sp_name *spn, LEX_STRING definer)
char show_str_buf[768];
String show_str(show_str_buf, sizeof(show_str_buf), system_charset_info);
List<Item> field_list;
- const char *sql_mode_str;
+ byte *sql_mode_str;
ulong sql_mode_len=0;
show_str.length(0);
diff --git a/sql/event.h b/sql/event.h
index 6df6267abc4..4adacdd4e3a 100644
--- a/sql/event.h
+++ b/sql/event.h
@@ -112,7 +112,6 @@ public:
enum enum_event_status status;
sp_head *sphead;
ulong sql_mode;
-
const uchar *body_begin;
bool dropped;
diff --git a/sql/event_executor.cc b/sql/event_executor.cc
index 9483c2ab165..b6c6981fd7d 100644
--- a/sql/event_executor.cc
+++ b/sql/event_executor.cc
@@ -268,7 +268,7 @@ init_event_thread(THD* thd)
thd->client_capabilities= 0;
thd->security_ctx->master_access= 0;
thd->security_ctx->db_access= 0;
- thd->security_ctx->host= (char*)my_localhost;
+ thd->security_ctx->host_or_ip= (char*)my_localhost;
my_net_init(&thd->net, 0);
thd->net.read_timeout = slave_net_timeout;
thd->slave_thread= 0;
diff --git a/sql/event_timed.cc b/sql/event_timed.cc
index 6440e221732..a1ec7f6b718 100644
--- a/sql/event_timed.cc
+++ b/sql/event_timed.cc
@@ -45,6 +45,8 @@ event_timed::init()
definer_user.str= definer_host.str= 0;
definer_user.length= definer_host.length= 0;
+ sql_mode= 0;
+
DBUG_VOID_RETURN;
}
@@ -109,17 +111,21 @@ void
event_timed::init_body(THD *thd)
{
DBUG_ENTER("event_timed::init_body");
- MEM_ROOT *root= thd->mem_root;
+ DBUG_PRINT("info", ("body=[%s] body_begin=0x%ld end=0x%ld", body_begin,
+ body_begin, thd->lex->ptr));
body.length= thd->lex->ptr - body_begin;
// Trim nuls at the end
while (body.length && body_begin[body.length-1] == '\0')
body.length--;
- //the first is always space which I cannot skip in the parser
- DBUG_ASSERT(*body_begin == ' ');
- body.length--;
- body.str= strmake_root(root, (char *)body_begin + 1, body.length);
+ /* the first is always whitespace which I cannot skip in the parser */
+ while (my_isspace(thd->variables.character_set_client, *body_begin))
+ {
+ ++body_begin;
+ --body.length;
+ }
+ body.str= strmake_root(thd->mem_root, (char *)body_begin, body.length);
DBUG_VOID_RETURN;
}
@@ -579,6 +585,9 @@ event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table)
et->comment.length= strlen(et->comment.str);
else
et->comment.length= 0;
+
+
+ et->sql_mode= (ulong) table->field[EVEX_FIELD_SQL_MODE]->val_int();
DBUG_RETURN(0);
error:
@@ -1232,6 +1241,7 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root)
char *old_query;
uint old_query_len;
st_sp_chistics *p;
+ ulong old_sql_mode= thd->variables.sql_mode;
char create_buf[2048];
String show_create(create_buf, sizeof(create_buf), system_charset_info);
CHARSET_INFO *old_character_set_client,
@@ -1251,6 +1261,8 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root)
thd->update_charset();
DBUG_ENTER("event_timed::compile");
+ DBUG_PRINT("info",("old_sql_mode=%d new_sql_mode=%d",old_sql_mode, sql_mode));
+ thd->variables.sql_mode= this->sql_mode;
/* Change the memory root for the execution time */
if (mem_root)
{
@@ -1302,7 +1314,7 @@ event_timed::compile(THD *thd, MEM_ROOT *mem_root)
TODO: Handle sql_mode!!
*/
sphead->set_definer(definer.str, definer.length);
- sphead->set_info(0, 0, &lex.sp_chistics, 0/*sql_mode*/);
+ sphead->set_info(0, 0, &lex.sp_chistics, sql_mode);
sphead->optimize();
ret= 0;
done:
@@ -1316,6 +1328,7 @@ done:
thd->query_length= old_query_len;
thd->db= old_db;
+ thd->variables.sql_mode= old_sql_mode;
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;
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 33c2e7869af..404d046ea9d 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -5519,7 +5519,7 @@ int ndbcluster_find_all_files(THD *thd)
{
NDBDICT::List::Element& elmt= list.elements[i];
int do_handle_table= 0;
- if (IS_TMP_PREFIX(elmt.name))
+ if (IS_TMP_PREFIX(elmt.name) || IS_NDB_BLOB_PREFIX(elmt.name))
{
DBUG_PRINT("info", ("Skipping %s.%s in NDB", elmt.database, elmt.name));
continue;
@@ -5656,7 +5656,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
for (i= 0 ; i < list.count ; i++)
{
NDBDICT::List::Element& elmt= list.elements[i];
- if (IS_TMP_PREFIX(elmt.name))
+ if (IS_TMP_PREFIX(elmt.name) || IS_NDB_BLOB_PREFIX(elmt.name))
{
DBUG_PRINT("info", ("Skipping %s.%s in NDB", elmt.database, elmt.name));
continue;
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc
index c6252d7cfd4..28756c54c7f 100644
--- a/sql/ha_ndbcluster_binlog.cc
+++ b/sql/ha_ndbcluster_binlog.cc
@@ -2080,7 +2080,19 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab,
DBUG_RETURN(-1);
}
- NdbEventOperation *op= ndb->createEventOperation(event_name);
+ NdbEventOperation* op;
+ if (do_schema_share)
+ op= ndb->createEventOperation(event_name);
+ else
+ {
+ // set injector_ndb database/schema from table internal name
+ int ret= ndb->setDatabaseAndSchemaName(ndbtab);
+ assert(ret == 0);
+ op= ndb->createEventOperation(event_name);
+ // reset to catch errors
+ ndb->setDatabaseName("");
+ ndb->setDatabaseSchemaName("");
+ }
if (!op)
{
pthread_mutex_unlock(&injector_mutex);
@@ -2097,23 +2109,6 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab,
if (share->flags & NSF_BLOB_FLAG)
op->mergeEvents(true); // currently not inherited from event
- if (share->flags & NSF_BLOB_FLAG)
- {
- /*
- * Given servers S1 S2, following results in out-of-date
- * event->m_tableImpl and column->m_blobTable.
- *
- * S1: create table t1(a int primary key);
- * S2: drop table t1;
- * S1: create table t2(a int primary key, b blob);
- * S1: alter table t2 add x int;
- * S1: alter table t2 drop x;
- *
- * TODO fix at right place before we get here
- */
- ndb->getDictionary()->fix_blob_events(ndbtab, event_name);
- }
-
int n_columns= ndbtab->getNoOfColumns();
int n_fields= table ? table->s->fields : 0; // XXX ???
for (int j= 0; j < n_columns; j++)
@@ -2664,7 +2659,8 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
goto err;
}
- if (!(ndb= new Ndb(g_ndb_cluster_connection, "")) ||
+ // empty database and schema
+ if (!(ndb= new Ndb(g_ndb_cluster_connection, "", "")) ||
ndb->init())
{
sql_print_error("NDB Binlog: Getting Ndb object failed");
@@ -2921,7 +2917,15 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
(unsigned) NDBEVENT::TE_FIRST_NON_DATA_EVENT)
ndb_binlog_thread_handle_data_event(ndb, pOp, row, trans);
else
+ {
+ // set injector_ndb database/schema from table internal name
+ int ret= ndb->setDatabaseAndSchemaName(pOp->getEvent()->getTable());
+ assert(ret == 0);
ndb_binlog_thread_handle_non_data_event(ndb, pOp, row);
+ // reset to catch errors
+ ndb->setDatabaseName("");
+ ndb->setDatabaseSchemaName("");
+ }
pOp= ndb->nextEvent();
} while (pOp && pOp->getGCI() == gci);
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index ef6b3d941a1..1146ea2428d 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1951,9 +1951,12 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
read_time= (double) HA_POS_ERROR;
goto free_mem;
}
- if (tree->type != SEL_TREE::KEY &&
- tree->type != SEL_TREE::KEY_SMALLER)
- goto free_mem;
+ /*
+ If the tree can't be used for range scans, proceed anyway, as we
+ can construct a group-min-max quick select
+ */
+ if (tree->type != SEL_TREE::KEY && tree->type != SEL_TREE::KEY_SMALLER)
+ tree= NULL;
}
}
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index 544f2a9911e..73d1abf8fdd 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5810,5 +5810,7 @@ ER_ILLEGAL_HA_CREATE_OPTION
eng "Table storage engine '%-.64s' does not support the create option '%.64s'"
ER_CANT_CHANGE_TX_ISOLATION 25001
eng "Transaction isolation level can't be changed while a transaction is in progress"
+ER_WARN_DEPRECATED_STATEMENT
+ eng "The '%s' statement is deprecated and will be removed in MySQL %s. Please use client programs (e.g. %s) instead."
ER_TABLE_LOG_ERROR
eng "Error in table log"
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index f732a3ecbd6..5b25141ee28 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3954,8 +3954,16 @@ fill_events_copy_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
sch_table->field[3]->store(et.definer.str, et.definer.length, scs);
sch_table->field[4]->store(et.body.str, et.body.length, scs);
- // [9] is SQL_MODE and is NULL for now, will be fixed later
- sch_table->field[9]->set_null();
+ // [9] is SQL_MODE
+ {
+ byte *sql_mode_str;
+ ulong sql_mode_len=0;
+ sql_mode_str=
+ sys_var_thd_sql_mode::symbolic_mode_representation(thd, et.sql_mode,
+ &sql_mode_len);
+ sch_table->field[9]->store((const char*)sql_mode_str, sql_mode_len, scs);
+ }
+
if (et.expression)
{
String show_str;
@@ -4802,7 +4810,7 @@ ST_FIELD_INFO events_fields_info[]=
{"EXECUTE_AT", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Execute at"},
{"INTERVAL_VALUE", 256, MYSQL_TYPE_STRING, 0, 1, "Interval value"},
{"INTERVAL_FIELD", 18, MYSQL_TYPE_STRING, 0, 1, "Interval field"},
- {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
{"STARTS", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Starts"},
{"ENDS", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Ends"},
{"STATUS", 8, MYSQL_TYPE_STRING, 0, 0, "Status"},
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 5cfd33ccfca..4788b405a7a 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -5289,7 +5289,11 @@ restore:
RESTORE_SYM table_or_tables
{
Lex->sql_command = SQLCOM_RESTORE_TABLE;
- WARN_DEPRECATED("RESTORE TABLE", "Command will be removed in next version.");
+ push_warning_printf(((THD *)yythd), MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_WARN_DEPRECATED_STATEMENT,
+ ER(ER_WARN_DEPRECATED_STATEMENT),
+ "RESTORE TABLE", "5.2",
+ "mysqldump, mysql, MySQL Administrator");
}
table_list FROM TEXT_STRING_sys
{
@@ -5300,7 +5304,11 @@ backup:
BACKUP_SYM table_or_tables
{
Lex->sql_command = SQLCOM_BACKUP_TABLE;
- WARN_DEPRECATED("BACKUP TABLE", "Command will be removed in next version.");
+ push_warning_printf(((THD *)yythd), MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_WARN_DEPRECATED_STATEMENT,
+ ER(ER_WARN_DEPRECATED_STATEMENT),
+ "BACKUP TABLE", "5.2",
+ "mysqldump, mysql, MySQL Administrator");
}
table_list TO_SYM TEXT_STRING_sys
{
@@ -8607,7 +8615,11 @@ load: LOAD DATA_SYM
LOAD TABLE_SYM table_ident FROM MASTER_SYM
{
LEX *lex=Lex;
- WARN_DEPRECATED("LOAD TABLE from MASTER", "Command will be removed in next version.");
+ push_warning_printf(((THD *)yythd), MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_WARN_DEPRECATED_STATEMENT,
+ ER(ER_WARN_DEPRECATED_STATEMENT),
+ "LOAD TABLE FROM MASTER", "5.2",
+ "mysqldump, mysql, MySQL Administrator");
if (lex->sphead)
{
my_error(ER_SP_BADSTATEMENT, MYF(0), "LOAD TABLE");