mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
2f6f08ed88
Changed info->s -> share to get more efficent code Updated arguments to page accessor functions to use MARIA_SHARE * instead of MARIA_HA *. Tested running tests in quick mode (no balance page on insert and only when critical on delete) Fixed bug in underflow handling in quick mode Fixed bug in log handler where it accessed not initialized variable Fixed bug in log handler where it didn't free mutex in unlikely error condition Removed double write of page in case of of some underflow conditions Added DBUG_PRINT in safemutex lock/unlock dbug/dbug.c: Compile without SAFE_MUTEX (to be able to use DBUG_PRINT in safe_mutex code) Use calls to get/set my_thread_var->dbug. (Make dbug independent of compile time options for mysys) include/my_pthread.h: Added prototypes for my_thread_var_get_dbug() & my_thread_var_set_dbug() mysql-test/lib/mtr_report.pl: Don't check warnings in log files if we are using --extern mysys/my_thr_init.c: Added my_thread_var_get_dbug() & my_thread_var_set_dbug() mysys/thr_mutex.c: Added DBUG printing of addresses to mutex for lock/unlock storage/maria/ma_blockrec.c: Fixed comment storage/maria/ma_check.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions storage/maria/ma_close.c: Indentation fixes storage/maria/ma_create.c: Calculate min_key_length correctly storage/maria/ma_dbug.c: Indentation fixes storage/maria/ma_delete.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions Removed some writing of key pages that underflow (will be written by caller) Fixed crashing bug in underflow handling when using quick mode storage/maria/ma_delete_all.c: Indentation fixes storage/maria/ma_dynrec.c: Indentation fixes storage/maria/ma_extra.c: Fixed indentation Removed old useless code Reset share->changed if we have written state storage/maria/ma_ft_update.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions storage/maria/ma_info.c: Indentation fixes storage/maria/ma_key_recover.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions storage/maria/ma_locking.c: Indentation fixes storage/maria/ma_loghandler.c: Removed wrapper functions translog_mutex_lock and translog_mutex_unlock (safemutex now does same kind of printing) Renamed LOGREC_REDO_INSERT_ROW_BLOB to LOGREC_REDO_INSERT_NOT_USED to mark it free Fixed some DBUG_PRINT to ensure that convert-dbug-for-diff works Fixed bug in translog_flush() that caused log to stop syncing to disk Added missing mutex_unlock in case of error storage/maria/ma_loghandler.h: Renamed LOGREC_REDO_INSERT_ROW_BLOB to LOGREC_REDO_INSERT_NOT_USED to mark it free storage/maria/ma_open.c: Indentation fixes storage/maria/ma_packrec.c: Indentation fixes storage/maria/ma_page.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions Added check that we never write a key page without content (except in recovery where a key page may temporary be without content) storage/maria/ma_preload.c: Updated arguments to page accessor functions storage/maria/ma_range.c: Updated arguments to page accessor functions storage/maria/ma_rkey.c: Indentation fixes storage/maria/ma_rprev.c: Indentation fixes storage/maria/ma_rt_index.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions storage/maria/ma_rt_index.h: Updated arguments to page accessor functions storage/maria/ma_rt_key.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions storage/maria/ma_rt_mbr.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions storage/maria/ma_rt_split.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions storage/maria/ma_search.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions storage/maria/ma_sort.c: Indentation fixes storage/maria/ma_statrec.c: Indentation fixes storage/maria/ma_test1.c: Added extra undo test Flush also keys in -u1, to ensure that the full log is flushed storage/maria/ma_test2.c: Added extra undo test Flush also keys in -u1, to ensure that the full log is flushed storage/maria/ma_test_recovery.expected: Updated results storage/maria/ma_test_recovery: Added extra undo test storage/maria/ma_update.c: Indentation fixes storage/maria/ma_write.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions Prepare for quick mode for insert (don't balance page) storage/maria/maria_chk.c: Added MARIA_SHARE *share to a lot of places to make code simpler info->s -> share Updated arguments to page accessor functions storage/maria/maria_def.h: Updated arguments to page accessor functions
141 lines
4.4 KiB
C
141 lines
4.4 KiB
C
/* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
|
|
|
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
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
/* Return useful base information for an open table */
|
|
|
|
#include "maria_def.h"
|
|
#ifdef __WIN__
|
|
#include <sys/stat.h>
|
|
#endif
|
|
|
|
/* Get position to last record */
|
|
|
|
MARIA_RECORD_POS maria_position(MARIA_HA *info)
|
|
{
|
|
return info->cur_row.lastpos;
|
|
}
|
|
|
|
|
|
/* Get information about the table */
|
|
/* if flag == 2 one get current info (no sync from database */
|
|
|
|
int maria_status(MARIA_HA *info, register MARIA_INFO *x, uint flag)
|
|
{
|
|
MY_STAT state;
|
|
MARIA_SHARE *share= info->s;
|
|
DBUG_ENTER("maria_status");
|
|
|
|
x->recpos= info->cur_row.lastpos;
|
|
if (flag == HA_STATUS_POS)
|
|
DBUG_RETURN(0); /* Compatible with ISAM */
|
|
if (!(flag & HA_STATUS_NO_LOCK))
|
|
{
|
|
pthread_mutex_lock(&share->intern_lock);
|
|
VOID(_ma_readinfo(info,F_RDLCK,0));
|
|
fast_ma_writeinfo(info);
|
|
pthread_mutex_unlock(&share->intern_lock);
|
|
}
|
|
if (flag & HA_STATUS_VARIABLE)
|
|
{
|
|
x->records = info->state->records;
|
|
x->deleted = info->state->del;
|
|
x->delete_length = info->state->empty;
|
|
x->data_file_length =info->state->data_file_length;
|
|
x->index_file_length=info->state->key_file_length;
|
|
|
|
x->keys = share->state.header.keys;
|
|
x->check_time = share->state.check_time;
|
|
x->mean_reclength = x->records ?
|
|
(ulong) ((x->data_file_length - x->delete_length) /x ->records) :
|
|
(ulong) share->min_pack_length;
|
|
}
|
|
if (flag & HA_STATUS_ERRKEY)
|
|
{
|
|
x->errkey= info->errkey;
|
|
x->dup_key_pos= info->dup_key_pos;
|
|
}
|
|
if (flag & HA_STATUS_CONST)
|
|
{
|
|
x->reclength = share->base.reclength;
|
|
x->max_data_file_length=share->base.max_data_file_length;
|
|
x->max_index_file_length=info->s->base.max_key_file_length;
|
|
x->filenr = info->dfile.file;
|
|
x->options = share->options;
|
|
x->create_time=share->state.create_time;
|
|
x->reflength= maria_get_pointer_length(share->base.max_data_file_length,
|
|
maria_data_pointer_size);
|
|
x->record_offset= (info->s->data_file_type == STATIC_RECORD ?
|
|
share->base.pack_reclength: 0);
|
|
x->sortkey= -1; /* No clustering */
|
|
x->rec_per_key = share->state.rec_per_key_part;
|
|
x->key_map = share->state.key_map;
|
|
x->data_file_name = share->data_file_name;
|
|
x->index_file_name = share->index_file_name;
|
|
x->data_file_type = share->data_file_type;
|
|
}
|
|
if ((flag & HA_STATUS_TIME) && !my_fstat(info->dfile.file, &state, MYF(0)))
|
|
x->update_time=state.st_mtime;
|
|
else
|
|
x->update_time=0;
|
|
if (flag & HA_STATUS_AUTO)
|
|
{
|
|
x->auto_increment= share->state.auto_increment+1;
|
|
if (!x->auto_increment) /* This shouldn't happen */
|
|
x->auto_increment= ~(ulonglong) 0;
|
|
}
|
|
DBUG_RETURN(0);
|
|
}
|
|
|
|
|
|
/*
|
|
Write a message to the error log.
|
|
|
|
SYNOPSIS
|
|
_ma_report_error()
|
|
file_name Name of table file (e.g. index_file_name).
|
|
errcode Error number.
|
|
|
|
DESCRIPTION
|
|
This function supplies my_error() with a table name. Most error
|
|
messages need one. Since string arguments in error messages are limited
|
|
to 64 characters by convention, we ensure that in case of truncation,
|
|
that the end of the index file path is in the message. This contains
|
|
the most valuable information (the table name and the database name).
|
|
|
|
RETURN
|
|
void
|
|
*/
|
|
|
|
void _ma_report_error(int errcode, const char *file_name)
|
|
{
|
|
uint length;
|
|
DBUG_ENTER("_ma_report_error");
|
|
DBUG_PRINT("enter",("errcode %d, table '%s'", errcode, file_name));
|
|
|
|
if ((length= strlen(file_name)) > 64)
|
|
{
|
|
/* we first remove the directory */
|
|
uint dir_length= dirname_length(file_name);
|
|
file_name+= dir_length;
|
|
if ((length-= dir_length) > 64)
|
|
{
|
|
/* still too long, chop start of table name */
|
|
file_name+= length - 64;
|
|
}
|
|
}
|
|
|
|
my_error(errcode, MYF(ME_NOREFRESH), file_name);
|
|
DBUG_VOID_RETURN;
|
|
}
|