diff options
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/sql/table.cc b/sql/table.cc index 7c266243d29..d6a715ae1b4 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -130,6 +130,24 @@ TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key, share->version= refresh_version; share->flush_version= flush_version; +#ifdef HAVE_ROW_BASED_REPLICATION + /* + This constant is used to mark that no table map version has been + assigned. No arithmetic is done on the value: it will be + overwritten with a value taken from MYSQL_BIN_LOG. + */ + share->table_map_version= ~(ulonglong)0; + + /* + Since alloc_table_share() can be called without any locking (for + example, ha_create_table... functions), we do not assign a table + map id here. Instead we assign a value that is not used + elsewhere, and then assign a table map id inside open_table() + under the protection of the LOCK_open mutex. + */ + share->table_map_id= ULONG_MAX; +#endif + memcpy((char*) &share->mem_root, (char*) &mem_root, sizeof(mem_root)); pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST); pthread_cond_init(&share->cond, NULL); @@ -180,6 +198,15 @@ void init_tmp_table_share(TABLE_SHARE *share, const char *key, share->path.length= share->normalized_path.length= strlen(path); share->frm_version= FRM_VER_TRUE_VARCHAR; +#ifdef HAVE_ROW_BASED_REPLICATION + /* + Temporary tables are not replicated, but we set up these fields + anyway to be able to catch errors. + */ + share->table_map_version= ~(ulonglong)0; + share->table_map_id= ULONG_MAX; +#endif + DBUG_VOID_RETURN; } @@ -371,6 +398,7 @@ err_not_open: share->error= error; open_table_error(share, error, (share->open_errno= my_errno), 0); } + DBUG_RETURN(error); } @@ -1503,24 +1531,6 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, *root_ptr= old_root; thd->status_var.opened_tables++; -#ifdef HAVE_REPLICATION - - /* - This constant is used to mark that no table map version has been - assigned. No arithmetic is done on the value: it will be - overwritten with a value taken from MYSQL_BIN_LOG. - */ - share->table_map_version= ~(ulonglong)0; - - /* - Since openfrm() can be called without any locking (for example, - ha_create_table... functions), we do not assign a table map id - here. Instead we assign a value that is not used elsewhere, and - then assign a table map id inside open_table() under the - protection of the LOCK_open mutex. - */ - share->table_map_id= ULONG_MAX; -#endif DBUG_RETURN (0); @@ -3326,8 +3336,15 @@ const char *Natural_join_column::db_name() if (view_field) return table_ref->view_db.str; + /* + Test that TABLE_LIST::db is the same as st_table_share::db to + ensure consistency. An exception are I_S schema tables, which + are inconsistent in this respect. + */ DBUG_ASSERT(!strcmp(table_ref->db, - table_ref->table->s->db.str)); + table_ref->table->s->db.str) || + (table_ref->schema_table && + table_ref->table->s->db.str[0] == 0)); return table_ref->db; } @@ -3529,7 +3546,15 @@ const char *Field_iterator_table_ref::db_name() else if (table_ref->is_natural_join) return natural_join_it.column_ref()->db_name(); - DBUG_ASSERT(!strcmp(table_ref->db, table_ref->table->s->db.str)); + /* + Test that TABLE_LIST::db is the same as st_table_share::db to + ensure consistency. An exception are I_S schema tables, which + are inconsistent in this respect. + */ + DBUG_ASSERT(!strcmp(table_ref->db, table_ref->table->s->db.str) || + (table_ref->schema_table && + table_ref->table->s->db.str[0] == 0)); + return table_ref->db; } |