summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/Makefile.am3
-rw-r--r--sql/field.cc3
-rw-r--r--sql/field.h7
-rw-r--r--sql/filesort.cc19
-rw-r--r--sql/ha_ndbcluster.cc25
-rw-r--r--sql/handler.cc47
-rw-r--r--sql/item.cc10
-rw-r--r--sql/item.h7
-rw-r--r--sql/item_cmpfunc.cc18
-rw-r--r--sql/item_func.cc42
-rw-r--r--sql/item_strfunc.cc2
-rw-r--r--sql/log.cc2
-rw-r--r--sql/my_decimal.h1
-rw-r--r--sql/mysql_priv.h3
-rw-r--r--sql/mysqld.cc8
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/sql_class.h5
-rw-r--r--sql/sql_insert.cc42
-rw-r--r--sql/sql_parse.cc25
-rw-r--r--sql/sql_partition.cc9
-rw-r--r--sql/sql_plugin.h3
-rw-r--r--sql/sql_prepare.cc10
-rw-r--r--sql/sql_select.cc5
-rw-r--r--sql/sql_show.cc95
-rw-r--r--sql/sql_table.cc78
-rw-r--r--sql/sql_yacc.yy8
-rw-r--r--sql/table.cc3
-rw-r--r--sql/table.h1
28 files changed, 296 insertions, 187 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am
index d280b22f493..fdf3f88c1f8 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -38,7 +38,8 @@ mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
@pstack_libs@ \
@mysql_plugin_libs@ \
$(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ \
- $(yassl_libs) $(openssl_libs)
+ $(yassl_libs) $(openssl_libs) \
+ @MYSQLD_EXTRA_LIBS@
noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
item_strfunc.h item_timefunc.h \
diff --git a/sql/field.cc b/sql/field.cc
index 82fe63ea78a..e6713e548ab 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -6395,7 +6395,8 @@ uint Field_string::get_key_image(uchar *buff, uint length, imagetype type_arg)
length / field_charset->mbmaxlen);
memcpy(buff, ptr, bytes);
if (bytes < length)
- bzero(buff + bytes, length - bytes);
+ field_charset->cset->fill(field_charset, (char*) buff + bytes,
+ length - bytes, field_charset->pad_char);
return bytes;
}
diff --git a/sql/field.h b/sql/field.h
index b3a773ddddf..3b4784adb2b 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -423,6 +423,12 @@ public:
return field_length / charset()->mbmaxlen;
}
+ virtual geometry_type get_geometry_type()
+ {
+ /* shouldn't get here. */
+ DBUG_ASSERT(0);
+ return GEOM_GEOMETRY;
+ }
/* Hash value */
virtual void hash(ulong *nr, ulong *nr2);
friend bool reopen_table(THD *,struct st_table *,bool);
@@ -1415,6 +1421,7 @@ public:
uint get_key_image(uchar *buff,uint length,imagetype type);
uint size_of() const { return sizeof(*this); }
int reset(void) { return !maybe_null() || Field_blob::reset(); }
+ geometry_type get_geometry_type() { return geom_type; };
};
#endif /*HAVE_SPATIAL*/
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 1d443e85327..b1dfb4d5e71 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -35,7 +35,8 @@ if (my_b_write((file),(uchar*) (from),param->ref_length)) \
/* functions defined in this file */
-static char **make_char_array(register uint fields, uint length, myf my_flag);
+static char **make_char_array(char **old_pos, register uint fields,
+ uint length, myf my_flag);
static BUFFPEK *read_buffpek_from_file(IO_CACHE *buffer_file, uint count);
static ha_rows find_all_keys(SORTPARAM *param,SQL_SELECT *select,
uchar * *sort_keys, IO_CACHE *buffer_file,
@@ -208,9 +209,9 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
ulong old_memavl;
ulong keys= memavl/(param.rec_length+sizeof(char*));
param.keys=(uint) min(records+1, keys);
- if (table_sort.sort_keys ||
- (table_sort.sort_keys= (uchar **) make_char_array(param.keys, param.rec_length,
- MYF(0))))
+ if ((table_sort.sort_keys=
+ (uchar **) make_char_array((char **) table_sort.sort_keys,
+ param.keys, param.rec_length, MYF(0))))
break;
old_memavl=memavl;
if ((memavl=memavl/4*3) < min_sort_memory && old_memavl > min_sort_memory)
@@ -352,14 +353,16 @@ void filesort_free_buffers(TABLE *table, bool full)
/* Make a array of string pointers */
-static char **make_char_array(register uint fields, uint length, myf my_flag)
+static char **make_char_array(char **old_pos, register uint fields,
+ uint length, myf my_flag)
{
register char **pos;
- char **old_pos,*char_pos;
+ char *char_pos;
DBUG_ENTER("make_char_array");
- if ((old_pos= (char**) my_malloc((uint) fields*(length+sizeof(char*)),
- my_flag)))
+ if (old_pos ||
+ (old_pos= (char**) my_malloc((uint) fields*(length+sizeof(char*)),
+ my_flag)))
{
pos=old_pos; char_pos=((char*) (pos+fields)) -length;
while (fields--) *(pos++) = (char_pos+= length);
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index aeaea90feb6..2eb3826ebee 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -278,11 +278,6 @@ inline
int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans,
bool force_release)
{
-#ifdef NOT_USED
- int m_batch_execute= 0;
- if (m_batch_execute)
- return 0;
-#endif
h->release_completed_operations(trans, force_release);
return h->m_ignore_no_key ?
execute_no_commit_ignore_no_key(h,trans) :
@@ -294,11 +289,6 @@ int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans,
inline
int execute_commit(ha_ndbcluster *h, NdbTransaction *trans)
{
-#ifdef NOT_USED
- int m_batch_execute= 0;
- if (m_batch_execute)
- return 0;
-#endif
return trans->execute(NdbTransaction::Commit,
NdbOperation::AbortOnError,
h->m_force_send);
@@ -307,11 +297,6 @@ int execute_commit(ha_ndbcluster *h, NdbTransaction *trans)
inline
int execute_commit(THD *thd, NdbTransaction *trans)
{
-#ifdef NOT_USED
- int m_batch_execute= 0;
- if (m_batch_execute)
- return 0;
-#endif
return trans->execute(NdbTransaction::Commit,
NdbOperation::AbortOnError,
thd->variables.ndb_force_send);
@@ -321,11 +306,6 @@ inline
int execute_no_commit_ie(ha_ndbcluster *h, NdbTransaction *trans,
bool force_release)
{
-#ifdef NOT_USED
- int m_batch_execute= 0;
- if (m_batch_execute)
- return 0;
-#endif
h->release_completed_operations(trans, force_release);
return trans->execute(NdbTransaction::NoCommit,
NdbOperation::AO_IgnoreError,
@@ -2925,7 +2905,8 @@ int ha_ndbcluster::update_row(const uchar *old_data, uchar *new_data)
* If IGNORE the ignore constraint violations on primary and unique keys,
* but check that it is not part of INSERT ... ON DUPLICATE KEY UPDATE
*/
- if (m_ignore_dup_key && thd->lex->sql_command == SQLCOM_UPDATE)
+ if (m_ignore_dup_key && (thd->lex->sql_command == SQLCOM_UPDATE ||
+ thd->lex->sql_command == SQLCOM_UPDATE_MULTI))
{
int peek_res= peek_indexed_rows(new_data, pk_update);
@@ -4267,8 +4248,6 @@ THR_LOCK_DATA **ha_ndbcluster::store_lock(THD *thd,
extern MASTER_INFO *active_mi;
static int ndbcluster_update_apply_status(THD *thd, int do_update)
{
- return 0;
-
Thd_ndb *thd_ndb= get_thd_ndb(thd);
Ndb *ndb= thd_ndb->ndb;
NDBDICT *dict= ndb->getDictionary();
diff --git a/sql/handler.cc b/sql/handler.cc
index 8d656c4c89d..1a468f306e3 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1392,6 +1392,25 @@ bool ha_flush_logs(handlerton *db_type)
return FALSE;
}
+static const char *check_lowercase_names(handler *file, const char *path,
+ char *tmp_path)
+{
+ if (lower_case_table_names != 2 || (file->ha_table_flags() & HA_FILE_BASED))
+ return path;
+
+ /* Ensure that table handler get path in lower case */
+ if (tmp_path != path)
+ strmov(tmp_path, path);
+
+ /*
+ we only should turn into lowercase database/table part
+ so start the process after homedirectory
+ */
+ my_casedn_str(files_charset_info, tmp_path + mysql_data_home_len);
+ return tmp_path;
+}
+
+
/** @brief
This should return ENOENT if the file doesn't exists.
The .frm file will be deleted only if we return 0 or ENOENT
@@ -1415,13 +1434,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
! (file=get_new_handler((TABLE_SHARE*)0, thd->mem_root, table_type)))
DBUG_RETURN(ENOENT);
- if (lower_case_table_names == 2 && !(file->ha_table_flags() & HA_FILE_BASED))
- {
- /* Ensure that table handler get path in lower case */
- strmov(tmp_path, path);
- my_casedn_str(files_charset_info, tmp_path);
- path= tmp_path;
- }
+ path= check_lowercase_names(file, path, tmp_path);
if ((error= file->delete_table(path)) && generate_warning)
{
/*
@@ -2597,15 +2610,7 @@ int ha_create_table(THD *thd, const char *path,
if (update_create_info)
update_create_info_from_table(create_info, &table);
- name= share.path.str;
- if (lower_case_table_names == 2 &&
- !(table.file->ha_table_flags() & HA_FILE_BASED))
- {
- /* Ensure that handler gets name in lower case */
- strmov(name_buff, name);
- my_casedn_str(files_charset_info, name_buff);
- name= name_buff;
- }
+ name= check_lowercase_names(table.file, share.path.str, name_buff);
error= table.file->create(name, &table, create_info);
VOID(closefrm(&table, 0));
@@ -2655,7 +2660,8 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name)
frmblob and frmlen are set, write the frm to disk
*/
- (void)strxnmov(path,FN_REFLEN-1,mysql_data_home,"/",db,"/",name,NullS);
+ (void)strxnmov(path,FN_REFLEN-1,mysql_data_home,FN_ROOTDIR,
+ db,FN_ROOTDIR,name,NullS);
// Save the frm file
error= writefrm(path, frmblob, frmlen);
my_free(frmblob, MYF(0));
@@ -2676,12 +2682,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name)
update_create_info_from_table(&create_info, &table);
create_info.table_options|= HA_OPTION_CREATE_FROM_ENGINE;
- if (lower_case_table_names == 2 &&
- !(table.file->ha_table_flags() & HA_FILE_BASED))
- {
- /* Ensure that handler gets name in lower case */
- my_casedn_str(files_charset_info, path);
- }
+ check_lowercase_names(table.file, path, path);
error=table.file->create(path,&table,&create_info);
VOID(closefrm(&table, 1));
diff --git a/sql/item.cc b/sql/item.cc
index 8dd3c484804..4638a1d044d 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4404,9 +4404,11 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
field= new Field_blob(max_length, maybe_null, name, collation.collation);
break; // Blob handled outside of case
case MYSQL_TYPE_GEOMETRY:
- return new Field_geom(max_length, maybe_null, name, table->s,
+ field= new Field_geom(max_length, maybe_null, name, table->s,
(Field::geometry_type)
- ((Item_geometry_func *)this)->get_geometry_type());
+ ((type() == Item::TYPE_HOLDER) ?
+ ((Item_type_holder *)this)->get_geometry_type() :
+ ((Item_geometry_func *)this)->get_geometry_type()));
}
if (field)
field->init(table);
@@ -6515,6 +6517,10 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item)
if (Field::result_merge_type(fld_type) == INT_RESULT)
decimals= 0;
prev_decimal_int_part= item->decimal_int_part();
+ if (item->field_type() == MYSQL_TYPE_GEOMETRY)
+ geometry_type= (item->type() == Item::FIELD_ITEM) ?
+ ((Item_field *)item)->get_geometry_type() :
+ (Field::geometry_type)((Item_geometry_func *)item)->get_geometry_type();
}
diff --git a/sql/item.h b/sql/item.h
index daa69b8a125..91f116b985e 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1399,6 +1399,11 @@ public:
int fix_outer_field(THD *thd, Field **field, Item **reference);
virtual Item *update_value_transformer(uchar *select_arg);
void print(String *str);
+ Field::geometry_type get_geometry_type()
+ {
+ DBUG_ASSERT(field_type() == MYSQL_TYPE_GEOMETRY);
+ return field->get_geometry_type();
+ }
friend class Item_default_value;
friend class Item_insert_value;
friend class st_select_lex_unit;
@@ -2699,6 +2704,7 @@ class Item_type_holder: public Item
protected:
TYPELIB *enum_set_typelib;
enum_field_types fld_type;
+ Field::geometry_type geometry_type;
void get_full_info(Item *item);
@@ -2718,6 +2724,7 @@ public:
Field *make_field_by_type(TABLE *table);
static uint32 display_length(Item *item);
static enum_field_types get_real_type(Item *);
+ Field::geometry_type get_geometry_type() { return geometry_type; };
};
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index fbb6e81c7ec..543bc827c48 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1772,6 +1772,7 @@ void Item_func_between::fix_length_and_dec()
int i;
bool datetime_found= FALSE;
compare_as_dates= TRUE;
+ THD *thd= current_thd;
/*
As some compare functions are generated after sql_yacc,
@@ -1810,6 +1811,23 @@ void Item_func_between::fix_length_and_dec()
ge_cmp.set_datetime_cmp_func(args, args + 1);
le_cmp.set_datetime_cmp_func(args, args + 2);
}
+ else if (args[0]->real_item()->type() == FIELD_ITEM &&
+ thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
+ thd->lex->sql_command != SQLCOM_SHOW_CREATE)
+ {
+ Field *field=((Item_field*) (args[0]->real_item()))->field;
+ if (field->can_be_compared_as_longlong())
+ {
+ /*
+ The following can't be recoded with || as convert_constant_item
+ changes the argument
+ */
+ if (convert_constant_item(thd, field,&args[1]))
+ cmp_type=INT_RESULT; // Works for all types.
+ if (convert_constant_item(thd, field,&args[2]))
+ cmp_type=INT_RESULT; // Works for all types.
+ }
+ }
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index b0346cc5224..fb2f361f676 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1954,7 +1954,13 @@ void Item_func_round::fix_length_and_dec()
{
max_length= args[0]->max_length;
decimals= args[0]->decimals;
- hybrid_type= REAL_RESULT;
+ if (args[0]->result_type() == DECIMAL_RESULT)
+ {
+ max_length++;
+ hybrid_type= DECIMAL_RESULT;
+ }
+ else
+ hybrid_type= REAL_RESULT;
return;
}
@@ -3439,6 +3445,7 @@ longlong Item_func_get_lock::val_int()
THD *thd=current_thd;
User_level_lock *ull;
int error;
+ DBUG_ENTER("Item_func_get_lock::val_int");
/*
In slave thread no need to get locks, everything is serialized. Anyway
@@ -3448,7 +3455,7 @@ longlong Item_func_get_lock::val_int()
it's not guaranteed to be same as on master.
*/
if (thd->slave_thread)
- return 1;
+ DBUG_RETURN(1);
pthread_mutex_lock(&LOCK_user_locks);
@@ -3456,8 +3463,10 @@ longlong Item_func_get_lock::val_int()
{
pthread_mutex_unlock(&LOCK_user_locks);
null_value=1;
- return 0;
+ DBUG_RETURN(0);
}
+ DBUG_PRINT("info", ("lock %.*s, thd=%ld", res->length(), res->ptr(),
+ (long) thd->real_id));
null_value=0;
if (thd->ull)
@@ -3477,14 +3486,16 @@ longlong Item_func_get_lock::val_int()
delete ull;
pthread_mutex_unlock(&LOCK_user_locks);
null_value=1; // Probably out of memory
- return 0;
+ DBUG_RETURN(0);
}
ull->set_thread(thd);
thd->ull=ull;
pthread_mutex_unlock(&LOCK_user_locks);
- return 1; // Got new lock
+ DBUG_PRINT("info", ("made new lock"));
+ DBUG_RETURN(1); // Got new lock
}
ull->count++;
+ DBUG_PRINT("info", ("ull->count=%d", ull->count));
/*
Structure is now initialized. Try to get the lock.
@@ -3498,9 +3509,13 @@ longlong Item_func_get_lock::val_int()
error= 0;
while (ull->locked && !thd->killed)
{
+ DBUG_PRINT("info", ("waiting on lock"));
error= pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime);
if (error == ETIMEDOUT || error == ETIME)
+ {
+ DBUG_PRINT("info", ("lock wait timeout"));
break;
+ }
error= 0;
}
@@ -3524,6 +3539,7 @@ longlong Item_func_get_lock::val_int()
ull->thread_id= thd->thread_id;
thd->ull=ull;
error=0;
+ DBUG_PRINT("info", ("got the lock"));
}
pthread_mutex_unlock(&LOCK_user_locks);
@@ -3533,7 +3549,7 @@ longlong Item_func_get_lock::val_int()
thd->mysys_var->current_cond= 0;
pthread_mutex_unlock(&thd->mysys_var->mutex);
- return !error ? 1 : 0;
+ DBUG_RETURN(!error ? 1 : 0);
}
@@ -3551,11 +3567,14 @@ longlong Item_func_release_lock::val_int()
String *res=args[0]->val_str(&value);
User_level_lock *ull;
longlong result;
+ THD *thd=current_thd;
+ DBUG_ENTER("Item_func_release_lock::val_int");
if (!res || !res->length())
{
null_value=1;
- return 0;
+ DBUG_RETURN(0);
}
+ DBUG_PRINT("info", ("lock %.*s", res->length(), res->ptr()));
null_value=0;
result=0;
@@ -3568,15 +3587,20 @@ longlong Item_func_release_lock::val_int()
}
else
{
+ DBUG_PRINT("info", ("ull->locked=%d ull->thread=%lu thd=%lu",
+ (int) ull->locked,
+ (long)ull->thread_id,
+ (long)thd->thread_id));
if (ull->locked && current_thd->thread_id == ull->thread_id)
{
+ DBUG_PRINT("info", ("release lock"));
result=1; // Release is ok
item_user_lock_release(ull);
- current_thd->ull=0;
+ thd->ull=0;
}
}
pthread_mutex_unlock(&LOCK_user_locks);
- return result;
+ DBUG_RETURN(result);
}
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index f9ca53a8355..3dc352338a4 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -3364,7 +3364,7 @@ String *Item_func_uuid::val_str(String *str)
*--s=_dig_vec_lower[mac[i] >> 4];
}
randominit(&uuid_rand, tmp + (ulong) server_start_time,
- tmp + thd->status_var.bytes_sent);
+ tmp + (ulong) thd->status_var.bytes_sent);
set_clock_seq_str();
}
diff --git a/sql/log.cc b/sql/log.cc
index 6ef1c1ea912..ac6ea92c61a 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -296,6 +296,8 @@ bool Log_to_csv_event_handler::open_log_table(uint log_table_type)
table->db= log_thd->db;
table->db_length= log_thd->db_length;
+ lex_start(log_thd);
+ log_thd->clear_error();
if (simple_open_n_lock_tables(log_thd, table) ||
table->table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
table->table->file->ha_rnd_init(0))
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index f9ba99a4509..800ae23425b 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -40,6 +40,7 @@ C_MODE_END
/* the number of digits that my_decimal can possibly contain */
#define DECIMAL_MAX_POSSIBLE_PRECISION (DECIMAL_BUFF_LENGTH * 9)
+
/*
maximum guaranteed precision of number in decimal digits (number of our
digits * number of decimal digits in one our big digit - number of decimal
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 7fb4d95f1f6..bd786ed81ca 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -1598,6 +1598,7 @@ extern int creating_table; // How many mysql_create_table() are running
*/
extern time_t server_start_time;
+extern uint mysql_data_home_len;
extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
mysql_real_data_home[], *opt_mysql_tmpdir, mysql_charsets_dir[],
def_ft_boolean_syntax[sizeof(ft_boolean_syntax)];
@@ -1920,6 +1921,8 @@ uint filename_to_tablename(const char *from, char *to, uint to_length);
uint tablename_to_filename(const char *from, char *to, uint to_length);
uint build_table_filename(char *buff, size_t bufflen, const char *db,
const char *table, const char *ext, uint flags);
+uint build_table_shadow_filename(char *buff, size_t bufflen,
+ ALTER_PARTITION_PARAM_TYPE *lpt);
/* Flags for conversion functions. */
#define FN_FROM_IS_TMP (1 << 0)
#define FN_TO_IS_TMP (1 << 1)
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 1fa08a1d862..caccc395eb5 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -489,6 +489,7 @@ key_map key_map_full(0); // Will be initialized later
const char *opt_date_time_formats[3];
+uint mysql_data_home_len;
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
char server_version[SERVER_VERSION_LENGTH];
char *mysqld_unix_port, *opt_mysql_tmpdir;
@@ -3778,6 +3779,7 @@ int main(int argc, char **argv)
mysql_data_home= mysql_data_home_buff;
mysql_data_home[0]=FN_CURLIB; // all paths are relative from here
mysql_data_home[1]=0;
+ mysql_data_home_len= 2;
if ((user_info= check_user(mysqld_user)))
{
@@ -6681,8 +6683,8 @@ SHOW_VAR status_vars[]= {
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONG},
{"Binlog_cache_disk_use", (char*) &binlog_cache_disk_use, SHOW_LONG},
{"Binlog_cache_use", (char*) &binlog_cache_use, SHOW_LONG},
- {"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONG_STATUS},
- {"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONG_STATUS},
+ {"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
+ {"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
{"Com_admin_commands", (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS},
{"Com_alter_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
{"Com_alter_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_EVENT]), SHOW_LONG_STATUS},
@@ -7064,6 +7066,7 @@ static void mysql_init_variables(void)
sizeof(mysql_real_data_home)-1);
mysql_data_home_buff[0]=FN_CURLIB; // all paths are relative from here
mysql_data_home_buff[1]=0;
+ mysql_data_home_len= 2;
/* Replication parameters */
master_user= (char*) "test";
@@ -7225,6 +7228,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
strmake(mysql_real_data_home,argument, sizeof(mysql_real_data_home)-1);
/* Correct pointer set by my_getopt (for embedded library) */
mysql_data_home= mysql_real_data_home;
+ mysql_data_home_len= strlen(mysql_data_home);
break;
case 'u':
if (!mysqld_user || !strcmp(mysqld_user, argument))
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 46dfbc7c7f9..6ac3e38bb7a 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -699,8 +699,6 @@ static SHOW_VAR fixed_vars[]= {
#ifdef HAVE_SYS_UN_H
{"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
#endif
- {"table_definition_cache", (char*) &table_def_size, SHOW_LONG},
- {"table_lock_wait_timeout", (char*) &table_lock_wait_timeout, SHOW_LONG },
#ifdef HAVE_THR_SETCONCURRENCY
{"thread_concurrency", (char*) &concurrency, SHOW_LONG},
#endif
diff --git a/sql/sql_class.h b/sql/sql_class.h
index d9dc4117319..de7aaafbe3b 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -73,6 +73,7 @@ typedef struct st_copy_info {
ha_rows updated;
ha_rows copied;
ha_rows error_count;
+ ha_rows touched; /* Number of touched records */
enum enum_duplicates handle_duplicates;
int escape_char, last_errno;
bool ignore;
@@ -343,8 +344,8 @@ struct system_variables
typedef struct system_status_var
{
- ulong bytes_received;
- ulong bytes_sent;
+ ulonglong bytes_received;
+ ulonglong bytes_sent;
ulong com_other;
ulong com_stat[(uint) SQLCOM_END];
ulong created_tmp_disk_tables;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 9067df2f014..0ce52779ce1 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -932,20 +932,24 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
if (values_list.elements == 1 && (!(thd->options & OPTION_WARNINGS) ||
!thd->cuted_fields))
{
- thd->row_count_func= info.copied+info.deleted+info.updated;
+ thd->row_count_func= info.copied + info.deleted +
+ ((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
+ info.touched : info.updated);
send_ok(thd, (ulong) thd->row_count_func, id);
}
else
{
char buff[160];
+ ha_rows updated=((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
+ info.touched : info.updated);
if (ignore)
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(lock_type == TL_WRITE_DELAYED) ? (ulong) 0 :
(ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
else
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
- (ulong) (info.deleted+info.updated), (ulong) thd->cuted_fields);
- thd->row_count_func= info.copied+info.deleted+info.updated;
+ (ulong) (info.deleted + updated), (ulong) thd->cuted_fields);
+ thd->row_count_func= info.copied + info.deleted + updated;
::send_ok(thd, (ulong) thd->row_count_func, id, buff);
}
thd->abort_on_warning= 0;
@@ -1415,19 +1419,20 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
goto before_trg_err;
table->file->restore_auto_increment(prev_insert_id);
- if ((error=table->file->ha_update_row(table->record[1],
- table->record[0])))
- {
- if (info->ignore &&
- !table->file->is_fatal_error(error, HA_CHECK_DUP_KEY))
- {
- goto ok_or_after_trg_err;
- }
- goto err;
- }
if ((table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ) ||
- compare_record(table))
+ compare_record(table))
{
+ if ((error=table->file->ha_update_row(table->record[1],
+ table->record[0])))
+ {
+ if (info->ignore &&
+ !table->file->is_fatal_error(error, HA_CHECK_DUP_KEY))
+ {
+ goto ok_or_after_trg_err;
+ }
+ goto err;
+ }
+
info->updated++;
/*
If ON DUP KEY UPDATE updates a row instead of inserting one, it's
@@ -1446,6 +1451,11 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
info->copied++;
}
+ if (table->next_number_field)
+ table->file->adjust_next_insert_id_after_explicit_value(
+ table->next_number_field->val_int());
+ info->touched++;
+
goto ok_or_after_trg_err;
}
else /* DUP_REPLACE */
@@ -3136,7 +3146,9 @@ bool select_insert::send_eof()
else
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) (info.deleted+info.updated), (ulong) thd->cuted_fields);
- thd->row_count_func= info.copied+info.deleted+info.updated;
+ thd->row_count_func= info.copied + info.deleted +
+ ((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
+ info.touched : info.updated);
id= (thd->first_successful_insert_id_in_cur_stmt > 0) ?
thd->first_successful_insert_id_in_cur_stmt :
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index c644aeab499..132fc5b0b4f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1820,6 +1820,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_VARIABLES:
case SQLCOM_SHOW_CHARSETS:
case SQLCOM_SHOW_COLLATIONS:
+ case SQLCOM_SHOW_STORAGE_ENGINES:
case SQLCOM_SELECT:
thd->status_var.last_query_cost= 0.0;
if (all_tables)
@@ -2922,9 +2923,6 @@ end_with_restore_list:
thd->security_ctx->priv_user),
lex->verbose);
break;
- case SQLCOM_SHOW_STORAGE_ENGINES:
- res= mysqld_show_storage_engines(thd);
- break;
case SQLCOM_SHOW_AUTHORS:
res= mysqld_show_authors(thd);
break;
@@ -4612,7 +4610,17 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
Security_context *sctx= thd->security_ctx;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
ulong db_access;
- bool db_is_pattern= test(want_access & GRANT_ACL);
+ /*
+ GRANT command:
+ In case of database level grant the database name may be a pattern,
+ in case of table|column level grant the database name can not be a pattern.
+ We use 'dont_check_global_grants' as a flag to determine
+ if it's database level grant command
+ (see SQLCOM_GRANT case, mysql_execute_command() function) and
+ set db_is_pattern according to 'dont_check_global_grants' value.
+ */
+ bool db_is_pattern= (test(want_access & GRANT_ACL) &&
+ dont_check_global_grants);
#endif
ulong dummy;
DBUG_ENTER("check_access");
@@ -5024,17 +5032,14 @@ bool check_merge_table_access(THD *thd, char *db,
Check stack size; Send error if there isn't enough stack to continue
****************************************************************************/
-#if STACK_DIRECTION < 0
-#define used_stack(A,B) (long) (A - B)
-#else
-#define used_stack(A,B) (long) (B - A)
-#endif
+#ifndef EMBEDDED_LIBRARY
+
+#define used_stack(A,B) (long)(A > B ? A - B : B - A)
#ifndef DBUG_OFF
long max_stack_used;
#endif
-#ifndef EMBEDDED_LIBRARY
/*
Note: The 'buf' parameter is necessary, even if it is unused here.
- fix_fields functions has a "dummy" buffer large enough for the
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index d47aacee924..04e7645a8aa 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -5459,8 +5459,7 @@ static bool write_log_drop_shadow_frm(ALTER_PARTITION_PARAM_TYPE *lpt)
char shadow_path[FN_LEN];
DBUG_ENTER("write_log_drop_shadow_frm");
- build_table_filename(shadow_path, sizeof(shadow_path), lpt->db,
- lpt->table_name, "#", 0);
+ build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
pthread_mutex_lock(&LOCK_gdl);
if (write_log_replace_delete_frm(lpt, 0UL, NULL,
(const char*)shadow_path, FALSE))
@@ -5508,8 +5507,7 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt)
part_info->first_log_entry= NULL;
build_table_filename(path, sizeof(path), lpt->db,
lpt->table_name, "", 0);
- build_table_filename(shadow_path, sizeof(shadow_path), lpt->db,
- lpt->table_name, "#", 0);
+ build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
pthread_mutex_lock(&LOCK_gdl);
if (write_log_replace_delete_frm(lpt, 0UL, shadow_path, path, TRUE))
goto error;
@@ -5674,8 +5672,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
part_info->first_log_entry= NULL;
build_table_filename(path, sizeof(path), lpt->db,
lpt->table_name, "", 0);
- build_table_filename(shadow_path, sizeof(shadow_path), lpt->db,
- lpt->table_name, "#", 0);
+ build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
pthread_mutex_lock(&LOCK_gdl);
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
lpt->alter_info->flags & ALTER_REORGANIZE_PARTITION))
diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h
index 70ce21a64da..e8f2cb6ee5e 100644
--- a/sql/sql_plugin.h
+++ b/sql/sql_plugin.h
@@ -33,7 +33,8 @@ class sys_var;
*/
#define SHOW_FUNC SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG, \
SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, \
- SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH
+ SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH, \
+ SHOW_LONGLONG_STATUS
#include <mysql/plugin.h>
#undef SHOW_FUNC
typedef enum enum_mysql_show_type SHOW_TYPE;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 716ca08beb1..9d739102b6f 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -572,6 +572,8 @@ void set_param_date(Item_param *param, uchar **pos, ulong len)
static void set_param_str(Item_param *param, uchar **pos, ulong len)
{
ulong length= get_param_length(pos, len);
+ if (length > len)
+ length= len;
param->set_str((const char *)*pos, length);
*pos+= length;
}
@@ -742,6 +744,8 @@ static bool insert_params_with_log(Prepared_statement *stmt, uchar *null_array,
if (read_pos >= data_end)
DBUG_RETURN(1);
param->set_param_func(param, &read_pos, data_end - read_pos);
+ if (param->state == Item_param::NO_VALUE)
+ DBUG_RETURN(1);
}
}
res= param->query_val_str(&str);
@@ -778,6 +782,8 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array,
if (read_pos >= data_end)
DBUG_RETURN(1);
param->set_param_func(param, &read_pos, data_end - read_pos);
+ if (param->state == Item_param::NO_VALUE)
+ DBUG_RETURN(1);
}
}
if (param->convert_str_value(stmt->thd))
@@ -860,6 +866,8 @@ static bool emb_insert_params(Prepared_statement *stmt, String *expanded_query)
client_param->length ?
*client_param->length :
client_param->buffer_length);
+ if (param->state == Item_param::NO_VALUE)
+ DBUG_RETURN(1);
}
}
if (param->convert_str_value(thd))
@@ -902,6 +910,8 @@ static bool emb_insert_params_with_log(Prepared_statement *stmt,
client_param->length ?
*client_param->length :
client_param->buffer_length);
+ if (param->state == Item_param::NO_VALUE)
+ DBUG_RETURN(1);
}
}
res= param->query_val_str(&str);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 8caf45f2e38..dc5e33518d2 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -10417,7 +10417,9 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
*/
while (!table->file->rnd_next(new_table.record[1]))
{
- if ((write_err= new_table.file->write_row(new_table.record[1])))
+ write_err= new_table.file->write_row(new_table.record[1]);
+ DBUG_EXECUTE_IF("raise_error", write_err= HA_ERR_FOUND_DUPP_KEY ;);
+ if (write_err)
goto err;
}
/* copy row that filled HEAP table */
@@ -10457,6 +10459,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
err2:
delete new_table.file;
thd->proc_info=save_proc_info;
+ table->mem_root= new_table.mem_root;
DBUG_RETURN(1);
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 624ecf88c02..903c8ab74f1 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -79,58 +79,6 @@ append_algorithm(TABLE_LIST *table, String *buff);
** List all table types supported
***************************************************************************/
-static my_bool show_handlerton(THD *thd, plugin_ref plugin,
- void *arg)
-{
- handlerton *default_type= (handlerton *) arg;
- Protocol *protocol= thd->protocol;
- handlerton *hton= plugin_data(plugin, handlerton *);
-
- if (!(hton->flags & HTON_HIDDEN))
- {
- protocol->prepare_for_resend();
- protocol->store(plugin_name(plugin)->str, plugin_name(plugin)->length,
- system_charset_info);
- const char *option_name= show_comp_option_name[(int) hton->state];
-
- if (hton->state == SHOW_OPTION_YES && default_type == hton)
- option_name= "DEFAULT";
- protocol->store(option_name, system_charset_info);
- protocol->store(plugin_decl(plugin)->descr, system_charset_info);
- protocol->store(hton->commit ? "YES" : "NO", system_charset_info);
- protocol->store(hton->prepare ? "YES" : "NO", system_charset_info);
- protocol->store(hton->savepoint_set ? "YES" : "NO", system_charset_info);
-
- return protocol->write() ? 1 : 0;
- }
- return 0;
-}
-
-bool mysqld_show_storage_engines(THD *thd)
-{
- List<Item> field_list;
- Protocol *protocol= thd->protocol;
- DBUG_ENTER("mysqld_show_storage_engines");
-
- field_list.push_back(new Item_empty_string("Engine",10));
- field_list.push_back(new Item_empty_string("Support",10));
- field_list.push_back(new Item_empty_string("Comment",80));
- field_list.push_back(new Item_empty_string("Transactions",3));
- field_list.push_back(new Item_empty_string("XA",3));
- field_list.push_back(new Item_empty_string("Savepoints",3));
-
- if (protocol->send_fields(&field_list,
- Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
- DBUG_RETURN(TRUE);
-
- if (plugin_foreach(thd, show_handlerton,
- MYSQL_STORAGE_ENGINE_PLUGIN, ha_default_handlerton(thd)))
- DBUG_RETURN(TRUE);
-
- send_eof(thd);
- DBUG_RETURN(FALSE);
-}
-
static int make_version_string(char *buf, int buf_length, uint version)
{
return my_snprintf(buf, buf_length, "%d.%d", version>>8,version&0xff);
@@ -2109,6 +2057,8 @@ static bool show_status_array(THD *thd, const char *wild,
case SHOW_LONG_NOFLUSH: // the difference lies in refresh_status()
end= int10_to_str(*(long*) value, buff, 10);
break;
+ case SHOW_LONGLONG_STATUS:
+ value= ((char *) status_var + (ulonglong) value);
case SHOW_LONGLONG:
end= longlong10_to_str(*(longlong*) value, buff, 10);
break;
@@ -3313,6 +3263,7 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin,
handlerton *hton= plugin_data(plugin, handlerton *);
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
CHARSET_INFO *scs= system_charset_info;
+ handlerton *default_type= ha_default_handlerton(thd);
DBUG_ENTER("iter_schema_engines");
if (!(hton->flags & HTON_HIDDEN))
@@ -3321,16 +3272,16 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin,
if (!(wild && wild[0] &&
wild_case_compare(scs, name->str,wild)))
{
- LEX_STRING state[2]= {{ C_STRING_WITH_LEN("ENABLED") },
- { C_STRING_WITH_LEN("DISABLED") }};
LEX_STRING yesno[2]= {{ C_STRING_WITH_LEN("NO") },
{ C_STRING_WITH_LEN("YES") }};
LEX_STRING *tmp;
+ const char *option_name= show_comp_option_name[(int) hton->state];
restore_record(table, s->default_values);
table->field[0]->store(name->str, name->length, scs);
- tmp= &state[test(hton->state)];
- table->field[1]->store(tmp->str, tmp->length, scs);
+ if (hton->state == SHOW_OPTION_YES && default_type == hton)
+ option_name= "DEFAULT";
+ table->field[1]->store(option_name, strlen(option_name), scs);
table->field[2]->store(plugin_decl(plugin)->descr,
strlen(plugin_decl(plugin)->descr), scs);
tmp= &yesno[test(hton->commit)];
@@ -3652,6 +3603,7 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
DBUG_ENTER("get_schema_views_record");
char definer[USER_HOST_BUFF_SIZE];
uint definer_len;
+ bool updatable_view;
if (tables->view)
{
@@ -3689,7 +3641,34 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
else
table->field[4]->store(STRING_WITH_LEN("NONE"), cs);
- if (tables->updatable_view)
+ updatable_view= 0;
+ if (tables->algorithm != VIEW_ALGORITHM_TMPTABLE)
+ {
+ /*
+ We should use tables->view->select_lex.item_list here and
+ can not use Field_iterator_view because the view always uses
+ temporary algorithm during opening for I_S and
+ TABLE_LIST fields 'field_translation' & 'field_translation_end'
+ are uninitialized is this case.
+ */
+ List<Item> *fields= &tables->view->select_lex.item_list;
+ List_iterator<Item> it(*fields);
+ Item *item;
+ Item_field *field;
+ /*
+ chech that at least one coulmn in view is updatable
+ */
+ while ((item= it++))
+ {
+ if ((field= item->filed_for_view_update()) && field->field &&
+ !field->field->table->pos_in_table_list->schema_table)
+ {
+ updatable_view= 1;
+ break;
+ }
+ }
+ }
+ if (updatable_view)
table->field[5]->store(STRING_WITH_LEN("YES"), cs);
else
table->field[5]->store(STRING_WITH_LEN("NO"), cs);
@@ -4046,7 +4025,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table,
table->field[22]->store(part_elem->part_comment,
strlen(part_elem->part_comment), cs);
else
- table->field[22]->store(STRING_WITH_LEN("default"), cs);
+ table->field[22]->store(STRING_WITH_LEN(""), cs);
if (part_elem->nodegroup_id != UNDEF_NODEGROUP)
table->field[23]->store((longlong) part_elem->nodegroup_id, TRUE);
else
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index cdedb05564d..5abf995d49a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1161,6 +1161,31 @@ void release_ddl_log()
*/
+/**
+ @brief construct a temporary shadow file name.
+
+ @details Make a shadow file name used by ALTER TABLE to construct the
+ modified table (with keeping the original). The modified table is then
+ moved back as original table. The name must start with the temp file
+ prefix so it gets filtered out by table files listing routines.
+
+ @param[out] buff buffer to receive the constructed name
+ @param bufflen size of buff
+ @param lpt alter table data structure
+
+ @retval path length
+*/
+
+uint build_table_shadow_filename(char *buff, size_t bufflen,
+ ALTER_PARTITION_PARAM_TYPE *lpt)
+{
+ char tmp_name[FN_REFLEN];
+ my_snprintf (tmp_name, sizeof (tmp_name), "%s-%s", tmp_file_prefix,
+ lpt->table_name);
+ return build_table_filename(buff, bufflen, lpt->db, tmp_name, "", FN_IS_TMP);
+}
+
+
/*
SYNOPSIS
mysql_write_frm()
@@ -1201,8 +1226,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
/*
Build shadow frm file name
*/
- build_table_filename(shadow_path, sizeof(shadow_path), lpt->db,
- lpt->table_name, "#", 0);
+ build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
strxmov(shadow_frm_name, shadow_path, reg_ext, NullS);
if (flags & WFRM_WRITE_SHADOW)
{
@@ -1225,6 +1249,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
if (part_info)
{
+ TABLE_SHARE *share= lpt->table->s;
if (!(part_syntax_buf= generate_partition_syntax(part_info,
&syntax_len,
TRUE, TRUE)))
@@ -1232,7 +1257,16 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
DBUG_RETURN(TRUE);
}
part_info->part_info_string= part_syntax_buf;
- part_info->part_info_len= syntax_len;
+ share->partition_info_len= part_info->part_info_len= syntax_len;
+ if (share->partition_info_buffer_size < syntax_len + 1)
+ {
+ share->partition_info_buffer_size= syntax_len+1;
+ if (!(share->partition_info=
+ (char*) alloc_root(&share->mem_root, syntax_len+1)))
+ DBUG_RETURN(TRUE);
+
+ }
+ memcpy((char*) share->partition_info, part_syntax_buf, syntax_len + 1);
}
}
#endif
@@ -5713,21 +5747,31 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
table_list->table_name_length,
table_list->table_name, 0);
- /* Disable alter of enabled log tables */
- if (table_kind && logger.is_log_table_enabled(table_kind))
+ if (table_kind)
{
- my_error(ER_BAD_LOG_STATEMENT, MYF(0), "ALTER");
- DBUG_RETURN(TRUE);
- }
+ /* Disable alter of enabled log tables */
+ if (logger.is_log_table_enabled(table_kind))
+ {
+ my_error(ER_BAD_LOG_STATEMENT, MYF(0), "ALTER");
+ DBUG_RETURN(TRUE);
+ }
- /* Disable alter of log tables to unsupported engine */
- if (table_kind &&
- (create_info->used_fields & HA_CREATE_USED_ENGINE) &&
- (!create_info->db_type || /* unknown engine */
- !(create_info->db_type->flags & HTON_SUPPORT_LOG_TABLES)))
- {
- my_error(ER_UNSUPORTED_LOG_ENGINE, MYF(0));
- DBUG_RETURN(TRUE);
+ /* Disable alter of log tables to unsupported engine */
+ if ((create_info->used_fields & HA_CREATE_USED_ENGINE) &&
+ (!create_info->db_type || /* unknown engine */
+ !(create_info->db_type->flags & HTON_SUPPORT_LOG_TABLES)))
+ {
+ my_error(ER_UNSUPORTED_LOG_ENGINE, MYF(0));
+ DBUG_RETURN(TRUE);
+ }
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (alter_info->flags & ALTER_PARTITION)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "PARTITION", "log table");
+ DBUG_RETURN(TRUE);
+ }
+#endif
}
}
@@ -5756,8 +5800,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
strxnmov(new_name_buff, sizeof (new_name_buff) - 1, mysql_data_home, "/", db,
"/", table_name, reg_ext, NullS);
(void) unpack_filename(new_name_buff, new_name_buff);
- if (lower_case_table_names != 2)
- my_casedn_str(files_charset_info, new_name_buff);
/*
If this is just a rename of a view, short cut to the
following scenario: 1) lock LOCK_open 2) do a RENAME
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 1073c8141df..737285e56d8 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -7509,7 +7509,8 @@ select_derived2:
{
LEX *lex= Lex;
lex->derived_tables|= DERIVED_SUBQUERY;
- if (!lex->expr_allows_subselect)
+ if (!lex->expr_allows_subselect ||
+ lex->sql_command == (int)SQLCOM_PURGE)
{
my_parse_error(ER(ER_SYNTAX_ERROR));
MYSQL_YYABORT;
@@ -9049,6 +9050,7 @@ purge:
{
LEX *lex=Lex;
lex->type=0;
+ lex->sql_command = SQLCOM_PURGE;
} purge_options
{}
;
@@ -9060,7 +9062,6 @@ purge_options:
purge_option:
TO_SYM TEXT_STRING_sys
{
- Lex->sql_command = SQLCOM_PURGE;
Lex->to_log = $2.str;
}
| BEFORE_SYM expr
@@ -11234,7 +11235,8 @@ subselect_init:
subselect_start:
{
LEX *lex=Lex;
- if (!lex->expr_allows_subselect)
+ if (!lex->expr_allows_subselect ||
+ lex->sql_command == (int)SQLCOM_PURGE)
{
my_parse_error(ER(ER_SYNTAX_ERROR));
MYSQL_YYABORT;
diff --git a/sql/table.cc b/sql/table.cc
index 745f3a2a34e..e969ae4397a 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -726,7 +726,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
{
uint32 partition_info_len = uint4korr(next_chunk);
#ifdef WITH_PARTITION_STORAGE_ENGINE
- if ((share->partition_info_len= partition_info_len))
+ if ((share->partition_info_buffer_size=
+ share->partition_info_len= partition_info_len))
{
if (!(share->partition_info= (char*)
memdup_root(&share->mem_root, next_chunk + 4,
diff --git a/sql/table.h b/sql/table.h
index 77807530ef1..90c07979512 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -243,6 +243,7 @@ typedef struct st_table_share
bool auto_partitioned;
const char *partition_info;
uint partition_info_len;
+ uint partition_info_buffer_size;
const char *part_state;
uint part_state_len;
handlerton *default_part_db_type;