mariadb/sql/my_lock.c
unknown cc589bef15 Fixed bug in undo_key_delete; Caused crashed key files in recovery
Maria is now used for internal temporary tables in MySQL
Better usage of VARCHAR and long strings in temporary tables
Use packed fields if BLOCK_RECORD is used
null_bytes are not anymore stored in a separate field
New interface to remember and restore scan position
Fixed bugs in unique handling
Don't sync Maria temporary tables
Lock control file while it's used to stop several processes from using it
Changed value of MA_DONT_OVERWRITE_FILE as it collided with MY_SYNC_DIR
Split MY_DONT_WAIT into MY_NO_WAIT and MY_SHORT_WAIT (for my_lock())
Added MY_FORCE_LOCK


include/my_sys.h:
  Changed value of MA_DONT_OVERWRITE_FILE as it collided with MY_SYNC_DIR
  Split MY_DONT_WAIT into MY_NO_WAIT and MY_SHORT_WAIT (for my_lock())
  Added MY_FORCE_LOCK
include/myisam.h:
  Make MyISAM columndef compile time compatible with Maria
mysql-test/lib/mtr_process.pl:
  Removed confusing warning (It's common that there is a lot of other files than pid files)
mysql-test/mysql-test-run.pl:
  Added --sync-frm to speed up tests
mysql-test/r/maria-recovery.result:
  Updated results from wrong push
mysql-test/suite/rpl/t/rpl_innodb_bug28430.test:
  Marked test as --big
mysys/my_lock.c:
  If MY_FORCE_LOCK is given, use locking even if my_disable_locking is given
  If MY_NO_WAIT is given, return at once if lock is occupied
  If MY_SHORT_WAIT is given, wait some time for lock before returning (This was called MY_DONT_WAIT before)
mysys/my_thr_init.c:
  Fix that we don't give name to thread before it's properly initied
sql/handler.cc:
  Added myisam.h
sql/handler.h:
  Changes to use Maria for internal temporary tables
  Removed not needed argument to restart_rnd_next()
  Added function remember_rnd_pos()
sql/my_lock.c:
  If MY_FORCE_LOCK is given, use locking even if my_disable_locking is given
  If MY_NO_WAIT is given, return at once if lock is occupied
  If MY_SHORT_WAIT is given, wait some time for lock before returning (This was called MY_DONT_WAIT before)
sql/mysql_priv.h:
  Added maria_hton
sql/sql_class.h:
  Changes to use Maria for internal temporary tables
sql/sql_select.cc:
  Changes to use Maria for internal temporary tables
  Temporary tables didn't properly switch to dynamic row format if long strings was used
  Better usage of VARCHAR in temporary tables
  Use new interface to restart scan in duplicate removal
sql/sql_select.h:
  Changes to use Maria for internal temporary tables
sql/sql_show.cc:
  Changes to use Maria for internal temporary tables
  Removed all end space
sql/sql_table.cc:
  Set HA_OPTION_PACK_RECORD if we are not using default or static record
sql/sql_union.cc:
  If MY_FORCE_LOCK is given, use locking even if my_disable_locking is given
  If MY_NO_WAIT is given, return at once if lock is occupied
  If MY_SHORT_WAIT is given, wait some time for lock before returning (This was called MY_DONT_WAIT before)
sql/sql_update.cc:
  If MY_FORCE_LOCK is given, use locking even if my_disable_locking is given
  If MY_NO_WAIT is given, return at once if lock is occupied
  If MY_SHORT_WAIT is given, wait some time for lock before returning (This was called MY_DONT_WAIT before)
storage/maria/ha_maria.cc:
  Use packed fields
  null_bytes are not anymore stored in a separate field
  Changes to use Maria for internal temporary tables
  Give warning if we try to do an ALTER TABLE to a unusable row format
storage/maria/ha_maria.h:
  Allow Maria with block format to restart scanning at given position
storage/maria/ma_blockrec.c:
  Added functions to remember and restore scan position
  Allocate cur_row.extents so that we don't have to do a malloc on first read
  Fixed bug when using packed row without packed strings
  Removed unneeded calls to free_full_pages()
  Fixed unlikely bug when using old bitmap to read head page and head page had gone away
  Remember row position when doing undo of delete and update row (needed for undo of key delete)
storage/maria/ma_blockrec.h:
  Added functions to remember and restore scan position
storage/maria/ma_close.c:
  Don't sync temporary tables
storage/maria/ma_control_file.c:
  Lock control file while it's used to stop several processes from using it
storage/maria/ma_create.c:
  Fixed bug when using FIELD_NORMAL that was longer than FULL_PAGE_SIZE
  Fixed bug that casued fields to not be ordered according to offset
  Fixed bug in unique creation
storage/maria/ma_delete.c:
  Don't write record reference when deleting key.
  (Rowid is likely to be different when we undo this)
storage/maria/ma_dynrec.c:
  Fixed core dump when comparing records (happended in unique handling)
storage/maria/ma_extra.c:
  MY_DONT_WAIT -> MY_SHORT_WAIT
  Removed TODO comment. (Was not relevant as all other instances are guranteed to be closed when we the code is excecuted)
  Added DBUG_ASSERT() to prove above.
storage/maria/ma_key_recover.c:
  CLR's for UNDO_ROW_DELETE and UNDO_ROW_UPDATE now include rowid for the row.
  This was needed for undo_key_delete to work, as undo of delete row is likely to put row in a new position.
  undo_delete_key now doesn't include row position
storage/maria/ma_open.c:
  Added virtual functions for remembering and restoring scan position
  Fixed wrong key search method when using multi-byte character sets (Bug#32705)
  Store original column number in index file
  
  NOTE: Index files are now incompatible with previous versions!
  (Ok as we haven't yet made a public Maria release)
storage/maria/ma_recovery.c:
  Set info->cur_row.lastpos when reading CLR's for UNDO_ROW_DELETE or UNDO_ROW_UPDATE
storage/maria/ma_scan.c:
  Added default function to remember and restore scan position
storage/maria/maria_def.h:
  Added virtual functions & variables to remember and restore scan position
  Added MARIA_MAX_CONTROL_FILE_LOCK_RETRY
storage/myisam/ha_myisam.cc:
  Fixed compiler errors as columdef->type is now an enum, not an integer
  Added functions to remember and restore scan position
storage/myisam/ha_myisam.h:
  Added functions to remember and restore scan position
storage/myisam/mi_check.c:
  MY_DONT_WAIT -> MY_SHORT_WAIT
storage/myisam/mi_extra.c:
  MY_DONT_WAIT -> MY_SHORT_WAIT
storage/myisam/mi_open.c:
  MY_DONT_WAIT -> MY_SHORT_WAIT
storage/myisam/myisamdef.h:
  MY_DONT_WAIT -> MY_SHORT_WAIT
2007-12-17 01:17:37 +02:00

91 lines
2.7 KiB
C

/* Copyright (C) 2000-2003 MySQL 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 */
#if defined(__NETWARE__)
#include "../mysys/my_lock.c"
#else
#undef MAP_TO_USE_RAID /* Avoid RAID mappings */
#include <my_global.h>
#include <my_sys.h>
#include <mysys_err.h>
#include <my_pthread.h>
#include <thr_alarm.h>
#include <errno.h>
/**
@breif Lock a part of a file
@note
This works like mysys/my_lock.c, with the exception that this function
uses the thr_alarm() to break long lock statements.
(mysys can't use thr_alarm() as by default the alarm handling doesn't
exists)
*/
int my_lock(File fd,int locktype,my_off_t start,my_off_t length,myf MyFlags)
{
thr_alarm_t alarmed;
ALARM alarm_buff;
uint wait_for_alarm;
struct flock m_lock;
DBUG_ENTER("my_lock");
DBUG_PRINT("my",("Fd: %d Op: %d start: %ld Length: %ld MyFlags: %d",
fd,locktype,(ulong) start,(ulong) length,MyFlags));
if (my_disable_locking && ! (MyFlags & MY_FORCE_LOCK))
DBUG_RETURN(0); /* purecov: inspected */
m_lock.l_type=(short) locktype;
m_lock.l_whence=0L;
m_lock.l_start=(long) start;
m_lock.l_len=(long) length;
if (fcntl(fd,F_SETLK,&m_lock) != -1) /* Check if we can lock */
DBUG_RETURN(0); /* Ok, file locked */
if (!(MyFlags & MY_NO_WAIT))
{
wait_for_alarm= (MyFlags & MY_SHORT_WAIT ? MY_HOW_OFTEN_TO_ALARM :
(uint) 12*60*60);
DBUG_PRINT("info",("Was locked, trying with alarm"));
if (!thr_alarm(&alarmed,wait_for_alarm,&alarm_buff))
{
int value;
while ((value=fcntl(fd,F_SETLKW,&m_lock)) && !thr_got_alarm(&alarmed) &&
errno == EINTR) ;
thr_end_alarm(&alarmed);
if (value != -1)
DBUG_RETURN(0);
}
else
{
errno=EINTR;
}
}
if (errno == EINTR || errno == EACCES)
my_errno=EAGAIN; /* Easier to check for this */
else
my_errno=errno;
if (MyFlags & MY_WME)
{
if (locktype == F_UNLCK)
my_error(EE_CANTUNLOCK,MYF(ME_BELL+ME_WAITTANG),errno);
else
my_error(EE_CANTLOCK,MYF(ME_BELL+ME_WAITTANG),errno);
}
DBUG_PRINT("error",("errno: %d",errno));
DBUG_RETURN(-1);
}
#endif