diff options
author | unknown <monty@donna.mysql.com> | 2001-01-15 17:17:43 +0200 |
---|---|---|
committer | unknown <monty@donna.mysql.com> | 2001-01-15 17:17:43 +0200 |
commit | 4d37689abeeaacb662c31d58038d2386a5228f8f (patch) | |
tree | 4264a6499afeab1b99e53f927059e5450643a435 | |
parent | 4e264107df5c286d0a06ff28699aec398e36e684 (diff) | |
download | mariadb-git-4d37689abeeaacb662c31d58038d2386a5228f8f.tar.gz |
Fixed test when exeeding file quota on write
Sanity checks when opening MyISAM files
Docs/manual.texi:
Added information about Borland c++
myisam/mi_check.c:
Cleanup
myisam/mi_open.c:
Added sanity checking
myisam/myisamchk.c:
Better error messages
mysys/my_chsize.c:
Cleanup
mysys/my_seek.c:
Changed debug message
mysys/my_write.c:
Fixed test when exeeding file quota
-rw-r--r-- | Docs/manual.texi | 35 | ||||
-rw-r--r-- | myisam/mi_check.c | 2 | ||||
-rw-r--r-- | myisam/mi_open.c | 23 | ||||
-rw-r--r-- | myisam/myisamchk.c | 11 | ||||
-rw-r--r-- | mysys/my_chsize.c | 7 | ||||
-rw-r--r-- | mysys/my_seek.c | 4 | ||||
-rw-r--r-- | mysys/my_write.c | 17 |
7 files changed, 75 insertions, 24 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi index c62156b45df..6e698ada56a 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -677,6 +677,7 @@ MySQL ODBC Support Using MySQL with Some Common Programs * Apache:: Using @strong{MySQL} with Apache +* Borland C++:: Problems and Common Errors @@ -18682,7 +18683,7 @@ TRUNCATE table_name Is in 3.23 and the same thing as @code{DELETE FROM table_name}. @xref{DELETE}. The differences are: -@table @bullet +@itemize @bullet @item Implemented as a drop and re-create of the table, which makes this much faster when deleting many rows. @@ -18695,7 +18696,7 @@ Doesn't return the number of deleted rows. As long as the table definition file @file{table_name.frm} is valid, the table can be re-created this way, even if the data or index files have become corrupted. -@end table +@end itemize @findex SELECT @node SELECT, JOIN, TRUNCATE, Reference @@ -32332,10 +32333,11 @@ likely it is that we can fix the problem! @menu * Apache:: Using @strong{MySQL} with Apache +* Borland C++:: @end menu @cindex Apache -@node Apache, , Common programs, Common programs +@node Apache, Borland C++, Common programs, Common programs @section Using MySQL with Apache The contrib section includes programs that let you authenticate your @@ -32358,6 +32360,29 @@ LOAD DATA INFILE '/local/access_log' INTO TABLE table_name FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' @end example +@cindex Borland C++ compiler +@node Borland C++, , Apache, Common programs +@section Borland C++ + +You can compile the @strong{MySQL} windows source with Borland C++ 5.02. +(The windows source includes only projects for Microsoft VC++, for +Borland C++ you have to do the project files yourself). + +One known problem with Borland C++ is that it uses a different structure +alignment than VC++. This means that you will run into problems if you +try to use the default @code{libmysql.dll} libraries (that was compiled +with VC++) with Borland C++. You can do one of the following to avoid +this problem. + +@itemize @bullet +@item +You can use the static @strong{MySQL} libraries for Borland C++ that you +can find on @uref{http://www.mysql.net/downloads/os-win32.html}. +@item +Only call @code{mysql_init()} with @code{NULL} as an argument, not a +pre-allocated MYSQL struct. +@end itemize + @cindex problems, common errors @cindex errors, common @node Problems, Common problems, Common programs, Top @@ -37108,7 +37133,7 @@ This will create a thread-safe client library @code{libmysqlclient_r}. connection. You can let two threads share the same connection as long as you do the following: -@table @bullet +@itemize @bullet @item Two threads can't send a query to the @strong{MySQL} at the same time on the same connection. In particular, you have to ensure that between a @@ -37132,7 +37157,7 @@ threads may query the same connection. If you program with POSIX threads, you can use @code{pthread_mutex_lock()} and @code{pthread_mutex_unlock()} to establish and release a mutex lock. -@end table +@end itemize You may get some errors because of undefined symbols when linking your client with @code{mysqlclient_r}. In most cases this is because you haven't diff --git a/myisam/mi_check.c b/myisam/mi_check.c index b394fb25e97..67503bd4f6c 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -543,7 +543,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, if (next_page+info->s->blocksize > max_length) goto err; info->state->key_file_length=(max_length & - ~ (my_off_t) (info->s->blocksize-1)); + ~ (my_off_t) (info->s->blocksize-1)); } if (!_mi_fetch_keypage(info,keyinfo,next_page,temp_buff,0)) { diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 2eab33228dc..0280355ae72 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -185,6 +185,22 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) HA_ERR_CRASHED_ON_REPAIR : HA_ERR_CRASHED_ON_USAGE); goto err; } + + /* sanity check */ + if (share->base.keystart > 65535 || share->base.rec_reflength > 8) + { + my_errno=HA_ERR_CRASHED; + goto err; + } + + if (share->base.max_key_length > MI_MAX_KEY_BUFF || keys > MI_MAX_KEY || + key_parts >= MI_MAX_KEY * MI_MAX_KEY_SEG) + { + DBUG_PRINT("error",("Wrong key info: Max_key_length: %d keys: %d key_parts: %d", share->base.max_key_length, keys, key_parts)); + my_errno=HA_ERR_UNSUPPORTED; + goto err; + } + /* Correct max_file_length based on length of sizeof_t */ max_data_file_length= (share->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ? @@ -220,13 +236,6 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) share->base.max_data_file_length=(my_off_t) max_data_file_length; share->base.max_key_file_length=(my_off_t) max_key_file_length; - if (share->base.max_key_length > MI_MAX_KEY_BUFF || keys > MI_MAX_KEY || - key_parts >= MI_MAX_KEY * MI_MAX_KEY_SEG) - { - DBUG_PRINT("error",("Wrong key info: Max_key_length: %d keys: %d key_parts: %d", share->base.max_key_length, keys, key_parts)); - my_errno=HA_ERR_UNSUPPORTED; - goto err; - } if (share->options & HA_OPTION_COMPRESS_RECORD) share->base.max_key_length+=2; /* For safety */ diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 0e6f5927a3a..8e794b7e708 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -200,7 +200,7 @@ static struct option long_options[] = static void print_version(void) { - printf("%s Ver 1.40 for %s at %s\n",my_progname,SYSTEM_TYPE, + printf("%s Ver 1.41 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE); } @@ -506,6 +506,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) param->error_printed=1; switch (my_errno) { case HA_ERR_CRASHED: + mi_check_print_error(param,"'%s' doesn't have a correct index definition. You need to recreate it before you can do a repair",filename); + break; case HA_ERR_WRONG_TABLE_DEF: mi_check_print_error(param,"'%s' is not a MyISAM-table",filename); break; @@ -1205,9 +1207,10 @@ static int mi_sort_records(MI_CHECK *param, param->temp_filename); goto err; } - if (filecopy(param,new_file,info->dfile,0L,share->pack.header_length, - "datafile-header")) - goto err; + if (share->pack.header_length) + if (filecopy(param,new_file,info->dfile,0L,share->pack.header_length, + "datafile-header")) + goto err; info->rec_cache.file=new_file; /* Use this file for cacheing*/ lock_memory(param); diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c index 1063e9381bf..fe44ff1b12e 100644 --- a/mysys/my_chsize.c +++ b/mysys/my_chsize.c @@ -44,8 +44,8 @@ int my_chsize(File fd, my_off_t newlength, myf MyFlags) my_off_t oldsize; char buff[IO_SIZE]; - bzero(buff,IO_SIZE); oldsize = my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME+MY_FAE)); + DBUG_PRINT("info",("old_size: %ld", (ulong) oldsize)); #ifdef HAVE_FTRUNCATE if (oldsize > newlength) @@ -64,9 +64,12 @@ int my_chsize(File fd, my_off_t newlength, myf MyFlags) if (oldsize > newlength) { /* Fill diff with null */ VOID(my_seek(fd, newlength, MY_SEEK_SET, MYF(MY_WME+MY_FAE))); - swap(long, newlength, oldsize); + swap(my_off_t, newlength, oldsize); } #endif + /* Full file with 0 until it's as big as requested */ + bzero(buff,IO_SIZE); + my_seek(fd, old_length, MY_SEEK_SET, MYF(MY_WME+MY_FAE)); while (newlength-oldsize > IO_SIZE) { if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP))) diff --git a/mysys/my_seek.c b/mysys/my_seek.c index 12f8ced0642..d8e8cf83b6d 100644 --- a/mysys/my_seek.c +++ b/mysys/my_seek.c @@ -24,8 +24,8 @@ my_off_t my_seek(File fd, my_off_t pos, int whence, myf MyFlags) { reg1 os_off_t newpos; DBUG_ENTER("my_seek"); - DBUG_PRINT("my",("Fd: %d Pos: %lu Whence: %d MyFlags: %d", - fd, (ulong) pos, whence, MyFlags)); + DBUG_PRINT("my",("Fd: %d Hpos: %lu Pos: %lu Whence: %d MyFlags: %d", + fd, ((ulonglong) pos) >> 32, (ulong) pos, whence, MyFlags)); newpos=lseek(fd, pos, whence); if (newpos == (os_off_t) -1) { diff --git a/mysys/my_write.c b/mysys/my_write.c index 03cbec4a0d6..61d6c7d2180 100644 --- a/mysys/my_write.c +++ b/mysys/my_write.c @@ -41,7 +41,8 @@ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags) Count-=writenbytes; } my_errno=errno; - DBUG_PRINT("error",("Write only %d bytes",writenbytes)); + DBUG_PRINT("error",("Write only %d bytes, error: %d", + writenbytes,my_errno)); #ifndef NO_BACKGROUND #ifdef THREAD if (my_thread_var->abort) @@ -56,8 +57,18 @@ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags) VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC)); continue; } - if ((writenbytes == 0 && my_errno == EINTR) || - (writenbytes > 0 && (uint) writenbytes != (uint) -1)) + if (!writenbytes) + { + /* We may come here on an interrupt or if the file quote is exeeded */ + if (my_errno == EINTR) + continue; + if (!errors++) /* Retry once */ + { + errno=EFBIG; /* Assume this is the error */ + continue; + } + } + else if ((uint) writenbytes != (uint) -1) continue; /* Retry */ #endif if (MyFlags & (MY_NABP | MY_FNABP)) |