summaryrefslogtreecommitdiff
path: root/sql/sql_statistics.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-09-10 22:22:57 -0700
committerIgor Babaev <igor@askmonty.org>2012-09-10 22:22:57 -0700
commitff36e9fc518a4f8b463a09aeb9499c4552a27534 (patch)
tree2cd741c8d2bd0776e66386ca4935d23d83de933f /sql/sql_statistics.cc
parent8c131f1262099d4088f3c83642bd09cd83aab148 (diff)
downloadmariadb-git-ff36e9fc518a4f8b463a09aeb9499c4552a27534.tar.gz
Fixed bug mdev-485.
RBR should be turned off when statistical tables are modified in the result of the execution of a DDL statement. Revised the fix for bug mdev-463. Ensured suppression of RBR for the modifications of the statistical tables triggered by the execution of any analyze operation.
Diffstat (limited to 'sql/sql_statistics.cc')
-rw-r--r--sql/sql_statistics.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 69da8d81a36..7c5086da439 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -2171,6 +2171,7 @@ int update_statistics_for_table(THD *thd, TABLE *table)
Open_tables_backup open_tables_backup;
uint i;
int err;
+ bool save_binlog_row_based;
int rc= 0;
TABLE *stat_table;
@@ -2187,6 +2188,9 @@ int update_statistics_for_table(THD *thd, TABLE *table)
DBUG_RETURN(rc);
}
+ if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+ thd->clear_current_stmt_binlog_format_row();
+
/* Update the statistical table table_stat */
stat_table= tables[TABLE_STAT].table;
Table_stat table_stat(stat_table, table);
@@ -2231,6 +2235,9 @@ int update_statistics_for_table(THD *thd, TABLE *table)
}
}
+ if (save_binlog_row_based)
+ thd->set_current_stmt_binlog_format_row();
+
close_system_tables(thd, &open_tables_backup);
DBUG_RETURN(rc);
@@ -2510,6 +2517,7 @@ int read_statistics_for_tables_if_needed(THD *thd, TABLE_LIST *tables)
int delete_statistics_for_table(THD *thd, LEX_STRING *db, LEX_STRING *tab)
{
int err;
+ bool save_binlog_row_based;
TABLE *stat_table;
TABLE_LIST tables[STATISTICS_TABLES];
Open_tables_backup open_tables_backup;
@@ -2528,6 +2536,9 @@ int delete_statistics_for_table(THD *thd, LEX_STRING *db, LEX_STRING *tab)
DBUG_RETURN(rc);
}
+ if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+ thd->clear_current_stmt_binlog_format_row();
+
/* Delete statistics on table from the statistical table index_stat */
stat_table= tables[INDEX_STAT].table;
Index_stat index_stat(stat_table, db, tab);
@@ -2561,6 +2572,9 @@ int delete_statistics_for_table(THD *thd, LEX_STRING *db, LEX_STRING *tab)
rc= 1;
}
+ if (save_binlog_row_based)
+ thd->set_current_stmt_binlog_format_row();
+
close_system_tables(thd, &open_tables_backup);
DBUG_RETURN(rc);
@@ -2595,6 +2609,7 @@ int delete_statistics_for_table(THD *thd, LEX_STRING *db, LEX_STRING *tab)
int delete_statistics_for_column(THD *thd, TABLE *tab, Field *col)
{
int err;
+ bool save_binlog_row_based;
TABLE *stat_table;
TABLE_LIST tables;
Open_tables_backup open_tables_backup;
@@ -2613,6 +2628,9 @@ int delete_statistics_for_column(THD *thd, TABLE *tab, Field *col)
DBUG_RETURN(rc);
}
+ if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+ thd->clear_current_stmt_binlog_format_row();
+
stat_table= tables.table;
Column_stat column_stat(stat_table, tab);
column_stat.set_key_fields(col);
@@ -2623,6 +2641,9 @@ int delete_statistics_for_column(THD *thd, TABLE *tab, Field *col)
rc= 1;
}
+ if (save_binlog_row_based)
+ thd->set_current_stmt_binlog_format_row();
+
close_system_tables(thd, &open_tables_backup);
DBUG_RETURN(rc);
@@ -2657,6 +2678,7 @@ int delete_statistics_for_column(THD *thd, TABLE *tab, Field *col)
int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info)
{
int err;
+ bool save_binlog_row_based;
TABLE *stat_table;
TABLE_LIST tables;
Open_tables_backup open_tables_backup;
@@ -2675,6 +2697,9 @@ int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info)
DBUG_RETURN(rc);
}
+ if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+ thd->clear_current_stmt_binlog_format_row();
+
stat_table= tables.table;
Index_stat index_stat(stat_table, tab);
index_stat.set_index_prefix_key_fields(key_info);
@@ -2685,6 +2710,9 @@ int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info)
rc= 1;
}
+ if (save_binlog_row_based)
+ thd->set_current_stmt_binlog_format_row();
+
close_system_tables(thd, &open_tables_backup);
DBUG_RETURN(rc);
@@ -2722,6 +2750,7 @@ int rename_table_in_stat_tables(THD *thd, LEX_STRING *db, LEX_STRING *tab,
LEX_STRING *new_db, LEX_STRING *new_tab)
{
int err;
+ bool save_binlog_row_based;
TABLE *stat_table;
TABLE_LIST tables[STATISTICS_TABLES];
Open_tables_backup open_tables_backup;
@@ -2740,6 +2769,9 @@ int rename_table_in_stat_tables(THD *thd, LEX_STRING *db, LEX_STRING *tab,
DBUG_RETURN(rc);
}
+ if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+ thd->clear_current_stmt_binlog_format_row();
+
/* Rename table in the statistical table index_stat */
stat_table= tables[INDEX_STAT].table;
Index_stat index_stat(stat_table, db, tab);
@@ -2775,6 +2807,9 @@ int rename_table_in_stat_tables(THD *thd, LEX_STRING *db, LEX_STRING *tab,
rc= 1;
}
+ if (save_binlog_row_based)
+ thd->set_current_stmt_binlog_format_row();
+
close_system_tables(thd, &open_tables_backup);
DBUG_RETURN(rc);
@@ -2812,6 +2847,7 @@ int rename_column_in_stat_tables(THD *thd, TABLE *tab, Field *col,
const char *new_name)
{
int err;
+ bool save_binlog_row_based;
TABLE *stat_table;
TABLE_LIST tables;
Open_tables_backup open_tables_backup;
@@ -2830,6 +2866,9 @@ int rename_column_in_stat_tables(THD *thd, TABLE *tab, Field *col,
DBUG_RETURN(rc);
}
+ if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+ thd->clear_current_stmt_binlog_format_row();
+
/* Rename column in the statistical table table_stat */
stat_table= tables.table;
Column_stat column_stat(stat_table, tab);
@@ -2840,6 +2879,10 @@ int rename_column_in_stat_tables(THD *thd, TABLE *tab, Field *col,
if (err & !rc)
rc= 1;
}
+
+ if (save_binlog_row_based)
+ thd->set_current_stmt_binlog_format_row();
+
close_system_tables(thd, &open_tables_backup);
DBUG_RETURN(rc);