summaryrefslogtreecommitdiff
path: root/storage/myisammrg
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2009-09-08 00:50:10 +0400
committerSergey Petrunya <psergey@askmonty.org>2009-09-08 00:50:10 +0400
commit29f0dcb56337a3e352ad7a70dcff6b25bb605325 (patch)
tree84935c21dc958724ae7dcbeeca0c0f08986fc430 /storage/myisammrg
parent915a624cbcb58a10a2cfb2e2e4fd5029191fa86a (diff)
parent8a2454f8e9fce648272577fcf8006ae6e6806cf9 (diff)
downloadmariadb-git-29f0dcb56337a3e352ad7a70dcff6b25bb605325.tar.gz
Merge MySQL->MariaDB
* Finished Monty and Jani's merge * Some InnoDB tests still fail (because it's old xtradb code run against newer testsuite). They are expected to go after mergning with the latest xtradb.
Diffstat (limited to 'storage/myisammrg')
-rwxr-xr-xstorage/myisammrg/CMakeLists.txt11
-rw-r--r--storage/myisammrg/ha_myisammrg.cc18
-rw-r--r--storage/myisammrg/ha_myisammrg.h3
-rw-r--r--storage/myisammrg/myrg_info.c18
-rw-r--r--storage/myisammrg/myrg_open.c20
5 files changed, 48 insertions, 22 deletions
diff --git a/storage/myisammrg/CMakeLists.txt b/storage/myisammrg/CMakeLists.txt
index 1c94e2bd50c..60cfffc67ff 100755
--- a/storage/myisammrg/CMakeLists.txt
+++ b/storage/myisammrg/CMakeLists.txt
@@ -12,14 +12,10 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
SET(MYISAMMRG_SOURCES myrg_close.c myrg_create.c myrg_delete.c myrg_extra.c myrg_info.c
ha_myisammrg.cc
@@ -28,7 +24,4 @@ SET(MYISAMMRG_SOURCES myrg_close.c myrg_create.c myrg_delete.c myrg_extra.c myr
myrg_rprev.c myrg_rrnd.c myrg_rsame.c myrg_static.c myrg_update.c
myrg_write.c myrg_records.c)
-IF(NOT SOURCE_SUBLIBS)
- ADD_LIBRARY(myisammrg ${MYISAMMRG_SOURCES})
- ADD_DEPENDENCIES(myisammrg GenError)
-ENDIF(NOT SOURCE_SUBLIBS)
+MYSQL_STORAGE_ENGINE(MYISAMMRG)
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index a1e6ae842bf..67f2d6457c7 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -139,7 +139,8 @@ extern int check_definition(MI_KEYDEF *t1_keyinfo,
uint t1_keys, uint t1_recs,
MI_KEYDEF *t2_keyinfo,
MI_COLUMNDEF *t2_recinfo,
- uint t2_keys, uint t2_recs, bool strict);
+ uint t2_keys, uint t2_recs, bool strict,
+ TABLE *table_arg);
static void split_file_name(const char *file_name,
LEX_STRING *db, LEX_STRING *name);
@@ -546,7 +547,8 @@ int ha_myisammrg::attach_children(void)
if (myrg_attach_children(this->file, this->test_if_locked |
current_thd->open_options,
- myisammrg_attach_children_callback, this))
+ myisammrg_attach_children_callback, this,
+ (my_bool *) &need_compat_check))
{
DBUG_PRINT("error", ("my_errno %d", my_errno));
DBUG_RETURN(my_errno ? my_errno : -1);
@@ -597,7 +599,7 @@ int ha_myisammrg::attach_children(void)
if (check_definition(keyinfo, recinfo, keys, recs,
u_table->table->s->keyinfo, u_table->table->s->rec,
u_table->table->s->base.keys,
- u_table->table->s->base.fields, false))
+ u_table->table->s->base.fields, false, NULL))
{
DBUG_PRINT("error", ("table definition mismatch: '%s'",
u_table->table->filename));
@@ -884,7 +886,6 @@ int ha_myisammrg::info(uint flag)
*/
mrg_info.errkey= MAX_KEY;
}
- errkey= mrg_info.errkey;
table->s->keys_in_use.set_prefix(table->s->keys);
stats.mean_rec_length= mrg_info.reclength;
@@ -926,14 +927,19 @@ int ha_myisammrg::info(uint flag)
with such a number, it'll be an error later anyway.
*/
bzero((char*) table->key_info[0].rec_per_key,
- sizeof(table->key_info[0].rec_per_key) * table->s->key_parts);
+ sizeof(table->key_info[0].rec_per_key[0]) * table->s->key_parts);
#endif
memcpy((char*) table->key_info[0].rec_per_key,
(char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key) *
+ sizeof(table->key_info[0].rec_per_key[0]) *
min(file->keys, table->s->key_parts));
}
}
+ if (flag & HA_STATUS_ERRKEY)
+ {
+ errkey= mrg_info.errkey;
+ my_store_ptr(dup_ref, ref_length, mrg_info.dupp_key_pos);
+ }
return 0;
}
diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h
index 3434aa2f4ed..4a65a60d97b 100644
--- a/storage/myisammrg/ha_myisammrg.h
+++ b/storage/myisammrg/ha_myisammrg.h
@@ -44,7 +44,8 @@ class ha_myisammrg: public handler
HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED |
HA_ANY_INDEX_MAY_BE_UNIQUE | HA_CAN_BIT_FIELD |
HA_HAS_RECORDS |
- HA_NO_COPY_ON_ALTER);
+ HA_NO_COPY_ON_ALTER |
+ HA_DUPLICATE_POS);
}
ulong index_flags(uint inx, uint part, bool all_parts) const
{
diff --git a/storage/myisammrg/myrg_info.c b/storage/myisammrg/myrg_info.c
index 7ea2dbf58e3..1930351ec8f 100644
--- a/storage/myisammrg/myrg_info.c
+++ b/storage/myisammrg/myrg_info.c
@@ -58,9 +58,27 @@ int myrg_status(MYRG_INFO *info,register MYMERGE_INFO *x,int flag)
x->reclength= info->reclength;
x->options= info->options;
if (current_table)
+ {
+ /*
+ errkey is set to the index number of the myisam tables. But
+ since the MERGE table can have less keys than the MyISAM
+ tables, errkey cannot be be used as an index into the key_info
+ on the server. This value will be overwritten with MAX_KEY by
+ the MERGE engine.
+ */
x->errkey= current_table->table->errkey;
+ /*
+ Calculate the position of the duplicate key to be the sum of the
+ offset of the myisam file and the offset into the file at which
+ the duplicate key is located.
+ */
+ x->dupp_key_pos= current_table->file_offset + current_table->table->dupp_key_pos;
+ }
else
+ {
x->errkey= 0;
+ x->dupp_key_pos= 0;
+ }
x->rec_per_key = info->rec_per_key_part;
}
DBUG_RETURN(0);
diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c
index 14ba2853b22..01420f47a0c 100644
--- a/storage/myisammrg/myrg_open.c
+++ b/storage/myisammrg/myrg_open.c
@@ -365,11 +365,14 @@ MYRG_INFO *myrg_parent_open(const char *parent_name,
The callback returns the MyISAM table handle of the child table.
Check table definition match.
- @param[in] m_info MERGE parent table structure
- @param[in] handle_locking if contains HA_OPEN_FOR_REPAIR, warn about
- incompatible child tables, but continue
- @param[in] callback function to call for each child table
- @param[in] callback_param data pointer to give to the callback
+ @param[in] m_info MERGE parent table structure
+ @param[in] handle_locking if contains HA_OPEN_FOR_REPAIR, warn about
+ incompatible child tables, but continue
+ @param[in] callback function to call for each child table
+ @param[in] callback_param data pointer to give to the callback
+ @param[in] need_compat_check pointer to ha_myisammrg::need_compat_check
+ (we need this one to decide if previously
+ allocated buffers can be reused).
@return status
@retval 0 OK
@@ -382,7 +385,7 @@ MYRG_INFO *myrg_parent_open(const char *parent_name,
int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
MI_INFO *(*callback)(void*),
- void *callback_param)
+ void *callback_param, my_bool *need_compat_check)
{
ulonglong file_offset;
MI_INFO *myisam;
@@ -423,6 +426,11 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
m_info->reclength= myisam->s->base.reclength;
min_keys= myisam->s->base.keys;
key_parts= myisam->s->base.key_parts;
+ if (*need_compat_check && m_info->rec_per_key_part)
+ {
+ my_free((char *) m_info->rec_per_key_part, MYF(0));
+ m_info->rec_per_key_part= NULL;
+ }
if (!m_info->rec_per_key_part)
{
if(!(m_info->rec_per_key_part= (ulong*)