summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_partition.cc28
-rw-r--r--sql/ha_partition.h3
-rw-r--r--sql/mysqld.cc7
-rw-r--r--sql/sql_delete.cc6
-rw-r--r--sql/sql_lex.h9
-rw-r--r--sql/sql_partition.cc38
-rw-r--r--sql/sql_show.cc2
-rw-r--r--sql/sql_table.cc12
-rw-r--r--sql/sql_yacc.yy8
9 files changed, 47 insertions, 66 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 1ce899ff33f..4fd8a0f67a9 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -877,10 +877,7 @@ int ha_partition::optimize(THD *thd, HA_CHECK_OPT *check_opt)
{
DBUG_ENTER("ha_partition::optimize");
- DBUG_RETURN(handle_opt_partitions(thd, check_opt,
- OPTIMIZE_PARTS,
- thd->lex->alter_info.flags &
- ALTER_OPTIMIZE_PARTITION ? FALSE : TRUE));
+ DBUG_RETURN(handle_opt_partitions(thd, check_opt, OPTIMIZE_PARTS));
}
@@ -901,10 +898,7 @@ int ha_partition::analyze(THD *thd, HA_CHECK_OPT *check_opt)
{
DBUG_ENTER("ha_partition::analyze");
- DBUG_RETURN(handle_opt_partitions(thd, check_opt,
- ANALYZE_PARTS,
- thd->lex->alter_info.flags &
- ALTER_ANALYZE_PARTITION ? FALSE : TRUE));
+ DBUG_RETURN(handle_opt_partitions(thd, check_opt, ANALYZE_PARTS));
}
@@ -925,10 +919,7 @@ int ha_partition::check(THD *thd, HA_CHECK_OPT *check_opt)
{
DBUG_ENTER("ha_partition::check");
- DBUG_RETURN(handle_opt_partitions(thd, check_opt,
- CHECK_PARTS,
- thd->lex->alter_info.flags &
- ALTER_CHECK_PARTITION ? FALSE : TRUE));
+ DBUG_RETURN(handle_opt_partitions(thd, check_opt, CHECK_PARTS));
}
@@ -949,12 +940,10 @@ int ha_partition::repair(THD *thd, HA_CHECK_OPT *check_opt)
{
DBUG_ENTER("ha_partition::repair");
- DBUG_RETURN(handle_opt_partitions(thd, check_opt,
- REPAIR_PARTS,
- thd->lex->alter_info.flags &
- ALTER_REPAIR_PARTITION ? FALSE : TRUE));
+ DBUG_RETURN(handle_opt_partitions(thd, check_opt, REPAIR_PARTS));
}
+
/*
Handle optimize/analyze/check/repair of one partition
@@ -1057,7 +1046,6 @@ static bool print_admin_msg(THD* thd, const char* msg_type,
thd Thread object
check_opt Options
flag Optimize/Analyze/Check/Repair flag
- all_parts All partitions or only a subset
RETURN VALUE
>0 Failure
@@ -1065,7 +1053,7 @@ static bool print_admin_msg(THD* thd, const char* msg_type,
*/
int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
- uint flag, bool all_parts)
+ uint flag)
{
List_iterator<partition_element> part_it(m_part_info->partitions);
uint no_parts= m_part_info->no_parts;
@@ -1073,7 +1061,7 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
uint i= 0;
int error;
DBUG_ENTER("ha_partition::handle_opt_partitions");
- DBUG_PRINT("enter", ("all_parts %u, flag= %u", all_parts, flag));
+ DBUG_PRINT("enter", ("flag= %u", flag));
do
{
@@ -1082,7 +1070,7 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
when ALTER TABLE <CMD> PARTITION ...
it should only do named partitions, otherwise all partitions
*/
- if (all_parts ||
+ if (!(thd->lex->alter_info.flags & ALTER_ADMIN_PARTITION) ||
part_elem->part_state == PART_CHANGED)
{
if (m_is_sub_partitioned)
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index 0d86c162bde..9b2a496507c 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -1003,8 +1003,7 @@ public:
virtual bool is_crashed() const;
private:
- int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
- uint flags, bool all_parts);
+ int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, uint flags);
public:
/*
-------------------------------------------------------------------------
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index abb778394e6..c0a1b2e5306 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -6666,9 +6666,10 @@ The minimum value for this variable is 4096.",
"Directory for plugins.",
(uchar**) &opt_plugin_dir_ptr, (uchar**) &opt_plugin_dir_ptr, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"plugin_load", OPT_PLUGIN_LOAD,
- "Optional colon separated list of plugins to load, where each plugin is "
- "identified by name and path to library seperated by an equals.",
+ {"plugin-load", OPT_PLUGIN_LOAD,
+ "Optional colon-separated list of plugins to load, where each plugin is "
+ "identified as name=library, where name is the plugin name and library "
+ "is the plugin library in plugin_dir.",
(uchar**) &opt_plugin_load, (uchar**) &opt_plugin_load, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 73a46aaac98..f7c44152571 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -398,7 +398,11 @@ cleanup:
free_underlaid_joins(thd, select_lex);
if (error < 0 || (thd->lex->ignore && !thd->is_fatal_error))
{
- thd->row_count_func= deleted;
+ /*
+ If a TRUNCATE TABLE was issued, the number of rows should be reported as
+ zero since the exact number is unknown.
+ */
+ thd->row_count_func= reset_auto_increment ? 0 : deleted;
my_ok(thd, (ha_rows) thd->row_count_func);
DBUG_PRINT("info",("%ld records deleted",(long) deleted));
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 53ae984e795..24731b600e9 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -843,15 +843,12 @@ inline bool st_select_lex_unit::is_union ()
#define ALTER_COALESCE_PARTITION (1L << 15)
#define ALTER_REORGANIZE_PARTITION (1L << 16)
#define ALTER_PARTITION (1L << 17)
-#define ALTER_OPTIMIZE_PARTITION (1L << 18)
+#define ALTER_ADMIN_PARTITION (1L << 18)
#define ALTER_TABLE_REORG (1L << 19)
#define ALTER_REBUILD_PARTITION (1L << 20)
#define ALTER_ALL_PARTITION (1L << 21)
-#define ALTER_ANALYZE_PARTITION (1L << 22)
-#define ALTER_CHECK_PARTITION (1L << 23)
-#define ALTER_REPAIR_PARTITION (1L << 24)
-#define ALTER_REMOVE_PARTITIONING (1L << 25)
-#define ALTER_FOREIGN_KEY (1L << 26)
+#define ALTER_REMOVE_PARTITIONING (1L << 22)
+#define ALTER_FOREIGN_KEY (1L << 23)
enum enum_alter_table_change_level
{
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index da80a2125e9..5ed64ea8fd5 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -2078,16 +2078,16 @@ char *generate_partition_syntax(partition_info *part_info,
err+= add_string_len(fptr, part_info->part_func_string,
part_info->part_func_len);
err+= add_end_parenthesis(fptr);
- err+= add_space(fptr);
if ((!part_info->use_default_no_partitions) &&
part_info->use_default_partitions)
{
+ err+= add_string(fptr, "\n");
err+= add_string(fptr, "PARTITIONS ");
err+= add_int(fptr, part_info->no_parts);
- err+= add_space(fptr);
}
if (part_info->is_sub_partitioned())
{
+ err+= add_string(fptr, "\n");
err+= add_subpartition_by(fptr);
/* Must be hash partitioning for subpartitioning */
if (part_info->linear_hash_ind)
@@ -2100,13 +2100,12 @@ char *generate_partition_syntax(partition_info *part_info,
err+= add_string_len(fptr, part_info->subpart_func_string,
part_info->subpart_func_len);
err+= add_end_parenthesis(fptr);
- err+= add_space(fptr);
if ((!part_info->use_default_no_subpartitions) &&
part_info->use_default_subpartitions)
{
+ err+= add_string(fptr, "\n");
err+= add_string(fptr, "SUBPARTITIONS ");
err+= add_int(fptr, part_info->no_subparts);
- err+= add_space(fptr);
}
}
tot_no_parts= part_info->partitions.elements;
@@ -2115,6 +2114,7 @@ char *generate_partition_syntax(partition_info *part_info,
if (!part_info->use_default_partitions)
{
bool first= TRUE;
+ err+= add_string(fptr, "\n");
err+= add_begin_parenthesis(fptr);
i= 0;
do
@@ -2126,6 +2126,7 @@ char *generate_partition_syntax(partition_info *part_info,
if (!first)
{
err+= add_comma(fptr);
+ err+= add_string(fptr, "\n");
err+= add_space(fptr);
}
first= FALSE;
@@ -2140,6 +2141,7 @@ char *generate_partition_syntax(partition_info *part_info,
}
else
{
+ err+= add_string(fptr, "\n");
err+= add_space(fptr);
err+= add_begin_parenthesis(fptr);
List_iterator<partition_element> sub_it(part_elem->subpartitions);
@@ -2154,6 +2156,8 @@ char *generate_partition_syntax(partition_info *part_info,
if (j != (no_subparts-1))
{
err+= add_comma(fptr);
+ err+= add_string(fptr, "\n");
+ err+= add_space(fptr);
err+= add_space(fptr);
}
else
@@ -4195,12 +4199,13 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
!(thd->work_part_info= thd->lex->part_info->get_clone()))
DBUG_RETURN(TRUE);
+ /* ALTER_ADMIN_PARTITION is handled in mysql_admin_table */
+ DBUG_ASSERT(!(alter_info->flags & ALTER_ADMIN_PARTITION));
+
if (alter_info->flags &
(ALTER_ADD_PARTITION | ALTER_DROP_PARTITION |
ALTER_COALESCE_PARTITION | ALTER_REORGANIZE_PARTITION |
- ALTER_TABLE_REORG | ALTER_OPTIMIZE_PARTITION |
- ALTER_CHECK_PARTITION | ALTER_ANALYZE_PARTITION |
- ALTER_REPAIR_PARTITION | ALTER_REBUILD_PARTITION))
+ ALTER_TABLE_REORG | ALTER_REBUILD_PARTITION))
{
partition_info *tab_part_info= table->part_info;
partition_info *alt_part_info= thd->work_part_info;
@@ -4591,11 +4596,7 @@ that are reorganised.
}
tab_part_info->no_parts-= no_parts_dropped;
}
- else if ((alter_info->flags & ALTER_OPTIMIZE_PARTITION) ||
- (alter_info->flags & ALTER_ANALYZE_PARTITION) ||
- (alter_info->flags & ALTER_CHECK_PARTITION) ||
- (alter_info->flags & ALTER_REPAIR_PARTITION) ||
- (alter_info->flags & ALTER_REBUILD_PARTITION))
+ else if (alter_info->flags & ALTER_REBUILD_PARTITION)
{
uint no_parts_found;
uint no_parts_opt= alter_info->partition_names.elements;
@@ -4603,18 +4604,7 @@ that are reorganised.
if (no_parts_found != no_parts_opt &&
(!(alter_info->flags & ALTER_ALL_PARTITION)))
{
- const char *ptr;
- if (alter_info->flags & ALTER_OPTIMIZE_PARTITION)
- ptr= "OPTIMIZE";
- else if (alter_info->flags & ALTER_ANALYZE_PARTITION)
- ptr= "ANALYZE";
- else if (alter_info->flags & ALTER_CHECK_PARTITION)
- ptr= "CHECK";
- else if (alter_info->flags & ALTER_REPAIR_PARTITION)
- ptr= "REPAIR";
- else
- ptr= "REBUILD";
- my_error(ER_DROP_PARTITION_NON_EXISTENT, MYF(0), ptr);
+ my_error(ER_DROP_PARTITION_NON_EXISTENT, MYF(0), "REBUILD");
DBUG_RETURN(TRUE);
}
if (!(*fast_alter_partition))
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index ca7e222e18d..1b6f5131c48 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1453,7 +1453,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
FALSE,
show_table_options))))
{
- packet->append(STRING_WITH_LEN(" /*!50100"));
+ packet->append(STRING_WITH_LEN("\n/*!50100"));
packet->append(part_syntax, part_syntax_len);
packet->append(STRING_WITH_LEN(" */"));
my_free(part_syntax, MYF(0));
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index a5b7a90569d..0ee9566dc61 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4198,7 +4198,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
table->next_local= save_next_local;
thd->open_options&= ~extra_open_options;
#ifdef WITH_PARTITION_STORAGE_ENGINE
- if (table->table && table->table->part_info)
+ if (table->table)
{
/*
Set up which partitions that should be processed
@@ -4206,11 +4206,13 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
*/
Alter_info *alter_info= &lex->alter_info;
- if (alter_info->flags & ALTER_ANALYZE_PARTITION ||
- alter_info->flags & ALTER_CHECK_PARTITION ||
- alter_info->flags & ALTER_OPTIMIZE_PARTITION ||
- alter_info->flags & ALTER_REPAIR_PARTITION)
+ if (alter_info->flags & ALTER_ADMIN_PARTITION)
{
+ if (!table->table->part_info)
+ {
+ my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0));
+ DBUG_RETURN(TRUE);
+ }
uint no_parts_found;
uint no_parts_opt= alter_info->partition_names.elements;
no_parts_found= set_part_state(alter_info, table->table->part_info,
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 8d9b3a2d4b5..93f6ac4391d 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -5658,7 +5658,7 @@ alter_commands:
{
LEX *lex= Lex;
lex->sql_command = SQLCOM_OPTIMIZE;
- lex->alter_info.flags|= ALTER_OPTIMIZE_PARTITION;
+ lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
lex->no_write_to_binlog= $3;
lex->check_opt.init();
}
@@ -5668,7 +5668,7 @@ alter_commands:
{
LEX *lex= Lex;
lex->sql_command = SQLCOM_ANALYZE;
- lex->alter_info.flags|= ALTER_ANALYZE_PARTITION;
+ lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
lex->no_write_to_binlog= $3;
lex->check_opt.init();
}
@@ -5676,7 +5676,7 @@ alter_commands:
{
LEX *lex= Lex;
lex->sql_command = SQLCOM_CHECK;
- lex->alter_info.flags|= ALTER_CHECK_PARTITION;
+ lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
lex->check_opt.init();
}
opt_mi_check_type
@@ -5685,7 +5685,7 @@ alter_commands:
{
LEX *lex= Lex;
lex->sql_command = SQLCOM_REPAIR;
- lex->alter_info.flags|= ALTER_REPAIR_PARTITION;
+ lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
lex->no_write_to_binlog= $3;
lex->check_opt.init();
}