mariadb/myisam/mi_page.c
unknown 45199f545c After merge fixes
Cleanup of mi_print_error() handling
Deleted 'merge' directory


BitKeeper/deleted/.del-mrg_close.c~1fa9230422daa62a:
  Delete: merge/mrg_close.c
BitKeeper/deleted/.del-mrg_create.c~b747c8ec2b801f6:
  Delete: merge/mrg_create.c
BitKeeper/deleted/.del-mrg_delete.c~38b4156885bb4537:
  Delete: merge/mrg_delete.c
BitKeeper/deleted/.del-mrg_extra.c~7eb6181e1761907e:
  Delete: merge/mrg_extra.c
BitKeeper/deleted/.del-mrg_info.c~37728e7238cc5a11:
  Delete: merge/mrg_info.c
BitKeeper/deleted/.del-mrg_locking.c~112756a2d581e1d0:
  Delete: merge/mrg_locking.c
BitKeeper/deleted/.del-mrg_open.c~6e1d5c8bfa62a519:
  Delete: merge/mrg_open.c
BitKeeper/deleted/.del-mrg_panic.c~e204e43cd6d55406:
  Delete: merge/mrg_panic.c
BitKeeper/deleted/.del-mrg_rrnd.c~6087c3dd7ecb77:
  Delete: merge/mrg_rrnd.c
BitKeeper/deleted/.del-mrg_rsame.c~3e8ed4be2a0952b1:
  Delete: merge/mrg_rsame.c
BitKeeper/deleted/.del-mrg_static.c~75a4b78a165dbd0:
  Delete: merge/mrg_static.c
BitKeeper/deleted/.del-mrg_update.c~4110a4f1fbf1ab45:
  Delete: merge/mrg_update.c
BitKeeper/deleted/.del-Makefile.am~41238af048e60515:
  Delete: merge/Makefile.am
BitKeeper/deleted/.del-make-ccc~4f1acbfc127e25d5:
  Delete: merge/make-ccc
BitKeeper/deleted/.del-mrg_def.h~a10557d12a87ef1c:
  Delete: merge/mrg_def.h
BitKeeper/deleted/.del-.cvsignore~2f287ba794db3da7:
  Delete: merge/.cvsignore
include/myisam.h:
  Added 'share' to st_mi_keydef' to not have to pass 'st_myisam_info' to functions
myisam/ft_static.c:
  Removed compiler warning
myisam/mi_delete.c:
  Cleanup of mi_print_error() handling
  Break if get_key() return 0
  Don't test for HA_ERR_CRASHED; Print errors when my_errno is set
myisam/mi_extra.c:
  Cleanup of mi_print_error() handling
myisam/mi_key.c:
  Cleanup of mi_print_error() handling
myisam/mi_keycache.c:
  Cleanup of mi_print_error() handling
myisam/mi_locking.c:
  Cleanup of mi_print_error() handling
myisam/mi_open.c:
  Added 'my_isam_share' to MI_KEYDEF
myisam/mi_page.c:
  Cleanup of mi_print_error() handling
myisam/mi_range.c:
  get_key() calls mi_print_error() if needed
myisam/mi_rkey.c:
  Cleanup of mi_print_error() handling
myisam/mi_search.c:
  Cleanup of mi_print_error() handling
  Break if get_key() return 0
  Don't test for HA_ERR_CRASHED; Print errors when my_errno is set
myisam/mi_update.c:
  Cleanup of mi_print_error() handling
myisam/mi_write.c:
  Cleanup of mi_print_error() handling
  Break if get_key() return 0
  Don't test for HA_ERR_CRASHED; Print errors when my_errno is set
myisam/myisamdef.h:
  Cleanup of mi_print_error() handling
mysql-test/r/grant.result:
  Update results after merge
mysql-test/r/timezone2.result:
  Update results after merge
mysql-test/t/grant.test:
  New error numbers
mysql-test/t/timezone2.test:
  New error numbers
sql/item_func.cc:
  Remove duplicate include file
sql/sql_acl.cc:
  Remove warnings from valgrind
sql/tztime.cc:
  Print wrong timezone names to log
2004-12-31 03:47:56 +02:00

160 lines
5 KiB
C

