summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/manual.texi15
-rw-r--r--client/mysql.cc12
-rw-r--r--include/getopt.h4
-rw-r--r--include/global.h12
-rw-r--r--include/my_sys.h7
-rw-r--r--include/mysql_com.h5
-rw-r--r--include/thr_alarm.h76
-rw-r--r--isam/isamchk.c4
-rw-r--r--libmysql/libmysql.c4
-rw-r--r--libmysql/net.c19
-rw-r--r--libmysql/violite.c5
-rw-r--r--myisam/ChangeLog4
-rw-r--r--myisam/mi_create.c14
-rw-r--r--myisam/myisamchk.c4
-rw-r--r--mysys/default.c10
-rw-r--r--mysys/getopt.c4
-rw-r--r--mysys/mf_format.c2
-rw-r--r--mysys/mf_path.c2
-rw-r--r--mysys/my_create.c6
-rw-r--r--mysys/my_lock.c2
-rw-r--r--mysys/my_open.c4
-rw-r--r--mysys/thr_alarm.c112
-rw-r--r--readline/input.c100
-rw-r--r--readline/rltty.c7
-rw-r--r--sql/ha_myisam.cc6
-rw-r--r--sql/my_lock.c2
-rw-r--r--sql/mysql_priv.h8
-rw-r--r--sql/mysqld.cc26
-rw-r--r--sql/net_serv.cc20
-rw-r--r--sql/sql_base.cc14
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_delete.cc3
-rw-r--r--sql/sql_load.cc2
-rw-r--r--sql/sql_parse.cc39
-rw-r--r--sql/sql_select.cc3
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/violite.c5
38 files changed, 428 insertions, 139 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi
index ee56c5d22ce..8b822649e06 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -17586,7 +17586,7 @@ The options work for all table types, if not otherwise indicated:
@multitable @columnfractions .20 .80
@item @code{AUTO_INCREMENT} @tab The next auto_increment value you want to set for your table (MyISAM).
-@item @code{AVG_ROW_LENGTH} @tab An approximation of the average row length for your table. You only need to set this for tables with variable size records.
+@item @code{AVG_ROW_LENGTH} @tab An approximation of the average row length for your table. You only need to set this for large tables with variable size records.
@item @code{CHECKSUM} @tab Set this to 1 if you want @strong{MySQL} to maintain a checksum for all rows (makes the table a little slower to update but makes it easier to find corrupted tables) (MyISAM).
@item @code{COMMENT} @tab A 60-character comment for your table.
@item @code{MAX_ROWS} @tab Max number of rows you plan to store in the table.
@@ -17601,7 +17601,8 @@ When you use a @code{MyISAM} table, @strong{MySQL} uses the product of
@code{max_rows * avg_row_length} to decide how big the resulting table
will be. If you don't specify any of the above options, the maximum size
for a table will be 4G (or 2G if your operating systems only supports 2G
-tables).
+tables). The reason for this is just to keep down the pointer sizes
+to make the index smaller and faster if you don't really need big files.
If you don't use @code{PACK_KEYS}, the default is to only pack strings,
not numbers. If you use @code{PACK_KEYS=1}, numbers will be packed as well.
@@ -38893,6 +38894,16 @@ though, so Version 3.23 is not released as a stable version yet.
@appendixsubsec Changes in release 3.23.29
@itemize @bullet
@item
+Applied patches for OS2 by @code{Yuri Dario}.
+@item
+@code[FLUSH TABLES table_name} didn't always flush table properly to
+disk; One some cases the index tree wasn't completely written to disk.
+@item
+@code{--bootstrap} is now run in a separate thread. This fixes the problem
+that @code{mysql_install_db} core dumped on some Linux machines.
+@item
+Changed @code{mi_create()} to use less stack.
+@item
Changed crash-me and the MySQL benchmarks to also work with FrontBase.
@item
Allow @code{RESTRICT} and @code{CASCADE} after @code{DROP TABLE} to make
diff --git a/client/mysql.cc b/client/mysql.cc
index 76eed7e2548..9b6c52fdb6a 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -39,6 +39,8 @@
#include "my_readline.h"
#include <signal.h>
+const char *VER="11.8";
+
gptr sql_alloc(unsigned size); // Don't use mysqld alloc for these
void sql_element_free(void *ptr);
#include "sql_string.h"
@@ -109,8 +111,6 @@ static HashTable ht;
enum enum_info_type { INFO_INFO,INFO_ERROR,INFO_RESULT};
typedef enum enum_info_type INFO_TYPE;
-const char *VER="11.7";
-
static MYSQL mysql; /* The connection */
static bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
connected=0,opt_raw_data=0,unbuffered=0,output_tables=0,
@@ -2156,10 +2156,7 @@ com_status(String *buffer __attribute__((unused)),
}
#ifndef __WIN__
tee_fprintf(stdout, "Current pager:\t\t%s\n", pager);
- if (opt_outfile)
- tee_fprintf(stdout, "Using outfile:\t\tYes: '%s'\n", outfile);
- else
- printf("Using outfile:\t\tNo\n");
+ tee_fprintf(stdout, "Using outfile:\t\t'%s'\n", opt_outfile ? outfile : "");
#endif
tee_fprintf(stdout, "Server version:\t\t%s\n", mysql_get_server_info(&mysql));
tee_fprintf(stdout, "Protocol version:\t%d\n", mysql_get_proto_info(&mysql));
@@ -2169,6 +2166,9 @@ com_status(String *buffer __attribute__((unused)),
tee_fprintf(stdout, "TCP port:\t\t%d\n", mysql.port);
else
tee_fprintf(stdout, "UNIX socket:\t\t%s\n", mysql.unix_socket);
+ if (mysql.net.compress)
+ tee_fprintf(stdout, "Protocol:\t\tCompressed\n");
+
if ((status=mysql_stat(&mysql)) && !mysql_error(&mysql)[0])
{
char *pos,buff[40];
diff --git a/include/getopt.h b/include/getopt.h
index eb29226b1dc..790915b97df 100644
--- a/include/getopt.h
+++ b/include/getopt.h
@@ -99,7 +99,9 @@ struct option
#define optional_argument 2
#if ( defined (__STDC__) && __STDC__ ) || defined(__cplusplus) || defined(MSDOS)
-#ifdef __GNU_LIBRARY__
+#ifdef __EMX__
+int getopt (int, char **, __const__ char *);
+#elif defined( __GNU_LIBRARY__)
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
diff --git a/include/global.h b/include/global.h
index 006a0173c34..fda0b3f0e54 100644
--- a/include/global.h
+++ b/include/global.h
@@ -21,6 +21,13 @@
#ifndef _global_h
#define _global_h
+#if defined( __EMX__) && !defined( MYSQL_SERVER)
+// moved here to use below VOID macro redefinition
+#define INCL_BASE
+#define INCL_NOPMAPI
+#include <os2.h>
+#endif // __EMX__
+
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
#include <config-win.h>
#else
@@ -381,8 +388,13 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define FN_DEVCHAR ':'
#ifndef FN_LIBCHAR
+#ifdef __EMX__
+#define FN_LIBCHAR '\\'
+#define FN_ROOTDIR "\\"
+#else
#define FN_LIBCHAR '/'
#define FN_ROOTDIR "/"
+#endif
#define MY_NFILE 1024 /* This is only used to save filenames */
#endif
diff --git a/include/my_sys.h b/include/my_sys.h
index 98aab1062a2..aa465ba6d21 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -41,6 +41,13 @@ extern int NEAR my_errno; /* Last error in mysys */
#include <stdarg.h>
+#ifdef __EMX__
+/* record loging flags (F_GETLK, F_SETLK, F_SETLKW) */
+#define F_RDLCK 1 /* FreeBSD: shared or read lock */
+#define F_UNLCK 2 /* FreeBSD: unlock */
+#define F_WRLCK 3 /* FreeBSD: exclusive or write lock */
+#endif
+
#define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; }
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
#define MY_INIT(name); { my_progname= name; my_init(); }
diff --git a/include/mysql_com.h b/include/mysql_com.h
index cc9f8de7597..f7052225dce 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -30,11 +30,6 @@
#define LOCAL_HOST "localhost"
#define LOCAL_HOST_NAMEDPIPE "."
-#if defined(__EMX__) || defined(__OS2__)
-#undef MYSQL_UNIX_ADDR
-#define MYSQL_OS2_ADDR "\\socket\\MySQL"
-#define MYSQL_UNIX_ADDR MYSQL_OS2_ADDR
-#endif
#if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
#define MYSQL_NAMEDPIPE "MySQL"
#define MYSQL_SERVICENAME "MySql"
diff --git a/include/thr_alarm.h b/include/thr_alarm.h
index 0c268c09f0e..da68b9fce07 100644
--- a/include/thr_alarm.h
+++ b/include/thr_alarm.h
@@ -23,13 +23,6 @@
extern "C" {
#endif
-typedef struct st_alarm {
- ulong expire_time;
- int alarmed; /* 1 when alarm is due */
- pthread_t thread;
- my_bool malloced;
-} ALARM;
-
#ifndef USE_ALARM_THREAD
#define USE_ONE_SIGNAL_HAND /* One must call process_alarm */
#endif
@@ -46,55 +39,74 @@ typedef struct st_alarm {
#define THR_SERVER_ALARM SIGALRM
#endif
-#ifdef DONT_USE_THR_ALARM
+#if defined(DONT_USE_THR_ALARM)
#define USE_ALARM_THREAD
#undef USE_ONE_SIGNAL_HAND
-typedef struct st_win_timer
+typedef struct st_thr_alarm_entry
{
uint crono;
-} thr_alarm_t;
+} thr_alarm_entry;
#define thr_alarm_init(A) (A)->crono=0
-#define thr_alarm_in_use(A) (A).crono
+#define thr_alarm_in_use(A) (A)->crono
#define init_thr_alarm(A)
#define thr_alarm_kill(A)
#define end_thr_alarm()
#define thr_alarm(A,B) (((A)->crono=1)-1)
-#define thr_got_alarm(A) (A).crono
+#define thr_got_alarm(A) (A)->crono
#define thr_end_alarm(A)
#else
-
-#ifdef __WIN__
-typedef struct st_win_timer
+#if defined(__WIN__)
+typedef struct st_thr_alarm_entry
{
rf_SetTimer crono;
-} thr_alarm_t;
+} thr_alarm_entry;
-bool thr_got_alarm(thr_alarm_t *alrm);
-#define thr_alarm_init(A) (A)->crono=0
-#define thr_alarm_in_use(A) (A)->crono
-#define init_thr_alarm(A)
-#define thr_alarm_kill(A)
-#else
+#elif defined(__EMX__)
+
+typedef struct st_thr_alarm_entry
+{
+ uint crono;
+ uint event;
+} thr_alarm_entry;
+
+#else /* System with posix threads */
+
+typedef int thr_alarm_entry;
+
+#define thr_got_alarm(thr_alarm) (**(thr_alarm))
-typedef int* thr_alarm_t;
-#define thr_got_alarm(thr_alarm) (*thr_alarm)
-#define thr_alarm_init(A) (*A)=0
-#define thr_alarm_in_use(A) ((A) != 0)
-void init_thr_alarm(uint max_alarm);
-void thr_alarm_kill(pthread_t thread_id);
-sig_handler process_alarm(int);
#endif /* __WIN__ */
-bool thr_alarm(thr_alarm_t *alarmed,uint sec, ALARM *buff);
+typedef thr_alarm_entry* thr_alarm_t;
+
+typedef struct st_alarm {
+ ulong expire_time;
+ thr_alarm_entry alarmed; /* set when alarm is due */
+ pthread_t thread;
+ my_bool malloced;
+} ALARM;
+
+#define thr_alarm_init(A) (*(A))=0
+#define thr_alarm_in_use(A) (*(A)!= 0)
+void init_thr_alarm(uint max_alarm);
+bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
+void thr_alarm_kill(pthread_t thread_id);
void thr_end_alarm(thr_alarm_t *alarmed);
void end_thr_alarm(void);
+sig_handler process_alarm(int);
+#ifndef thr_got_alarm
+bool thr_got_alarm(thr_alarm_t *alrm);
+#endif
+
+
#endif /* DONT_USE_THR_ALARM */
#ifdef __cplusplus
}
-#endif
-#endif
+#endif /* __cplusplus */
+#endif /* _thr_alarm_h */
+
diff --git a/isam/isamchk.c b/isam/isamchk.c
index 2f2471c4376..ce96655a7a5 100644
--- a/isam/isamchk.c
+++ b/isam/isamchk.c
@@ -193,6 +193,10 @@ char **argv;
int error;
MY_INIT(argv[0]);
+#ifdef __EMX__
+ _wildcard (&argc, &argv);
+#endif
+
get_options(&argc,(char***) &argv);
nisam_quick_table_bits=(uint) decode_bits;
error=0;
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 37e656edb96..8f750affd5f 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1465,8 +1465,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (db)
client_flag|=CLIENT_CONNECT_WITH_DB;
#ifdef HAVE_COMPRESS
- if (mysql->server_capabilities & CLIENT_COMPRESS &&
- (mysql->options.compress || client_flag & CLIENT_COMPRESS))
+ if ((mysql->server_capabilities & CLIENT_COMPRESS) &&
+ (mysql->options.compress || (client_flag & CLIENT_COMPRESS)))
client_flag|=CLIENT_COMPRESS; /* We will use compression */
else
#endif
diff --git a/libmysql/net.c b/libmysql/net.c
index dac1fe0bd68..d8898facb26 100644
--- a/libmysql/net.c
+++ b/libmysql/net.c
@@ -71,7 +71,7 @@ extern ulong mysqld_net_retry_count;
typedef my_bool thr_alarm_t;
typedef my_bool ALARM;
#define thr_alarm_init(A) (*A)=0
-#define thr_alarm_in_use(A) (A)
+#define thr_alarm_in_use(A) (*(A))
#define thr_end_alarm(A)
#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
static inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
@@ -330,7 +330,7 @@ net_real_write(NET *net,const char *packet,ulong len)
{
my_bool interrupted = vio_should_retry(net->vio);
#if (!defined(__WIN__) && !defined(__EMX__))
- if ((interrupted || length==0) && !thr_alarm_in_use(alarmed))
+ if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed))
{
if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff))
{ /* Always true for client */
@@ -355,7 +355,7 @@ net_real_write(NET *net,const char *packet,ulong len)
}
else
#endif /* (!defined(__WIN__) && !defined(__EMX__)) */
- if (thr_alarm_in_use(alarmed) && !thr_got_alarm(alarmed) &&
+ if (thr_alarm_in_use(&alarmed) && !thr_got_alarm(&alarmed) &&
interrupted)
{
if (retry_count++ < RETRY_COUNT)
@@ -389,7 +389,7 @@ net_real_write(NET *net,const char *packet,ulong len)
if (net->compress)
my_free((char*) packet,MYF(0));
#endif
- if (thr_alarm_in_use(alarmed))
+ if (thr_alarm_in_use(&alarmed))
{
thr_end_alarm(&alarmed);
vio_blocking(net->vio, net_blocking);
@@ -412,10 +412,9 @@ net_real_write(NET *net,const char *packet,ulong len)
static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
{
- char buff[1024];
ALARM alarm_buff;
uint retry_count=0;
- if (!thr_alarm_in_use(alarmed))
+ if (!thr_alarm_in_use(&alarmed))
{
if (!thr_alarm(alarmed,net->timeout,&alarm_buff) ||
(!vio_is_blocking(net->vio) && vio_blocking(net->vio,TRUE) < 0))
@@ -427,7 +426,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
if ((int) (length=vio_read(net->vio,(char*) net->buff,remain)) <= 0L)
{
my_bool interrupted = vio_should_retry(net->vio);
- if (!thr_got_alarm(alarmed) && interrupted)
+ if (!thr_got_alarm(&alarmed) && interrupted)
{ /* Probably in MIT threads */
if (retry_count++ < RETRY_COUNT)
continue;
@@ -482,7 +481,7 @@ my_real_read(NET *net, ulong *complen)
an alarm to not 'read forever', change the socket to non blocking
mode and try again
*/
- if ((interrupted || length == 0) && !thr_alarm_in_use(alarmed))
+ if ((interrupted || length == 0) && !thr_alarm_in_use(&alarmed))
{
if (!thr_alarm(&alarmed,net->timeout,&alarm_buff)) /* Don't wait too long */
{
@@ -514,7 +513,7 @@ my_real_read(NET *net, ulong *complen)
}
}
#endif /* (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER) */
- if (thr_alarm_in_use(alarmed) && !thr_got_alarm(alarmed) &&
+ if (thr_alarm_in_use(&alarmed) && !thr_got_alarm(&alarmed) &&
interrupted)
{ /* Probably in MIT threads */
if (retry_count++ < RETRY_COUNT)
@@ -598,7 +597,7 @@ my_real_read(NET *net, ulong *complen)
}
end:
- if (thr_alarm_in_use(alarmed))
+ if (thr_alarm_in_use(&alarmed))
{
thr_end_alarm(&alarmed);
vio_blocking(net->vio, net_blocking);
diff --git a/libmysql/violite.c b/libmysql/violite.c
index 4efda9f3b90..253ef7bb468 100644
--- a/libmysql/violite.c
+++ b/libmysql/violite.c
@@ -38,8 +38,7 @@
#if defined(__EMX__)
#include <sys/ioctl.h>
-#define ioctlsocket(A,B,C) ioctl((A),(B),(void *)(C),sizeof(*(C)))
-#undef HAVE_FCNTL
+#define ioctlsocket ioctl
#endif /* defined(__EMX__) */
#if defined(MSDOS) || defined(__WIN__)
@@ -111,7 +110,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
#else /* !defined(__WIN__) && !defined(__EMX__) */
{
/* set to blocking mode by default */
- ulong arg=0;
+ ulong arg=0, r;
r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg));
}
#endif
diff --git a/myisam/ChangeLog b/myisam/ChangeLog
index d212039fedf..504202be43f 100644
--- a/myisam/ChangeLog
+++ b/myisam/ChangeLog
@@ -1,3 +1,7 @@
+2000-11-27 Michael Widenius <monty@mysql.com>
+
+* Changed mi_create.c to use less stack.
+
2000-08-23 Michael Widenius <monty@mysql.com>
* Fixed bug when comparing DECIMAL/NUMERIC key parts.
diff --git a/myisam/mi_create.c b/myisam/mi_create.c
index 92aef5e25de..38573951468 100644
--- a/myisam/mi_create.c
+++ b/myisam/mi_create.c
@@ -43,7 +43,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
base_pos,varchar_count,long_varchar_count,varchar_length,
max_key_block_length,unique_key_parts,offset;
ulong reclength, real_reclength,min_pack_length;
- char buff[max(FN_REFLEN,2048)];
+ char buff[FN_REFLEN];
ulong pack_reclength;
ulonglong tot_length,max_rows;
enum en_fieldtype type;
@@ -52,7 +52,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
MI_UNIQUEDEF *uniquedef;
MI_KEYSEG *keyseg,tmp_keyseg;
MI_COLUMNDEF *rec;
- ulong rec_per_key_part[MI_MAX_POSSIBLE_KEY*MI_MAX_KEY_SEG];
+ ulong *rec_per_key_part;
my_off_t key_root[MI_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE];
MI_CREATE_INFO tmp_create_info;
DBUG_ENTER("mi_create");
@@ -87,7 +87,12 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
}
if (ci->reloc_rows > ci->max_rows)
- ci->reloc_rows=ci->max_rows; /* Check if wrong parameter */
+ ci->reloc_rows=ci->max_rows; /* Check if wrong parameter */
+
+ if (!(rec_per_key_part=
+ (ulong*) my_malloc((keys + uniques)*MI_MAX_KEY_SEG*sizeof(long),
+ MYF(MY_WME | MY_ZEROFILL))))
+ DBUG_RETURN(my_errno);
/* Start by checking fields and field-types used */
@@ -214,7 +219,6 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
max_key_length=0; tot_length=0 ; key_segs=0;
max_key_block_length=0;
share.state.rec_per_key_part=rec_per_key_part;
- bzero((char*) rec_per_key_part,sizeof(rec_per_key_part));
share.state.key_root=key_root;
share.state.key_del=key_del;
if (uniques)
@@ -581,6 +585,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
pthread_mutex_unlock(&THR_LOCK_myisam);
if (my_close(file,MYF(0)))
goto err;
+ my_free((char*) rec_per_key_part,MYF(0));
DBUG_RETURN(0);
err:
@@ -606,6 +611,7 @@ err:
my_delete(buff,MYF(0));
}
}
+ my_free((char*) rec_per_key_part, MYF(0));
DBUG_RETURN(my_errno=save_errno); /* return the fatal errno */
}
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index f2b3f337c67..1201b7b6657 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -84,6 +84,10 @@ int main(int argc, char **argv)
int error;
MY_INIT(argv[0]);
+#ifdef __EMX__
+ _wildcard (&argc, &argv);
+#endif
+
myisamchk_init(&check_param);
check_param.opt_lock_memory=1; /* Lock memory if possible */
check_param.using_global_keycache = 0;
diff --git a/mysys/default.c b/mysys/default.c
index e7e2e7cc8ff..6518fb5816f 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -146,6 +146,12 @@ void load_defaults(const char *conf_file, const char **groups,
&group))
goto err;
#endif
+#ifdef __EMX__
+ if (getenv("ETC") &&
+ search_default_file(&args, &alloc, getenv("ETC"), conf_file,
+ default_ext, &group))
+ goto err;
+#endif
for (dirs=default_directories ; *dirs; dirs++)
{
int error=0;
@@ -357,6 +363,10 @@ void print_defaults(const char *conf_file, const char **groups)
GetWindowsDirectory(name,sizeof(name));
printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_ext);
#endif
+#ifdef __EMX__
+ if (getenv("ETC"))
+ printf("%s\\%s%s ", getenv("ETC"), conf_file, default_ext);
+#endif
for (dirs=default_directories ; *dirs; dirs++)
{
if (**dirs)
diff --git a/mysys/getopt.c b/mysys/getopt.c
index 88fdbff7811..a2a3b5bbec9 100644
--- a/mysys/getopt.c
+++ b/mysys/getopt.c
@@ -660,8 +660,12 @@ _getopt_internal (int argc, char *const *argv, const char *optstring, const stru
}
}
+#ifdef __EMX__
+int getopt (int argc, char **argv, __const__ char *optstring)
+#else
int
getopt (int argc, char *const *argv, const char *optstring)
+#endif
{
return _getopt_internal (argc, argv, optstring,
(const struct option *) 0,
diff --git a/mysys/mf_format.c b/mysys/mf_format.c
index 47d5e17cf22..3050fd88e90 100644
--- a/mysys/mf_format.c
+++ b/mysys/mf_format.c
@@ -117,7 +117,7 @@ my_string fn_format(my_string to, const char *name, const char *dsk,
if (flag & 32 || (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
{
if (realpath(to,buff))
- strmov(to,buff);
+ strnmov(to,buff,FN_REFLEN-1);
}
}
#endif
diff --git a/mysys/mf_path.c b/mysys/mf_path.c
index f7dcf34e6b4..3158c45470c 100644
--- a/mysys/mf_path.c
+++ b/mysys/mf_path.c
@@ -74,7 +74,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(MSDOS) || defined(__WIN__) || defined(__EMX__)
#define F_OK 0
#define PATH_SEP ';'
#define PROGRAM_EXTENSION ".exe"
diff --git a/mysys/my_create.c b/mysys/my_create.c
index 068fd7109f6..8273170fc0a 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -20,7 +20,7 @@
#include <my_dir.h>
#include "mysys_err.h"
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
#include <share.h>
#endif
@@ -42,13 +42,13 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d",
FileName, CreateFlags, access_flags, MyFlags));
-#if !defined(NO_OPEN_3)
+#if !defined(NO_OPEN_3) && !defined(__EMX__)
fd = open((my_string) FileName, access_flags | O_CREAT,
CreateFlags ? CreateFlags : my_umask);
#elif defined(VMS)
fd = open((my_string) FileName, access_flags | O_CREAT, 0,
"ctx=stm","ctx=bin");
-#elif defined(MSDOS) || defined(__WIN__)
+#elif defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
if (access_flags & O_SHARE)
fd = sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY,
SH_DENYNO, MY_S_IREAD | MY_S_IWRITE);
diff --git a/mysys/my_lock.c b/mysys/my_lock.c
index ed637648353..6486e07834b 100644
--- a/mysys/my_lock.c
+++ b/mysys/my_lock.c
@@ -33,9 +33,11 @@
#include <os2emx.h>
#endif
+#ifndef __EMX__
#ifdef HAVE_FCNTL
static struct flock lock; /* Must be static for sun-sparc */
#endif
+#endif
/* Lock a part of a file */
diff --git a/mysys/my_open.c b/mysys/my_open.c
index 98733266d1b..aadf197d2cb 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -19,7 +19,7 @@
#include "mysys_priv.h"
#include "mysys_err.h"
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
#include <share.h>
#endif
@@ -34,7 +34,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(MSDOS) || defined(__WIN__) || defined(__EMX__)
if (Flags & O_SHARE)
fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO);
else
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 2397e315eff..72515932141 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -37,7 +37,7 @@
static my_bool alarm_aborted=1;
my_bool thr_alarm_inited=0;
-#if !defined(__WIN__) && !defined(__OS2__)
+#if !defined(__WIN__) && !defined(__EMX__)
static pthread_mutex_t LOCK_alarm;
static sigset_t full_signal_set;
@@ -460,42 +460,91 @@ static void *alarm_handler(void *arg __attribute__((unused)))
** thr_alarm for OS/2
*****************************************************************************/
-#elif defined(__OS2__)
+#elif defined(__EMX__)
#define INCL_BASE
#define INCL_NOPMAPI
#include <os2.h>
+static pthread_mutex_t LOCK_alarm;
+static sigset_t full_signal_set;
+static QUEUE alarm_queue;
+pthread_t alarm_thread;
+
+#ifdef USE_ALARM_THREAD
+static pthread_cond_t COND_alarm;
+static void *alarm_handler(void *arg);
+#define reschedule_alarms() pthread_cond_signal(&COND_alarm)
+#else
+#define reschedule_alarms() pthread_kill(alarm_thread,THR_SERVER_ALARM)
+#endif
+
+sig_handler process_alarm(int sig __attribute__((unused)))
+{
+ sigset_t old_mask;
+ ALARM *alarm_data;
+ DBUG_PRINT("info",("sig: %d active alarms: %d",sig,alarm_queue.elements));
+}
+
+
+/*
+** Remove another thread from the alarm
+*/
+
+void thr_alarm_kill(pthread_t thread_id)
+{
+ uint i;
+
+ pthread_mutex_lock(&LOCK_alarm);
+ for (i=0 ; i < alarm_queue.elements ; i++)
+ {
+ if (pthread_equal(((ALARM*) queue_element(&alarm_queue,i))->thread,
+ thread_id))
+ {
+ ALARM *tmp=(ALARM*) queue_remove(&alarm_queue,i);
+ tmp->expire_time=0;
+ queue_insert(&alarm_queue,(byte*) tmp);
+ reschedule_alarms();
+ break;
+ }
+ }
+ pthread_mutex_unlock(&LOCK_alarm);
+}
+
bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm)
{
APIRET rc;
if (alarm_aborted)
{
- alrm->crono=0;
- alrm->event=0;
+ alarm->alarmed.crono=0;
+ alarm->alarmed.event=0;
return 1;
}
- if (!(rc = DosCreateEventSem(NULL,(HEV *)&alrm->event,DC_SEM_SHARED,FALSE)))
+ if (rc = DosCreateEventSem(NULL,(HEV *) &alarm->alarmed.event,
+ DC_SEM_SHARED,FALSE))
{
printf("Error creating event semaphore! [%d] \n",rc);
- alrm->crono=0;
- alrm->event=0;
+ alarm->alarmed.crono=0;
+ alarm->alarmed.event=0;
return 1;
}
- if (!(rc = DosAsyncTimer((long) sec*1000L, (HSEM) alrm->event,(HTIMER *) &alrm->crono))) {
+ if (rc = DosAsyncTimer((long) sec*1000L, (HSEM) alarm->alarmed.event,
+ (HTIMER *) &alarm->alarmed.crono))
+ {
printf("Error starting async timer! [%d] \n",rc);
- DosCloseEventSem((HEV) alrm->event);
- alrm->crono=0;
- alrm->event=0;
+ DosCloseEventSem((HEV) alarm->alarmed.event);
+ alarm->alarmed.crono=0;
+ alarm->alarmed.event=0;
return 1;
} /* endif */
-
+ (*alrm)= &alarm->alarmed;
return 1;
}
-bool thr_got_alarm(thr_alarm_t *alrm)
+bool thr_got_alarm(thr_alarm_t *alrm_ptr)
{
+ thr_alarm_t alrm= *alrm_ptr;
APIRET rc;
if (alrm->crono)
@@ -511,8 +560,9 @@ bool thr_got_alarm(thr_alarm_t *alrm)
}
-void thr_end_alarm(thr_alarm_t *alrm)
+void thr_end_alarm(thr_alarm_t *alrm_ptr)
{
+ thr_alarm_t alrm= *alrm_ptr;
if (alrm->crono)
{
DosStopTimer((HTIMER) alrm->crono);
@@ -542,21 +592,35 @@ void init_thr_alarm(uint max_alarm)
#else /* __WIN__ */
+void thr_alarm_kill(pthread_t thread_id)
+{
+ /* Can't do this yet */
+}
+
+sig_handler process_alarm(int sig __attribute__((unused)))
+{
+ /* Can't do this yet */
+}
+
+
bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm)
{
if (alarm_aborted)
{
- alrm->crono=0;
+ alarm->alarmed.crono=0;
return 1;
}
- if (!(alrm->crono=SetTimer((HWND) NULL,0, sec*1000,(TIMERPROC) NULL)))
+ if (!(alarm->alarmed.crono=SetTimer((HWND) NULL,0, sec*1000,
+ (TIMERPROC) NULL)))
return 1;
+ (*alrm)= &alarm->alarmed;
return 0;
}
-bool thr_got_alarm(thr_alarm_t *alrm)
+bool thr_got_alarm(thr_alarm_t *alrm_ptr)
{
+ thr_alarm_t alrm= *alrm_ptr;
MSG msg;
if (alrm->crono)
{
@@ -571,8 +635,9 @@ bool thr_got_alarm(thr_alarm_t *alrm)
}
-void thr_end_alarm(thr_alarm_t *alrm)
+void thr_end_alarm(thr_alarm_t *alrm_ptr)
{
+ thr_alarm_t alrm= *alrm_ptr;
if (alrm->crono)
{
KillTimer(NULL, alrm->crono);
@@ -587,6 +652,13 @@ void end_thr_alarm(void)
DBUG_VOID_RETURN;
}
+void init_thr_alarm(uint max_alarm)
+{
+ DBUG_ENTER("init_thr_alarm");
+ alarm_aborted=0; /* Yes, Gimmie alarms */
+ DBUG_VOID_RETURN;
+}
+
#endif /* __WIN__ */
#endif /* THREAD */
@@ -634,12 +706,12 @@ static void *test_thread(void *arg)
}
else
{
- for (retry=0 ; !thr_got_alarm(got_alarm) && retry < 10 ; retry++)
+ for (retry=0 ; !thr_got_alarm(&got_alarm) && retry < 10 ; retry++)
{
printf("Thread: %s Waiting %d sec\n",my_thread_name(),wait_time);
select(0,(fd_set_ptr) &fd,0,0,0);
}
- if (!thr_got_alarm(got_alarm))
+ if (!thr_got_alarm(&got_alarm))
{
printf("Thread: %s didn't get an alarm. Aborting!\n",
my_thread_name());
diff --git a/readline/input.c b/readline/input.c
index 2813c1b9903..a9e5c9d143f 100644
--- a/readline/input.c
+++ b/readline/input.c
@@ -171,12 +171,23 @@ rl_unget_char (key)
return (0);
}
+#if defined(__EMX__)
+int waiting_char = -1;
+#endif
+
/* If a character is available to be read, then read it
and stuff it into IBUFFER. Otherwise, just return. */
static void
rl_gather_tyi ()
{
-#if defined (__GO32__)
+#if defined (__EMX__)
+ if (isatty (0) && (waiting_char = _read_kbd(0, 0, 0)) != -1 && ibuffer_space ())
+ {
+ int i;
+ i = (*rl_getc_function) (rl_instream);
+ rl_stuff_char (i);
+ }
+#elif defined (__GO32__)
char input;
if (isatty (0) && kbhit () && ibuffer_space ())
@@ -263,6 +274,10 @@ rl_gather_tyi ()
int
_rl_input_available ()
{
+#if defined (__EMX__)
+ if (isatty (0) && (waiting_char = _read_kbd(0, 0, 0)) != -1)
+ return 1;
+#else /* __EMX__ */
#if defined(HAVE_SELECT)
fd_set readfds, exceptfds;
struct timeval timeout;
@@ -288,6 +303,7 @@ _rl_input_available ()
if (ioctl (tty, FIONREAD, &chars_avail) == 0)
return (chars_avail);
#endif
+#endif /* !__EMX__ */
return 0;
}
@@ -397,6 +413,88 @@ rl_getc (stream)
int result, flags;
unsigned char c;
+#if defined (__EMX__)
+ if (isatty (0))
+ {
+ int key;
+
+ if (waiting_char != -1)
+ {
+ key = waiting_char;
+ waiting_char = -1;
+ }
+ else
+ {
+#ifdef __RSXNT__
+ pc_flush();
+#endif
+ key = _read_kbd(0, 1, 0);
+ }
+
+ while (key == 0)
+ {
+ key |= (_read_kbd(0, 1, 0) << 8);
+ /* printf("<%04X> ", key);
+ fflush(stdout); */
+
+ switch (key)
+ {
+ case 0x4B00: /* left arrow */
+ key = 'B' - 64;
+ break;
+ case 0x4D00: /* right arrow */
+ key = 'F' - 64;
+ break;
+ case 0x7300: /* ctrl left arrow */
+ key = 27;
+ waiting_char = 'B';
+ break;
+ case 0x7400: /* ctrl right arrow */
+ key = 27;
+ waiting_char = 'F';
+ break;
+ case 0x4800: /* up arrow */
+ key = 'P' - 64;
+ break;
+ case 0x5000: /* down arrow */
+ key = 'N' - 64;
+ break;
+ case 0x8D00: /* ctrl up arrow */
+ key = 'R' - 64;
+ break;
+ case 0x9100: /* ctrl down arrow */
+ key = 'S' - 64;
+ break;
+ case 0x4700: /* home key */
+ key = 'A' - 64;
+ break;
+ case 0x4F00: /* end key */
+ key = 'E' - 64;
+ break;
+ case 0x7700: /* ctrl home key */
+ key = 27;
+ waiting_char = '<';
+ break;
+ case 0x7500: /* ctrl end key */
+ key = 27;
+ waiting_char = '>';
+ break;
+ case 0x5300: /* delete key */
+ key = 'D' - 64;
+ break;
+ case 0x5200: /* insert key */
+ key = 'V' - 64;
+ break;
+ default: /* ignore all other special keys, read next */
+ key = _read_kbd(0, 1, 0);
+ break;
+ }
+ }
+
+ return (key & 0xFF);
+ }
+#endif /* __EMX__ */
+
#if defined (__GO32__)
if (isatty (0))
return (getkey () & 0x7F);
diff --git a/readline/rltty.c b/readline/rltty.c
index a5ef938b5c0..b4d0cf127d5 100644
--- a/readline/rltty.c
+++ b/readline/rltty.c
@@ -156,6 +156,13 @@ set_winsize (tty)
if (ioctl (tty, TIOCGWINSZ, &w) == 0)
(void) ioctl (tty, TIOCSWINSZ, &w);
}
+#else
+static void
+set_winsize (tty)
+ int tty;
+{
+// dummy function, required by other code. What should be doing?
+}
#endif /* TIOCGWINSZ */
#if defined (NEW_TTY_DRIVER)
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 7f658303a4c..229c24df107 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -199,11 +199,11 @@ err:
return error;
}
+ /* Name is here without an extension */
+
int ha_myisam::open(const char *name, int mode, uint test_if_locked)
{
- char name_buff[FN_REFLEN];
- if (!(file=mi_open(fn_format(name_buff,name,"","",2 | 4), mode,
- test_if_locked)))
+ if (!(file=mi_open(name, mode, test_if_locked)))
return (my_errno ? my_errno : -1);
if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_TMP_TABLE))
diff --git a/sql/my_lock.c b/sql/my_lock.c
index 6c35634203f..7025682d40e 100644
--- a/sql/my_lock.c
+++ b/sql/my_lock.c
@@ -54,7 +54,7 @@ int my_lock(File fd,int locktype,my_off_t start,my_off_t length,myf MyFlags)
if (!thr_alarm(&alarmed,wait_for_alarm,&alarm_buff))
{
int value;
- while ((value=fcntl(fd,F_SETLKW,&lock)) && !thr_got_alarm(alarmed) &&
+ while ((value=fcntl(fd,F_SETLKW,&lock)) && !thr_got_alarm(&alarmed) &&
errno == EINTR) ;
thr_end_alarm(&alarmed);
if (value != -1)
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 10e470ffc78..f2f9e48e889 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -27,6 +27,8 @@
#include <my_base.h> /* Needed by field.h */
#include <violite.h>
+#undef write // remove pthread.h macro definition for EMX
+
typedef ulong table_map; /* Used for table bits in join */
typedef ulong key_map; /* Used for finding keys */
typedef ulong key_part_map; /* Used for finding key parts */
@@ -223,7 +225,7 @@ bool mysql_change_db(THD *thd,const char *name);
void mysql_parse(THD *thd,char *inBuf,uint length);
void mysql_init_select(LEX *lex);
pthread_handler_decl(handle_one_connection,arg);
-int handle_bootstrap(THD *thd,FILE *file);
+pthread_handler_decl(handle_bootstrap,arg);
sig_handler end_thread_signal(int sig);
void end_thread(THD *thd,bool put_in_cache);
void flush_thread_cache();
@@ -405,7 +407,8 @@ bool rename_temporary_table(TABLE *table, const char *new_db,
const char *table_name);
void remove_db_from_cache(const my_string db);
void flush_tables();
-bool remove_table_from_cache(THD *thd, const char *db, const char *table);
+bool remove_table_from_cache(THD *thd, const char *db, const char *table,
+ bool return_if_owned_by_thd=0);
bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables);
void copy_field_from_tmp_record(Field *field,int offset);
int fill_record(List<Item> &fields,List<Item> &values);
@@ -462,6 +465,7 @@ extern time_t start_time;
extern const char *command_name[];
extern I_List<THD> threads;
extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
+extern FILE *bootstrap_file;
extern pthread_key(MEM_ROOT*,THR_MALLOC);
extern pthread_key(NET*, THR_NET);
extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open,
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 316b97f5c52..78fcc2f563c 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -159,6 +159,7 @@ static bool opt_log,opt_update_log,opt_bin_log,opt_slow_log,opt_noacl,
opt_disable_networking=0, opt_bootstrap=0,opt_skip_show_db=0,
opt_ansi_mode=0,opt_myisam_log=0, opt_large_files=sizeof(my_off_t) > 4;
bool opt_sql_bin_update = 0, opt_log_slave_updates = 0;
+FILE *bootstrap_file=0;
extern MASTER_INFO glob_mi;
extern int init_master_info(MASTER_INFO* mi);
@@ -1001,7 +1002,8 @@ static void init_signals(void)
#elif defined(__EMX__)
static void sig_reload(int signo)
{
- reload_acl_and_cache(~0); // Flush everything
+ //reload_acl_and_cache(~0); // Flush everything
+ reload_acl_and_cache((THD*) 0,~0, (TABLE_LIST*) 0); // Flush everything
signal(signo, SIG_ACK);
}
@@ -1327,7 +1329,7 @@ int main(int argc, char **argv)
{
struct tm *start_tm;
start_tm=localtime(&start_time);
- strmov(time_zone=tzname[start_tm->tm_isdst == 1 ? 1 : 0]);
+ strmov(time_zone,tzname[start_tm->tm_isdst == 1 ? 1 : 0]);
}
#endif
#endif
@@ -1780,9 +1782,25 @@ static int bootstrap(FILE *file)
my_net_init(&thd->net,(Vio*) 0);
thd->max_packet_length=thd->net.max_packet;
thd->master_access= ~0;
+ thd->thread_id=thread_id++;
thread_count++;
- thd->real_id=pthread_self();
- error=handle_bootstrap(thd,file);
+
+ bootstrap_file=file;
+ if (pthread_create(&thd->real_id,&connection_attrib,handle_bootstrap,
+ (void*) thd))
+ {
+ sql_print_error("Warning: Can't create thread to handle bootstrap");
+ return -1;
+ }
+ /* Wait for thread to die */
+ (void) pthread_mutex_lock(&LOCK_thread_count);
+ while (thread_count)
+ {
+ (void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
+ DBUG_PRINT("quit",("One thread died (count=%u)",thread_count));
+ }
+ (void) pthread_mutex_unlock(&LOCK_thread_count);
+ error= thd->fatal_error;
net_end(&thd->net);
delete thd;
return error;
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 14bf2700378..8b0603473a6 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -71,7 +71,7 @@ extern ulong mysqld_net_retry_count;
typedef my_bool thr_alarm_t;
typedef my_bool ALARM;
#define thr_alarm_init(A) (*A)=0
-#define thr_alarm_in_use(A) (A)
+#define thr_alarm_in_use(A) (*(A))
#define thr_end_alarm(A)
#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
static inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
@@ -271,7 +271,7 @@ net_real_write(NET *net,const char *packet,ulong len)
int length;
char *pos,*end;
thr_alarm_t alarmed;
-#if (!defined(__WIN__) && !defined(__EMX__))
+#if !defined(__WIN__)
ALARM alarm_buff;
#endif
uint retry_count=0;
@@ -330,7 +330,7 @@ net_real_write(NET *net,const char *packet,ulong len)
{
my_bool interrupted = vio_should_retry(net->vio);
#if (!defined(__WIN__) && !defined(__EMX__))
- if ((interrupted || length==0) && !thr_alarm_in_use(alarmed))
+ if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed))
{
if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff))
{ /* Always true for client */
@@ -355,7 +355,7 @@ net_real_write(NET *net,const char *packet,ulong len)
}
else
#endif /* (!defined(__WIN__) && !defined(__EMX__)) */
- if (thr_alarm_in_use(alarmed) && !thr_got_alarm(alarmed) &&
+ if (thr_alarm_in_use(&alarmed) && !thr_got_alarm(&alarmed) &&
interrupted)
{
if (retry_count++ < RETRY_COUNT)
@@ -389,7 +389,7 @@ net_real_write(NET *net,const char *packet,ulong len)
if (net->compress)
my_free((char*) packet,MYF(0));
#endif
- if (thr_alarm_in_use(alarmed))
+ if (thr_alarm_in_use(&alarmed))
{
thr_end_alarm(&alarmed);
vio_blocking(net->vio, net_blocking);
@@ -414,7 +414,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
{
ALARM alarm_buff;
uint retry_count=0;
- if (!thr_alarm_in_use(alarmed))
+ if (!thr_alarm_in_use(&alarmed))
{
if (!thr_alarm(alarmed,net->timeout,&alarm_buff) ||
(!vio_is_blocking(net->vio) && vio_blocking(net->vio,TRUE) < 0))
@@ -426,7 +426,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
if ((int) (length=vio_read(net->vio,(char*) net->buff,remain)) <= 0L)
{
my_bool interrupted = vio_should_retry(net->vio);
- if (!thr_got_alarm(alarmed) && interrupted)
+ if (!thr_got_alarm(&alarmed) && interrupted)
{ /* Probably in MIT threads */
if (retry_count++ < RETRY_COUNT)
continue;
@@ -481,7 +481,7 @@ my_real_read(NET *net, ulong *complen)
an alarm to not 'read forever', change the socket to non blocking
mode and try again
*/
- if ((interrupted || length == 0) && !thr_alarm_in_use(alarmed))
+ if ((interrupted || length == 0) && !thr_alarm_in_use(&alarmed))
{
if (!thr_alarm(&alarmed,net->timeout,&alarm_buff)) /* Don't wait too long */
{
@@ -513,7 +513,7 @@ my_real_read(NET *net, ulong *complen)
}
}
#endif /* (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER) */
- if (thr_alarm_in_use(alarmed) && !thr_got_alarm(alarmed) &&
+ if (thr_alarm_in_use(&alarmed) && !thr_got_alarm(&alarmed) &&
interrupted)
{ /* Probably in MIT threads */
if (retry_count++ < RETRY_COUNT)
@@ -597,7 +597,7 @@ my_real_read(NET *net, ulong *complen)
}
end:
- if (thr_alarm_in_use(alarmed))
+ if (thr_alarm_in_use(&alarmed))
{
thr_end_alarm(&alarmed);
vio_blocking(net->vio, net_blocking);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 3560fc42d49..66c4a22ad67 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -275,7 +275,7 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
bool found=0;
for (TABLE_LIST *table=tables ; table ; table=table->next)
{
- if (remove_table_from_cache(thd, table->db, table->name))
+ if (remove_table_from_cache(thd, table->db, table->name, 1))
found=1;
}
if (!found)
@@ -1972,7 +1972,8 @@ void flush_tables()
** Returns true if the table is in use by another thread
*/
-bool remove_table_from_cache(THD *thd, const char *db,const char *table_name)
+bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
+ bool return_if_owned_by_thd)
{
char key[MAX_DBKEY_LENGTH];
uint key_length;
@@ -1985,13 +1986,12 @@ bool remove_table_from_cache(THD *thd, const char *db,const char *table_name)
table;
table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length))
{
+ THD *in_use;
table->version=0L; /* Free when thread is ready */
- if (!table->in_use)
+ if (!(in_use=table->in_use))
relink_unused(table);
- else if (table->in_use != thd)
+ else if (in_use != thd)
{
- THD *in_use=table->in_use;
-
in_use->some_tables_deleted=1;
if (table->db_stat)
result=1;
@@ -2009,6 +2009,8 @@ bool remove_table_from_cache(THD *thd, const char *db,const char *table_name)
pthread_mutex_unlock(&in_use->mysys_var->mutex);
}
}
+ else
+ result= result || return_if_owned_by_thd;
}
while (unused_tables && !unused_tables->version)
VOID(hash_delete(&open_cache,(byte*) unused_tables));
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 696c111c01a..5be229a2695 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -80,7 +80,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
global_read_lock(0)
{
proc_info="login";
- host=user=db=query=ip=0;
+ host=user=priv_user=db=query=ip=0;
locked=killed=count_cuted_fields=some_tables_deleted=no_errors=password=
query_start_used=0;
query_length=col_access=0;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 4003b057c06..83c70f29d19 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -21,7 +21,6 @@
#pragma interface /* gcc class implementation */
#endif
-
class Query_log_event;
class Load_log_event;
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 1159fc56ee6..807464552a7 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -24,8 +24,7 @@
This will work even if the .ISM and .ISD tables are destroyed
*/
-int generate_table(THD *thd, TABLE_LIST *table_list,
- TABLE *locked_table)
+int generate_table(THD *thd, TABLE_LIST *table_list, TABLE *locked_table)
{
char path[FN_REFLEN];
int error;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index de6d006a80e..1cb042537fc 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -163,7 +163,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
// the file must be:
if (!((stat_info.st_mode & S_IROTH) == S_IROTH && // readable by others
+#ifndef __EMX__
(stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink
+#endif
((stat_info.st_mode & S_IFREG) == S_IFREG ||
(stat_info.st_mode & S_IFIFO) == S_IFIFO)))
{
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 195a7a4f525..5eba2ab880b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -428,19 +428,26 @@ end_thread:
return(0); /* purecov: deadcode */
}
+/*
+ Execute commands from bootstrap_file.
+ Used when creating the initial grant tables
+*/
-int handle_bootstrap(THD *thd,FILE *file)
+pthread_handler_decl(handle_bootstrap,arg)
{
+ THD *thd=(THD*) arg;
+ FILE *file=bootstrap_file;
+ char *buff;
DBUG_ENTER("handle_bootstrap");
+
+ pthread_detach_this_thread();
thd->thread_stack= (char*) &thd;
- if (init_thr_lock() ||
- my_pthread_setspecific_ptr(THR_THD, thd) ||
- my_pthread_setspecific_ptr(THR_MALLOC, &thd->mem_root) ||
- my_pthread_setspecific_ptr(THR_NET, &thd->net))
+ if (my_thread_init() || thd->store_globals())
{
close_connection(&thd->net,ER_OUT_OF_RESOURCES);
- DBUG_RETURN(-1);
+ thd->fatal_error=1;
+ goto end;
}
thd->mysys_var=my_thread_var;
thd->dbug_thread_id=my_thread_id();
@@ -455,8 +462,9 @@ int handle_bootstrap(THD *thd,FILE *file)
thd->proc_info=0;
thd->version=refresh_version;
+ thd->priv_user=thd->user="boot";
- char *buff= (char*) thd->net.buff;
+ buff= (char*) thd->net.buff;
init_sql_alloc(&thd->mem_root,8192,8192);
while (fgets(buff, thd->net.max_packet, file))
{
@@ -470,13 +478,20 @@ int handle_bootstrap(THD *thd,FILE *file)
mysql_parse(thd,thd->query,length);
close_thread_tables(thd); // Free tables
if (thd->fatal_error)
- {
- DBUG_RETURN(-1);
- }
+ break;
free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC));
}
- free_root(&thd->mem_root,MYF(0));
- DBUG_RETURN(0);
+ thd->priv_user=thd->user=0;
+
+ /* thd->fatal_error should be set in case something went wrong */
+end:
+ (void) pthread_mutex_lock(&LOCK_thread_count);
+ thread_count--;
+ (void) pthread_cond_broadcast(&COND_thread_count);
+ (void) pthread_mutex_unlock(&LOCK_thread_count);
+ my_thread_end();
+ pthread_exit(0);
+ DBUG_RETURN(0); // Never reached
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 29ef01e8196..8856d31645c 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -3520,6 +3520,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
{
Field *field=(*group->item)->tmp_table_field();
bool maybe_null=(*group->item)->maybe_null;
+ key_part_info->null_bit=0;
key_part_info->field= field;
key_part_info->offset= field->offset();
key_part_info->length= (uint16) field->pack_length();
@@ -3581,6 +3582,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
keyinfo->name=(char*) "tmp";
if (null_count)
{
+ key_part_info->null_bit=0;
key_part_info->offset=0;
key_part_info->length=(null_count+7)/8;
key_part_info->field=new Field_string((char*) table->record[0],
@@ -3596,6 +3598,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
for (i=0,reg_field=table->field; i < field_count;
i++, reg_field++, key_part_info++)
{
+ key_part_info->null_bit=0;
key_part_info->field= *reg_field;
key_part_info->offset= (*reg_field)->offset();
key_part_info->length= (uint16) (*reg_field)->pack_length();
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 2c59f4b3482..f51e1d1abe8 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1482,7 +1482,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
}
-#ifdef __WIN__
+#if defined( __WIN__) || defined( __EMX__)
// Win32 can't rename an open table, so we must close the org table!
table_name=thd->strdup(table_name); // must be saved
if (close_cached_table(thd,table))
diff --git a/sql/violite.c b/sql/violite.c
index 4efda9f3b90..253ef7bb468 100644
--- a/sql/violite.c
+++ b/sql/violite.c
@@ -38,8 +38,7 @@
#if defined(__EMX__)
#include <sys/ioctl.h>
-#define ioctlsocket(A,B,C) ioctl((A),(B),(void *)(C),sizeof(*(C)))
-#undef HAVE_FCNTL
+#define ioctlsocket ioctl
#endif /* defined(__EMX__) */
#if defined(MSDOS) || defined(__WIN__)
@@ -111,7 +110,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
#else /* !defined(__WIN__) && !defined(__EMX__) */
{
/* set to blocking mode by default */
- ulong arg=0;
+ ulong arg=0, r;
r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg));
}
#endif