summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/config-win.h3
-rw-r--r--include/m_string.h6
-rw-r--r--include/my_base.h3
-rw-r--r--include/my_net.h4
-rw-r--r--include/my_nosys.h3
-rw-r--r--include/my_sys.h16
-rw-r--r--include/my_tree.h8
-rw-r--r--libmysqld/CMakeLists.txt2
-rw-r--r--mysql-test/lib/mtr_misc.pl9
-rw-r--r--mysql-test/r/archive.result2
-rw-r--r--mysql-test/r/auto_increment.result6
-rw-r--r--mysql-test/t/archive.test2
-rw-r--r--mysql-test/t/auto_increment.test11
-rw-r--r--mysys/mf_keycache.c8
-rw-r--r--mysys/mf_path.c2
-rw-r--r--mysys/mf_tempfile.c2
-rw-r--r--mysys/my_access.c4
-rw-r--r--mysys/my_clock.c2
-rw-r--r--mysys/my_copy.c2
-rw-r--r--mysys/my_create.c9
-rw-r--r--mysys/my_dup.c2
-rw-r--r--mysys/my_gethostbyname.c2
-rw-r--r--mysys/my_getwd.c36
-rw-r--r--mysys/my_init.c2
-rw-r--r--mysys/my_lib.c114
-rw-r--r--mysys/my_net.c4
-rw-r--r--mysys/my_open.c4
-rw-r--r--mysys/my_redel.c4
-rw-r--r--sql/handler.cc31
-rw-r--r--sql/handler.h1
-rw-r--r--sql/net_serv.cc7
-rw-r--r--sql/share/errmsg.txt2
-rw-r--r--sql/sql_table.cc14
-rw-r--r--storage/archive/ha_archive.cc21
-rw-r--r--storage/csv/ha_tina.cc27
35 files changed, 130 insertions, 245 deletions
diff --git a/include/config-win.h b/include/config-win.h
index 6d0f40adbd3..aa372762191 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -25,6 +25,7 @@ functions */
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Avoid endless warnings about sprintf() etc. being unsafe. */
#define _CRT_SECURE_NO_DEPRECATE 1
+#define _USE_32BIT_TIME_T 1 /* force time_t to be 32 bit */
#endif
#include <sys/locking.h>
@@ -95,7 +96,7 @@ functions */
#define O_SHORT_LIVED 0
#define SH_DENYNO _SH_DENYNO
#else
-#define O_BINARY _O_BINARY /* compability with MSDOS */
+#define O_BINARY _O_BINARY /* compability with older style names */
#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */
#define O_TEMPORARY _O_TEMPORARY
#define O_SHORT_LIVED _O_SHORT_LIVED
diff --git a/include/m_string.h b/include/m_string.h
index f57b3eff8a0..9f7ec220f2c 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -106,12 +106,6 @@ extern char NEAR _dig_vec_lower[];
#define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
#endif
-#ifdef MSDOS
-#undef bmove_align
-#define bmove512(A,B,C) bmove_align(A,B,C)
-extern void bmove_align(gptr dst,const gptr src,uint len);
-#endif
-
#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
#define bmove512(A,B,C) memcpy(A,B,C)
#endif
diff --git a/include/my_base.h b/include/my_base.h
index 0390106880a..e77bffeaf94 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -33,9 +33,6 @@
#define EOVERFLOW 84
#endif
-#ifdef MSDOS
-#include <share.h> /* Neaded for sopen() */
-#endif
#if !defined(USE_MY_FUNC) && !defined(THREAD)
#include <my_nosys.h> /* For faster code, after test */
#endif /* USE_MY_FUNC */
diff --git a/include/my_net.h b/include/my_net.h
index f953a832e6b..b26e525016b 100644
--- a/include/my_net.h
+++ b/include/my_net.h
@@ -44,7 +44,7 @@ C_MODE_START
#include <sys/ioctl.h>
#endif
-#if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__NETWARE__)
+#if !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__NETWARE__)
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
@@ -53,7 +53,7 @@ C_MODE_START
#endif
#endif
-#if defined(MSDOS) || defined(__WIN__)
+#if defined(__WIN__)
#define O_NONBLOCK 1 /* For emulation of fcntl() */
#endif
diff --git a/include/my_nosys.h b/include/my_nosys.h
index 605906f0e07..41b919c1a72 100644
--- a/include/my_nosys.h
+++ b/include/my_nosys.h
@@ -27,9 +27,6 @@ extern "C" {
#ifndef __MY_NOSYS__
#define __MY_NOSYS__
-#ifdef MSDOS
-#include <io.h> /* Get prototypes for read()... */
-#endif
#ifndef HAVE_STDLIB_H
#include <malloc.h>
#endif
diff --git a/include/my_sys.h b/include/my_sys.h
index d49b6f63aae..5024505a821 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -201,22 +201,6 @@ extern void my_large_free(gptr ptr, myf my_flags);
#define my_afree(PTR) my_free(PTR,MYF(MY_WME))
#endif /* HAVE_ALLOCA */
-#ifdef MSDOS
-#ifdef __ZTC__
-void * __CDECL halloc(long count,size_t length);
-void __CDECL hfree(void *ptr);
-#endif
-#if defined(USE_HALLOC)
-#if defined(_VCM_) || defined(M_IC80386)
-#undef USE_HALLOC
-#endif
-#endif
-#ifdef USE_HALLOC
-#define malloc(a) halloc((long) (a),1)
-#define free(a) hfree(a)
-#endif
-#endif /* MSDOS */
-
#ifndef errno /* did we already get it? */
#ifdef HAVE_ERRNO_AS_DEFINE
#include <errno.h> /* errno is a define */
diff --git a/include/my_tree.h b/include/my_tree.h
index 03dc9d5c829..e9746ca1b2c 100644
--- a/include/my_tree.h
+++ b/include/my_tree.h
@@ -40,19 +40,11 @@ typedef int (*tree_walk_action)(void *,element_count,void *);
typedef enum { free_init, free_free, free_end } TREE_FREE;
typedef void (*tree_element_free)(void*, TREE_FREE, void *);
-#ifdef MSDOS
-typedef struct st_tree_element {
- struct st_tree_element *left,*right;
- unsigned long count;
- uchar colour; /* black is marked as 1 */
-} TREE_ELEMENT;
-#else
typedef struct st_tree_element {
struct st_tree_element *left,*right;
uint32 count:31,
colour:1; /* black is marked as 1 */
} TREE_ELEMENT;
-#endif /* MSDOS */
#define ELEMENT_CHILD(element, offs) (*(TREE_ELEMENT**)((char*)element + offs))
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 8bd0e0baa32..ff8ceda5c5b 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -33,7 +33,7 @@ ADD_LIBRARY(mysqldemb emb_qcache.cc libmysqld.c lib_sql.cc
../sql/field_conv.cc ../sql/field.cc ../sql/filesort.cc
../sql/gstream.cc ../sql/ha_heap.cc ../sql/ha_myisam.cc
../sql/ha_myisammrg.cc ${mysql_se_ha_src}
- ../sql/handler.cc ../sql/handlerton-win.cc ../sql/hash_filo.cc
+ ../sql/handler.cc ../sql/hash_filo.cc
../sql/hostname.cc ../sql/init.cc ../sql/item_buff.cc
../sql/item_cmpfunc.cc ../sql/item.cc ../sql/item_create.cc
../sql/item_func.cc ../sql/item_geofunc.cc ../sql/item_row.cc
diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl
index b5a2e5a4a68..bc44c440c32 100644
--- a/mysql-test/lib/mtr_misc.pl
+++ b/mysql-test/lib/mtr_misc.pl
@@ -108,7 +108,14 @@ sub mtr_exe_exists (@) {
map {$_.= ".exe"} @path if $::glob_win32;
foreach my $path ( @path )
{
- return $path if -x $path;
+ if($::glob_win32)
+ {
+ return $path if -f $path;
+ }
+ else
+ {
+ return $path if -x $path;
+ }
}
if ( @path == 1 )
{
diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result
index 09813458069..19cb0c9768f 100644
--- a/mysql-test/r/archive.result
+++ b/mysql-test/r/archive.result
@@ -1,4 +1,4 @@
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result
index 525f64ea902..d9e9392f618 100644
--- a/mysql-test/r/auto_increment.result
+++ b/mysql-test/r/auto_increment.result
@@ -418,3 +418,9 @@ a val
2 1
3 1
drop table t1;
+CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
+INSERT INTO t1 VALUES(0, 0);
+INSERT INTO t1 VALUES(1, 1);
+ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
+ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'
+DROP TABLE t1;
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index 7e091991475..c89d31c69b9 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -5,7 +5,7 @@
-- source include/have_archive.inc
--disable_warnings
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
--enable_warnings
CREATE TABLE t1 (
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 26b103b0107..e0b024d021b 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -275,3 +275,14 @@ update t1 set a=2 where a=1;
insert into t1 (val) values (1);
select * from t1;
drop table t1;
+
+#
+# Test key duplications with auto-increment in ALTER TABLE
+# bug #14573
+#
+CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
+INSERT INTO t1 VALUES(0, 0);
+INSERT INTO t1 VALUES(1, 1);
+--error ER_DUP_ENTRY
+ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
+DROP TABLE t1;
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 1dab9a47ed8..71d73048a7b 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -84,14 +84,6 @@
#define KEYCACHE_DEBUG_LOG "my_key_cache_debug.log"
*/
-#if defined(MSDOS) && !defined(M_IC80386)
-/* we nead much memory */
-#undef my_malloc_lock
-#undef my_free_lock
-#define my_malloc_lock(A,B) halloc((long) (A/IO_SIZE),IO_SIZE)
-#define my_free_lock(A,B) hfree(A)
-#endif /* defined(MSDOS) && !defined(M_IC80386) */
-
#define STRUCT_PTR(TYPE, MEMBER, a) \
(TYPE *) ((char *) (a) - offsetof(TYPE, MEMBER))
diff --git a/mysys/mf_path.c b/mysys/mf_path.c
index cdaee74dd2c..571c4aa9fba 100644
--- a/mysys/mf_path.c
+++ b/mysys/mf_path.c
@@ -73,7 +73,7 @@ my_string my_path(my_string to, const char *progname,
/* test if file without filename is found in path */
/* Returns to if found and to has dirpart if found, else NullS */
-#if defined(MSDOS) || defined(__WIN__)
+#if defined(__WIN__)
#define F_OK 0
#define PATH_SEP ';'
#define PROGRAM_EXTENSION ".exe"
diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c
index b079b9ec8e3..4f6cbd2f243 100644
--- a/mysys/mf_tempfile.c
+++ b/mysys/mf_tempfile.c
@@ -24,7 +24,7 @@
#endif
#ifdef HAVE_TEMPNAM
-#if !defined(MSDOS) && !defined(__NETWARE__)
+#if !defined(__NETWARE__)
extern char **environ;
#endif
#endif
diff --git a/mysys/my_access.c b/mysys/my_access.c
index 871de8de0b8..9255d716919 100644
--- a/mysys/my_access.c
+++ b/mysys/my_access.c
@@ -156,7 +156,7 @@ int check_if_legal_tablename(const char *name)
}
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(__WIN__) || defined(__EMX__)
/*
@@ -199,4 +199,4 @@ int check_if_legal_filename(const char *path)
DBUG_RETURN(0);
}
-#endif /* defined(MSDOS) || defined(__WIN__) || defined(__EMX__) */
+#endif /* defined(__WIN__) || defined(__EMX__) */
diff --git a/mysys/my_clock.c b/mysys/my_clock.c
index 384239bb2b2..41d659c0ffe 100644
--- a/mysys/my_clock.c
+++ b/mysys/my_clock.c
@@ -24,7 +24,7 @@
long my_clock(void)
{
-#if !defined(MSDOS) && !defined(__WIN__) && !defined(__NETWARE__)
+#if !defined(__WIN__) && !defined(__NETWARE__)
struct tms tmsbuf;
VOID(times(&tmsbuf));
return (tmsbuf.tms_utime + tmsbuf.tms_stime);
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index 342b1cdc104..a8a3a775040 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -95,7 +95,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
DBUG_RETURN(0); /* File copyed but not stat */
VOID(chmod(to, stat_buff.st_mode & 07777)); /* Copy modes */
-#if !defined(MSDOS) && !defined(__WIN__) && !defined(__NETWARE__)
+#if !defined(__WIN__) && !defined(__NETWARE__)
VOID(chown(to, stat_buff.st_uid,stat_buff.st_gid)); /* Copy ownership */
#endif
#if !defined(VMS) && !defined(__ZTC__)
diff --git a/mysys/my_create.c b/mysys/my_create.c
index d42e7e0db69..d27edb31d32 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -19,7 +19,7 @@
#include <my_dir.h>
#include "mysys_err.h"
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN__)
+#if defined(__WIN__)
#include <share.h>
#endif
@@ -47,13 +47,6 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
#elif defined(VMS)
fd = open((my_string) FileName, access_flags | O_CREAT, 0,
"ctx=stm","ctx=bin");
-#elif defined(MSDOS)
- if (access_flags & O_SHARE)
- fd = sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY,
- SH_DENYNO, MY_S_IREAD | MY_S_IWRITE);
- else
- fd = open((my_string) FileName, access_flags | O_CREAT | O_BINARY,
- MY_S_IREAD | MY_S_IWRITE);
#elif defined(__WIN__)
fd= my_sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY,
SH_DENYNO, MY_S_IREAD | MY_S_IWRITE);
diff --git a/mysys/my_dup.c b/mysys/my_dup.c
index f4c420eb459..9666f5b1858 100644
--- a/mysys/my_dup.c
+++ b/mysys/my_dup.c
@@ -19,7 +19,7 @@
#include "mysys_err.h"
#include <my_dir.h>
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN__)
+#if defined(__WIN__)
#include <share.h>
#endif
diff --git a/mysys/my_gethostbyname.c b/mysys/my_gethostbyname.c
index 27281f3489d..0644ba02bbd 100644
--- a/mysys/my_gethostbyname.c
+++ b/mysys/my_gethostbyname.c
@@ -18,7 +18,7 @@
/* Thread safe version of gethostbyname_r() */
#include "mysys_priv.h"
-#if !defined(MSDOS) && !defined(__WIN__)
+#if !defined(__WIN__)
#include <netdb.h>
#endif
#include <my_net.h>
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index 765c30bc281..de8ad108ba4 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -22,7 +22,7 @@
#ifdef HAVE_GETWD
#include <sys/param.h>
#endif
-#if defined(MSDOS) || defined(__WIN__)
+#if defined(__WIN__)
#include <m_ctype.h>
#include <dos.h>
#include <direct.h>
@@ -39,11 +39,9 @@ int my_getwd(my_string buf, uint size, myf MyFlags)
DBUG_ENTER("my_getwd");
DBUG_PRINT("my",("buf: 0x%lx size: %d MyFlags %d", buf,size,MyFlags));
-#if ! defined(MSDOS)
if (curr_dir[0]) /* Current pos is saved here */
VOID(strmake(buf,&curr_dir[0],size-1));
else
-#endif
{
#if defined(HAVE_GETCWD)
if (!getcwd(buf,size-2) && MyFlags & MY_WME)
@@ -87,43 +85,13 @@ int my_setwd(const char *dir, myf MyFlags)
int res;
size_s length;
my_string start,pos;
-#if defined(VMS) || defined(MSDOS)
+#if defined(VMS)
char buff[FN_REFLEN];
#endif
DBUG_ENTER("my_setwd");
DBUG_PRINT("my",("dir: '%s' MyFlags %d", dir, MyFlags));
start=(my_string) dir;
-#if defined(MSDOS) /* MSDOS chdir can't change drive */
-#if !defined(_DDL) && !defined(WIN32)
- if ((pos=(char*) strchr(dir,FN_DEVCHAR)) != 0)
- {
- uint drive,drives;
-
- pos++; /* Skip FN_DEVCHAR */
- drive=(uint) (my_toupper(&my_charset_latin1,dir[0])-'A'+1);
- drives= (uint) -1;
- if ((pos-(byte*) dir) == 2 && drive > 0 && drive < 32)
- {
- _dos_setdrive(drive,&drives);
- _dos_getdrive(&drives);
- }
- if (drive != drives)
- {
- *pos='\0'; /* Dir is now only drive */
- my_errno=errno;
- my_error(EE_SETWD,MYF(ME_BELL+ME_WAITTANG),dir,ENOENT);
- DBUG_RETURN(-1);
- }
- dir=pos; /* drive changed, change now path */
- }
-#endif
- if (*((pos=strend(dir)-1)) == FN_LIBCHAR && pos != dir)
- {
- strmov(buff,dir)[-1]=0; /* Remove last '/' */
- dir=buff;
- }
-#endif /* MSDOS*/
if (! dir[0] || (dir[0] == FN_LIBCHAR && dir[1] == 0))
dir=FN_ROOTDIR;
#ifdef VMS
diff --git a/mysys/my_init.c b/mysys/my_init.c
index 9efe0a0c20e..588bb6f46d6 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -181,7 +181,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals,
rus.ru_nvcsw, rus.ru_nivcsw);
#endif
-#if ( defined(MSDOS) || defined(__NETWARE__) ) && !defined(__WIN__)
+#if defined(__NETWARE__) && !defined(__WIN__)
fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC);
#endif
#if defined(SAFEMALLOC)
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index e96286a94a8..42c57e9d3c4 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -15,7 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* TODO: check for overun of memory for names. */
-/* Convert MSDOS-TIME to standar time_t */
+/* Convert MSDOS-TIME to standar time_t (still needed?) */
#define USES_TYPES /* sys/types is included */
#include "mysys_priv.h"
@@ -37,7 +37,7 @@
# if defined(HAVE_NDIR_H)
# include <ndir.h>
# endif
-# if defined(MSDOS) || defined(__WIN__)
+# if defined(__WIN__)
# include <dos.h>
# ifdef __BORLANDC__
# include <dir.h>
@@ -94,7 +94,7 @@ static int comp_names(struct fileinfo *a, struct fileinfo *b)
} /* comp_names */
-#if !defined(MSDOS) && !defined(__WIN__)
+#if !defined(__WIN__)
MY_DIR *my_dir(const char *path, myf MyFlags)
{
@@ -347,7 +347,7 @@ my_string directory_file_name (my_string dst, const char *src)
#endif /* VMS */
} /* directory_file_name */
-#elif defined(WIN32)
+#else
/*
*****************************************************************************
@@ -386,7 +386,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
*tmp_file++= '.'; /* From current dev-dir */
if (tmp_file[-1] != FN_LIBCHAR)
*tmp_file++ =FN_LIBCHAR;
- tmp_file[0]='*'; /* MSDOS needs this !??? */
+ tmp_file[0]='*'; /* Windows needs this !??? */
tmp_file[1]='.';
tmp_file[2]='*';
tmp_file[3]='\0';
@@ -509,109 +509,7 @@ error:
DBUG_RETURN((MY_DIR *) NULL);
} /* my_dir */
-#else /* MSDOS and not WIN32 */
-
-
-/******************************************************************************
-** At MSDOS you always get stat of files, but time is in packed MSDOS-format
-******************************************************************************/
-
-MY_DIR *my_dir(const char* path, myf MyFlags)
-{
- char *buffer;
- MY_DIR *result= 0;
- FILEINFO finfo;
- DYNAMIC_ARRAY *dir_entries_storage;
- MEM_ROOT *names_storage;
- struct find_t find;
- ushort mode;
- char tmp_path[FN_REFLEN],*tmp_file,attrib;
- DBUG_ENTER("my_dir");
- DBUG_PRINT("my",("path: '%s' stat: %d MyFlags: %d",path,MyFlags));
-
- /* Put LIB-CHAR as last path-character if not there */
-
- tmp_file=tmp_path;
- if (!*path)
- *tmp_file++ ='.'; /* From current dir */
- tmp_file= strmov(tmp_file,path);
- if (tmp_file[-1] == FN_DEVCHAR)
- *tmp_file++= '.'; /* From current dev-dir */
- if (tmp_file[-1] != FN_LIBCHAR)
- *tmp_file++ =FN_LIBCHAR;
- tmp_file[0]='*'; /* MSDOS needs this !??? */
- tmp_file[1]='.';
- tmp_file[2]='*';
- tmp_file[3]='\0';
-
- if (_dos_findfirst(tmp_path,_A_NORMAL | _A_SUBDIR, &find))
- goto error;
-
- if (!(buffer= my_malloc(ALIGN_SIZE(sizeof(MY_DIR)) +
- ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)) +
- sizeof(MEM_ROOT), MyFlags)))
- goto error;
-
- dir_entries_storage= (DYNAMIC_ARRAY*)(buffer + ALIGN_SIZE(sizeof(MY_DIR)));
- names_storage= (MEM_ROOT*)(buffer + ALIGN_SIZE(sizeof(MY_DIR)) +
- ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)));
-
- if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
- ENTRIES_START_SIZE, ENTRIES_INCREMENT))
- {
- my_free((gptr) buffer,MYF(0));
- goto error;
- }
- init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
-
- /* MY_DIR structure is allocated and completly initialized at this point */
- result= (MY_DIR*)buffer;
-
- do
- {
- if (!(finfo.name= strdup_root(names_storage, find.name)))
- goto error;
-
- if (MyFlags & MY_WANT_STAT)
- {
- if (!(finfo.mystat= (MY_STAT*)alloc_root(names_storage,
- sizeof(MY_STAT))))
- goto error;
-
- bzero(finfo.mystat, sizeof(MY_STAT));
- finfo.mystat->st_size= find.size;
- mode= MY_S_IREAD; attrib= find.attrib;
- if (!(attrib & _A_RDONLY))
- mode|= MY_S_IWRITE;
- if (attrib & _A_SUBDIR)
- mode|= MY_S_IFDIR;
- finfo.mystat->st_mode= mode;
- finfo.mystat->st_mtime= ((uint32) find.wr_date << 16) + find.wr_time;
- }
- else
- finfo.mystat= NULL;
-
- if (push_dynamic(dir_entries_storage, (gptr)&finfo))
- goto error;
-
- } while (_dos_findnext(&find) == 0);
-
- result->dir_entry= (FILEINFO *)dir_entries_storage->buffer;
- result->number_off_files= dir_entries_storage->elements;
-
- if (!(MyFlags & MY_DONT_SORT))
- qsort((void *) result->dir_entry, result->number_off_files,
- sizeof(FILEINFO), (qsort_cmp) comp_names);
- DBUG_RETURN(result);
-
-error:
- my_dirend(result);
- if (MyFlags & MY_FAE+MY_WME)
- my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,errno);
- DBUG_RETURN((MY_DIR *) NULL);
-} /* my_dir */
-
-#endif /* WIN32 && MSDOS */
+#endif /* __WIN__ */
/****************************************************************************
** File status
diff --git a/mysys/my_net.c b/mysys/my_net.c
index be92adae353..09c09b280d1 100644
--- a/mysys/my_net.c
+++ b/mysys/my_net.c
@@ -20,7 +20,7 @@
#include <m_string.h>
/* for thread safe my_inet_ntoa */
-#if !defined(MSDOS) && !defined(__WIN__)
+#if !defined(__WIN__)
#include <netdb.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
@@ -31,7 +31,7 @@
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
-#endif /* !defined(MSDOS) && !defined(__WIN__) */
+#endif /* !defined(__WIN__) */
void my_inet_ntoa(struct in_addr in, char *buf)
{
diff --git a/mysys/my_open.c b/mysys/my_open.c
index ed323b3b1ad..6041ddde9fc 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -19,7 +19,7 @@
#include "mysys_err.h"
#include <my_dir.h>
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN__)
+#if defined(__WIN__)
#include <share.h>
#endif
@@ -45,7 +45,7 @@ File my_open(const char *FileName, int Flags, myf MyFlags)
DBUG_ENTER("my_open");
DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d",
FileName, Flags, MyFlags));
-#if defined(MSDOS) || defined(__WIN__)
+#if defined(__WIN__)
/*
Check that we don't try to open or create a file name that may
cause problems for us in the future (like PRN)
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index 02d3db8b860..abfe84102ef 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -90,14 +90,14 @@ int my_copystat(const char *from, const char *to, int MyFlags)
return 1;
VOID(chmod(to, statbuf.st_mode & 07777)); /* Copy modes */
-#if !defined(MSDOS) && !defined(__WIN__) && !defined(__NETWARE__)
+#if !defined(__WIN__) && !defined(__NETWARE__)
if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
{
if (MyFlags & MY_LINK_WARNING)
my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink);
}
VOID(chown(to, statbuf.st_uid, statbuf.st_gid)); /* Copy ownership */
-#endif /* MSDOS */
+#endif /* !__WIN__ && !__NETWARE__ */
#ifndef VMS
#ifndef __ZTC__
diff --git a/sql/handler.cc b/sql/handler.cc
index b9ef05a33c2..f51e91f1882 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1818,6 +1818,24 @@ ulonglong handler::get_auto_increment()
}
+void handler::print_keydupp_error(uint key_nr, const char *msg)
+{
+ /* Write the duplicated key in the error message */
+ char key[MAX_KEY_LENGTH];
+ String str(key,sizeof(key),system_charset_info);
+ /* Table is opened and defined at this point */
+ key_unpack(&str,table,(uint) key_nr);
+ uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(msg);
+ if (str.length() >= max_length)
+ {
+ str.length(max_length-4);
+ str.append(STRING_WITH_LEN("..."));
+ }
+ my_printf_error(ER_DUP_ENTRY, msg,
+ MYF(0), str.c_ptr(), table->key_info[key_nr].name);
+}
+
+
/*
Print error that we got from handler function
@@ -1857,18 +1875,7 @@ void handler::print_error(int error, myf errflag)
uint key_nr=get_dup_key(error);
if ((int) key_nr >= 0)
{
- /* Write the duplicated key in the error message */
- char key[MAX_KEY_LENGTH];
- String str(key,sizeof(key),system_charset_info);
- /* Table is opened and defined at this point */
- key_unpack(&str,table,(uint) key_nr);
- uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(ER(ER_DUP_ENTRY));
- if (str.length() >= max_length)
- {
- str.length(max_length-4);
- str.append(STRING_WITH_LEN("..."));
- }
- my_error(ER_DUP_ENTRY, MYF(0), str.c_ptr(), table->key_info[key_nr].name);
+ print_keydupp_error(key_nr, ER(ER_DUP_ENTRY));
DBUG_VOID_RETURN;
}
textno=ER_DUP_KEY;
diff --git a/sql/handler.h b/sql/handler.h
index afee6bb9f8d..9a5a3b04823 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -865,6 +865,7 @@ public:
virtual int ha_initialise();
int ha_open(TABLE *table, const char *name, int mode, int test_if_locked);
bool update_auto_increment();
+ void print_keydupp_error(uint key_nr, const char *msg);
virtual void print_error(int error, myf errflag);
virtual bool get_error_message(int error, String *buf);
uint get_dup_key(int error);
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 6763196ec37..03164827e8f 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -37,9 +37,6 @@
HFTODO this must be hidden if we don't want client capabilities in
embedded library
*/
-#ifdef __WIN__
-#include <winsock.h>
-#endif
#include <my_global.h>
#include <mysql.h>
#include <mysql_embed.h>
@@ -51,7 +48,9 @@
#include <violite.h>
#include <signal.h>
#include <errno.h>
-
+#ifdef __WIN__
+#include <winsock.h>
+#endif
#ifdef __NETWARE__
#include <sys/select.h>
#endif
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index c5a9fb75eed..5aab951b2ca 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5842,6 +5842,8 @@ ER_WRONG_PARTITION_NAME
swe "Felaktigt partitionsnamn"
ER_CANT_CHANGE_TX_ISOLATION 25001
eng "Transaction isolation level can't be changed while a transaction is in progress"
+ER_DUP_ENTRY_AUTOINCREMENT_CASE
+ eng "ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '%-.64s' for key '%-.64s'"
ER_EVENT_MODIFY_QUEUE_ERROR
eng "Internal scheduler error %d"
ER_EVENT_SET_VAR_ERROR
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index f530af33e48..289051c2dd1 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -6227,6 +6227,20 @@ copy_data_between_tables(TABLE *from,TABLE *to,
(error != HA_ERR_FOUND_DUPP_KEY &&
error != HA_ERR_FOUND_DUPP_UNIQUE))
{
+ if (error == HA_ERR_FOUND_DUPP_KEY)
+ {
+ uint key_nr= to->file->get_dup_key(error);
+ if ((int) key_nr >= 0)
+ {
+ const char *err_msg= ER(ER_DUP_ENTRY);
+ if (key_nr == 0 &&
+ (to->key_info[0].key_part[0].field->flags & AUTO_INCREMENT_FLAG))
+ err_msg= ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE);
+ to->file->print_keydupp_error(key_nr, err_msg);
+ break;
+ }
+ }
+
to->file->print_error(error,MYF(0));
break;
}
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index e39ee976eb1..f3f20f6b103 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -1239,7 +1239,7 @@ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt)
int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
{
DBUG_ENTER("ha_archive::optimize");
- int rc;
+ int rc= 0;
azio_stream writer;
char writer_filename[FN_REFLEN];
@@ -1342,7 +1342,20 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
azclose(&writer);
share->dirty= FALSE;
share->forced_flushes= 0;
+
+ // now we close both our writer and our reader for the rename
azclose(&(share->archive_write));
+ azclose(&archive);
+
+ // make the file we just wrote be our data file
+ rc = my_rename(writer_filename,share->data_file_name,MYF(0));
+
+ /*
+ now open the shared writer back up
+ we don't check rc here because we want to open the file back up even
+ if the optimize failed but we will return rc below so that we will
+ know it failed.
+ */
DBUG_PRINT("info", ("Reopening archive data file"));
if (!(azopen(&(share->archive_write), share->data_file_name,
O_WRONLY|O_APPEND|O_BINARY)))
@@ -1352,21 +1365,15 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
goto error;
}
- my_rename(writer_filename,share->data_file_name,MYF(0));
-
/*
Now we need to reopen our read descriptor since it has changed.
*/
- azclose(&archive);
if (!(azopen(&archive, share->data_file_name, O_RDONLY|O_BINARY)))
{
rc= HA_ERR_CRASHED_ON_USAGE;
goto error;
}
-
- DBUG_RETURN(0);
-
error:
azclose(&writer);
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index a26114e086d..f15ce7cccb5 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -472,14 +472,28 @@ int tina_end(ha_panic_function type)
/*
Finds the end of a line.
- Currently only supports files written on a UNIX OS.
+ Supports DOS, Unix, or Mac OS line endings.
*/
-byte * find_eoln(byte *data, off_t begin, off_t end)
+byte * find_eoln(byte *data, off_t begin, off_t end, int *eoln_len)
{
+ off_t dataend= begin;
+ *eoln_len= 0;
+
for (off_t x= begin; x < end; x++)
- if (data[x] == '\n')
- return data + x;
+ if (data[x] == '\r' || data[x] == '\n')
+ (*eoln_len)++;
+ else if (!(*eoln_len))
+ dataend++;
+ else
+ return data+dataend;
+ /*
+ if we only have one record in the file then our for loop will break
+ before we return. we should still have seen end of line markers and
+ so we just return the line here
+ */
+ if (*eoln_len > 0)
+ return data+dataend;
return 0;
}
@@ -627,6 +641,7 @@ int ha_tina::find_current_row(byte *buf)
{
byte *mapped_ptr;
byte *end_ptr;
+ int eoln_len;
DBUG_ENTER("ha_tina::find_current_row");
mapped_ptr= (byte *)share->mapped_file + current_position;
@@ -636,7 +651,7 @@ int ha_tina::find_current_row(byte *buf)
not to conflict with undergoing concurrent insert.
*/
if ((end_ptr= find_eoln(share->mapped_file, current_position,
- local_saved_data_file_length)) == 0)
+ local_saved_data_file_length, &eoln_len)) == 0)
DBUG_RETURN(HA_ERR_END_OF_FILE);
for (Field **field=table->field ; *field ; field++)
@@ -684,7 +699,7 @@ int ha_tina::find_current_row(byte *buf)
}
(*field)->store(buffer.ptr(), buffer.length(), system_charset_info);
}
- next_position= (end_ptr - share->mapped_file)+1;
+ next_position= (end_ptr - share->mapped_file)+eoln_len;
/* Maybe use \N for null? */
memset(buf, 0, table->s->null_bytes); /* We do not implement nulls! */