diff options
author | Sergei Golubchik <sergii@pisem.net> | 2010-06-01 21:52:20 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2010-06-01 21:52:20 +0200 |
commit | ffc8f62b08982cc1f2fabf8b4b38bd124c115a97 (patch) | |
tree | da42637b1ae9402a7436b715f9c0db57cdddc87a /storage/myisammrg | |
parent | 6b157f6be3cb056a93eb925df3880098c871b32a (diff) | |
parent | 0fc39acb8125fae95062e7b680b022b075a308c3 (diff) | |
download | mariadb-git-ffc8f62b08982cc1f2fabf8b4b38bd124c115a97.tar.gz |
merge 5.1->5.2
Diffstat (limited to 'storage/myisammrg')
-rw-r--r-- | storage/myisammrg/ha_myisammrg.cc | 141 | ||||
-rw-r--r-- | storage/myisammrg/myrg_open.c | 8 |
2 files changed, 89 insertions, 60 deletions
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index b0e64fec344..f27f22761b1 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -216,36 +216,14 @@ const char *ha_myisammrg::index_type(uint key_number) static int myisammrg_parent_open_callback(void *callback_param, const char *filename) { - ha_myisammrg *ha_myrg; - TABLE *parent; + ha_myisammrg *ha_myrg= (ha_myisammrg*) callback_param; + TABLE *parent= ha_myrg->table_ptr(); TABLE_LIST *child_l; - const char *db; - const char *table_name; size_t dirlen; char dir_path[FN_REFLEN]; + char name_buf[NAME_LEN]; DBUG_ENTER("myisammrg_parent_open_callback"); - /* Extract child table name and database name from filename. */ - dirlen= dirname_length(filename); - if (dirlen >= FN_REFLEN) - { - /* purecov: begin inspected */ - DBUG_PRINT("error", ("name too long: '%.64s'", filename)); - my_errno= ENAMETOOLONG; - DBUG_RETURN(1); - /* purecov: end */ - } - table_name= filename + dirlen; - dirlen--; /* Strip off trailing '/'. */ - memcpy(dir_path, filename, dirlen); - dir_path[dirlen]= '\0'; - db= base_name(dir_path); - dirlen-= db - dir_path; /* This is now the length of 'db'. */ - DBUG_PRINT("myrg", ("open: '%s'.'%s'", db, table_name)); - - ha_myrg= (ha_myisammrg*) callback_param; - parent= ha_myrg->table_ptr(); - /* Get a TABLE_LIST object. */ if (!(child_l= (TABLE_LIST*) alloc_root(&parent->mem_root, sizeof(TABLE_LIST)))) @@ -257,13 +235,70 @@ static int myisammrg_parent_open_callback(void *callback_param, } bzero((char*) child_l, sizeof(TABLE_LIST)); - /* Set database (schema) name. */ - child_l->db_length= dirlen; - child_l->db= strmake_root(&parent->mem_root, db, dirlen); - /* Set table name. */ - child_l->table_name_length= strlen(table_name); - child_l->table_name= strmake_root(&parent->mem_root, table_name, - child_l->table_name_length); + /* + Depending on MySQL version, filename may be encoded by table name to + file name encoding or not. Always encoded if parent table is created + by 5.1.46+. Encoded if parent is created by 5.1.6+ and child table is + in different database. + */ + if (!has_path(filename)) + { + /* Child is in the same database as parent. */ + child_l->db_length= parent->s->db.length; + child_l->db= strmake_root(&parent->mem_root, parent->s->db.str, + child_l->db_length); + /* Child table name is encoded in parent dot-MRG starting with 5.1.46. */ + if (parent->s->mysql_version >= 50146) + { + child_l->table_name_length= filename_to_tablename(filename, name_buf, + sizeof(name_buf)); + child_l->table_name= strmake_root(&parent->mem_root, name_buf, + child_l->table_name_length); + } + else + { + child_l->table_name_length= strlen(filename); + child_l->table_name= strmake_root(&parent->mem_root, filename, + child_l->table_name_length); + } + } + else + { + DBUG_ASSERT(strlen(filename) < sizeof(dir_path)); + fn_format(dir_path, filename, "", "", 0); + /* Extract child table name and database name from filename. */ + dirlen= dirname_length(dir_path); + /* Child db/table name is encoded in parent dot-MRG starting with 5.1.6. */ + if (parent->s->mysql_version >= 50106) + { + child_l->table_name_length= filename_to_tablename(dir_path + dirlen, + name_buf, + sizeof(name_buf)); + child_l->table_name= strmake_root(&parent->mem_root, name_buf, + child_l->table_name_length); + dir_path[dirlen - 1]= 0; + dirlen= dirname_length(dir_path); + child_l->db_length= filename_to_tablename(dir_path + dirlen, name_buf, + sizeof(name_buf)); + child_l->db= strmake_root(&parent->mem_root, name_buf, child_l->db_length); + } + else + { + child_l->table_name_length= strlen(dir_path + dirlen); + child_l->table_name= strmake_root(&parent->mem_root, dir_path + dirlen, + child_l->table_name_length); + dir_path[dirlen - 1]= 0; + dirlen= dirname_length(dir_path); + child_l->db_length= strlen(dir_path + dirlen); + child_l->db= strmake_root(&parent->mem_root, dir_path + dirlen, + child_l->db_length); + } + } + + DBUG_PRINT("myrg", ("open: '%.*s'.'%.*s'", (int)(child_l->db_length), + child_l->db, (int)(child_l->table_name_length), + child_l->table_name)); + /* Convert to lowercase if required. */ if (lower_case_table_names && child_l->table_name_length) child_l->table_name_length= my_casedn_str(files_charset_info, @@ -395,13 +430,13 @@ static MI_INFO *myisammrg_attach_children_callback(void *callback_param) @detail This function initializes the MERGE storage engine structures and adds a child list of TABLE_LIST to the parent TABLE. - @param[in] name MERGE table path name - @param[in] mode read/write mode, unused - @param[in] test_if_locked open flags + @param[in] name MERGE table path name + @param[in] mode read/write mode, unused + @param[in] test_if_locked_arg open flags @return status - @retval 0 OK - @retval -1 Error, my_errno gives reason + @retval 0 OK + @retval -1 Error, my_errno gives reason */ int ha_myisammrg::open(const char *name, int mode __attribute__((unused)), @@ -409,7 +444,7 @@ int ha_myisammrg::open(const char *name, int mode __attribute__((unused)), { DBUG_ENTER("ha_myisammrg::open"); DBUG_PRINT("myrg", ("name: '%s' table: 0x%lx", name, (long) table)); - DBUG_PRINT("myrg", ("test_if_locked: %u", test_if_locked_arg)); + DBUG_PRINT("myrg", ("test_if_locked_arg: %u", test_if_locked_arg)); /* Save for later use. */ test_if_locked= test_if_locked_arg; @@ -1135,7 +1170,7 @@ int ha_myisammrg::create(const char *name, register TABLE *form, /* Create child path names. */ for (pos= table_names; tables; tables= tables->next_local) { - const char *table_name; + const char *table_name= buff; /* Construct the path to the MyISAM table. Try to meet two conditions: @@ -1161,10 +1196,12 @@ int ha_myisammrg::create(const char *name, register TABLE *form, as the MyISAM tables are from the same database as the MERGE table. */ if ((dirname_length(buff) == dirlgt) && ! memcmp(buff, name, dirlgt)) - table_name= tables->table_name; - else - if (! (table_name= thd->strmake(buff, length))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* purecov: inspected */ + { + table_name+= dirlgt; + length-= dirlgt; + } + if (!(table_name= thd->strmake(table_name, length))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* purecov: inspected */ *pos++= table_name; } @@ -1185,7 +1222,7 @@ void ha_myisammrg::append_create_info(String *packet) const char *current_db; size_t db_length; THD *thd= current_thd; - MYRG_TABLE *open_table, *first; + TABLE_LIST *open_table, *first; if (file->merge_insert_method != MERGE_INSERT_DISABLED) { @@ -1203,14 +1240,11 @@ void ha_myisammrg::append_create_info(String *packet) current_db= table->s->db.str; db_length= table->s->db.length; - for (first=open_table=file->open_tables ; - open_table != file->end_table ; - open_table++) + for (first= open_table= table->child_l;; + open_table= open_table->next_global) { - LEX_STRING db, name; - LINT_INIT(db.str); + LEX_STRING db= { open_table->db, open_table->db_length }; - split_file_name(open_table->table->filename, &db, &name); if (open_table != first) packet->append(','); /* Report database for mapped table if it isn't in current database */ @@ -1221,7 +1255,10 @@ void ha_myisammrg::append_create_info(String *packet) append_identifier(thd, packet, db.str, db.length); packet->append('.'); } - append_identifier(thd, packet, name.str, name.length); + append_identifier(thd, packet, open_table->table_name, + open_table->table_name_length); + if (&open_table->next_global == table->child_last_l) + break; } packet->append(')'); } diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c index 32ac719ec4d..ea306c5ba9c 100644 --- a/storage/myisammrg/myrg_open.c +++ b/storage/myisammrg/myrg_open.c @@ -312,14 +312,6 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, if (!child_name_buff[0] || (child_name_buff[0] == '#')) continue; - if (!has_path(child_name_buff)) - { - VOID(strmake(parent_name_buff + dir_length, child_name_buff, - sizeof(parent_name_buff) - 1 - dir_length)); - VOID(cleanup_dirname(child_name_buff, parent_name_buff)); - } - else - fn_format(child_name_buff, child_name_buff, "", "", 0); DBUG_PRINT("info", ("child: '%s'", child_name_buff)); /* Callback registers child with handler table. */ |