@brief Compare table structure/options between a non partitioned table and a specific partition of a partitioned table. @param thd Thread object. @param table Non partitioned table. @param part_table Partitioned table. @param part_elem Partition element to use for partition specific compare. */
| 194 | @param part_elem Partition element to use for partition specific compare. |
| 195 | */ |
| 196 | bool compare_table_with_partition(THD *thd, TABLE *table, TABLE *part_table, |
| 197 | partition_element *part_elem, uint part_id) |
| 198 | { |
| 199 | HA_CREATE_INFO table_create_info; |
| 200 | Table_specification_st part_create_info; |
| 201 | Alter_info part_alter_info; |
| 202 | Alter_table_ctx part_alter_ctx; // Not used |
| 203 | DBUG_ENTER("compare_table_with_partition"); |
| 204 | |
| 205 | bool metadata_equal= false; |
| 206 | part_create_info.init(); |
| 207 | table_create_info.init(); |
| 208 | |
| 209 | update_create_info_from_table(&table_create_info, table); |
| 210 | /* get the current auto_increment value */ |
| 211 | table->file->update_create_info(&table_create_info); |
| 212 | /* mark all columns used, since they are used when preparing the new table */ |
| 213 | part_table->use_all_columns(); |
| 214 | table->use_all_columns(); |
| 215 | if (unlikely(mysql_prepare_alter_table(thd, part_table, &part_create_info, |
| 216 | &part_alter_info, &part_alter_ctx))) |
| 217 | { |
| 218 | my_error(ER_TABLES_DIFFERENT_METADATA, MYF(0)); |
| 219 | DBUG_RETURN(TRUE); |
| 220 | } |
| 221 | /* db_type is not set in prepare_alter_table */ |
| 222 | part_create_info.db_type= part_table->part_info->default_engine_type; |
| 223 | ((ha_partition*)(part_table->file))->update_part_create_info(&part_create_info, part_id); |
| 224 | /* |
| 225 | Since we exchange the partition with the table, allow exchanging |
| 226 | auto_increment value as well. |
| 227 | */ |
| 228 | part_create_info.auto_increment_value= |
| 229 | table_create_info.auto_increment_value; |
| 230 | |
| 231 | /* Check compatible row_types and set create_info accordingly. */ |
| 232 | { |
| 233 | enum row_type part_row_type= part_table->file->get_row_type(); |
| 234 | enum row_type table_row_type= table->file->get_row_type(); |
| 235 | if (part_row_type != table_row_type) |
| 236 | { |
| 237 | my_error(ER_PARTITION_EXCHANGE_DIFFERENT_OPTION, MYF(0), |
| 238 | "ROW_FORMAT"); |
| 239 | DBUG_RETURN(true); |
| 240 | } |
| 241 | part_create_info.row_type= table->s->row_type; |
| 242 | } |
| 243 | |
| 244 | /* |
| 245 | NOTE: ha_blackhole does not support check_if_compatible_data, |
| 246 | so this always fail for blackhole tables. |
| 247 | ha_myisam compares pointers to verify that DATA/INDEX DIRECTORY is |
| 248 | the same, so any table using data/index_file_name will fail. |
| 249 | */ |
| 250 | if (mysql_compare_tables(table, &part_alter_info, &part_create_info, |
| 251 | &metadata_equal)) |
| 252 | { |
| 253 | my_error(ER_TABLES_DIFFERENT_METADATA, MYF(0)); |
no test coverage detected