/* Copyright (C) 2000 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; either version 2 of the License, or
(at your option) any later version.
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 */
/* Read and write key blocks */
#include "myisamdef.h"
/* Fetch a key-page in memory */
uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo,
my_off_t page, int level,
uchar *buff, int return_buffer)
{
uchar *tmp;
uint page_size;
DBUG_ENTER("_mi_fetch_keypage");
DBUG_PRINT("enter",("page: %ld",page));
tmp=(uchar*) key_cache_read(info->s->key_cache,
info->s->kfile, page, level, (byte*) buff,
(uint) keyinfo->block_length,
(uint) keyinfo->block_length,
return_buffer);
if (tmp == info->buff)
info->buff_used=1;
else if (!tmp)
{
DBUG_PRINT("error",("Got errno: %d from key_cache_read",my_errno));
info->last_keypage=HA_OFFSET_ERROR;
mi_print_error(info->s, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_RETURN(0);
}
info->last_keypage=page;
page_size=mi_getint(tmp);
if (page_size < 4 || page_size > keyinfo->block_length)
{
DBUG_PRINT("error",("page %lu had wrong page length: %u",
(ulong) page, page_size));
DBUG_DUMP("page", (char*) tmp, keyinfo->block_length);
info->last_keypage = HA_OFFSET_ERROR;
mi_print_error(info->s, HA_ERR_CRASHED);
my_errno = HA_ERR_CRASHED;
tmp = 0;
}
DBUG_RETURN(tmp);
} /* _mi_fetch_keypage */
/* Write a key-page on disk */
int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo,
my_off_t page, int level, uchar *buff)
{
reg3 uint length;
DBUG_ENTER("_mi_write_keypage");
#ifndef FAST /* Safety check */
if (page < info->s->base.keystart ||
page+keyinfo->block_length > info->state->key_file_length ||
(page & (MI_MIN_KEY_BLOCK_LENGTH-1)))
{
DBUG_PRINT("error",("Trying to write inside key status region: key_start: %lu length: %lu page: %lu",
(long) info->s->base.keystart,
(long) info->state->key_file_length,
(long) page));
my_errno=EINVAL;
DBUG_RETURN((-1));
}
DBUG_PRINT("page",("write page at: %lu",(long) page,buff));
DBUG_DUMP("buff",(byte*) buff,mi_getint(buff));
#endif
if ((length=keyinfo->block_length) > IO_SIZE*2 &&
info->state->key_file_length != page+length)
length= ((mi_getint(buff)+IO_SIZE-1) & (uint) ~(IO_SIZE-1));
#ifdef HAVE_purify
{
length=mi_getint(buff);
bzero((byte*) buff+length,keyinfo->block_length-length);
length=keyinfo->block_length;
}
#endif
DBUG_RETURN((key_cache_write(info->s->key_cache,
info->s->kfile,page, level, (byte*) buff,length,
(uint) keyinfo->block_length,
(int) ((info->lock_type != F_UNLCK) ||
info->s->delay_key_write))));
} /* mi_write_keypage */
/* Remove page from disk */
int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos,
int level)
{
my_off_t old_link;
char buff[8];
DBUG_ENTER("_mi_dispose");
DBUG_PRINT("enter",("pos: %ld", (long) pos));
old_link=info->s->state.key_del[keyinfo->block_size];
info->s->state.key_del[keyinfo->block_size]=pos;
mi_sizestore(buff,old_link);
info->s->state.changed|= STATE_NOT_SORTED_PAGES;
DBUG_RETURN(key_cache_write(info->s->key_cache,
info->s->kfile, pos , level, buff,
sizeof(buff),
(uint) keyinfo->block_length,
(int) (info->lock_type != F_UNLCK)));
} /* _mi_dispose */
/* Make new page on disk */
my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level)
{
my_off_t pos;
char buff[8];
DBUG_ENTER("_mi_new");
if ((pos=info->s->state.key_del[keyinfo->block_size]) == HA_OFFSET_ERROR)
{
if (info->state->key_file_length >=
info->s->base.max_key_file_length - keyinfo->block_length)
{
my_errno=HA_ERR_INDEX_FILE_FULL;
DBUG_RETURN(HA_OFFSET_ERROR);
}
pos=info->state->key_file_length;
info->state->key_file_length+= keyinfo->block_length;
}
else
{
if (!key_cache_read(info->s->key_cache,
info->s->kfile, pos, level,
buff,
(uint) sizeof(buff),
(uint) keyinfo->block_length,0))
pos= HA_OFFSET_ERROR;
else
info->s->state.key_del[keyinfo->block_size]=mi_sizekorr(buff);
}
info->s->state.changed|= STATE_NOT_SORTED_PAGES;
DBUG_PRINT("exit",("Pos: %ld",(long) pos));
DBUG_RETURN(pos);
} /* _mi_new */