summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/mysql/libmysql/Makefile.in6
-rw-r--r--ext/mysql/libmysql/acinclude.m417
-rw-r--r--ext/mysql/libmysql/array.c6
-rw-r--r--ext/mysql/libmysql/bchange.c4
-rw-r--r--ext/mysql/libmysql/bmove_upp.c4
-rw-r--r--ext/mysql/libmysql/charset.c518
-rw-r--r--ext/mysql/libmysql/config-win.h (renamed from ext/mysql/libmysql/config-win32.h)67
-rw-r--r--ext/mysql/libmysql/ct_init.c6
-rw-r--r--ext/mysql/libmysql/ctype-latin1.c139
-rw-r--r--ext/mysql/libmysql/ctype.c54
-rw-r--r--ext/mysql/libmysql/ctype_autoconf.c44
-rw-r--r--ext/mysql/libmysql/ctype_extra_sources.c82
-rw-r--r--ext/mysql/libmysql/dbug.c32
-rw-r--r--ext/mysql/libmysql/dbug.h3
-rw-r--r--ext/mysql/libmysql/default.c35
-rw-r--r--ext/mysql/libmysql/dll.c6
-rw-r--r--ext/mysql/libmysql/errmsg.c10
-rw-r--r--ext/mysql/libmysql/errmsg.h12
-rw-r--r--ext/mysql/libmysql/errors.c6
-rw-r--r--ext/mysql/libmysql/get_password.c109
-rw-r--r--ext/mysql/libmysql/global.h99
-rw-r--r--ext/mysql/libmysql/int2str.c52
-rw-r--r--ext/mysql/libmysql/is_prefix.c4
-rw-r--r--ext/mysql/libmysql/libmysql.c332
-rw-r--r--ext/mysql/libmysql/list.c8
-rw-r--r--ext/mysql/libmysql/longlong2str.c54
-rw-r--r--ext/mysql/libmysql/m_ctype.h236
-rw-r--r--ext/mysql/libmysql/m_string.h26
-rw-r--r--ext/mysql/libmysql/mf_casecnv.c189
-rw-r--r--ext/mysql/libmysql/mf_dirname.c4
-rw-r--r--ext/mysql/libmysql/mf_fn_ext.c13
-rw-r--r--ext/mysql/libmysql/mf_format.c4
-rw-r--r--ext/mysql/libmysql/mf_loadpath.c7
-rw-r--r--ext/mysql/libmysql/mf_pack.c60
-rw-r--r--ext/mysql/libmysql/mf_path.c10
-rw-r--r--ext/mysql/libmysql/mf_unixpath.c4
-rw-r--r--ext/mysql/libmysql/mf_wcomp.c4
-rw-r--r--ext/mysql/libmysql/mulalloc.c4
-rw-r--r--ext/mysql/libmysql/my_alarm.h4
-rw-r--r--ext/mysql/libmysql/my_alloc.c6
-rw-r--r--ext/mysql/libmysql/my_compress.c4
-rw-r--r--ext/mysql/libmysql/my_config.h12
-rw-r--r--ext/mysql/libmysql/my_create.c12
-rw-r--r--ext/mysql/libmysql/my_delete.c4
-rw-r--r--ext/mysql/libmysql/my_dir.h5
-rw-r--r--ext/mysql/libmysql/my_div.c4
-rw-r--r--ext/mysql/libmysql/my_error.c11
-rw-r--r--ext/mysql/libmysql/my_fopen.c7
-rw-r--r--ext/mysql/libmysql/my_getwd.c6
-rw-r--r--ext/mysql/libmysql/my_init.c27
-rw-r--r--ext/mysql/libmysql/my_lib.c597
-rw-r--r--ext/mysql/libmysql/my_list.h4
-rw-r--r--ext/mysql/libmysql/my_malloc.c4
-rw-r--r--ext/mysql/libmysql/my_messnc.c6
-rw-r--r--ext/mysql/libmysql/my_net.c14
-rw-r--r--ext/mysql/libmysql/my_net.h13
-rw-r--r--ext/mysql/libmysql/my_once.c4
-rw-r--r--ext/mysql/libmysql/my_open.c10
-rw-r--r--ext/mysql/libmysql/my_pthread.c20
-rw-r--r--ext/mysql/libmysql/my_pthread.h88
-rw-r--r--ext/mysql/libmysql/my_read.c4
-rw-r--r--ext/mysql/libmysql/my_realloc.c4
-rw-r--r--ext/mysql/libmysql/my_static.c6
-rw-r--r--ext/mysql/libmysql/my_static.h6
-rw-r--r--ext/mysql/libmysql/my_sys.h71
-rw-r--r--ext/mysql/libmysql/my_tempnam.c4
-rw-r--r--ext/mysql/libmysql/my_thr_init.c21
-rw-r--r--ext/mysql/libmysql/my_wincond.c15
-rw-r--r--ext/mysql/libmysql/my_write.c4
-rw-r--r--ext/mysql/libmysql/mysql.h68
-rw-r--r--ext/mysql/libmysql/mysql_com.h50
-rw-r--r--ext/mysql/libmysql/mysql_version.h14
-rw-r--r--ext/mysql/libmysql/mysqld_error.h19
-rw-r--r--ext/mysql/libmysql/mysys_err.h7
-rw-r--r--ext/mysql/libmysql/mysys_priv.h10
-rw-r--r--ext/mysql/libmysql/net.c170
-rw-r--r--ext/mysql/libmysql/password.c4
-rw-r--r--ext/mysql/libmysql/safemalloc.c11
-rw-r--r--ext/mysql/libmysql/str2int.c3
-rw-r--r--ext/mysql/libmysql/strcend.c3
-rw-r--r--ext/mysql/libmysql/strcont.c4
-rw-r--r--ext/mysql/libmysql/strfill.c4
-rw-r--r--ext/mysql/libmysql/string.c8
-rw-r--r--ext/mysql/libmysql/strinstr.c4
-rw-r--r--ext/mysql/libmysql/strmake.c4
-rw-r--r--ext/mysql/libmysql/strmov.c9
-rw-r--r--ext/mysql/libmysql/strnmov.c3
-rw-r--r--ext/mysql/libmysql/strto.c3
-rw-r--r--ext/mysql/libmysql/strtoll.c4
-rw-r--r--ext/mysql/libmysql/strtoull.c4
-rw-r--r--ext/mysql/libmysql/strxmov.c2
-rw-r--r--ext/mysql/libmysql/thr_alarm.h19
-rw-r--r--ext/mysql/libmysql/thr_mutex.c26
-rw-r--r--ext/mysql/libmysql/typelib.c11
-rw-r--r--ext/mysql/libmysql/violite.c36
-rw-r--r--ext/mysql/libmysql/violite.h6
96 files changed, 2793 insertions, 980 deletions
diff --git a/ext/mysql/libmysql/Makefile.in b/ext/mysql/libmysql/Makefile.in
index aaf98db2bc..e40915d13d 100644
--- a/ext/mysql/libmysql/Makefile.in
+++ b/ext/mysql/libmysql/Makefile.in
@@ -1,7 +1,7 @@
LTLIBRARY_NAME = libmysql_client.la
LTLIBRARY_SOURCES = libmysql.c errmsg.c net.c violite.c password.c \
- my_init.c my_static.c my_malloc.c my_realloc.c my_create.c \
+ my_init.c my_lib.c my_static.c my_malloc.c my_realloc.c my_create.c \
my_delete.c my_tempnam.c my_open.c mf_casecnv.c my_read.c \
my_write.c errors.c my_error.c my_getwd.c my_div.c mf_pack.c \
my_messnc.c mf_dirname.c mf_fn_ext.c mf_wcomp.c typelib.c safemalloc.c \
@@ -9,8 +9,8 @@ LTLIBRARY_SOURCES = libmysql.c errmsg.c net.c violite.c password.c \
my_pthread.c my_thr_init.c thr_mutex.c mulalloc.c string.c default.c \
my_compress.c array.c my_once.c list.c my_net.c dbug.c \
strmov.c strxmov.c strnmov.c strmake.c strend.c strfill.c \
- ct_init.c is_prefix.c int2str.c str2int.c strinstr.c \
+ is_prefix.c int2str.c str2int.c strinstr.c \
strcont.c strcend.c bchange.c bmove.c bmove_upp.c \
- longlong2str.c strtoull.c strtoll.c ctype-latin1.c
+ longlong2str.c strtoull.c strtoll.c charset.c ctype.c
include $(top_srcdir)/build/dynlib.mk
diff --git a/ext/mysql/libmysql/acinclude.m4 b/ext/mysql/libmysql/acinclude.m4
index 5db85cdbcd..8373790f50 100644
--- a/ext/mysql/libmysql/acinclude.m4
+++ b/ext/mysql/libmysql/acinclude.m4
@@ -184,6 +184,22 @@ AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $mysql_cv_btype_last_arg_accept,[ ])
CXXFLAGS="$ac_save_CXXFLAGS"
])
+dnl Find type of qsort
+AC_DEFUN(MYSQL_TYPE_QSORT,
+[AC_CACHE_CHECK([return type of qsort], mysql_cv_type_qsort,
+[AC_TRY_COMPILE([#include <stdlib.h>
+#ifdef __cplusplus extern "C"
+#endif
+void qsort(void *base, size_t nel, size_t width,
+ int (*compar) (const void *, const void *));
+],
+[int i;], mysql_cv_type_qsort=void, mysql_cv_type_qsort=int)])
+AC_DEFINE_UNQUOTED(RETQSORTTYPE, $mysql_cv_type_qsort, [ ])
+if test "$mysql_cv_type_qsort" = "void"
+then
+ AC_DEFINE_UNQUOTED(QSORT_TYPE_IS_VOID, 1, [ ])
+fi ])
+
#---START: Used in for client configure
AC_DEFUN(MYSQL_CHECK_ULONG,
@@ -269,6 +285,7 @@ MYSQL_CHECK_UCHAR
MYSQL_CHECK_UINT
MYSQL_TYPE_ACCEPT
+MYSQL_TYPE_QSORT
AC_REQUIRE([AC_TYPE_SIGNAL])
])
diff --git a/ext/mysql/libmysql/array.c b/ext/mysql/libmysql/array.c
index f8ba10c253..dcf1cb07b4 100644
--- a/ext/mysql/libmysql/array.c
+++ b/ext/mysql/libmysql/array.c
@@ -1,9 +1,9 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Handling of arrays that can grow dynamicly. */
-#if defined(WIN32) || defined(__WIN32__)
+#if defined(WIN32) || defined(__WIN__)
#undef SAFEMALLOC /* Problems with threads */
#endif
diff --git a/ext/mysql/libmysql/bchange.c b/ext/mysql/libmysql/bchange.c
index 6cd4c41457..95d363d52d 100644
--- a/ext/mysql/libmysql/bchange.c
+++ b/ext/mysql/libmysql/bchange.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* File : bchange.c
Author : Michael widenius
diff --git a/ext/mysql/libmysql/bmove_upp.c b/ext/mysql/libmysql/bmove_upp.c
index 435abfb6d6..e10f6978f7 100644
--- a/ext/mysql/libmysql/bmove_upp.c
+++ b/ext/mysql/libmysql/bmove_upp.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* File : bmove.c
Author : Michael widenius
diff --git a/ext/mysql/libmysql/charset.c b/ext/mysql/libmysql/charset.c
new file mode 100644
index 0000000000..d63bd41800
--- /dev/null
+++ b/ext/mysql/libmysql/charset.c
@@ -0,0 +1,518 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
+#include "mysys_priv.h"
+#include "mysys_err.h"
+#include <m_ctype.h>
+#include <m_string.h>
+#include <my_dir.h>
+
+const char *charsets_dir = NULL;
+static DYNAMIC_ARRAY cs_info_table;
+static TYPELIB available_charsets;
+static int charset_initialized=0;
+
+#define MAX_LINE 1024
+
+#define CTYPE_TABLE_SIZE 257
+#define TO_LOWER_TABLE_SIZE 256
+#define TO_UPPER_TABLE_SIZE 256
+#define SORT_ORDER_TABLE_SIZE 256
+
+struct simpleconfig_buf_st {
+ FILE *f;
+ char buf[MAX_LINE];
+ char *p;
+};
+
+/* Defined in strings/ctype.c */
+
+CHARSET_INFO *find_compiled_charset(uint cs_number);
+uint compiled_charset_number(const char *name);
+const char *compiled_charset_name(uint charset_number);
+
+
+static my_bool get_word(struct simpleconfig_buf_st *fb, char *buf)
+{
+ char *endptr=fb->p;
+
+ for (;;)
+ {
+ while (isspace(*endptr))
+ ++endptr;
+ if (*endptr && *endptr != '#') /* Not comment */
+ break; /* Found something */
+ if ((fgets(fb->buf, sizeof(fb->buf), fb->f)) == NULL)
+ return TRUE; /* end of file */
+ endptr = fb->buf;
+ }
+
+ while (!isspace(*endptr))
+ *buf++= *endptr++;
+ *buf=0;
+ fb->p = endptr;
+
+ return FALSE;
+}
+
+
+static char *get_charsets_dir(char *buf)
+{
+ const char *sharedir = SHAREDIR;
+ DBUG_ENTER("get_charsets_dir");
+
+ if (charsets_dir != NULL)
+ strnmov(buf, charsets_dir, FN_REFLEN);
+ else
+ {
+ if (test_if_hard_path(sharedir) ||
+ is_prefix(sharedir, DEFAULT_CHARSET_HOME))
+ strxmov(buf, sharedir, "/", CHARSET_DIR, NullS);
+ else
+ strxmov(buf, DEFAULT_CHARSET_HOME, "/", sharedir, "/", CHARSET_DIR,
+ NullS);
+ }
+ convert_dirname(buf);
+ DBUG_PRINT("info",("charsets dir='%s'", buf));
+ DBUG_RETURN(strend(buf));
+}
+
+
+static my_bool read_charset_index(TYPELIB *charsets, myf myflags)
+{
+ struct simpleconfig_buf_st fb;
+ char buf[MAX_LINE];
+ DYNAMIC_ARRAY cs;
+ my_string s;
+
+ strmov(get_charsets_dir(buf), "Index");
+
+ if ((fb.f = my_fopen(buf, O_RDONLY, myflags)) == NULL)
+ return TRUE;
+ fb.buf[0] = '\0';
+ fb.p = fb.buf;
+
+ if (init_dynamic_array(&cs, sizeof(my_string), 32, 32))
+ return TRUE;
+
+ while (!get_word(&fb, buf))
+ {
+ uint length;
+ if (!(s= (char*) my_once_alloc(length= (uint) strlen(buf)+1, myflags)))
+ {
+ my_fclose(fb.f,myflags);
+ return TRUE;
+ }
+ memcpy(s,buf,length);
+ insert_dynamic(&cs, (gptr) &s);
+ }
+ my_fclose(fb.f,myflags);
+
+ /* I seriously doubt this is the best way to initialize this
+ * TYPELIB from the Index file. But it's the best way I could
+ * come up with right now. */
+
+ charsets->count = cs.elements;
+ charsets->name = "";
+ if (!(charsets->type_names =
+ (const char **) my_once_alloc((cs.elements + 1) * sizeof(const char *),
+ myflags)))
+ return TRUE;
+ /* unwarranted chumminess with dynamic_array implementation? */
+ memcpy((char*) charsets->type_names, cs.buffer,
+ cs.elements * sizeof(my_string *));
+ charsets->type_names[cs.elements] = NullS;
+ delete_dynamic(&cs);
+
+ return FALSE;
+}
+
+
+static my_bool init_available_charsets(myf myflags)
+{
+ my_bool error=0;
+ /*
+ We have to use charset_initialized to not lock on THR_LOCK_charset
+ inside get_internal_charset...
+ */
+ if (!charset_initialized)
+ {
+ /*
+ To make things thread safe we are not allowing other threads to interfere
+ while we may changing the cs_info_table
+ */
+ pthread_mutex_lock(&THR_LOCK_charset);
+ if (!cs_info_table.buffer) /* If not initialized */
+ {
+ init_dynamic_array(&cs_info_table, sizeof(CHARSET_INFO*), 16, 8);
+ error = read_charset_index(&available_charsets, myflags);
+ }
+ charset_initialized=1;
+ pthread_mutex_unlock(&THR_LOCK_charset);
+ }
+ return error || available_charsets.count == 0;
+}
+
+
+void free_charsets(void)
+{
+ delete_dynamic(&cs_info_table);
+}
+
+
+static my_bool fill_array(uchar *array, int sz, struct simpleconfig_buf_st *fb)
+{
+ char buf[MAX_LINE];
+ while (sz--)
+ {
+ if (get_word(fb, buf))
+ {
+ DBUG_PRINT("error",("get_word failed, expecting %d more words", sz + 1));
+ return 1;
+ }
+ *array++ = (uchar) strtol(buf, NULL, 16);
+ }
+ return 0;
+}
+
+
+static void get_charset_conf_name(uint cs_number, char *buf)
+{
+ strxmov(get_charsets_dir(buf),
+ get_type(&available_charsets, cs_number - 1), ".conf", NullS);
+}
+
+
+static my_bool read_charset_file(uint cs_number, CHARSET_INFO *set,
+ myf myflags)
+{
+ struct simpleconfig_buf_st fb;
+ char buf[FN_REFLEN];
+ my_bool result;
+ DBUG_ENTER("read_charset_file");
+ DBUG_PRINT("enter",("cs_number: %d", cs_number));
+
+ if (cs_number <= 0)
+ DBUG_RETURN(TRUE);
+
+ get_charset_conf_name(cs_number, buf);
+ DBUG_PRINT("info",("file name: %s", buf));
+
+ if ((fb.f = my_fopen(buf, O_RDONLY, myflags)) == NULL)
+ DBUG_RETURN(TRUE);
+
+ fb.buf[0] = '\0'; /* Init for get_word */
+ fb.p = fb.buf;
+
+ result=FALSE;
+ if (fill_array(set->ctype, CTYPE_TABLE_SIZE, &fb) ||
+ fill_array(set->to_lower, TO_LOWER_TABLE_SIZE, &fb) ||
+ fill_array(set->to_upper, TO_UPPER_TABLE_SIZE, &fb) ||
+ fill_array(set->sort_order, SORT_ORDER_TABLE_SIZE, &fb))
+ result=TRUE;
+
+ my_fclose(fb.f, MYF(0));
+ DBUG_RETURN(result);
+}
+
+
+uint get_charset_number(const char *charset_name)
+{
+ my_bool error;
+ error = init_available_charsets(MYF(0)); /* If it isn't initialized */
+ if (error)
+ return compiled_charset_number(charset_name);
+ else
+ return find_type((char*)charset_name, &available_charsets, 1);
+}
+
+const char *get_charset_name(uint charset_number)
+{
+ my_bool error;
+ error = init_available_charsets(MYF(0)); /* If it isn't initialized */
+ if (error)
+ return compiled_charset_name(charset_number);
+ else
+ return get_type(&available_charsets, charset_number - 1);
+}
+
+
+static CHARSET_INFO *find_charset(CHARSET_INFO **table, uint cs_number,
+ size_t tablesz)
+{
+ uint i;
+ for (i = 0; i < tablesz; ++i)
+ if (table[i]->number == cs_number)
+ return table[i];
+ return NULL;
+}
+
+static CHARSET_INFO *find_charset_by_name(CHARSET_INFO **table, const char *name,
+ size_t tablesz)
+{
+ uint i;
+ for (i = 0; i < tablesz; ++i)
+ if (!strcmp(table[i]->name,name))
+ return table[i];
+ return NULL;
+}
+
+static CHARSET_INFO *add_charset(uint cs_number, const char *cs_name)
+{
+ CHARSET_INFO tmp_cs,*cs;
+ uchar tmp_ctype[CTYPE_TABLE_SIZE];
+ uchar tmp_to_lower[TO_LOWER_TABLE_SIZE];
+ uchar tmp_to_upper[TO_UPPER_TABLE_SIZE];
+ uchar tmp_sort_order[SORT_ORDER_TABLE_SIZE];
+
+ /* Don't allocate memory if we are not sure we can find the char set */
+ cs= &tmp_cs;
+ bzero((char*) cs, sizeof(*cs));
+ cs->ctype=tmp_ctype;
+ cs->to_lower=tmp_to_lower;
+ cs->to_upper=tmp_to_upper;
+ cs->sort_order=tmp_sort_order;
+ if (read_charset_file(cs_number, cs, MYF(MY_WME)))
+ return NULL;
+
+ cs = (CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO),
+ MYF(MY_WME));
+ *cs=tmp_cs;
+ cs->name = (char *) my_once_alloc((uint) strlen(cs_name)+1, MYF(MY_WME));
+ cs->ctype = (uchar*) my_once_alloc(CTYPE_TABLE_SIZE, MYF(MY_WME));
+ cs->to_lower = (uchar*) my_once_alloc(TO_LOWER_TABLE_SIZE, MYF(MY_WME));
+ cs->to_upper = (uchar*) my_once_alloc(TO_UPPER_TABLE_SIZE, MYF(MY_WME));
+ cs->sort_order=(uchar*) my_once_alloc(SORT_ORDER_TABLE_SIZE, MYF(MY_WME));
+ cs->number = cs_number;
+ memcpy((char*) cs->name, (char*) cs_name, strlen(cs_name) + 1);
+ memcpy((char*) cs->ctype, (char*) tmp_ctype, sizeof(tmp_ctype));
+ memcpy((char*) cs->to_lower, (char*) tmp_to_lower, sizeof(tmp_to_lower));
+ memcpy((char*) cs->to_upper, (char*) tmp_to_upper, sizeof(tmp_to_upper));
+ memcpy((char*) cs->sort_order, (char*) tmp_sort_order,
+ sizeof(tmp_sort_order));
+ insert_dynamic(&cs_info_table, (gptr) &cs);
+ return cs;
+}
+
+static CHARSET_INFO *get_internal_charset(uint cs_number)
+{
+ CHARSET_INFO *cs;
+ /*
+ To make things thread safe we are not allowing other threads to interfere
+ while we may changing the cs_info_table
+ */
+ pthread_mutex_lock(&THR_LOCK_charset);
+ if (!(cs = find_charset((CHARSET_INFO**) cs_info_table.buffer, cs_number,
+ cs_info_table.elements)))
+ if (!(cs = find_compiled_charset(cs_number)))
+ cs=add_charset(cs_number, get_charset_name(cs_number));
+ pthread_mutex_unlock(&THR_LOCK_charset);
+ return cs;
+}
+
+
+static CHARSET_INFO *get_internal_charset_by_name(const char *name)
+{
+ CHARSET_INFO *cs;
+ /*
+ To make things thread safe we are not allowing other threads to interfere
+ while we may changing the cs_info_table
+ */
+ pthread_mutex_lock(&THR_LOCK_charset);
+ if (!(cs = find_charset_by_name((CHARSET_INFO**) cs_info_table.buffer, name,
+ cs_info_table.elements)))
+ if (!(cs = find_compiled_charset_by_name(name)))
+ cs=add_charset(get_charset_number(name), name);
+ pthread_mutex_unlock(&THR_LOCK_charset);
+ return cs;
+}
+
+
+CHARSET_INFO *get_charset(uint cs_number, myf flags)
+{
+ CHARSET_INFO *cs;
+ (void) init_available_charsets(MYF(0)); /* If it isn't initialized */
+ cs=get_internal_charset(cs_number);
+
+ if (!cs && flags & MY_WME)
+ {
+ char index_file[FN_REFLEN], cs_string[23];
+ strmov(get_charsets_dir(index_file), "Index");
+ cs_string[0]='#';
+ int10_to_str(cs_number, cs_string+1, 10);
+ my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_string, index_file);
+ }
+ return cs;
+}
+
+my_bool set_default_charset(uint cs, myf flags)
+{
+ CHARSET_INFO *new;
+ DBUG_ENTER("set_default_charset");
+ DBUG_PRINT("enter",("character set: %d",(int) cs));
+ new = get_charset(cs, flags);
+ if (!new)
+ {
+ DBUG_PRINT("error",("Couldn't set default character set"));
+ DBUG_RETURN(TRUE); /* error */
+ }
+ default_charset_info = new;
+ DBUG_RETURN(FALSE);
+}
+
+CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags)
+{
+ CHARSET_INFO *cs;
+ (void) init_available_charsets(MYF(0)); /* If it isn't initialized */
+ cs=get_internal_charset_by_name(cs_name);
+
+ if (!cs && (flags & MY_WME))
+ {
+ char index_file[FN_REFLEN];
+ strmov(get_charsets_dir(index_file), "Index");
+ my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_name, index_file);
+ }
+
+ return cs;
+}
+
+my_bool set_default_charset_by_name(const char *cs_name, myf flags)
+{
+ CHARSET_INFO *new;
+ DBUG_ENTER("set_default_charset_by_name");
+ DBUG_PRINT("enter",("character set: %s", cs_name));
+ new = get_charset_by_name(cs_name, flags);
+ if (!new)
+ {
+ DBUG_PRINT("error",("Couldn't set default character set"));
+ DBUG_RETURN(TRUE); /* error */
+ }
+
+ default_charset_info = new;
+ DBUG_RETURN(FALSE);
+}
+
+/* Only append name if it doesn't exist from before */
+
+static my_bool charset_in_string(const char *name, DYNAMIC_STRING *s)
+{
+ uint length= (uint) strlen(name);
+ const char *pos;
+ for (pos=s->str ; (pos=strstr(pos,name)) ; pos++)
+ {
+ if (! pos[length] || pos[length] == ' ')
+ return TRUE; /* Already existed */
+ }
+
+ return FALSE;
+}
+
+static void charset_append(DYNAMIC_STRING *s, const char *name)
+{
+ if (!charset_in_string(name, s)) {
+ dynstr_append(s, name);
+ dynstr_append(s, " ");
+ }
+}
+
+
+/* Returns a dynamically-allocated string listing the character sets
+ requested. The caller is responsible for freeing the memory. */
+
+char * list_charsets(myf want_flags)
+{
+ DYNAMIC_STRING s;
+ char *p;
+
+ init_dynamic_string(&s, NullS, 256, 1024);
+
+ if (want_flags & MY_COMPILED_SETS)
+ {
+ CHARSET_INFO *cs;
+ for (cs = compiled_charsets; cs->number > 0; cs++)
+ {
+ dynstr_append(&s, cs->name);
+ dynstr_append(&s, " ");
+ }
+ }
+
+ if (want_flags & MY_CONFIG_SETS)
+ {
+ uint i;
+ const char *cs_name;
+ char buf[FN_REFLEN];
+ MY_STAT stat;
+
+ for (i = 0; i < available_charsets.count; i++)
+ {
+ cs_name = get_type(&available_charsets, i);
+ if (charset_in_string(cs_name, &s))
+ continue;
+ get_charset_conf_name(i + 1, buf);
+ if (!my_stat(buf, &stat, MYF(0)))
+ continue; /* conf file doesn't exist */
+ dynstr_append(&s, cs_name);
+ dynstr_append(&s, " ");
+ }
+ }
+
+ if (want_flags & MY_INDEX_SETS)
+ {
+ uint i;
+ for (i = 0; i < available_charsets.count; i++)
+ charset_append(&s, get_type(&available_charsets, i));
+ }
+
+ if (want_flags & MY_LOADED_SETS)
+ {
+ uint i;
+ for (i = 0; i < cs_info_table.elements; i++)
+ charset_append(&s,
+ dynamic_element(&cs_info_table, i, CHARSET_INFO *)->name);
+ }
+ s.str[s.length - 1] = '\0'; /* chop trailing space */
+ p = my_strdup(s.str, MYF(MY_WME));
+ dynstr_free(&s);
+
+ return p;
+}
+
+/****************************************************************************
+* Code for debugging.
+****************************************************************************/
+
+
+static void _print_array(uint8 *data, uint size)
+{
+ uint i;
+ for (i = 0; i < size; ++i)
+ {
+ if (i == 0 || i % 16 == size % 16) printf(" ");
+ printf(" %02x", data[i]);
+ if ((i+1) % 16 == size % 16) printf("\n");
+ }
+}
+
+/* _print_csinfo is called from test_charset.c */
+void _print_csinfo(CHARSET_INFO *cs)
+{
+ printf("%s #%d\n", cs->name, cs->number);
+ printf("ctype:\n"); _print_array(cs->ctype, 257);
+ printf("to_lower:\n"); _print_array(cs->to_lower, 256);
+ printf("to_upper:\n"); _print_array(cs->to_upper, 256);
+ printf("sort_order:\n"); _print_array(cs->sort_order, 256);
+ printf("collate: %3s (%d, %p, %p, %p, %p, %p)\n",
+ cs->strxfrm_multiply ? "yes" : "no",
+ cs->strxfrm_multiply,
+ cs->strcoll,
+ cs->strxfrm,
+ cs->strnncoll,
+ cs->strnxfrm,
+ cs->like_range);
+ printf("multi-byte: %3s (%d, %p, %p, %p)\n",
+ cs->mbmaxlen ? "yes" : "no",
+ cs->mbmaxlen,
+ cs->ismbchar,
+ cs->ismbhead,
+ cs->mbcharlen);
+}
diff --git a/ext/mysql/libmysql/config-win32.h b/ext/mysql/libmysql/config-win.h
index e8335739cc..b082906ba0 100644
--- a/ext/mysql/libmysql/config-win32.h
+++ b/ext/mysql/libmysql/config-win.h
@@ -1,3 +1,6 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
/* Defines for Win32 to make it compatible for MySQL */
#include <sys/locking.h>
@@ -7,14 +10,21 @@
#include <io.h>
#include <malloc.h>
-#ifdef __NT__
+#if defined(__NT__)
#define SYSTEM_TYPE "NT"
+#elif defined(__WIN2000__)
+#define SYSTEM_TYPE "WIN2000"
#else
#define SYSTEM_TYPE "Win95/Win98"
#endif
-#define MACHINE_TYPE "i586" /* Define to machine type name */
-#ifndef __WIN32__
-#define __WIN32__ /* To make it easier in VC++ */
+
+#ifdef _WIN32
+#define MACHINE_TYPE "i32" /* Define to machine type name */
+#else
+#define MACHINE_TYPE "i64" /* Define to machine type name */
+#endif
+#ifndef __WIN__
+#define __WIN__ /* To make it easier in VC++ */
#endif
/* File and lock constants */
@@ -61,7 +71,6 @@
typedef unsigned short ushort;
typedef unsigned int uint;
-typedef unsigned int size_t;
typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
typedef __int64 longlong;
typedef int sigset_t;
@@ -70,6 +79,12 @@ typedef int sigset_t;
Use my_off_t or os_off_t instead */
typedef long off_t;
typedef __int64 os_off_t;
+#ifdef _WIN64
+typedef UINT_PTR rf_SetTimer;
+#else
+typedef unsigned int size_t;
+typedef uint rf_SetTimer;
+#endif
#define Socket_defined
#define my_socket SOCKET
@@ -98,6 +113,11 @@ typedef __int64 os_off_t;
#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
#endif
+/* Use all character sets in MySQL */
+#define USE_MB 1
+#define USE_MB_IDENT 1
+#define USE_STRCOLL 1
+
/* Convert some simple functions to Posix */
#define sigset(A,B) signal((A),(B))
@@ -117,6 +137,11 @@ inline double rint(double nr)
return (((c-nr) >= (nr-f)) ? f :c);
}
+#ifdef _WIN64
+#define ulonglong2double(A) ((double) (A))
+#define my_off_t2double(A) ((double) (A))
+
+#else
inline double ulonglong2double(ulonglong value)
{
longlong nr=(longlong) value;
@@ -124,11 +149,11 @@ inline double ulonglong2double(ulonglong value)
return (double) nr;
return (18446744073709551616.0 + (double) nr);
}
-
#define my_off_t2double(A) ulonglong2double(A)
+#endif /* _WIN64 */
#else
#define inline __inline
-#endif
+#endif /* __cplusplus */
#if SIZEOF_OFF_T > 4
#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
@@ -194,6 +219,7 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_MEMMOVE
#define HAVE_GETCWD
#define HAVE_TELL
+#define HAVE_TZNAME
#define HAVE_PUTENV
#define HAVE_SELECT
#define HAVE_SETLOCALE
@@ -204,9 +230,12 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_RINT /* defined in this file */
#define NO_FCNTL_NONBLOCK /* No FCNTL */
#define HAVE_ALLOCA
-#define HAVE_STRPBRK
-#define HAVE_STRSTR
-/*#define HAVE_COMPRESS*/
+#define HAVE_COMPRESS
+
+#ifdef NOT_USED
+#define HAVE_SNPRINTF /* Gave link error */
+#define _snprintf snprintf
+#endif
#ifdef _MSC_VER
#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
@@ -219,12 +248,15 @@ inline double ulonglong2double(ulonglong value)
/* MYSQL OPTIONS */
+#ifdef _CUSTOMCONFIG_
+#include <custom_conf.h>
+#else
#define DEFAULT_MYSQL_HOME "c:\\mysql"
#define PACKAGE "mysql"
-#define PROTOCOL_VERSION 10
#define DEFAULT_BASEDIR "C:\\"
-#define MY_CHARSET_CURRENT MY_CHARSET_LATIN1
-#define MY_CHARSET "isolatin1"
+#define SHAREDIR "share"
+#define DEFAULT_CHARSET_HOME "C:/mysql/"
+#endif
/* File name handling */
@@ -240,6 +272,13 @@ inline double ulonglong2double(ulonglong value)
/* The following is only used for statistics, so it should be good enough */
#ifdef __NT__ /* This should also work on Win98 but .. */
#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
+#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
+#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
#else
-#define thread_safe_add(V,C,L) InterlockedExchange((long*) &(V),(V)+(C))
+#define thread_safe_add(V,C,L) \
+ pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
+#define thread_safe_sub(V,C,L) \
+ pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
+#define statistic_add(V,C,L) (V)+=(C)
#endif
+#define statistic_increment(V,L) thread_safe_increment((V),(L))
diff --git a/ext/mysql/libmysql/ct_init.c b/ext/mysql/libmysql/ct_init.c
deleted file mode 100644
index b0b1a8e126..0000000000
--- a/ext/mysql/libmysql/ct_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Generate definitions of ctype arrays
-*/
-
-#include <global.h>
-#define CTYPE_LIBRARY /* initialize ctype arrays */
-#include "m_ctype.h"
diff --git a/ext/mysql/libmysql/ctype-latin1.c b/ext/mysql/libmysql/ctype-latin1.c
deleted file mode 100644
index f6b135b1c6..0000000000
--- a/ext/mysql/libmysql/ctype-latin1.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
-
-/* This implements the ISO 8859 Latin1 character-set */
-
-#include <global.h>
-#include "m_string.h"
-
-uchar NEAR ctype_latin1[257] = {
-0,
-32,32,32,32,32,32,32,32,32,40,40,40,40,40,32,32,
-32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
-72,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-132,132,132,132,132,132,132,132,132,132,16,16,16,16,16,16,
-16,129,129,129,129,129,129,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,16,16,16,16,16,
-16,130,130,130,130,130,130,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,2,2,2,2,16,16,16,16,32,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-72,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,16,1,1,1,1,1,1,1,2,
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-2,2,2,2,2,2,2,16,2,2,2,2,2,2,2,2,
-};
-
-uchar NEAR to_lower_latin1[]={
-'\000','\001','\002','\003','\004','\005','\006','\007',
-'\010','\011','\012','\013','\014','\015','\016','\017',
-'\020','\021','\022','\023','\024','\025','\026','\027',
-'\030','\031','\032','\033','\034','\035','\036','\037',
-' ', '!', '"', '#', '$', '%', '&', '\'',
-'(', ')', '*', '+', ',', '-', '.', '/',
-'0', '1', '2', '3', '4', '5', '6', '7',
-'8', '9', ':', ';', '<', '=', '>', '?',
-'@', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
-'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
-'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
-'x', 'y', 'z', '[', '\\', ']', '^', '_',
-'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
-'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
-'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
-'x', 'y', 'z', '{', '|', '}', '~', '\177',
-
-(uchar) '\200',(uchar) '\201',(uchar) '\202',(uchar) '\203',(uchar) '\204',(uchar) '\205',(uchar) '\206',(uchar) '\207',
-(uchar) '\210',(uchar) '\211',(uchar) '\212',(uchar) '\213',(uchar) '\214',(uchar) '\215',(uchar) '\216',(uchar) '\217',
-(uchar) '\220',(uchar) '\221',(uchar) '\222',(uchar) '\223',(uchar) '\224',(uchar) '\225',(uchar) '\226',(uchar) '\227',
-(uchar) '\230',(uchar) '\231',(uchar) '\232',(uchar) '\233',(uchar) '\234',(uchar) '\235',(uchar) '\236',(uchar) '\237',
-(uchar) '\240',(uchar) '\241',(uchar) '\242',(uchar) '\243',(uchar) '\244',(uchar) '\245',(uchar) '\246',(uchar) '\247',
-(uchar) '\250',(uchar) '\251',(uchar) '\252',(uchar) '\253',(uchar) '\254',(uchar) '\255',(uchar) '\256',(uchar) '\257',
-(uchar) '\260',(uchar) '\261',(uchar) '\262',(uchar) '\263',(uchar) '\264',(uchar) '\265',(uchar) '\266',(uchar) '\267',
-(uchar) '\270',(uchar) '\271',(uchar) '\272',(uchar) '\273',(uchar) '\274',(uchar) '\275',(uchar) '\276',(uchar) '\277',
-(uchar) '\340',(uchar) '\341',(uchar) '\342',(uchar) '\343',(uchar) '\344',(uchar) '\345',(uchar) '\346',(uchar) '\347',
-(uchar) '\350',(uchar) '\351',(uchar) '\352',(uchar) '\353',(uchar) '\354',(uchar) '\355',(uchar) '\356',(uchar) '\357',
-(uchar) '\360',(uchar) '\361',(uchar) '\362',(uchar) '\363',(uchar) '\364',(uchar) '\365',(uchar) '\366',(uchar) '\327',
-(uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\337',
-(uchar) '\340',(uchar) '\341',(uchar) '\342',(uchar) '\343',(uchar) '\344',(uchar) '\345',(uchar) '\346',(uchar) '\347',
-(uchar) '\350',(uchar) '\351',(uchar) '\352',(uchar) '\353',(uchar) '\354',(uchar) '\355',(uchar) '\356',(uchar) '\357',
-(uchar) '\360',(uchar) '\361',(uchar) '\362',(uchar) '\363',(uchar) '\364',(uchar) '\365',(uchar) '\366',(uchar) '\367',
-(uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\377',
-};
-
-uchar NEAR to_upper_latin1[]={
-'\000','\001','\002','\003','\004','\005','\006','\007',
-'\010','\011','\012','\013','\014','\015','\016','\017',
-'\020','\021','\022','\023','\024','\025','\026','\027',
-'\030','\031','\032','\033','\034','\035','\036','\037',
-' ', '!', '"', '#', '$', '%', '&', '\'',
-'(', ')', '*', '+', ',', '-', '.', '/',
-'0', '1', '2', '3', '4', '5', '6', '7',
-'8', '9', ':', ';', '<', '=', '>', '?',
-'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
-'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
-'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
-'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
-'`', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
-'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
-'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
-'X', 'Y', 'Z', '{', '|', '}', '~', '\177',
-
-(uchar) '\200',(uchar) '\201',(uchar) '\202',(uchar) '\203',(uchar) '\204',(uchar) '\205',(uchar) '\206',(uchar) '\207',
-(uchar) '\210',(uchar) '\211',(uchar) '\212',(uchar) '\213',(uchar) '\214',(uchar) '\215',(uchar) '\216',(uchar) '\217',
-(uchar) '\220',(uchar) '\221',(uchar) '\222',(uchar) '\223',(uchar) '\224',(uchar) '\225',(uchar) '\226',(uchar) '\227',
-(uchar) '\230',(uchar) '\231',(uchar) '\232',(uchar) '\233',(uchar) '\234',(uchar) '\235',(uchar) '\236',(uchar) '\237',
-(uchar) '\240',(uchar) '\241',(uchar) '\242',(uchar) '\243',(uchar) '\244',(uchar) '\245',(uchar) '\246',(uchar) '\247',
-(uchar) '\250',(uchar) '\251',(uchar) '\252',(uchar) '\253',(uchar) '\254',(uchar) '\255',(uchar) '\256',(uchar) '\257',
-(uchar) '\260',(uchar) '\261',(uchar) '\262',(uchar) '\263',(uchar) '\264',(uchar) '\265',(uchar) '\266',(uchar) '\267',
-(uchar) '\270',(uchar) '\271',(uchar) '\272',(uchar) '\273',(uchar) '\274',(uchar) '\275',(uchar) '\276',(uchar) '\277',
-(uchar) '\300',(uchar) '\301',(uchar) '\302',(uchar) '\303',(uchar) '\304',(uchar) '\305',(uchar) '\306',(uchar) '\307',
-(uchar) '\310',(uchar) '\311',(uchar) '\312',(uchar) '\313',(uchar) '\314',(uchar) '\315',(uchar) '\316',(uchar) '\317',
-(uchar) '\320',(uchar) '\321',(uchar) '\322',(uchar) '\323',(uchar) '\324',(uchar) '\325',(uchar) '\326',(uchar) '\327',
-(uchar) '\330',(uchar) '\331',(uchar) '\332',(uchar) '\333',(uchar) '\334',(uchar) '\335',(uchar) '\336',(uchar) '\337',
-(uchar) '\300',(uchar) '\301',(uchar) '\302',(uchar) '\303',(uchar) '\304',(uchar) '\305',(uchar) '\306',(uchar) '\307',
-(uchar) '\310',(uchar) '\311',(uchar) '\312',(uchar) '\313',(uchar) '\314',(uchar) '\315',(uchar) '\316',(uchar) '\317',
-(uchar) '\320',(uchar) '\321',(uchar) '\322',(uchar) '\323',(uchar) '\324',(uchar) '\325',(uchar) '\326',(uchar) '\367',
-(uchar) '\330',(uchar) '\331',(uchar) '\332',(uchar) '\333',(uchar) '\334',(uchar) '\335',(uchar) '\336',(uchar) '\377',
-};
-
-#ifndef __WIN32__
-uchar NEAR sort_order_latin1[]={
-#else
-uchar sort_order_latin1[]={
-#endif
-'\000','\001','\002','\003','\004','\005','\006','\007',
-'\010','\011','\012','\013','\014','\015','\016','\017',
-'\020','\021','\022','\023','\024','\025','\026','\027',
-'\030','\031','\032','\033','\034','\035','\036','\037',
-' ', '!', '"', '#', '$', '%', '&', '\'',
-'(', ')', '*', '+', ',', '-', '.', '/',
-'0', '1', '2', '3', '4', '5', '6', '7',
-'8', '9', ':', ';', '<', '=', '>', '?',
-'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
-'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
-'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
-'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
-'`', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
-'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
-'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
-'X', 'Y', 'Z', '{', '|', '}', '~', '\177',
-
-(uchar) '\200',(uchar) '\201',(uchar) '\202',(uchar) '\203',(uchar) '\204',(uchar) '\205',(uchar) '\206',(uchar) '\207',
-(uchar) '\210',(uchar) '\211',(uchar) '\212',(uchar) '\213',(uchar) '\214',(uchar) '\215',(uchar) '\216',(uchar) '\217',
-(uchar) '\220',(uchar) '\221',(uchar) '\222',(uchar) '\223',(uchar) '\224',(uchar) '\225',(uchar) '\226',(uchar) '\227',
-(uchar) '\230',(uchar) '\231',(uchar) '\232',(uchar) '\233',(uchar) '\234',(uchar) '\235',(uchar) '\236',(uchar) '\237',
-(uchar) '\240',(uchar) '\241',(uchar) '\242',(uchar) '\243',(uchar) '\244',(uchar) '\245',(uchar) '\246',(uchar) '\247',
-(uchar) '\250',(uchar) '\251',(uchar) '\252',(uchar) '\253',(uchar) '\254',(uchar) '\255',(uchar) '\256',(uchar) '\257',
-(uchar) '\260',(uchar) '\261',(uchar) '\262',(uchar) '\263',(uchar) '\264',(uchar) '\265',(uchar) '\266',(uchar) '\267',
-(uchar) '\270',(uchar) '\271',(uchar) '\272',(uchar) '\273',(uchar) '\274',(uchar) '\275',(uchar) '\276',(uchar) '\277',
-'A', 'A', 'A', 'A', '\\', '[', '\\', 'C',
-'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I',
-'D', 'N', 'O', 'O', 'O', 'O', ']', (uchar) '\327',
-(uchar) '\330','U', 'U', 'U', 'Y', 'Y', (uchar) '\336',(uchar) '\337',
-'A', 'A', 'A', 'A', '\\', '[', '\\', 'C',
-'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I',
-'D', 'N', 'O', 'O', 'O', 'O', ']', (uchar) '\367',
-(uchar) '\330','U', 'U', 'U', 'Y', 'Y', (uchar) '\336',(uchar) '\377',
-};
diff --git a/ext/mysql/libmysql/ctype.c b/ext/mysql/libmysql/ctype.c
new file mode 100644
index 0000000000..151266ce0e
--- /dev/null
+++ b/ext/mysql/libmysql/ctype.c
@@ -0,0 +1,54 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
+#include <global.h>
+
+#include <m_ctype.h>
+
+/* generated by make, using conf_to_src */
+#include "ctype_extra_sources.c"
+
+/* generated by configure */
+#include "ctype_autoconf.c"
+
+CHARSET_INFO *default_charset_info = &compiled_charsets[0];
+
+CHARSET_INFO *find_compiled_charset(uint cs_number)
+{
+ CHARSET_INFO *cs;
+ for (cs = compiled_charsets; cs->number > 0; cs++)
+ if (cs->number == cs_number)
+ return cs;
+
+ return NULL;
+}
+
+CHARSET_INFO *find_compiled_charset_by_name(const char *name)
+{
+ CHARSET_INFO *cs;
+ for (cs = compiled_charsets; cs->number > 0; cs++)
+ if (!strcmp(cs->name, name))
+ return cs;
+
+ return NULL;
+}
+
+uint8 compiled_charset_number(const char *name)
+{
+ CHARSET_INFO *cs;
+ for (cs = compiled_charsets; cs->number > 0; cs++)
+ if (!strcmp(cs->name, name))
+ return cs->number;
+
+ return 0; /* this mimics find_type() */
+}
+
+const char *compiled_charset_name(uint8 charset_number)
+{
+ CHARSET_INFO *cs;
+ for (cs = compiled_charsets; cs->number > 0; cs++)
+ if (cs->number == charset_number)
+ return cs->name;
+
+ return "?"; /* this mimics get_type() */
+}
diff --git a/ext/mysql/libmysql/ctype_autoconf.c b/ext/mysql/libmysql/ctype_autoconf.c
new file mode 100644
index 0000000000..22da693433
--- /dev/null
+++ b/ext/mysql/libmysql/ctype_autoconf.c
@@ -0,0 +1,44 @@
+/* This file is generated automatically by configure. */
+
+CHARSET_INFO compiled_charsets[] = {
+
+ /* this information is filled in by configure */
+ {
+ 8, /* number */
+ "latin1", /* name */
+ ctype_latin1,
+ to_lower_latin1,
+ to_upper_latin1,
+ sort_order_latin1,
+ 0, /* strxfrm_multiply */
+ NULL, /* strcoll */
+ NULL, /* strxfrm */
+ NULL, /* strnncoll */
+ NULL, /* strnxfrm */
+ NULL, /* like_range */
+ 0, /* mbmaxlen */
+ NULL, /* ismbchar */
+ NULL, /* ismbhead */
+ NULL /* mbcharlen */
+ },
+
+ /* this information is filled in by configure */
+ {
+ 0, /* end-of-list marker */
+ NullS,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ NULL
+ }
+};
diff --git a/ext/mysql/libmysql/ctype_extra_sources.c b/ext/mysql/libmysql/ctype_extra_sources.c
new file mode 100644
index 0000000000..97f0d38646
--- /dev/null
+++ b/ext/mysql/libmysql/ctype_extra_sources.c
@@ -0,0 +1,82 @@
+/* The latin1 character set. Generated automatically by configure and
+ * the ./conf_to_src program
+ */
+
+uchar ctype_latin1[] = {
+ 0,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 40, 40, 40, 40, 40, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 72, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 132,132,132,132,132,132,132,132,132,132, 16, 16, 16, 16, 16, 16,
+ 16,129,129,129,129,129,129, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 16, 16, 16, 16,
+ 16,130,130,130,130,130,130, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 16, 16, 32,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 72, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 16, 1, 1, 1, 1, 1, 1, 1, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 16, 2, 2, 2, 2, 2, 2, 2, 2
+};
+
+uchar to_lower_latin1[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
+ 112,113,114,115,116,117,118,119,120,121,122, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
+ 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
+ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
+ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
+ 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
+ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
+ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
+ 240,241,242,243,244,245,246,215,248,249,250,251,252,253,254,223,
+ 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
+ 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
+};
+
+uchar to_upper_latin1[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127,
+ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
+ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
+ 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
+ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
+ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
+ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
+ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
+ 208,209,210,211,212,213,214,247,216,217,218,219,220,221,222,255
+};
+
+uchar sort_order_latin1[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127,
+ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
+ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
+ 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
+ 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
+ 65, 65, 65, 65, 92, 91, 92, 67, 69, 69, 69, 69, 73, 73, 73, 73,
+ 68, 78, 79, 79, 79, 79, 93,215,216, 85, 85, 85, 89, 89,222,223,
+ 65, 65, 65, 65, 92, 91, 92, 67, 69, 69, 69, 69, 73, 73, 73, 73,
+ 68, 78, 79, 79, 79, 79, 93,247,216, 85, 85, 85, 89, 89,222,255
+};
+
+
diff --git a/ext/mysql/libmysql/dbug.c b/ext/mysql/libmysql/dbug.c
index 8eb5fea5eb..c004de587f 100644
--- a/ext/mysql/libmysql/dbug.c
+++ b/ext/mysql/libmysql/dbug.c
@@ -72,7 +72,7 @@
#include <global.h>
#include <m_string.h>
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN32__)
+#if defined(MSDOS) || defined(__WIN__)
#include <process.h>
#endif
@@ -123,7 +123,7 @@
* Typedefs to make things more obvious.
*/
-#ifndef __WIN32__
+#ifndef __WIN__
typedef int BOOLEAN;
#else
#define BOOLEAN BOOL
@@ -310,11 +310,13 @@ static char *static_strtok(char *s1,pchar chr);
#if !defined(HAVE_ACCESS) || defined(MSDOS)
#define EXISTS(pathname) (FALSE) /* Assume no existance */
#define Writable(name) (TRUE)
-#define ChangeOwner(name)
#else
#define EXISTS(pathname) (access (pathname, F_OK) == 0)
#define WRITABLE(pathname) (access (pathname, W_OK) == 0)
#endif
+#ifndef MSDOS
+#define ChangeOwner(name)
+#endif
/*
* Translate some calls among different systems.
@@ -1055,20 +1057,20 @@ struct link *linkp;
const char *cp;
{
REGISTER struct link *scan;
- REGISTER BOOLEAN accept;
+ REGISTER BOOLEAN result;
if (linkp == NULL) {
- accept = TRUE;
+ result = TRUE;
} else {
- accept = FALSE;
+ result = FALSE;
for (scan = linkp; scan != NULL; scan = scan -> next_link) {
if (STREQ (scan -> str, cp)) {
- accept = TRUE;
+ result = TRUE;
break;
}
}
}
- return (accept);
+ return (result);
}
@@ -1217,20 +1219,20 @@ static BOOLEAN DoProfile ()
BOOLEAN _db_keyword_ (keyword)
const char *keyword;
{
- REGISTER BOOLEAN accept;
+ REGISTER BOOLEAN result;
CODE_STATE *state;
if (!init_done)
_db_push_ ("");
state=code_state();
- accept = FALSE;
+ result = FALSE;
if (DEBUGGING &&
state->level <= stack -> maxdepth &&
InList (stack -> functions, state->func) &&
InList (stack -> keywords, keyword) &&
InList (stack -> processes, _db_process_))
- accept = TRUE;
- return (accept);
+ result = TRUE;
+ return (result);
}
/*
@@ -1921,7 +1923,7 @@ static void dbug_flush(CODE_STATE *state)
if (stack->flags & FLUSH_ON_WRITE)
#endif
{
-#if defined(MSDOS) || defined(__WIN32__)
+#if defined(MSDOS) || defined(__WIN__)
if (_db_fp_ != stdout && _db_fp_ != stderr)
{
if (!(freopen(stack->name,"a",_db_fp_)))
@@ -1988,7 +1990,7 @@ static unsigned long Clock ()
}
#else
-#if defined(MSDOS) || defined(__WIN32__)
+#if defined(MSDOS) || defined(__WIN__)
static ulong Clock()
{
@@ -2038,7 +2040,7 @@ static unsigned long Clock ()
}
#endif
#endif /* amiga */
-#endif /* MSDOS || __WIN32__ */
+#endif /* MSDOS || __WIN__ */
#endif /* RUSAGE */
diff --git a/ext/mysql/libmysql/dbug.h b/ext/mysql/libmysql/dbug.h
index 3331f9032d..b2d8980e10 100644
--- a/ext/mysql/libmysql/dbug.h
+++ b/ext/mysql/libmysql/dbug.h
@@ -1,3 +1,6 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
#ifndef _dbug_h
#define _dbug_h
#ifdef __cplusplus
diff --git a/ext/mysql/libmysql/default.c b/ext/mysql/libmysql/default.c
index b1e33f3e59..07df9bb9b7 100644
--- a/ext/mysql/libmysql/default.c
+++ b/ext/mysql/libmysql/default.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1998 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/****************************************************************************
** Add all options from files named "group".cnf from the default_directories
@@ -28,7 +28,7 @@
/* Which directories are searched for options (and in which order) */
const char *default_directories[]= {
-#ifdef __WIN32__
+#ifdef __WIN__
"C:/",
#else
"/etc/",
@@ -36,14 +36,14 @@ const char *default_directories[]= {
#ifdef DATADIR
DATADIR,
#endif
-#ifndef __WIN32__
+#ifndef __WIN__
"~/",
#endif
NullS,
};
#define default_ext ".cnf" /* extension for config file */
-#ifdef __WIN32__
+#ifdef __WIN__
#include <winbase.h>
#define windows_ext ".ini"
#endif
@@ -59,7 +59,7 @@ void load_defaults(const char *conf_file, const char **groups,
DYNAMIC_ARRAY args;
const char **dirs, *extra_default_file;
TYPELIB group;
- my_bool print_defaults=0;
+ my_bool found_print_defaults=0;
MEM_ROOT alloc;
char *ptr,**res;
DBUG_ENTER("load_defaults");
@@ -78,7 +78,7 @@ void load_defaults(const char *conf_file, const char **groups,
res[i-1]=argv[0][i];
(*argc)--;
*argv=res;
- memcpy(ptr,&alloc,sizeof(alloc)); /* Save alloc root for free */
+ *(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */
DBUG_VOID_RETURN;
}
@@ -88,8 +88,8 @@ void load_defaults(const char *conf_file, const char **groups,
extra_default_file=strchr(argv[0][1],'=')+1;
group.count=0;
- group.name= (char*) "defaults";
- group.type_names=(char**) groups;
+ group.name= "defaults";
+ group.type_names= groups;
for (; *groups ; groups++)
group.count++;
@@ -109,7 +109,7 @@ void load_defaults(const char *conf_file, const char **groups,
}
else
{
-#ifdef __WIN32__
+#ifdef __WIN__
char system_dir[FN_REFLEN];
GetWindowsDirectory(system_dir,sizeof(system_dir));
if (search_default_file(&args, &alloc, system_dir, conf_file, windows_ext,
@@ -140,7 +140,7 @@ void load_defaults(const char *conf_file, const char **groups,
/* Check if we wan't to see the new argument list */
if (*argc >= 2 && !strcmp(argv[0][1],"--print-defaults"))
{
- print_defaults=1;
+ found_print_defaults=1;
--*argc; ++*argv; /* skipp argument */
}
@@ -150,9 +150,9 @@ void load_defaults(const char *conf_file, const char **groups,
(*argc)+=args.elements;
*argv= (char**) res;
- memcpy(ptr,&alloc,sizeof(alloc)); /* Save alloc root for free */
+ *(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */
delete_dynamic(&args);
- if (print_defaults)
+ if (found_print_defaults)
{
int i;
printf("%s would have been started with the following arguments:\n",
@@ -173,7 +173,7 @@ void load_defaults(const char *conf_file, const char **groups,
void free_defaults(char **argv)
{
MEM_ROOT ptr;
- memcpy((char*) &ptr,(char *) argv - sizeof(ptr),sizeof(ptr));
+ memcpy_fixed((char*) &ptr,(char *) argv - sizeof(ptr), sizeof(ptr));
free_root(&ptr);
}
@@ -308,7 +308,9 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
void print_defaults(const char *conf_file, const char **groups)
{
+#ifdef __WIN__
bool have_ext=fn_ext(conf_file)[0] != 0;
+#endif
char name[FN_REFLEN];
const char **dirs;
puts("\nDefault options are read from the following files in the given order:");
@@ -317,7 +319,7 @@ void print_defaults(const char *conf_file, const char **groups)
fputs(conf_file,stdout);
else
{
-#ifdef __WIN32__
+#ifdef __WIN__
GetWindowsDirectory(name,sizeof(name));
printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_ext);
#endif
@@ -342,4 +344,5 @@ void print_defaults(const char *conf_file, const char **groups)
--print-defaults Print the program argument list and exit\n\
--no-defaults Don't read default options from any options file\n\
--defaults-file=# Only read default options from the given file #");
-};
+}
+
diff --git a/ext/mysql/libmysql/dll.c b/ext/mysql/libmysql/dll.c
index a3116b33ad..fb666c0f3b 100644
--- a/ext/mysql/libmysql/dll.c
+++ b/ext/mysql/libmysql/dll.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1999 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
** Handling initialization of the dll library
@@ -29,7 +29,7 @@ void libmysql_init(void)
}
}
-#ifdef WIN32
+#ifdef __WIN__
static int inited=0,threads=0;
HINSTANCE NEAR s_hModule; /* Saved module handle */
diff --git a/ext/mysql/libmysql/errmsg.c b/ext/mysql/libmysql/errmsg.c
index 96f1f41554..f015a05ea3 100644
--- a/ext/mysql/libmysql/errmsg.c
+++ b/ext/mysql/libmysql/errmsg.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1997 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Error messages for MySQL clients */
/* error messages for the demon is in share/language/errmsg.sys */
@@ -29,7 +29,9 @@ const char *client_errors[]=
"Verbindung ueber Named Pipe; Host: %-.64s",
"Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)",
"Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)",
- "Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)"
+ "Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)",
+ "Can't initialize character set %-.64s (path: %-.64s)",
+ "Got packet bigger than 'max_allowed_packet'"
};
#else /* ENGLISH */
@@ -54,6 +56,8 @@ const char *client_errors[]=
"Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)",
"Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)",
"Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)",
+ "Can't initialize character set %-.64s (path: %-.64s)",
+ "Got packet bigger than 'max_allowed_packet'"
};
#endif
diff --git a/ext/mysql/libmysql/errmsg.h b/ext/mysql/libmysql/errmsg.h
index d88653929b..f81bf962db 100644
--- a/ext/mysql/libmysql/errmsg.h
+++ b/ext/mysql/libmysql/errmsg.h
@@ -1,11 +1,17 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Error messages for mysql clients */
/* error messages for the demon is in share/language/errmsg.sys */
+#ifdef __cplusplus
+extern "C" {
+#endif
void init_client_errs(void);
extern const char *client_errors[]; /* Error messages */
+#ifdef __cplusplus
+}
+#endif
#define CR_MIN_ERROR 2000 /* For easier client code */
#define CR_MAX_ERROR 2999
@@ -31,3 +37,5 @@ extern const char *client_errors[]; /* Error messages */
#define CR_NAMEDPIPEWAIT_ERROR 2016
#define CR_NAMEDPIPEOPEN_ERROR 2017
#define CR_NAMEDPIPESETSTATE_ERROR 2018
+#define CR_CANT_READ_CHARSET 2019
+#define CR_NET_PACKET_TOO_LARGE 2020
diff --git a/ext/mysql/libmysql/errors.c b/ext/mysql/libmysql/errors.c
index 358d092844..8a3a6682d0 100644
--- a/ext/mysql/libmysql/errors.c
+++ b/ext/mysql/libmysql/errors.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include "mysys_err.h"
@@ -30,6 +30,7 @@ const char * NEAR globerrs[GLOBERRS]=
"%d files and %d streams is left open\n",
"Disk is full writing '%s'. Waiting for someone to free space...",
"Can't create directory '%s' (Errcode: %d)",
+ "Character set '%s' is not a compiled character set and is not specified in the '%s' file"
};
void init_glob_errs(void)
@@ -64,5 +65,6 @@ void init_glob_errs()
EE(EE_OPEN_WARNING) = "%d files and %d streams is left open\n";
EE(EE_DISK_FULL) = "Disk is full writing '%s'. Waiting for someone to free space...";
EE(EE_CANT_MKDIR) ="Can't create directory '%s' (Errcode: %d)";
+ EE(EE_UNKNOWN_CHARSET)= "Character set is not a compiled character set and is not specified in the %s file";
}
#endif
diff --git a/ext/mysql/libmysql/get_password.c b/ext/mysql/libmysql/get_password.c
index e0a460c3a3..c0c6f90406 100644
--- a/ext/mysql/libmysql/get_password.c
+++ b/ext/mysql/libmysql/get_password.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
** Ask for a password from tty
@@ -21,7 +21,7 @@
#include <pwd.h>
#endif /* HAVE_PWD_H */
#else /* ! HAVE_GETPASS */
-#ifndef __WIN32__
+#ifndef __WIN__
#include <sys/ioctl.h>
#ifdef HAVE_TERMIOS_H /* For tty-password */
#include <termios.h>
@@ -41,14 +41,14 @@
#endif
#else
#include <conio.h>
-#endif /* __WIN32__ */
+#endif /* __WIN__ */
#endif /* HAVE_GETPASS */
#ifdef HAVE_GETPASSPHRASE /* For Solaris */
#define getpass(A) getpassphrase(A)
#endif
-#ifdef __WIN32__
+#ifdef __WIN__
/* were just going to fake it here and get input from
the keyboard */
@@ -88,7 +88,54 @@ char *get_tty_password(char *opt_message)
#else
-static void get_password(char *to,uint length,int file_no,bool echo);
+
+#ifndef HAVE_GETPASS
+/*
+** Can't use fgets, because readline will get confused
+** length is max number of chars in to, not counting \0
+* to will not include the eol characters.
+*/
+
+static void get_password(char *to,uint length,int fd,bool echo)
+{
+ char *pos=to,*end=to+length;
+
+ for (;;)
+ {
+ char tmp;
+ if (my_read(fd,&tmp,1,MYF(0)) != 1)
+ break;
+ if (tmp == '\b' || (int) tmp == 127)
+ {
+ if (pos != to)
+ {
+ if (echo)
+ {
+ fputs("\b \b",stdout);
+ fflush(stdout);
+ }
+ pos--;
+ continue;
+ }
+ }
+ if (tmp == '\n' || tmp == '\r' || tmp == 3)
+ break;
+ if (iscntrl(tmp) || pos == end)
+ continue;
+ if (echo)
+ {
+ fputc('*',stdout);
+ fflush(stdout);
+ }
+ *(pos++) = tmp;
+ }
+ while (pos != to && isspace(pos[-1]) == ' ')
+ pos--; /* Allow dummy space at end */
+ *pos=0;
+ return;
+}
+#endif /* ! HAVE_GETPASS */
+
char *get_tty_password(char *opt_message)
{
@@ -148,52 +195,4 @@ char *get_tty_password(char *opt_message)
DBUG_RETURN(my_strdup(buff,MYF(MY_FAE)));
}
-
-#ifndef HAVE_GETPASS
-/*
-** Can't use fgets, because readline will get confused
-** length is max number of chars in to, not counting \0
-* to will not include the eol characters.
-*/
-
-void get_password(char *to,uint length,int fd,bool echo)
-{
- char *pos=to,*end=to+length;
-
- for (;;)
- {
- char tmp;
- if (my_read(fd,&tmp,1,MYF(0)) != 1)
- break;
- if (tmp == '\b' || (int) tmp == 127)
- {
- if (pos != to)
- {
- if (echo)
- {
- fputs("\b \b",stdout);
- fflush(stdout);
- }
- pos--;
- continue;
- }
- }
- if (tmp == '\n' || tmp == '\r' || tmp == 3)
- break;
- if (iscntrl(tmp) || pos == end)
- continue;
- if (echo)
- {
- fputc('*',stdout);
- fflush(stdout);
- }
- *(pos++) = tmp;
- }
- while (pos != to && isspace(pos[-1]) == ' ')
- pos--; /* Allow dummy space at end */
- *pos=0;
- return;
-}
-#endif /* ! HAVE_GETPASS */
-
-#endif /*__WIN32__*/
+#endif /*__WIN__*/
diff --git a/ext/mysql/libmysql/global.h b/ext/mysql/libmysql/global.h
index 34b45c2418..4d035d3c6b 100644
--- a/ext/mysql/libmysql/global.h
+++ b/ext/mysql/libmysql/global.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* This is the main include file that should included 'first' in every
C file. */
@@ -7,17 +7,19 @@
#ifndef _global_h
#define _global_h
-#if defined(__WIN32__) || defined(WIN32)
-#include <config-win32.h>
+#if defined(_WIN32) || defined(_WIN64)
+#include <config-win.h>
#else
#include <my_config.h>
#endif
-#if defined(__cplusplus) && defined(inline)
-#undef inline /* fix configure problem */
+#if defined(__cplusplus)
+#if defined(inline)
+#undef inline /* fix configure problem */
#endif
+#endif /* _cplusplus */
/* The client defines this to avoid all thread code */
-#if defined(UNDEF_THREADS_HACK) && !defined(THREAD_SAFE_CLIENT)
+#if defined(UNDEF_THREADS_HACK)
#undef THREAD
#undef HAVE_mit_thread
#undef HAVE_LINUXTHREADS
@@ -33,9 +35,11 @@
#ifndef __STDC_EXT__
#define __STDC_EXT__ 1 /* To get large file support on hpux */
#endif
-/* #define _GNU_SOURCE 1 */ /* Get define for strtok_r on Alpha-linux */
+#if defined(THREAD) && defined(HAVE_LINUXTHREADS) && defined(HAVE_PTHREAD_RWLOCK_RDLOCK)
+#define _GNU_SOURCE 1
+#endif
-#if defined(THREAD) && !defined(__WIN32__)
+#if defined(THREAD) && !defined(__WIN__)
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
/* was #if defined(HAVE_LINUXTHREADS) || defined(HAVE_DEC_THREADS) || defined(HPUX) */
#if !defined(SCO)
@@ -71,12 +75,36 @@
#undef HAVE_PWRITE
#endif
+#ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */
+#undef HAVE_GETHOSTBYNAME_R
+#endif
+#ifdef UNDEF_HAVE_INITGROUPS /* For AIX 4.3 */
+#undef HAVE_INITGROUPS
+#endif
+
/* Fix a bug in gcc 2.8.0 on IRIX 6.2 */
#if SIZEOF_LONG == 4 && defined(__LONG_MAX__)
#undef __LONG_MAX__ /* Is a longlong value in gcc 2.8.0 ??? */
#define __LONG_MAX__ 2147483647
#endif
+/* egcs 1.1.2 has a problem with memcpy on Alpha */
+#if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
+#define BAD_MEMCPY
+#endif
+
+/* In Linux-alpha we have atomic.h if we are using gcc */
+#if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95))
+#define HAVE_ATOMIC_ADD
+#define HAVE_ATOMIC_SUB
+#endif
+
+/* In Linux-ia64 including atomic.h will give us an error */
+#if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__ia64__)
+#undef HAVE_ATOMIC_ADD
+#undef HAVE_ATOMIC_SUB
+#endif
+
#if defined(_lint) && !defined(lint)
#define lint
#endif
@@ -131,6 +159,10 @@
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
+#ifdef HAVE_ATOMIC_ADD
+#define __SMP__
+#include <asm/atomic.h>
+#endif
/* Go around some bugs in different OS and compilers */
#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
@@ -167,6 +199,7 @@
#endif
/* Define void to stop lint from generating "null effekt" comments */
+#ifndef DONT_DEFINE_VOID
#ifdef _lint
int __void__;
#define VOID(X) (__void__ = (int) (X))
@@ -174,6 +207,7 @@ int __void__;
#undef VOID
#define VOID(X) (X)
#endif
+#endif /* DONT_DEFINE_VOID */
#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
#define LINT_INIT(var) var=0 /* No uninitialize-warning */
@@ -242,6 +276,11 @@ typedef unsigned short ushort;
#endif
#include <dbug.h>
+#ifndef DBUG_OFF
+#define dbug_assert(A) assert(A)
+#else
+#define dbug_assert(A)
+#endif
#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/
#define ASCII_BITS_USED 8 /* Bit char used */
@@ -278,7 +317,7 @@ typedef int (*qsort_cmp)(const void *,const void *);
#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */
#endif
#ifdef HAVE_mit_thread
-typedef int size_socket; /* Type of last arg to accept */
+#define size_socket socklen_t /* Type of last arg to accept */
#else
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
@@ -359,7 +398,7 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define NO_PISAM /* Not needed anymore */
#define NO_MISAM /* Not needed anymore */
#define NO_HASH /* Not needed anymore */
-#ifdef __WIN32__
+#ifdef __WIN__
#define NO_DIR_LIBRARY /* Not standar dir-library */
#define USE_MY_STAT_STRUCT /* For my_lib */
#endif
@@ -381,7 +420,7 @@ extern void init_my_atof(void);
extern double my_atof(const char*);
#endif
#undef remove /* Crashes MySQL on SCO 5.0.0 */
-#ifndef __WIN32__
+#ifndef __WIN__
#define closesocket(A) close(A)
#ifndef ulonglong2double
#define ulonglong2double(A) ((double) (A))
@@ -401,7 +440,7 @@ extern double my_atof(const char*);
#ifdef HAVE_LINUXTHREADS
/* #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) */
-#define sigset(A,B) signal((A),(B))
+/* #define sigset(A,B) signal((A),(B)) */
#endif
/* Remove some things that mit_thread break or doesn't support */
@@ -470,6 +509,8 @@ typedef long my_ptrdiff_t;
#define NEAR /* Who needs segments ? */
#define FAR /* On a good machine */
#define HUGE_PTR
+#endif
+#ifndef STDCALL
#define STDCALL
#endif
@@ -527,7 +568,9 @@ typedef long longlong;
#endif
#undef SIZEOF_OFF_T
#define SIZEOF_OFF_T 8
-#endif
+#else
+#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
+#endif /* USE_RAID */
#if SIZEOF_OFF_T > 4
typedef ulonglong my_off_t;
@@ -535,7 +578,9 @@ typedef ulonglong my_off_t;
typedef unsigned long my_off_t;
#endif
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
-/*typedef off_t os_off_t;*/
+#ifndef __WIN__
+typedef off_t os_off_t;
+#endif
typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */
typedef short int15; /* Most effective integer 0 <= x <= 32767 */
@@ -723,8 +768,8 @@ typedef char bool; /* Ordinary boolean values 0 1 */
((byte*) &def_temp)[7]=(M)[0];\
(V) = def_temp; }
#else
-#define float4get(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(float))
-#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
+#define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
+#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float))
#define float8get(V,M) doubleget((V),(M))
#define float8store(V,M) doublestore((V),(M))
#endif /* WORDS_BIGENDIAN */
@@ -775,12 +820,24 @@ typedef char bool; /* Ordinary boolean values 0 1 */
#define shortstore(T,V) int2store(T,V)
#define longstore(T,V) int4store(T,V)
#ifndef doubleget
-#define doubleget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(double))
-#define doublestore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(double))
+#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
+#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
#endif
-#define longlongget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(ulonglong))
-#define longlongstore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(ulonglong))
+#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
+#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
#endif /* WORDS_BIGENDIAN */
+/* sprintf does not always return the number of bytes :- */
+#ifdef SPRINTF_RETURNS_INT
+#define my_sprintf(buff,args) sprintf args
+#else
+#ifdef SPRINTF_RETURNS_PTR
+#define my_sprintf(buff,args) ((int)(sprintf args - buff))
+#else
+#define my_sprintf(buff,args) sprintf args,strlen(buff)
+#endif
+#endif
+
+
#endif /* _global_h */
diff --git a/ext/mysql/libmysql/int2str.c b/ext/mysql/libmysql/int2str.c
index 9d6d435721..bb12b00cdc 100644
--- a/ext/mysql/libmysql/int2str.c
+++ b/ext/mysql/libmysql/int2str.c
@@ -1,3 +1,6 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
/*
Defines: int2str(), itoa(), ltoa()
@@ -33,6 +36,7 @@ char *int2str(register long int val, register char *dst, register int radix)
{
char buffer[65];
register char *p;
+ long int new_val;
if (radix < 0) {
if (radix < -36 || radix > -2) return NullS;
@@ -57,8 +61,9 @@ char *int2str(register long int val, register char *dst, register int radix)
*/
p = &buffer[sizeof(buffer)-1];
*p = '\0';
- *--p = _dig_vec[(ulong) val % (ulong) radix];
- val = (ulong) val / (ulong) radix;
+ new_val=(ulong) val / (ulong) radix;
+ *--p = _dig_vec[(uchar) ((ulong) val- (ulong) new_val*(ulong) radix)];
+ val = new_val;
#ifdef HAVE_LDIV
while (val != 0)
{
@@ -70,14 +75,53 @@ char *int2str(register long int val, register char *dst, register int radix)
#else
while (val != 0)
{
- *--p = _dig_vec[val%radix];
- val /= radix;
+ new_val=val/radix;
+ *--p = _dig_vec[(uchar) (val-new_val*radix)];
+ val= new_val;
}
#endif
while ((*dst++ = *p++) != 0) ;
return dst-1;
}
+
+/*
+ This is a faster version of the above optimized for the normal case of
+ radix 10 / -10
+*/
+
+char *int10_to_str(long int val,char *dst,int radix)
+{
+ char buffer[65];
+ register char *p;
+ long int new_val;
+
+ if (radix < 0) /* -10 */
+ {
+ if (val < 0)
+ {
+ *dst++ = '-';
+ val = -val;
+ }
+ }
+
+ p = &buffer[sizeof(buffer)-1];
+ *p = '\0';
+ new_val= (long) ((unsigned long int) val / 10);
+ *--p = '0'+ (char) ((unsigned long int) val - (unsigned long) new_val * 10);
+ val = new_val;
+
+ while (val != 0)
+ {
+ new_val=val/10;
+ *--p = '0' + (char) (val-new_val*10);
+ val= new_val;
+ }
+ while ((*dst++ = *p++) != 0) ;
+ return dst-1;
+}
+
+
#ifdef USE_MY_ITOA
/* Change to less general itoa interface */
diff --git a/ext/mysql/libmysql/is_prefix.c b/ext/mysql/libmysql/is_prefix.c
index 09b3accf75..c0ed472103 100644
--- a/ext/mysql/libmysql/is_prefix.c
+++ b/ext/mysql/libmysql/is_prefix.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* File : is_prefix.c
Author : Michael Widenius
diff --git a/ext/mysql/libmysql/libmysql.c b/ext/mysql/libmysql/libmysql.c
index 888d0e22c9..ebee8b6e10 100644
--- a/ext/mysql/libmysql/libmysql.c
+++ b/ext/mysql/libmysql/libmysql.c
@@ -1,10 +1,8 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
-
-#define PROTOCOL_VERSION 10
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#define DONT_USE_RAID
-#if defined(__WIN32__) || defined(WIN32)
+#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64)
#include <winsock.h>
#include <odbcinst.h>
#endif
@@ -20,10 +18,11 @@
#include <violite.h>
#include <sys/stat.h>
#include <signal.h>
+#include <time.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
-#if !defined(MSDOS) && !defined(__WIN32__)
+#if !defined(MSDOS) && !defined(__WIN__)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -38,7 +37,7 @@
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
-#if defined(THREAD) && !defined(__WIN32__)
+#if defined(THREAD) && !defined(__WIN__)
#include <my_pthread.h> /* because of signal() */
#endif
#ifndef INADDR_NONE
@@ -46,17 +45,16 @@
#endif
static my_bool mysql_client_init=0;
-static MYSQL *current_mysql;
uint mysql_port=0;
my_string mysql_unix_port=0;
-#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
+#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS)
-#if defined(MSDOS) || defined(__WIN32__)
+#if defined(MSDOS) || defined(__WIN__)
#define ERRNO WSAGetLastError()
#define perror(A)
#else
-#include <sys/errno.h>
+#include <errno.h>
#define ERRNO errno
#define SOCKET_ERROR -1
#define closesocket(A) close(A)
@@ -68,20 +66,21 @@ static MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields,
static int read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row,
ulong *lengths);
static void end_server(MYSQL *mysql);
-static void remember_connection(MYSQL *mysql);
static void read_user_name(char *name);
static void append_wild(char *to,char *end,const char *wild);
static my_bool mysql_reconnect(MYSQL *mysql);
static int send_file_to_server(MYSQL *mysql,const char *filename);
static sig_handler pipe_sig_handler(int sig);
+static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
+ const char *from, ulong length);
/*
Let the user specify that we don't want SIGPIPE; This doesn't however work
with threaded applications as we can have multiple read in progress.
*/
-#if !defined(__WIN32__) && defined(SIGPIPE) && !defined(THREAD)
-#define init_sigpipe_variables sig_return old_signal_handler;
+#if !defined(__WIN__) && defined(SIGPIPE) && !defined(THREAD)
+#define init_sigpipe_variables sig_return old_signal_handler=(sig_return) 0;
#define set_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) old_signal_handler=signal(SIGPIPE,pipe_sig_handler)
#define reset_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) signal(SIGPIPE,old_signal_handler);
#else
@@ -101,13 +100,14 @@ static sig_handler pipe_sig_handler(int sig);
static int connect2(File s, const struct sockaddr *name, uint namelen, uint to)
{
-#if defined(__WIN32__)
+#if defined(__WIN__)
return connect(s, (struct sockaddr*) name, namelen);
#else
int flags, res, s_err;
size_socket s_err_size = sizeof(uint);
fd_set sfds;
struct timeval tv;
+ time_t start_time, now_time;
/* If they passed us a timeout of zero, we should behave
* exactly like the normal connect() call does.
@@ -150,11 +150,25 @@ static int connect2(File s, const struct sockaddr *name, uint namelen, uint to)
FD_ZERO(&sfds);
FD_SET(s, &sfds);
- tv.tv_sec = (long) to;
- tv.tv_usec = 0;
- res = select(s+1, NULL, &sfds, NULL, &tv);
- if (res <= 0) /* Never became writable */
- return(-1);
+ /*
+ * select could be interrupted by a signal, and if it is,
+ * the timeout should be adjusted and the select restarted
+ * to work around OSes that don't restart select and
+ * implementations of select that don't adjust tv upon
+ * failure to reflect the time remaining
+ */
+ start_time = time(NULL);
+ for (;;)
+ {
+ tv.tv_sec = (long) to;
+ tv.tv_usec = 0;
+ if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0)
+ break;
+ now_time=time(NULL);
+ to-= (uint) (now_time - start_time);
+ if (errno != EINTR || (int) to <= 0)
+ return -1;
+ }
/* select() returned something more interesting than zero, let's
* see if we have any errors. If the next two statements pass,
@@ -178,7 +192,7 @@ static int connect2(File s, const struct sockaddr *name, uint namelen, uint to)
** Create a named pipe connection
*/
-#ifdef __WIN32__
+#ifdef __WIN__
HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host,
char **arg_unix_socket)
@@ -270,7 +284,9 @@ net_safe_read(MYSQL *mysql)
DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d",
vio_description(net->vio),len));
end_server(mysql);
- net->last_errno=CR_SERVER_LOST;
+ net->last_errno=(net->last_errno == ER_NET_PACKET_TOO_LARGE ?
+ CR_NET_PACKET_TOO_LARGE:
+ CR_SERVER_LOST);
strmov(net->last_error,ER(net->last_errno));
return(packet_error);
}
@@ -409,23 +425,21 @@ simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
mysql->net.last_errno=0;
mysql->info=0;
mysql->affected_rows= ~(my_ulonglong) 0;
- remember_connection(mysql);
net_clear(net); /* Clear receive buffer */
if (!arg)
arg="";
if (net_write_command(net,(uchar) command,arg,
- length ? length :strlen(arg)))
+ length ? length : (ulong) strlen(arg)))
{
DBUG_PRINT("error",("Can't send command to server. Error: %d",errno));
end_server(mysql);
if (mysql_reconnect(mysql) ||
net_write_command(net,(uchar) command,arg,
- length ? length :strlen(arg)))
+ length ? length : (ulong) strlen(arg)))
{
net->last_errno=CR_SERVER_GONE_ERROR;
strmov(net->last_error,ER(net->last_errno));
- reset_sigpipe(mysql);
goto end;
}
}
@@ -455,7 +469,7 @@ struct passwd *getpwuid(uid_t);
char* getlogin(void);
#endif
-#if !defined(MSDOS) && ! defined(VMS) && !defined(__WIN32__)
+#if !defined(MSDOS) && ! defined(VMS) && !defined(__WIN__)
static void read_user_name(char *name)
{
DBUG_ENTER("read_user_name");
@@ -502,7 +516,7 @@ static void read_user_name(char *name)
#endif
-#ifdef __WIN32__
+#ifdef __WIN__
static my_bool is_NT(void)
{
char *os=getenv("OS");
@@ -574,17 +588,6 @@ mysql_debug(const char *debug)
/**************************************************************************
-** Store the server socket currently in use
-** Used by pipe_handler if error on socket interrupt
-**************************************************************************/
-
-static void
-remember_connection(MYSQL *mysql)
-{
- current_mysql = mysql;
-}
-
-/**************************************************************************
** Close the server connection if we get a SIGPIPE
ARGSUSED
**************************************************************************/
@@ -660,12 +663,13 @@ mysql_free_result(MYSQL_RES *result)
static const char *default_options[]=
{"port","socket","compress","password","pipe", "timeout", "user",
"init-command", "host", "database", "debug", "return-found-rows",
-#ifdef HAVE_OPENSSL
"ssl_key" ,"ssl_cert" ,"ssl_ca" ,"ssl_capath",
-#endif /* HAVE_OPENSSL */
+ "character-set-dir", "default-character-set",
NullS
};
-static TYPELIB option_types={array_elements(default_options)-1,(char*) "options",(char **) default_options};
+
+static TYPELIB option_types={array_elements(default_options)-1,
+ "options",default_options};
static void mysql_read_default_options(struct st_mysql_options *options,
const char *filename,const char *group)
@@ -775,7 +779,21 @@ static void mysql_read_default_options(struct st_mysql_options *options,
my_free(options->ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
options->ssl_capath = my_strdup(opt_arg, MYF(MY_WME));
break;
+#else
+ case 13: /* Ignore SSL options */
+ case 14:
+ case 15:
+ case 16:
+ break;
#endif /* HAVE_OPENSSL */
+ case 17: /* charset-lib */
+ my_free(options->charset_dir,MYF(MY_ALLOW_ZERO_PTR));
+ options->charset_dir = my_strdup(opt_arg, MYF(MY_WME));
+ break;
+ case 18:
+ my_free(options->charset_name,MYF(MY_ALLOW_ZERO_PTR));
+ options->charset_name = my_strdup(opt_arg, MYF(MY_WME));
+ break;
default:
DBUG_PRINT("warning",("unknown option: %s",option[0]));
}
@@ -966,9 +984,13 @@ mysql_init(MYSQL *mysql)
}
else
bzero((char*) (mysql),sizeof(*(mysql)));
-#ifdef __WIN32__
+#ifdef __WIN__
mysql->options.connect_timeout=20;
#endif
+#if defined(SIGPIPE) && defined(THREAD)
+ if (!((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE))
+ (void) signal(SIGPIPE,pipe_sig_handler);
+#endif
return mysql;
}
@@ -997,7 +1019,7 @@ static void mysql_once_init()
if (!mysql_unix_port)
{
char *env;
-#ifdef __WIN32__
+#ifdef __WIN__
mysql_unix_port = (char*) MYSQL_NAMEDPIPE;
#else
mysql_unix_port = (char*) MYSQL_UNIX_ADDR;
@@ -1006,7 +1028,7 @@ static void mysql_once_init()
mysql_unix_port = env;
}
mysql_debug(NullS);
-#if defined(SIGPIPE)
+#if defined(SIGPIPE) && !defined(THREAD)
(void) signal(SIGPIPE,SIG_IGN);
#endif
}
@@ -1062,7 +1084,7 @@ mysql_ssl_clear(MYSQL *mysql)
mysql->options.ssl_ca = 0;
mysql->options.ssl_capath = 0;
mysql->options.use_ssl = false;
- delete reinterpret_cast<VioConnectorFd*>(mysql->connector_fd);
+ mysql->connector_fd->delete();
mysql->connector_fd = 0;
return 0;
}
@@ -1101,13 +1123,13 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
uint port, const char *unix_socket,uint client_flag)
{
- char buff[100],*end,*host_info;
+ char buff[100],charset_name_buff[16],*end,*host_info, *charset_name;
int sock;
- ulong ip_addr;
+ uint32 ip_addr;
struct sockaddr_in sock_addr;
uint pkt_length;
- NET *net;
-#ifdef __WIN32__
+ NET *net= &mysql->net;
+#ifdef __WIN__
HANDLE hPipe=INVALID_HANDLE_VALUE;
#endif
#ifdef HAVE_SYS_UN_H
@@ -1123,6 +1145,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
/* Don't give sigpipe errors if the client doesn't want them */
set_sigpipe(mysql);
+ net->vio = 0; /* If something goes wrong */
/* use default options */
if (mysql->options.my_cnf_file || mysql->options.my_cnf_group)
{
@@ -1155,10 +1178,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (!unix_socket)
unix_socket=mysql->options.unix_socket;
- remember_connection(mysql);
mysql->reconnect=1; /* Reconnect as default */
- net= &mysql->net;
- net->vio = 0; /* If something goes wrong */
+ mysql->server_status=SERVER_STATUS_AUTOCOMMIT;
/*
** Grab a socket and connect it to the server
@@ -1192,7 +1213,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
}
}
else
-#elif defined(__WIN32__)
+#elif defined(__WIN__)
{
if ((unix_socket ||
!host && is_NT() ||
@@ -1250,7 +1271,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if ((int) (ip_addr = inet_addr(host)) != (int) INADDR_NONE)
{
- memcpy(&sock_addr.sin_addr,&ip_addr,sizeof(ip_addr));
+ memcpy_fixed(&sock_addr.sin_addr,&ip_addr,sizeof(ip_addr));
}
else
#if defined(HAVE_GETHOSTBYNAME_R) && defined(_REENTRANT) && defined(THREAD)
@@ -1323,17 +1344,53 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
mysql->thread_id=uint4korr(end+1);
end+=5;
strmake(mysql->scramble_buff,end,8);
- if (pkt_length > (uint) (end+9 - (char*) net->read_pos))
- mysql->server_capabilities=uint2korr(end+9);
+ end+=9;
+ if (pkt_length >= (uint) (end+1 - (char*) net->read_pos))
+ mysql->server_capabilities=uint2korr(end);
+ if (pkt_length >= (uint) (end+18 - (char*) net->read_pos))
+ {
+ /* New protocol with 16 bytes to describe server characteristics */
+ mysql->server_language=end[2];
+ mysql->server_status=uint2korr(end+3);
+ }
+
+ /* Set character set */
+ if ((charset_name=mysql->options.charset_name))
+ {
+ const char *save=charsets_dir;
+ if (mysql->options.charset_dir)
+ charsets_dir=mysql->options.charset_dir;
+ mysql->charset=get_charset_by_name(mysql->options.charset_name,
+ MYF(MY_WME));
+ charsets_dir=save;
+ }
+ else if (mysql->server_language)
+ {
+ charset_name=charset_name_buff;
+ sprintf(charset_name,"%d",mysql->server_language); /* In case of errors */
+ mysql->charset=get_charset((uint8) mysql->server_language, MYF(MY_WME));
+ }
+ else
+ mysql->charset=default_charset_info;
+
+ if (!mysql->charset)
+ {
+ net->last_errno=CR_CANT_READ_CHARSET;
+ sprintf(net->last_error,ER(net->last_errno),
+ charset_name ? charset_name : "unknown",
+ mysql->options.charset_dir ? mysql->options.charset_dir :
+ "default");
+ goto error;
+ }
/* Save connection information */
if (!user) user="";
if (!passwd) passwd="";
if (!my_multi_malloc(MYF(0),
- &mysql->host_info,strlen(host_info)+1,
- &mysql->host,strlen(host)+1,
- &mysql->unix_socket,unix_socket ? strlen(unix_socket)+1
- :1,
+ &mysql->host_info, (uint) strlen(host_info)+1,
+ &mysql->host, (uint) strlen(host)+1,
+ &mysql->unix_socket,unix_socket ?
+ (uint) strlen(unix_socket)+1 : (uint) 1,
&mysql->server_version,
(uint) (end - (char*) net->read_pos),
NullS) ||
@@ -1352,8 +1409,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
strmov(mysql->server_version,(char*) net->read_pos+1);
mysql->port=port;
mysql->client_flag=client_flag | mysql->options.client_flag;
- DBUG_PRINT("info",("Server version = '%s' capabilites: %ld",
- mysql->server_version,mysql->server_capabilities));
+ DBUG_PRINT("info",("Server version = '%s' capabilites: %ld status: %d",
+ mysql->server_version,mysql->server_capabilities,
+ mysql->server_status));
/* Send client information for access check */
client_flag|=CLIENT_CAPABILITIES;
@@ -1415,6 +1473,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
strmake(buff+5,user,32);
else
read_user_name((char*) buff+5);
+#ifdef _CUSTOMCONFIG_
+#include "_cust_libmysql.h";
+#endif
DBUG_PRINT("info",("user: %s",buff+5));
end=scramble(strend(buff+5)+1, mysql->scramble_buff, passwd,
(my_bool) (mysql->protocol_version == 9));
@@ -1465,8 +1526,13 @@ static my_bool mysql_reconnect(MYSQL *mysql)
MYSQL tmp_mysql;
DBUG_ENTER("mysql_reconnect");
- if (!mysql->reconnect || !mysql->host_info)
+ if (!mysql->reconnect ||
+ (mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info)
+ {
+ /* Allov reconnect next time */
+ mysql->server_status&= ~SERVER_STATUS_IN_TRANS;
DBUG_RETURN(1);
+ }
mysql_init(&tmp_mysql);
tmp_mysql.options=mysql->options;
if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
@@ -1475,9 +1541,9 @@ static my_bool mysql_reconnect(MYSQL *mysql)
DBUG_RETURN(1);
tmp_mysql.free_me=mysql->free_me;
mysql->free_me=0;
- bzero((char*) &mysql->options,sizeof(&mysql->options));
+ bzero((char*) &mysql->options,sizeof(mysql->options));
mysql_close(mysql);
- memcpy(mysql,&tmp_mysql,sizeof(tmp_mysql));
+ *mysql=tmp_mysql;
net_clear(&mysql->net);
mysql->affected_rows= ~(my_ulonglong) 0;
DBUG_RETURN(0);
@@ -1528,7 +1594,7 @@ mysql_select_db(MYSQL *mysql, const char *db)
DBUG_ENTER("mysql_select_db");
DBUG_PRINT("enter",("db: '%s'",db));
- if ((error=simple_command(mysql,COM_INIT_DB,db,strlen(db),0)))
+ if ((error=simple_command(mysql,COM_INIT_DB,db,(uint) strlen(db),0)))
DBUG_RETURN(error);
my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
mysql->db=my_strdup(db,MYF(MY_WME));
@@ -1560,11 +1626,14 @@ mysql_close(MYSQL *mysql)
my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.init_command,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.user,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.host,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.password,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.unix_socket,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.db,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
/* Clear pointers for better safety */
mysql->host_info=mysql->user=mysql->passwd=mysql->db=0;
bzero((char*) &mysql->options,sizeof(mysql->options));
@@ -1588,12 +1657,12 @@ mysql_close(MYSQL *mysql)
int STDCALL
mysql_query(MYSQL *mysql, const char *query)
{
- return mysql_real_query(mysql,query,strlen(query));
+ return mysql_real_query(mysql,query, (uint) strlen(query));
}
int STDCALL
-mysql_real_query(MYSQL *mysql, const char *query,uint length)
+mysql_real_query(MYSQL *mysql, const char *query, uint length)
{
uchar *pos;
ulong field_count;
@@ -1612,6 +1681,10 @@ mysql_real_query(MYSQL *mysql, const char *query,uint length)
{
mysql->affected_rows= net_field_length_ll(&pos);
mysql->insert_id= net_field_length_ll(&pos);
+ if (mysql->server_capabilities & CLIENT_TRANSACTIONS)
+ {
+ mysql->server_status=uint2korr(pos); pos+=2;
+ }
if (pos < mysql->net.read_pos+length && net_field_length(&pos))
mysql->info=(char*) pos;
DBUG_RETURN(0);
@@ -1623,6 +1696,9 @@ mysql_real_query(MYSQL *mysql, const char *query,uint length)
DBUG_RETURN(-1);
goto get_info; /* Get info packet */
}
+ if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT))
+ mysql->server_status|= SERVER_STATUS_IN_TRANS;
+
mysql->extra_info= net_field_length_ll(&pos); /* Maybe number of rec */
if (!(fields=read_rows(mysql,(MYSQL_FIELD*) 0,5)))
DBUG_RETURN(-1);
@@ -1820,6 +1896,7 @@ mysql_fetch_row(MYSQL_RES *res)
}
else
{
+ DBUG_PRINT("info",("end of data"));
res->eof=1;
res->handle->status=MYSQL_STATUS_READY;
}
@@ -1829,7 +1906,10 @@ mysql_fetch_row(MYSQL_RES *res)
{
MYSQL_ROW tmp;
if (!res->data_cursor)
+ {
+ DBUG_PRINT("info",("end of data"));
DBUG_RETURN(res->current_row=(MYSQL_ROW) NULL);
+ }
tmp = res->data_cursor->data;
res->data_cursor = res->data_cursor->next;
DBUG_RETURN(res->current_row=tmp);
@@ -1880,7 +1960,7 @@ void STDCALL
mysql_data_seek(MYSQL_RES *result, my_ulonglong row)
{
MYSQL_ROWS *tmp=0;
- DBUG_PRINT("info",("mysql_data_seek(%d)",row));
+ DBUG_PRINT("info",("mysql_data_seek(%ld)",(long) row));
if (result->data)
for (tmp=result->data->data; row-- && tmp ; tmp = tmp->next) ;
result->current_row=0;
@@ -1889,7 +1969,7 @@ mysql_data_seek(MYSQL_RES *result, my_ulonglong row)
/*************************************************************************
** put the row or field cursor one a position one got from mysql_row_tell()
-** This dosen't restore any data. The next mysql_fetch_row or
+** This doesn't restore any data. The next mysql_fetch_row or
** mysql_fetch_field will return the next row or field after the last used
*************************************************************************/
@@ -2146,6 +2226,14 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
mysql->options.my_cnf_group=my_strdup(arg,MYF(MY_WME));
break;
+ case MYSQL_SET_CHARSET_DIR:
+ my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR));
+ mysql->options.charset_dir=my_strdup(arg,MYF(MY_WME));
+ break;
+ case MYSQL_SET_CHARSET_NAME:
+ my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
+ mysql->options.charset_name=my_strdup(arg,MYF(MY_WME));
+ break;
default:
DBUG_RETURN(-1);
}
@@ -2158,78 +2246,93 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
****************************************************************************/
/* MYSQL_RES */
-my_ulonglong mysql_num_rows(MYSQL_RES *res)
+my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res)
{
return res->row_count;
}
-unsigned int mysql_num_fields(MYSQL_RES *res)
+unsigned int STDCALL mysql_num_fields(MYSQL_RES *res)
{
return res->field_count;
}
-my_bool mysql_eof(MYSQL_RES *res)
+my_bool STDCALL mysql_eof(MYSQL_RES *res)
{
return res->eof;
}
-MYSQL_FIELD *mysql_fetch_field_direct(MYSQL_RES *res,uint fieldnr)
+MYSQL_FIELD * STDCALL mysql_fetch_field_direct(MYSQL_RES *res,uint fieldnr)
{
return &(res)->fields[fieldnr];
}
-MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *res)
+MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res)
{
return (res)->fields;
}
-MYSQL_ROWS *mysql_row_tell(MYSQL_RES *res)
+MYSQL_ROWS * STDCALL mysql_row_tell(MYSQL_RES *res)
{
return res->data_cursor;
}
-uint mysql_field_tell(MYSQL_RES *res)
+uint STDCALL mysql_field_tell(MYSQL_RES *res)
{
return (res)->current_field;
}
/* MYSQL */
-unsigned int mysql_field_count(MYSQL *mysql)
+unsigned int STDCALL mysql_field_count(MYSQL *mysql)
{
return mysql->field_count;
}
-my_ulonglong mysql_affected_rows(MYSQL *mysql)
+my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql)
{
return (mysql)->affected_rows;
}
-my_ulonglong mysql_insert_id(MYSQL *mysql)
+my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
{
return (mysql)->insert_id;
}
-uint mysql_errno(MYSQL *mysql)
+uint STDCALL mysql_errno(MYSQL *mysql)
{
return (mysql)->net.last_errno;
}
-char *mysql_error(MYSQL *mysql)
+char * STDCALL mysql_error(MYSQL *mysql)
{
return (mysql)->net.last_error;
}
-char *mysql_info(MYSQL *mysql)
+char *STDCALL mysql_info(MYSQL *mysql)
{
return (mysql)->info;
}
-ulong mysql_thread_id(MYSQL *mysql)
+ulong STDCALL mysql_thread_id(MYSQL *mysql)
{
return (mysql)->thread_id;
}
+const char * STDCALL mysql_character_set_name(MYSQL *mysql)
+{
+ return mysql->charset->name;
+}
+
+
+uint STDCALL mysql_thread_safe(void)
+{
+#ifdef THREAD
+ return 1;
+#else
+ return 0;
+#endif
+}
+
/****************************************************************************
** Some support functions
****************************************************************************/
@@ -2243,13 +2346,31 @@ ulong mysql_thread_id(MYSQL *mysql)
ulong STDCALL
mysql_escape_string(char *to,const char *from,ulong length)
{
+ return mysql_sub_escape_string(default_charset_info,to,from,length);
+}
+
+ulong STDCALL
+mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
+ ulong length)
+{
+ return mysql_sub_escape_string(mysql->charset,to,from,length);
+}
+
+
+static ulong
+mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
+ const char *from, ulong length)
+{
const char *to_start=to;
const char *end;
+#ifdef USE_MB
+ my_bool use_mb_flag=use_mb(charset_info);
+#endif
for (end=from+length; from != end ; from++)
{
#ifdef USE_MB
int l;
- if ((l = ismbchar(from, end)))
+ if (use_mb_flag && (l = my_ismbchar(charset_info, from, end)))
{
while (l--)
*to++ = *from++;
@@ -2296,7 +2417,8 @@ mysql_escape_string(char *to,const char *from,ulong length)
char * STDCALL
-mysql_odbc_escape_string(char *to, ulong to_length,
+mysql_odbc_escape_string(MYSQL *mysql,
+ char *to, ulong to_length,
const char *from, ulong from_length,
void *param,
char * (*extend_buffer)
@@ -2304,6 +2426,9 @@ mysql_odbc_escape_string(char *to, ulong to_length,
{
char *to_end=to+to_length-5;
const char *end;
+#ifdef USE_MB
+ my_bool use_mb_flag=use_mb(mysql->charset);
+#endif
for (end=from+from_length; from != end ; from++)
{
@@ -2317,7 +2442,7 @@ mysql_odbc_escape_string(char *to, ulong to_length,
#ifdef USE_MB
{
int l;
- if ((l = ismbchar(from, end)))
+ if (use_mb_flag && (l = my_ismbchar(mysql->charset, from, end)))
{
while (l--)
*to++ = *from++;
@@ -2361,3 +2486,34 @@ mysql_odbc_escape_string(char *to, ulong to_length,
}
return to;
}
+
+void STDCALL
+myodbc_remove_escape(MYSQL *mysql,char *name)
+{
+ char *to;
+#ifdef USE_MB
+ my_bool use_mb_flag=use_mb(mysql->charset);
+ char *end;
+ LINT_INIT(end);
+ if (use_mb_flag)
+ for (end=name; *end ; end++) ;
+#endif
+
+ for (to=name ; *name ; name++)
+ {
+#ifdef USE_MB
+ int l;
+ if (use_mb_flag && (l = my_ismbchar( mysql->charset, name , end ) ) )
+ {
+ while (l--)
+ *to++ = *name++;
+ name--;
+ continue;
+ }
+#endif
+ if (*name == '\\' && name[1])
+ name++;
+ *to++= *name;
+ }
+ *to=0;
+}
diff --git a/ext/mysql/libmysql/list.c b/ext/mysql/libmysql/list.c
index f39ac7e3e3..79bc7da4c5 100644
--- a/ext/mysql/libmysql/list.c
+++ b/ext/mysql/libmysql/list.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
Code for handling dubble-linked lists in C
@@ -14,6 +14,8 @@
LIST *list_add(LIST *root, LIST *element)
{
+ DBUG_ENTER("list_add");
+ DBUG_PRINT("enter",("root: %lx element: %lx", root, element));
if (root)
{
if (root->prev) /* If add in mid of list */
@@ -24,7 +26,7 @@ LIST *list_add(LIST *root, LIST *element)
else
element->prev=0;
element->next=root;
- return element; /* New root */
+ DBUG_RETURN(element); /* New root */
}
diff --git a/ext/mysql/libmysql/longlong2str.c b/ext/mysql/libmysql/longlong2str.c
index 9759208266..1899386862 100644
--- a/ext/mysql/libmysql/longlong2str.c
+++ b/ext/mysql/libmysql/longlong2str.c
@@ -1,3 +1,6 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
/*
Defines: longlong2str();
@@ -66,16 +69,61 @@ char *longlong2str(longlong val,char *dst,int radix)
ulonglong quo=(ulonglong) val/(uint) radix;
uint rem= (uint) (val- quo* (uint) radix);
*--p = _dig_vec[rem];
- val= quo;
+ val= quo;
}
long_val= (long) val;
while (long_val != 0)
{
- *--p = _dig_vec[long_val%radix];
- long_val /= radix;
+ long quo= long_val/radix;
+ *--p = _dig_vec[(uchar) (long_val - quo*radix)];
+ long_val= quo;
}
while ((*dst++ = *p++) != 0) ;
return dst-1;
}
#endif
+
+#ifndef longlong10_to_str
+char *longlong10_to_str(longlong val,char *dst,int radix)
+{
+ char buffer[65];
+ register char *p;
+ long long_val;
+
+ if (radix < 0)
+ {
+ if (val < 0)
+ {
+ *dst++ = '-';
+ val = -val;
+ }
+ }
+
+ if (val == 0)
+ {
+ *dst++='0';
+ *dst='\0';
+ return dst;
+ }
+ p = &buffer[sizeof(buffer)-1];
+ *p = '\0';
+
+ while ((ulonglong) val > (ulonglong) LONG_MAX)
+ {
+ ulonglong quo=(ulonglong) val/(uint) 10;
+ uint rem= (uint) (val- quo* (uint) 10);
+ *--p = _dig_vec[rem];
+ val= quo;
+ }
+ long_val= (long) val;
+ while (long_val != 0)
+ {
+ long quo= long_val/10;
+ *--p = _dig_vec[(uchar) (long_val - quo*10)];
+ long_val= quo;
+ }
+ while ((*dst++ = *p++) != 0) ;
+ return dst-1;
+}
+#endif
diff --git a/ext/mysql/libmysql/m_ctype.h b/ext/mysql/libmysql/m_ctype.h
index d3b55aafff..bd6e343c24 100644
--- a/ext/mysql/libmysql/m_ctype.h
+++ b/ext/mysql/libmysql/m_ctype.h
@@ -1,5 +1,6 @@
-/* Copyright (C) 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- For a more info consult the file COPYRIGHT distributed with this file */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
/*
A better inplementation of the UNIX ctype(3) library.
Notes: global.h should be included before ctype.h
@@ -8,41 +9,45 @@
#ifndef _m_ctype_h
#define _m_ctype_h
-#define MY_CHARSET_UNDEFINED 0
-#define MY_CHARSET_BIG5 1
-#define MY_CHARSET_CZECH 2
-#define MY_CHARSET_DEC8 3
-#define MY_CHARSET_DOS 4
-#define MY_CHARSET_GERMAN1 5
-#define MY_CHARSET_HP8 6
-#define MY_CHARSET_KOI8_RU 7
-#define MY_CHARSET_LATIN1 8
-#define MY_CHARSET_LATIN2 9
-#define MY_CHARSET_SWE7 10
-#define MY_CHARSET_USA7 11
-#define MY_CHARSET_UJIS 12
-#define MY_CHARSET_SJIS 13
-#define MY_CHARSET_CP1251 14
-#define MY_CHARSET_DANISH 15
-#define MY_CHARSET_HEBREW 16
-#define MY_CHARSET_WIN1251 17
-#define MY_CHARSET_TIS620 18
-#define MY_CHARSET_EUC_KR 19
-#define MY_CHARSET_ESTONIA 20
-#define MY_CHARSET_HUNGARIAN 21
-#define MY_CHARSET_KOI8_UKR 22
-#define MY_CHARSET_WIN1251UKR 23
-#define MY_CHARSET_GB2312 24
-#define MY_CHARSET_GREEK 25
-#define MY_CHARSET_WIN1250 26
-#define MY_CHARSET_CROAT 27
-#define MY_CHARSET_GBK 28
-
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef __WIN32__
+#define CHARSET_DIR "charsets/"
+
+typedef struct charset_info_st
+{
+ uint number;
+ const char *name;
+ uchar *ctype;
+ uchar *to_lower;
+ uchar *to_upper;
+ uchar *sort_order;
+
+ uint strxfrm_multiply;
+ int (*strcoll)(const uchar *, const uchar *);
+ int (*strxfrm)(uchar *, const uchar *, int);
+ int (*strnncoll)(const uchar *, int, const uchar *, int);
+ int (*strnxfrm)(uchar *, const uchar *, int, int);
+ my_bool (*like_range)(const char *, uint, pchar, uint,
+ char *, char *, uint *, uint *);
+
+ uint mbmaxlen;
+ int (*ismbchar)(const char *, const char *);
+ my_bool (*ismbhead)(uint);
+ int (*mbcharlen)(uint);
+} CHARSET_INFO;
+
+/* strings/ctype.c */
+extern CHARSET_INFO *default_charset_info;
+extern CHARSET_INFO *find_compiled_charset(uint cs_number);
+extern CHARSET_INFO *find_compiled_charset_by_name(const char *name);
+extern CHARSET_INFO compiled_charsets[];
+
+#define MY_CHARSET_UNDEFINED 0
+#define MY_CHARSET_CURRENT (default_charset_info->number)
+
+#ifdef __WIN__
#include <ctype.h>
#endif
/* Don't include std ctype.h when this is included */
@@ -51,14 +56,6 @@ extern "C" {
#define __CTYPE_INCLUDED
#define _CTYPE_USING /* Don't put names in global namespace. */
-#ifndef CTYPE_LIBRARY
-#define EXT extern
-#define D(x)
-#else
-#define EXT
-#define D(x) = x
-#endif
-
#define _U 01 /* Upper case */
#define _L 02 /* Lower case */
#define _N 04 /* Numeral (digit) */
@@ -68,17 +65,12 @@ extern "C" {
#define _B 0100 /* Blank */
#define _X 0200 /* heXadecimal digit */
-extern uchar NEAR ctype_latin1[];
-extern uchar NEAR to_upper_latin1[];
-extern uchar NEAR to_lower_latin1[];
-extern uchar NEAR sort_order_latin1[];
-
-#define my_ctype ctype_latin1
-#define my_to_upper to_upper_latin1
-#define my_to_lower to_lower_latin1
-#define my_sort_order sort_order_latin1
+#define my_ctype (default_charset_info->ctype)
+#define my_to_upper (default_charset_info->to_upper)
+#define my_to_lower (default_charset_info->to_lower)
+#define my_sort_order (default_charset_info->sort_order)
-#ifndef __WIN32__
+#ifndef __WIN__
#define _toupper(c) (char) my_to_upper[(uchar) (c)]
#define _tolower(c) (char) my_to_lower[(uchar) (c)]
#define toupper(c) (char) my_to_upper[(uchar) (c)]
@@ -102,7 +94,34 @@ extern uchar NEAR sort_order_latin1[];
#undef ctype
#endif /* ctype */
-#endif /* __WIN32__ */
+#endif /* __WIN__ */
+
+#define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_U | _L))
+#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _U)
+#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _L)
+#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _N)
+#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _X)
+#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_U | _L | _N))
+#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _S)
+#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _P)
+#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_P | _U | _L | _N | _B))
+#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
+#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _C)
+
+#define use_strcoll(s) ((s)->strcoll != NULL)
+#define MY_STRXFRM_MULTIPLY (default_charset_info->strxfrm_multiply)
+#define my_strnxfrm(s, a, b, c, d) ((s)->strnxfrm((a), (b), (c), (d)))
+#define my_strnncoll(s, a, b, c, d) ((s)->strnncoll((a), (b), (c), (d)))
+#define my_strxfrm(s, a, b, c, d) ((s)->strnxfrm((a), (b), (c)))
+#define my_strcoll(s, a, b) ((s)->strcoll((a), (b)))
+#define my_like_range(s, a, b, c, d, e, f, g, h) \
+ ((s)->like_range((a), (b), (c), (d), (e), (f), (g), (h)))
+
+#define use_mb(s) ((s)->ismbchar != NULL)
+#define MBMAXLEN (default_charset_info->mbmaxlen)
+#define my_ismbchar(s, a, b) ((s)->ismbchar((a), (b)))
+#define my_ismbhead(s, a) ((s)->ismbhead((a)))
+#define my_mbcharlen(s, a) ((s)->mbcharlen((a)))
/* Some macros that should be cleaned up a little */
#define isvar(c) (isalnum(c) || (c) == '_')
@@ -110,120 +129,13 @@ extern uchar NEAR sort_order_latin1[];
#define tocntrl(c) ((c) & 31)
#define toprint(c) ((c) | 64)
-/* Support for Japanese(UJIS) characters, by tommy@valley.ne.jp */
-#if MY_CHARSET_CURRENT == MY_CHARSET_UJIS
-#define USE_MB
-#define USE_MB_IDENT
-#define isujis(c) ((0xa1<=((c)&0xff) && ((c)&0xff)<=0xfe))
-#define iskata(c) ((0xa1<=((c)&0xff) && ((c)&0xff)<=0xdf))
-#define isujis_ss2(c) (((c)&0xff) == 0x8e)
-#define isujis_ss3(c) (((c)&0xff) == 0x8f)
-#define ismbchar(p, end) ((*(uchar*)(p)<0x80)? 0:\
- isujis(*(p)) && (end)-(p)>1 && isujis(*((p)+1))? 2:\
- isujis_ss2(*(p)) && (end)-(p)>1 && iskata(*((p)+1))? 2:\
- isujis_ss3(*(p)) && (end)-(p)>2 && isujis(*((p)+1)) && isujis(*((p)+2))? 3:\
- 0)
-#define ismbhead(c) (isujis(c) || isujis_ss2(c) || isujis_ss3(c))
-#define mbcharlen(c) (isujis(c)? 2: isujis_ss2(c)? 2: isujis_ss3(c)? 3: 0)
-#define MBMAXLEN 3
-#endif
-
-/* Support for Japanese(SJIS) characters, by tommy@valley.ne.jp */
-#if MY_CHARSET_CURRENT == MY_CHARSET_SJIS
-#define USE_MB
-#define USE_MB_IDENT
-#define issjishead(c) ((0x81<=((c)&0xff) && ((c)&0xff)<=0x9f) || (0xe0<=((c)&0xff) && ((c)&0xff)<=0xfc))
-#define issjistail(c) ((0x40<=((c)&0xff) && ((c)&0xff)<=0x7e) || (0x80<=((c)&0xff) && ((c)&0xff)<=0xfc))
-#define ismbchar(p, end) (issjishead(*(p)) && (end)-(p)>1 && issjistail(*((p)+1))? 2: 0)
-#define ismbhead(c) issjishead(c)
-#define mbcharlen(c) (issjishead(c)? 2: 0)
-#define MBMAXLEN 2
-#endif
-
-/* Support for Chinese(BIG5) characters, by jou@nematic.ieo.nctu.edu.tw
- modified by Wei He (hewei@mail.ied.ac.cn) */
-
-#if MY_CHARSET_CURRENT == MY_CHARSET_BIG5
-#define USE_MB
-#define USE_MB_IDENT
-#define isbig5head(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xf9)
-#define isbig5tail(c) ((0x40<=(uchar)(c) && (uchar)(c)<=0x7e) || \
- (0xa1<=(uchar)(c) && (uchar)(c)<=0xfe))
-#define ismbchar(p, end) (isbig5head(*(p)) && (end)-(p)>1 && isbig5tail(*((p)+1))? 2: 0)
-#define ismbhead(c) isbig5head(c)
-#define mbcharlen(c) (isbig5head(c)? 2: 0)
-#define MBMAXLEN 2
-#
-#undef USE_STRCOLL
-#define USE_STRCOLL
-#endif
-
-/* Support for Chinese(GB2312) characters, by Miles Tsai (net-bull@126.com)
- modified by Wei He (hewei@mail.ied.ac.cn) */
-
-#if MY_CHARSET_CURRENT == MY_CHARSET_GB2312
-#define USE_MB
-#define USE_MB_IDENT
-#define isgb2312head(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xf7)
-#define isgb2312tail(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xfe)
-#define ismbchar(p, end) (isgb2312head(*(p)) && (end)-(p)>1 && isgb2312tail(*((p)+1))? 2: 0)
-#define ismbhead(c) isgb2312head(c)
-#define mbcharlen(c) (isgb2312head(c)? 2:0)
-#define MBMAXLEN 2
-#endif
-
-/* Support for Chinese(GBK) characters, by hewei@mail.ied.ac.cn */
-
-#if MY_CHARSET_CURRENT == MY_CHARSET_GBK
-#define USE_MB
-#define USE_MB_IDENT
-#define isgbkhead(c) (0x81<=(uchar)(c) && (uchar)(c)<=0xfe)
-#define isgbktail(c) ((0x40<=(uchar)(c) && (uchar)(c)<=0x7e) || \
- (0x80<=(uchar)(c) && (uchar)(c)<=0xfe))
-#define ismbchar(p, end) (isgbkhead(*(p)) && (end)-(p)>1 && isgbktail(*((p)+1))? 2: 0)
-#define ismbhead(c) isgbkhead(c)
-#define mbcharlen(c) (isgbkhead(c)? 2:0)
-#define MBMAXLEN 2
-#undef USE_STRCOLL
-#define USE_STRCOLL
-#endif
-
-/* Define, how much will the string grow under strxfrm */
-#if MY_CHARSET_CURRENT == MY_CHARSET_CZECH
-#undef USE_STRCOLL
-#define USE_STRCOLL
-#endif
-#if MY_CHARSET_CURRENT == MY_CHARSET_TIS620
-#undef USE_STRCOLL
-#define USE_STRCOLL
+/* XXX: still need to take care of this one */
+#ifdef MY_CHARSET_TIS620
+#error The TIS620 charset is broken at the moment. Tell tim to fix it.
#define USE_TIS620
#include "t_ctype.h"
#endif
-/* Support for Korean(EUC_KR) characters, by powerm90@tinc.co.kr and mrpark@tinc.co.kr */
-#if MY_CHARSET_CURRENT == MY_CHARSET_EUC_KR
-#define USE_MB
-#define USE_MB_IDENT
-#define iseuc_kr(c) ((0xa1<=(uchar)(c) && (uchar)(c)<=0xfe))
-#define ismbchar(p, end) ((*(uchar*)(p)<0x80)? 0:\
- iseuc_kr(*(p)) && (end)-(p)>1 && iseuc_kr(*((p)+1))? 2:\
- 0)
-#define ismbhead(c) (iseuc_kr(c))
-#define mbcharlen(c) (iseuc_kr(c) ? 2 : 0)
-#define MBMAXLEN 2
-#endif
-
-#ifdef USE_STRCOLL
-extern uint MY_STRXFRM_MULTIPLY;
-extern int my_strnxfrm(unsigned char *, unsigned char *, int, int);
-extern int my_strnncoll(const unsigned char *, int, const unsigned char *, int);
-extern int my_strxfrm(unsigned char *, unsigned char *, int);
-extern int my_strcoll(const unsigned char *, const unsigned char *);
-extern my_bool my_like_range(const char *ptr,uint ptr_length,pchar escape,
- uint res_length, char *min_str,char *max_str,
- uint *min_length,uint *max_length);
-#endif
-
#ifdef __cplusplus
}
#endif
diff --git a/ext/mysql/libmysql/m_string.h b/ext/mysql/libmysql/m_string.h
index 37207b6612..bc1fa06046 100644
--- a/ext/mysql/libmysql/m_string.h
+++ b/ext/mysql/libmysql/m_string.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- For a more info consult the file COPYRIGHT distributed with this file */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* There may be prolems include all of theese. Try to test in
configure with ones are needed? */
@@ -8,6 +8,9 @@
#ifndef _m_string_h
#define _m_string_h
+#ifndef __USE_GNU
+#define __USE_GNU /* We want to use stpcpy */
+#endif
#if defined(HAVE_STRINGS_H)
#include <strings.h>
#endif
@@ -52,6 +55,10 @@
# define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
#endif
+#if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
+#define strmov(A,B) stpcpy((A),(B))
+#endif
+
/* Unixware 7 */
#if !defined(HAVE_BFILL)
# define bfill(A,B,C) memset((A),(C),(B))
@@ -78,6 +85,12 @@ extern char NEAR _dig_vec[]; /* Declared in int2str() */
#define strmake_overlapp(A,B,C) strmake(A,B,C)
#endif
+#ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
+#define memcpy_fixed(A,B,C) bmove((A),(B),(C))
+#else
+#define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
+#endif
+
#ifdef MSDOS
#undef bmove_allign
#define bmove512(A,B,C) bmove_allign(A,B,C)
@@ -136,7 +149,6 @@ extern char *strmake_overlapp(char *dst,const char *src, uint length);
#ifndef strmov
extern char *strmov(char *dst,const char *src);
#endif
-extern uint strnlen(const char *s,uint n);
extern char *strnmov(char *dst,const char *src,uint n);
extern char *strsuff(const char *src,const char *suffix);
extern char *strcont(const char *src,const char *set);
@@ -159,6 +171,9 @@ extern int strcmp(const char *, const char *);
extern size_t strlen(const char *);
#endif
#endif
+#ifndef HAVE_STRNLEN
+extern uint strnlen(const char *s, uint n);
+#endif
#if !defined(__cplusplus)
#ifndef HAVE_STRPBRK
@@ -168,7 +183,6 @@ extern char *strpbrk(const char *, const char *);
extern char *strstr(const char *, const char *);
#endif
#endif
-extern qsort_cmp get_ptr_compare(uint);
extern int is_prefix(const char *, const char *);
/* Conversion rutins */
@@ -178,16 +192,19 @@ extern char *my_itoa(int val,char *dst,int radix);
extern char *my_ltoa(long val,char *dst,int radix);
#endif
+extern char *llstr(longlong value,char *buff);
#ifndef HAVE_STRTOUL
extern long strtol(const char *str, char **ptr, int base);
extern ulong strtoul(const char *str, char **ptr, int base);
#endif
extern char *int2str(long val,char *dst,int radix);
+extern char *int10_to_str(long val,char *dst,int radix);
extern char *str2int(const char *src,int radix,long lower,long upper,
long *val);
#if SIZEOF_LONG == SIZEOF_LONG_LONG
#define longlong2str(A,B,C) int2str((A),(B),(C))
+#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
#define strtoll(A,B,C) strtol((A),(B),(C))
#define strtoull(A,B,C) strtoul((A),(B),(C))
#ifndef HAVE_STRTOULL
@@ -196,6 +213,7 @@ extern char *str2int(const char *src,int radix,long lower,long upper,
#else
#ifdef HAVE_LONG_LONG
extern char *longlong2str(longlong val,char *dst,int radix);
+extern char *longlong10_to_str(longlong val,char *dst,int radix);
#if (!defined(HAVE_STRTOULL) || defined(HAVE_mit_thread)) || defined(NO_STRTOLL_PROTO)
extern longlong strtoll(const char *str, char **ptr, int base);
extern ulonglong strtoull(const char *str, char **ptr, int base);
diff --git a/ext/mysql/libmysql/mf_casecnv.c b/ext/mysql/libmysql/mf_casecnv.c
index 6b24182b9c..3b8e6c6a75 100644
--- a/ext/mysql/libmysql/mf_casecnv.c
+++ b/ext/mysql/libmysql/mf_casecnv.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
Functions to convert to lover_case and to upper_case in scandinavia.
@@ -18,16 +18,17 @@ void caseup_str(my_string str)
{
#ifdef USE_MB
register uint32 l;
- register char *end=str+strlen(str);
- while (*str)
- {
- if ((l=ismbchar(str,end))) str+=l;
- else *str=toupper(*str),++str;
- }
-#else
- while ((*str = toupper(*str)) != 0)
- str++;
+ register char *end=str+(uint) strlen(str);
+ if (use_mb(default_charset_info))
+ while (*str)
+ {
+ if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
+ else *str=toupper(*str),++str;
+ }
+ else
#endif
+ while ((*str = toupper(*str)) != 0)
+ str++;
} /* caseup_str */
/* string to lowercase */
@@ -36,16 +37,17 @@ void casedn_str(my_string str)
{
#ifdef USE_MB
register uint32 l;
- register char *end=str+strlen(str);
- while (*str)
- {
- if ((l=ismbchar(str,end))) str+=l;
- else *str=tolower(*str),++str;
- }
-#else
- while ((*str= tolower(*str)) != 0)
- str++;
+ register char *end=str+(uint) strlen(str);
+ if (use_mb(default_charset_info))
+ while (*str)
+ {
+ if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
+ else *str=tolower(*str),++str;
+ }
+ else
#endif
+ while ((*str= tolower(*str)) != 0)
+ str++;
} /* casedn_str */
@@ -56,15 +58,16 @@ void caseup(my_string str, uint length)
#ifdef USE_MB
register uint32 l;
register char *end=str+length;
- while (str<end)
- {
- if ((l=ismbchar(str,end))) str+=l;
- else *str=toupper(*str),++str;
- }
-#else
- for ( ; length>0 ; length--, str++)
- *str= toupper(*str);
+ if (use_mb(default_charset_info))
+ while (str<end)
+ {
+ if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
+ else *str=toupper(*str),++str;
+ }
+ else
#endif
+ for ( ; length>0 ; length--, str++)
+ *str= toupper(*str);
} /* caseup */
/* to lowercase */
@@ -74,15 +77,16 @@ void casedn(my_string str, uint length)
#ifdef USE_MB
register uint32 l;
register char *end=str+length;
- while (str<end)
- {
- if ((l=ismbchar(str,end))) str+=l;
- else *str=tolower(*str),++str;
- }
-#else
- for ( ; length>0 ; length--, str++)
- *str= tolower(*str);
+ if (use_mb(default_charset_info))
+ while (str<end)
+ {
+ if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
+ else *str=tolower(*str),++str;
+ }
+ else
#endif
+ for ( ; length>0 ; length--, str++)
+ *str= tolower(*str);
} /* casedn */
/* to sort-string that can be compared to get text in order */
@@ -100,7 +104,7 @@ void case_sort(my_string str, uint length)
Wei He (hewei@mail.ied.ac.cn)
*/
-my_string strcasestr(const char *str, const char *search)
+my_string my_strcasestr(const char *str, const char *search)
{
uchar *i,*j,*pos;
@@ -108,7 +112,8 @@ my_string strcasestr(const char *str, const char *search)
skipp:
while (*pos != '\0')
{
- if (toupper((uchar) *pos++) == toupper((uchar) *search)) {
+ if (toupper((uchar) *pos++) == toupper((uchar) *search))
+ {
i=(uchar*) pos; j=(uchar*) search+1;
while (*j)
if (toupper(*i++) != toupper(*j++)) goto skipp;
@@ -125,23 +130,28 @@ int my_strcasecmp(const char *s, const char *t)
{
#ifdef USE_MB
register uint32 l;
- register const char *end=s+strlen(s);
- while (s<end)
+ register const char *end=s+(uint) strlen(s);
+ if (use_mb(default_charset_info))
{
- if ((l=ismbchar(s,end)))
+ while (s<end)
{
- while (l--)
- if (*s++ != *t++) return 1;
+ if ((l=my_ismbchar(default_charset_info, s,end)))
+ {
+ while (l--)
+ if (*s++ != *t++) return 1;
+ }
+ else if (my_ismbhead(default_charset_info, *t)) return 1;
+ else if (toupper((uchar) *s++) != toupper((uchar) *t++)) return 1;
}
- else if (ismbhead(*t)) return 1;
- else if (toupper((uchar) *s++) != toupper((uchar) *t++)) return 1;
+ return *t;
}
- return *t;
-#else
- while (toupper((uchar) *s) == toupper((uchar) *t++))
- if (!*s++) return 0;
- return ((int) toupper((uchar) s[0]) - (int) toupper((uchar) t[-1]));
+ else
#endif
+ {
+ while (toupper((uchar) *s) == toupper((uchar) *t++))
+ if (!*s++) return 0;
+ return ((int) toupper((uchar) s[0]) - (int) toupper((uchar) t[-1]));
+ }
}
@@ -150,46 +160,79 @@ int my_casecmp(const char *s, const char *t, uint len)
#ifdef USE_MB
register uint32 l;
register const char *end=s+len;
- while (s<end)
+ if (use_mb(default_charset_info))
{
- if ((l=ismbchar(s,end)))
+ while (s<end)
{
- while (l--)
- if (*s++ != *t++) return 1;
+ if ((l=my_ismbchar(default_charset_info, s,end)))
+ {
+ while (l--)
+ if (*s++ != *t++) return 1;
+ }
+ else if (my_ismbhead(default_charset_info, *t)) return 1;
+ else if (toupper((uchar) *s++) != toupper((uchar) *t++)) return 1;
}
- else if (ismbhead(*t)) return 1;
- else if (toupper((uchar) *s++) != toupper((uchar) *t++)) return 1;
+ return 0;
}
- return 0;
-#else
- while (len-- != 0 && toupper(*s++) == toupper(*t++)) ;
- return (int) len+1;
+ else
#endif
+ {
+ while (len-- != 0 && toupper(*s++) == toupper(*t++)) ;
+ return (int) len+1;
+ }
}
int my_strsortcmp(const char *s, const char *t)
{
#ifdef USE_STRCOLL
- return my_strcoll((uchar *)s, (uchar *)t);
-#else
- while (my_sort_order[(uchar) *s] == my_sort_order[(uchar) *t++])
- if (!*s++) return 0;
- return ((int) my_sort_order[(uchar) s[0]] - (int) my_sort_order[(uchar) t[-1]]);
+ if (use_strcoll(default_charset_info))
+ return my_strcoll(default_charset_info, (uchar *)s, (uchar *)t);
+ else
#endif
+ {
+ while (my_sort_order[(uchar) *s] == my_sort_order[(uchar) *t++])
+ if (!*s++) return 0;
+ return ((int) my_sort_order[(uchar) s[0]] -
+ (int) my_sort_order[(uchar) t[-1]]);
+ }
}
int my_sortcmp(const char *s, const char *t, uint len)
{
-#ifndef USE_STRCOLL
- while (len--)
+#ifdef USE_STRCOLL
+ if (use_strcoll(default_charset_info))
+ return my_strnncoll(default_charset_info,
+ (uchar *)s, len, (uchar *)t, len);
+ else
+#endif
{
- if (my_sort_order[(uchar) *s++] != my_sort_order[(uchar) *t++])
- return ((int) my_sort_order[(uchar) s[-1]] -
- (int) my_sort_order[(uchar) t[-1]]);
+ while (len--)
+ {
+ if (my_sort_order[(uchar) *s++] != my_sort_order[(uchar) *t++])
+ return ((int) my_sort_order[(uchar) s[-1]] -
+ (int) my_sort_order[(uchar) t[-1]]);
+ }
+ return 0;
}
- return 0;
-#else
- return my_strnncoll((uchar *)s, len, (uchar *)t, len);
+}
+
+int my_sortncmp(const char *s, uint s_len, const char *t, uint t_len)
+{
+#ifdef USE_STRCOLL
+ if (use_strcoll(default_charset_info))
+ return my_strnncoll(default_charset_info,
+ (uchar *)s, s_len, (uchar *)t, t_len);
+ else
#endif
+ {
+ uint len= min(s_len,t_len);
+ while (len--)
+ {
+ if (my_sort_order[(uchar) *s++] != my_sort_order[(uchar) *t++])
+ return ((int) my_sort_order[(uchar) s[-1]] -
+ (int) my_sort_order[(uchar) t[-1]]);
+ }
+ return (int) (s_len - t_len);
+ }
}
diff --git a/ext/mysql/libmysql/mf_dirname.c b/ext/mysql/libmysql/mf_dirname.c
index 0897be7882..49ff413074 100644
--- a/ext/mysql/libmysql/mf_dirname.c
+++ b/ext/mysql/libmysql/mf_dirname.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include <m_string.h>
diff --git a/ext/mysql/libmysql/mf_fn_ext.c b/ext/mysql/libmysql/mf_fn_ext.c
index 0a52e60af3..71a10108b7 100644
--- a/ext/mysql/libmysql/mf_fn_ext.c
+++ b/ext/mysql/libmysql/mf_fn_ext.c
@@ -1,15 +1,16 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Returnerar en pekare till filnamnets extension. */
#include "mysys_priv.h"
#include <m_string.h>
- /* Returnera en pekare till ett filnamns extension.
- Pekaren pekar p} extensions-karakt{ren. Om ingen extension hittas
- returneras en pekare till NULL-tecknet i filnamnet */
- /* Denna funktion r|r inte p} utg}ngsnamnet */
+ /* Return a pointerto the extension of the filename
+ The pointer points at the extension character (normally '.'))
+ If there isn't any extension, the pointer points at the end
+ NULL of the filename
+ */
my_string fn_ext(const char *name)
{
diff --git a/ext/mysql/libmysql/mf_format.c b/ext/mysql/libmysql/mf_format.c
index ca2188b199..59056b2766 100644
--- a/ext/mysql/libmysql/mf_format.c
+++ b/ext/mysql/libmysql/mf_format.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include <m_string.h>
diff --git a/ext/mysql/libmysql/mf_loadpath.c b/ext/mysql/libmysql/mf_loadpath.c
index 8e3118968d..4a1c250b3d 100644
--- a/ext/mysql/libmysql/mf_loadpath.c
+++ b/ext/mysql/libmysql/mf_loadpath.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include <m_string.h>
@@ -16,7 +16,8 @@ my_string my_load_path(my_string to, const char *path,
{
char buff[FN_REFLEN];
DBUG_ENTER("my_load_path");
- DBUG_PRINT("enter",("path: %s prefix: %d",path,own_path_prefix));
+ DBUG_PRINT("enter",("path: %s prefix: %s",path,
+ own_path_prefix ? own_path_prefix : ""));
if ((path[0] == FN_HOMELIB && path[1] == FN_LIBCHAR) ||
test_if_hard_path(path))
diff --git a/ext/mysql/libmysql/mf_pack.c b/ext/mysql/libmysql/mf_pack.c
index 3dab1621f5..030ca1dcad 100644
--- a/ext/mysql/libmysql/mf_pack.c
+++ b/ext/mysql/libmysql/mf_pack.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include <m_string.h>
@@ -39,13 +39,13 @@ void pack_dirname(my_string to, const char *from)
LINT_INIT(buff_length);
if (!(cwd_err= my_getwd(buff,FN_REFLEN,MYF(0))))
{
- buff_length=strlen(buff);
+ buff_length= (uint) strlen(buff);
d_length=(uint) (start-to);
if ((start == to ||
(buff_length == d_length && !bcmp(buff,start,d_length))) &&
*start != FN_LIBCHAR && *start)
{ /* Put current dir before */
- bchange(to,d_length,buff,buff_length,strlen(to)+1);
+ bchange(to,d_length,buff,buff_length,(uint) strlen(to)+1);
}
}
@@ -54,7 +54,7 @@ void pack_dirname(my_string to, const char *from)
length=0;
if (home_dir)
{
- length=strlen(home_dir);
+ length= (uint) strlen(home_dir);
if (home_dir[length-1] == FN_LIBCHAR)
length--; /* Don't test last '/' */
}
@@ -78,7 +78,7 @@ void pack_dirname(my_string to, const char *from)
}
if (is_prefix(to,buff))
{
- length=strlen(buff);
+ length= (uint) strlen(buff);
if (to[length])
(void) strmov_overlapp(to,to+length); /* Remove everything before */
else
@@ -198,6 +198,44 @@ uint cleanup_dirname(register my_string to, const char *from)
} /* cleanup_dirname */
+ /*
+ On system where you don't have symbolic links, the following
+ code will allow you to create a file:
+ directory-name.lnk that should contain the real path
+ to the directory. This will be used if the directory name
+ doesn't exists
+ */
+
+
+my_bool my_use_symdir=0; /* Set this if you want to use symdirs */
+
+#ifdef USE_SYMDIR
+void symdirget(char *dir)
+{
+ char buff[FN_REFLEN];
+ char *pos=strend(dir);
+ if (dir[0] && pos[-1] != FN_DEVCHAR && access(dir, F_OK))
+ {
+ FILE *fp;
+ char temp= *(--pos); /* May be "/" or "\" */
+ strmov(pos,".sym");
+ fp = my_fopen(dir, O_RDONLY,MYF(0));
+ *pos++=temp; *pos=0; /* Restore old filename */
+ if (fp)
+ {
+ if (fgets(buff, sizeof(buff), fp))
+ {
+ for (pos=strend(buff);
+ pos > buff && (iscntrl(pos[-1]) || isspace(pos[-1])) ;
+ pos --);
+ strmake(dir,buff, (uint) (pos-buff));
+ }
+ my_fclose(fp,MYF(0));
+ }
+ }
+}
+#endif /* USE_SYMDIR */
+
/* Unpacks dirname to name that can be used by open... */
/* Make that last char of to is '/' if from not empty and
from doesn't end in FN_DEVCHAR */
@@ -209,11 +247,11 @@ uint unpack_dirname(my_string to, const char *from)
/* to may be == from */
{
uint length,h_length;
- char buff[FN_REFLEN+1],*suffix,*tilde_expansion;
+ char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion;
DBUG_ENTER("unpack_dirname");
(void) intern_filename(buff,from); /* Change to intern name */
- length=strlen(buff); /* Fix that '/' is last */
+ length= (uint) strlen(buff); /* Fix that '/' is last */
if (length &&
#ifdef FN_DEVCHAR
buff[length-1] != FN_DEVCHAR &&
@@ -231,7 +269,7 @@ uint unpack_dirname(my_string to, const char *from)
if (tilde_expansion)
{
length-=(uint) (suffix-buff)-1;
- if (length+(h_length=strlen(tilde_expansion)) <= FN_REFLEN)
+ if (length+(h_length= (uint) strlen(tilde_expansion)) <= FN_REFLEN)
{
if (tilde_expansion[h_length-1] == FN_LIBCHAR)
h_length--;
@@ -243,6 +281,10 @@ uint unpack_dirname(my_string to, const char *from)
}
}
}
+#ifdef USE_SYMDIR
+ if (my_use_symdir)
+ symdirget(buff);
+#endif
DBUG_RETURN(system_filename(to,buff)); /* Fix for open */
} /* unpack_dirname */
diff --git a/ext/mysql/libmysql/mf_path.c b/ext/mysql/libmysql/mf_path.c
index c51a79e238..cf8aeea889 100644
--- a/ext/mysql/libmysql/mf_path.c
+++ b/ext/mysql/libmysql/mf_path.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include <m_string.h>
@@ -32,7 +32,7 @@ my_string my_path(my_string to, const char *progname,
if (!test_if_hard_path(to))
{
if (!my_getwd(curr_dir,FN_REFLEN,MYF(0)))
- bchange(to,0,curr_dir,strlen(curr_dir),strlen(to)+1);
+ bchange(to,0,curr_dir, (uint) strlen(curr_dir), (uint) strlen(to)+1);
}
}
else
@@ -60,7 +60,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(__WIN32__)
+#if defined(MSDOS) || defined(__WIN__)
#define F_OK 0
#define PATH_SEP ';'
#define PROGRAM_EXTENSION ".exe"
@@ -93,7 +93,7 @@ static char *find_file_in_path(char *to, const char *name)
}
}
}
-#ifdef __WIN32__
+#ifdef __WIN__
to[0]=FN_CURLIB;
strxmov(to+1,dir,name,ext,NullS);
if (!access(to,F_OK)) /* Test in current dir */
diff --git a/ext/mysql/libmysql/mf_unixpath.c b/ext/mysql/libmysql/mf_unixpath.c
index f28bfb3f23..79a99b4323 100644
--- a/ext/mysql/libmysql/mf_unixpath.c
+++ b/ext/mysql/libmysql/mf_unixpath.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include <m_string.h>
diff --git a/ext/mysql/libmysql/mf_wcomp.c b/ext/mysql/libmysql/mf_wcomp.c
index 8c9d43a01c..73e847f1c4 100644
--- a/ext/mysql/libmysql/mf_wcomp.c
+++ b/ext/mysql/libmysql/mf_wcomp.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Funktions for comparing with wild-cards */
diff --git a/ext/mysql/libmysql/mulalloc.c b/ext/mysql/libmysql/mulalloc.c
index 88cfd33ef5..793858afd4 100644
--- a/ext/mysql/libmysql/mulalloc.c
+++ b/ext/mysql/libmysql/mulalloc.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Malloc many pointers at the same time */
/* format myFlags,ptr,length,ptr,length ... until null ptr */
diff --git a/ext/mysql/libmysql/my_alarm.h b/ext/mysql/libmysql/my_alarm.h
index 42e41cc48f..b0fc91d74f 100644
--- a/ext/mysql/libmysql/my_alarm.h
+++ b/ext/mysql/libmysql/my_alarm.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
File to include when we want to use alarm or a loop_counter to display
diff --git a/ext/mysql/libmysql/my_alloc.c b/ext/mysql/libmysql/my_alloc.c
index 4dec9115d9..5ac2d69ffd 100644
--- a/ext/mysql/libmysql/my_alloc.c
+++ b/ext/mysql/libmysql/my_alloc.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Routines to handle mallocing of results which will be freed the same time */
@@ -98,7 +98,7 @@ void free_root(MEM_ROOT *root)
char *strdup_root(MEM_ROOT *root,const char *str)
{
- uint len=strlen(str)+1;
+ uint len= (uint) strlen(str)+1;
char *pos;
if ((pos=alloc_root(root,len)))
memcpy(pos,str,len);
diff --git a/ext/mysql/libmysql/my_compress.c b/ext/mysql/libmysql/my_compress.c
index 79d4d2963d..3aa7ba9491 100644
--- a/ext/mysql/libmysql/my_compress.c
+++ b/ext/mysql/libmysql/my_compress.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Written by Sinisa Milivojevic <sinisa@coresinc.com> */
diff --git a/ext/mysql/libmysql/my_config.h b/ext/mysql/libmysql/my_config.h
index f1038d825a..ba354523f8 100644
--- a/ext/mysql/libmysql/my_config.h
+++ b/ext/mysql/libmysql/my_config.h
@@ -1 +1,11 @@
-#include "php_config.h"
+#include <php_config.h>
+
+/* PHP might define ulong, but we want to use our own typedef */
+#ifdef ulong
+#undef ulong
+#endif
+
+/* The client doesn't use multiple charsets, so only the compiled-in
+ default is really needed */
+#define SHAREDIR "NONEXISTENT"
+#define DEFAULT_CHARSET_HOME SHAREDIR
diff --git a/ext/mysql/libmysql/my_create.c b/ext/mysql/libmysql/my_create.c
index d227140b09..f1d1e6f2fb 100644
--- a/ext/mysql/libmysql/my_create.c
+++ b/ext/mysql/libmysql/my_create.c
@@ -1,12 +1,12 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#define USES_TYPES
#include "mysys_priv.h"
#include <my_dir.h>
#include "mysys_err.h"
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN32__)
+#if defined(MSDOS) || defined(__WIN__)
#include <share.h>
#endif
@@ -34,7 +34,7 @@ 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) || defined(__WIN32__)
+#elif defined(MSDOS) || defined(__WIN__)
if (access_flags & O_SHARE)
fd = sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY,
SH_DENYNO, MY_S_IREAD | MY_S_IWRITE);
@@ -48,11 +48,15 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
if (fd >= 0)
{
if ((int) fd >= MY_NFILE)
+ {
+ DBUG_PRINT("exit",("fd: %d",fd));
DBUG_RETURN(fd); /* safeguard */
+ }
if ((my_file_info[fd].name = (char*) my_strdup(FileName,MyFlags)))
{
my_file_opened++;
my_file_info[fd].type = FILE_BY_CREATE;
+ DBUG_PRINT("exit",("fd: %d",fd));
DBUG_RETURN(fd);
}
VOID(my_close(fd,MyFlags));
diff --git a/ext/mysql/libmysql/my_delete.c b/ext/mysql/libmysql/my_delete.c
index b29631b90a..f1ffada90f 100644
--- a/ext/mysql/libmysql/my_delete.c
+++ b/ext/mysql/libmysql/my_delete.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
diff --git a/ext/mysql/libmysql/my_dir.h b/ext/mysql/libmysql/my_dir.h
index 0fdd5a148e..e0c79dadfe 100644
--- a/ext/mysql/libmysql/my_dir.h
+++ b/ext/mysql/libmysql/my_dir.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#ifndef _my_dir_h
#define _my_dir_h
@@ -76,6 +76,7 @@ typedef struct st_my_dir /* Struct returned from my_dir */
extern MY_DIR *my_dir(const char *path,myf MyFlags);
extern void my_dirend(MY_DIR *buffer);
extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags);
+extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags);
#endif /* MY_DIR_H */
diff --git a/ext/mysql/libmysql/my_div.c b/ext/mysql/libmysql/my_div.c
index 9650b28136..fc3ad59b4a 100644
--- a/ext/mysql/libmysql/my_div.c
+++ b/ext/mysql/libmysql/my_div.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
diff --git a/ext/mysql/libmysql/my_error.c b/ext/mysql/libmysql/my_error.c
index aeef85dbd4..78c2bb2a74 100644
--- a/ext/mysql/libmysql/my_error.c
+++ b/ext/mysql/libmysql/my_error.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include "mysys_err.h"
@@ -39,6 +39,7 @@ int my_error(int nr,myf MyFlags, ...)
if (tpos[0] != '%')
{
*endpos++= *tpos++; /* Copy ordinary char */
+ olen++;
continue;
}
if (*++tpos == '%') /* test if %% */
@@ -66,8 +67,10 @@ int my_error(int nr,myf MyFlags, ...)
{
register int iarg;
iarg = va_arg(ap, int);
- plen= (uint) (int2str((long) iarg,endpos,*tpos == 'd' ? -10 : 10)-
- endpos);
+ if (*tpos == 'd')
+ plen= (uint) (int2str((long) iarg,endpos, -10) - endpos);
+ else
+ plen= (uint) (int2str((long) (uint) iarg,endpos,10)- endpos);
if (olen + plen < ERRMSGSIZE+2) /* Replace parameter if possible */
{
endpos+=plen;
diff --git a/ext/mysql/libmysql/my_fopen.c b/ext/mysql/libmysql/my_fopen.c
index f22f492b4f..4930572e3f 100644
--- a/ext/mysql/libmysql/my_fopen.c
+++ b/ext/mysql/libmysql/my_fopen.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include "my_static.h"
@@ -49,7 +49,8 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags)
my_errno=errno;
DBUG_PRINT("error",("Got error %d on open",my_errno));
if (MyFlags & (MY_FFNF | MY_FAE | MY_WME))
- my_error(Flags & O_RDONLY ? EE_FILENOTFOUND : EE_CANTCREATEFILE,
+ my_error((Flags & O_RDONLY) || (Flags == O_RDONLY ) ? EE_FILENOTFOUND :
+ EE_CANTCREATEFILE,
MYF(ME_BELL+ME_WAITTANG), FileName,my_errno);
DBUG_RETURN((FILE*) 0);
} /* my_fopen */
diff --git a/ext/mysql/libmysql/my_getwd.c b/ext/mysql/libmysql/my_getwd.c
index 0267a3eaa6..99ce4b9e0a 100644
--- a/ext/mysql/libmysql/my_getwd.c
+++ b/ext/mysql/libmysql/my_getwd.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* my_setwd() and my_getwd() works with intern_filenames !! */
@@ -9,7 +9,7 @@
#ifdef HAVE_GETWD
#include <sys/param.h>
#endif
-#if defined(MSDOS) || defined(__WIN32__)
+#if defined(MSDOS) || defined(__WIN__)
#include <m_ctype.h>
#include <dos.h>
#include <direct.h>
diff --git a/ext/mysql/libmysql/my_init.c b/ext/mysql/libmysql/my_init.c
index db45d991d3..4955ae8090 100644
--- a/ext/mysql/libmysql/my_init.c
+++ b/ext/mysql/libmysql/my_init.c
@@ -1,10 +1,12 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include "my_static.h"
#include "mysys_err.h"
+#include "m_ctype.h"
#include <m_string.h>
+#include <m_ctype.h>
#ifdef THREAD
#include <my_pthread.h>
#endif
@@ -17,7 +19,7 @@
#include <my_static.c>
#include <m_ctype.h>
#endif
-#ifdef __WIN32__
+#ifdef __WIN__
#ifdef _MSC_VER
#include <locale.h>
#include <crtdbg.h>
@@ -44,7 +46,7 @@ void my_init(void)
pthread_init(); /* Must be called before DBUG_ENTER */
#endif
my_thread_global_init();
-#ifndef __WIN32__
+#ifndef __WIN__
sigfillset(&my_signals); /* signals blocked by mf_brkhant */
#endif
#endif
@@ -59,13 +61,15 @@ void my_init(void)
#ifndef VMS
if ((str=getenv("UMASK")) != 0)
my_umask=atoi(str) | 0600; /* Default creation of new files */
+ if ((str=getenv("UMASK_DIR")) != 0)
+ my_umask_dir=atoi(str) | 0700; /* Default creation of new dir's */
#endif
#ifdef VMS
init_ctype(); /* Stupid linker don't link _ctype.c */
#endif
DBUG_PRINT("exit",("home: '%s'",home_dir));
}
-#ifdef __WIN32__
+#ifdef __WIN__
win32_init_tcp_ip();
#endif
DBUG_VOID_RETURN;
@@ -94,7 +98,7 @@ void my_end(int infoflag)
#ifdef HAVE_GETRUSAGE
struct rusage rus;
if (!getrusage(RUSAGE_SELF, &rus))
- fprintf(info_file,"\nUser time %.2f, System time %.2f\nMaximum resident set size %d, Integral resident set size %d\nNon physical pagefaults %d, Physical pagefaults %d, Swaps %d\nBlocks in %d out %d, Messages in %d out %d, Signals %d\nVouluntary context switches %d, Invouluntary context switches %d\n",
+ fprintf(info_file,"\nUser time %.2f, System time %.2f\nMaximum resident set size %ld, Integral resident set size %ld\nNon physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\nBlocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\nVouluntary context switches %ld, Invouluntary context switches %ld\n",
(rus.ru_utime.tv_sec * SCALE_SEC +
rus.ru_utime.tv_usec / SCALE_USEC) / 100.0,
(rus.ru_stime.tv_sec * SCALE_SEC +
@@ -105,12 +109,13 @@ void my_end(int infoflag)
rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals,
rus.ru_nvcsw, rus.ru_nivcsw);
#endif
-#if defined(MSDOS) && !defined(__WIN32__)
+#if defined(MSDOS) && !defined(__WIN__)
fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC);
#endif
+ free_charsets();
#if defined(SAFEMALLOC)
TERMINATE(stderr); /* Give statistic on screen */
-#elif defined(__WIN32__) && defined(_MSC_VER)
+#elif defined(__WIN__) && defined(_MSC_VER)
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
@@ -129,13 +134,13 @@ void my_end(int infoflag)
my_thread_end();
my_thread_global_end();
#endif
-#ifdef __WIN32__
+#ifdef __WIN__
if (have_tcpip);
WSACleanup( );
-#endif /* __WIN32__ */
+#endif /* __WIN__ */
} /* my_end */
-#ifdef __WIN32__
+#ifdef __WIN__
/*
This code is specially for running MySQL, but it should work in
diff --git a/ext/mysql/libmysql/my_lib.c b/ext/mysql/libmysql/my_lib.c
new file mode 100644
index 0000000000..764309d120
--- /dev/null
+++ b/ext/mysql/libmysql/my_lib.c
@@ -0,0 +1,597 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
+/* TODO: check for overun of memory for names. */
+/* Convert MSDOS-TIME to standar time_t */
+
+#define USES_TYPES /* sys/types is included */
+#include "mysys_priv.h"
+#include <m_string.h>
+#include <my_dir.h> /* Structs used by my_dir,includes sys/types */
+#include "mysys_err.h"
+#if defined(HAVE_DIRENT_H)
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# if defined(HAVE_SYS_NDIR_H)
+# include <sys/ndir.h>
+# endif
+# if defined(HAVE_SYS_DIR_H)
+# include <sys/dir.h>
+# endif
+# if defined(HAVE_NDIR_H)
+# include <ndir.h>
+# endif
+# if defined(MSDOS) || defined(__WIN__)
+# include <dos.h>
+# ifdef __BORLANDC__
+# include <dir.h>
+# endif
+# endif
+#endif
+#ifdef VMS
+#include <rms.h>
+#include <iodef.h>
+#include <descrip.h>
+#endif
+#if defined(THREAD) && defined(HAVE_READDIR_R)
+#define READDIR(A,B,C) ((errno=readdir_r(A,B,&C)) != 0 || !C)
+#else
+#define READDIR(A,B,C) (!(C=readdir(A)))
+#endif
+
+
+#define STARTSIZE ONCE_ALLOC_INIT*8 /* some mallocmargin */
+
+static int comp_names(struct fileinfo *a,struct fileinfo *b);
+
+
+ /* We need this because program don't know with malloc we used */
+
+void my_dirend(MY_DIR *buffer)
+{
+ DBUG_ENTER("my_dirend");
+ if (buffer)
+ my_free((gptr) buffer,MYF(0));
+ DBUG_VOID_RETURN;
+} /* my_dirend */
+
+
+ /* Compare in sort of filenames */
+
+static int comp_names(struct fileinfo *a, struct fileinfo *b)
+{
+ return (strcmp(a->name,b->name));
+} /* comp_names */
+
+
+#if !defined(MSDOS) && !defined(__WIN__)
+
+MY_DIR *my_dir(const char *path, myf MyFlags)
+{
+ DIR *dirp;
+ struct dirent *dp;
+ struct fileinfo *fnames;
+ char *buffer, *obuffer, *tempptr;
+ uint fcnt,i,size,firstfcnt, maxfcnt,length;
+ char tmp_path[FN_REFLEN+1],*tmp_file;
+ my_ptrdiff_t diff;
+ bool eof;
+#ifdef THREAD
+ char dirent_tmp[sizeof(struct dirent)+_POSIX_PATH_MAX+1];
+#endif
+ DBUG_ENTER("my_dir");
+ DBUG_PRINT("my",("path: '%s' stat: %d MyFlags: %d",path,MyFlags));
+
+#if defined(THREAD) && !defined(HAVE_READDIR_R)
+ pthread_mutex_lock(&THR_LOCK_open);
+#endif
+
+ dirp = opendir(directory_file_name(tmp_path,(my_string) path));
+ size = STARTSIZE;
+ if (dirp == NULL || ! (buffer = (char *) my_malloc(size, MyFlags)))
+ goto error;
+
+ fcnt = 0;
+ tmp_file=strend(tmp_path);
+ firstfcnt = maxfcnt = (size - sizeof(MY_DIR)) /
+ (sizeof(struct fileinfo) + FN_LEN);
+ fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR));
+ tempptr = (char *) (fnames + maxfcnt);
+
+#ifdef THREAD
+ dp= (struct dirent*) dirent_tmp;
+#else
+ dp=0;
+#endif
+ eof=0;
+ for (;;)
+ {
+ while (fcnt < maxfcnt &&
+ !(eof= READDIR(dirp,(struct dirent*) dirent_tmp,dp)))
+ {
+ bzero((gptr) (fnames+fcnt),sizeof(fnames[0])); /* for purify */
+ fnames[fcnt].name = tempptr;
+ tempptr = strmov(tempptr,dp->d_name) + 1;
+ if (MyFlags & MY_WANT_STAT)
+ {
+ VOID(strmov(tmp_file,dp->d_name));
+ VOID(my_stat(tmp_path, &fnames[fcnt].mystat, MyFlags));
+ }
+ ++fcnt;
+ }
+ if (eof)
+ break;
+ size += STARTSIZE; obuffer = buffer;
+ if (!(buffer = (char *) my_realloc((gptr) buffer, size,
+ MyFlags | MY_FREE_ON_ERROR)))
+ goto error; /* No memory */
+ length= (uint) (sizeof(struct fileinfo ) * firstfcnt);
+ diff= PTR_BYTE_DIFF(buffer , obuffer) + (int) length;
+ fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR));
+ tempptr= ADD_TO_PTR(tempptr,diff,char*);
+ for (i = 0; i < maxfcnt; i++)
+ fnames[i].name = ADD_TO_PTR(fnames[i].name,diff,char*);
+
+ /* move filenames upp a bit */
+ maxfcnt += firstfcnt;
+ bmove_upp(tempptr,tempptr-length,
+ (uint) (tempptr- (char*) (fnames+maxfcnt)));
+ }
+
+ (void) closedir(dirp);
+ {
+ MY_DIR * s = (MY_DIR *) buffer;
+ s->number_off_files = (uint) fcnt;
+ s->dir_entry = fnames;
+ }
+ if (!(MyFlags & MY_DONT_SORT))
+ qsort((void *) fnames, (size_s) fcnt, sizeof(struct fileinfo),
+ (qsort_cmp) comp_names);
+#if defined(THREAD) && !defined(HAVE_READDIR_R)
+ pthread_mutex_unlock(&THR_LOCK_open);
+#endif
+ DBUG_RETURN((MY_DIR *) buffer);
+
+ error:
+#if defined(THREAD) && !defined(HAVE_READDIR_R)
+ pthread_mutex_unlock(&THR_LOCK_open);
+#endif
+ my_errno=errno;
+ if (dirp)
+ (void) closedir(dirp);
+ if (MyFlags & (MY_FAE+MY_WME))
+ my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,my_errno);
+ DBUG_RETURN((MY_DIR *) NULL);
+} /* my_dir */
+
+
+/*
+ * Convert from directory name to filename.
+ * On VMS:
+ * xyzzy:[mukesh.emacs] => xyzzy:[mukesh]emacs.dir.1
+ * xyzzy:[mukesh] => xyzzy:[000000]mukesh.dir.1
+ * On UNIX, it's simple: just make sure there is a terminating /
+
+ * Returns pointer to dst;
+ */
+
+my_string directory_file_name (my_string dst, const char *src)
+{
+#ifndef VMS
+
+ /* Process as Unix format: just remove test the final slash. */
+
+ my_string end;
+
+ if (src[0] == 0)
+ src= (char*) "."; /* Use empty as current */
+ end=strmov(dst, src);
+ if (end[-1] != FN_LIBCHAR)
+ {
+ end[0]=FN_LIBCHAR; /* Add last '/' */
+ end[1]='\0';
+ }
+ return dst;
+
+#else /* VMS */
+
+ long slen;
+ long rlen;
+ my_string ptr, rptr;
+ char bracket;
+ struct FAB fab = cc$rms_fab;
+ struct NAM nam = cc$rms_nam;
+ char esa[NAM$C_MAXRSS];
+
+ if (! src[0])
+ src="[.]"; /* Empty is == current dir */
+
+ slen = strlen (src) - 1;
+ if (src[slen] == FN_C_AFTER_DIR || src[slen] == FN_C_AFTER_DIR_2 ||
+ src[slen] == FN_DEVCHAR)
+ {
+ /* VMS style - convert [x.y.z] to [x.y]z, [x] to [000000]x */
+ fab.fab$l_fna = src;
+ fab.fab$b_fns = slen + 1;
+ fab.fab$l_nam = &nam;
+ fab.fab$l_fop = FAB$M_NAM;
+
+ nam.nam$l_esa = esa;
+ nam.nam$b_ess = sizeof esa;
+ nam.nam$b_nop |= NAM$M_SYNCHK;
+
+ /* We call SYS$PARSE to handle such things as [--] for us. */
+ if (SYS$PARSE(&fab, 0, 0) == RMS$_NORMAL)
+ {
+ slen = nam.nam$b_esl - 1;
+ if (esa[slen] == ';' && esa[slen - 1] == '.')
+ slen -= 2;
+ esa[slen + 1] = '\0';
+ src = esa;
+ }
+ if (src[slen] != FN_C_AFTER_DIR && src[slen] != FN_C_AFTER_DIR_2)
+ {
+ /* what about when we have logical_name:???? */
+ if (src[slen] == FN_DEVCHAR)
+ { /* Xlate logical name and see what we get */
+ VOID(strmov(dst,src));
+ dst[slen] = 0; /* remove colon */
+ if (!(src = getenv (dst)))
+ return dst; /* Can't translate */
+
+ /* should we jump to the beginning of this procedure?
+ Good points: allows us to use logical names that xlate
+ to Unix names,
+ Bad points: can be a problem if we just translated to a device
+ name...
+ For now, I'll punt and always expect VMS names, and hope for
+ the best! */
+
+ slen = strlen (src) - 1;
+ if (src[slen] != FN_C_AFTER_DIR && src[slen] != FN_C_AFTER_DIR_2)
+ { /* no recursion here! */
+ VOID(strmov(dst, src));
+ return(dst);
+ }
+ }
+ else
+ { /* not a directory spec */
+ VOID(strmov(dst, src));
+ return(dst);
+ }
+ }
+
+ bracket = src[slen]; /* End char */
+ if (!(ptr = strchr (src, bracket - 2)))
+ { /* no opening bracket */
+ VOID(strmov (dst, src));
+ return dst;
+ }
+ if (!(rptr = strrchr (src, '.')))
+ rptr = ptr;
+ slen = rptr - src;
+ VOID(strmake (dst, src, slen));
+
+ if (*rptr == '.')
+ { /* Put bracket and add */
+ dst[slen++] = bracket; /* (rptr+1) after this */
+ }
+ else
+ {
+ /* If we have the top-level of a rooted directory (i.e. xx:[000000]),
+ then translate the device and recurse. */
+
+ if (dst[slen - 1] == ':'
+ && dst[slen - 2] != ':' /* skip decnet nodes */
+ && strcmp(src + slen, "[000000]") == 0)
+ {
+ dst[slen - 1] = '\0';
+ if ((ptr = getenv (dst))
+ && (rlen = strlen (ptr) - 1) > 0
+ && (ptr[rlen] == FN_C_AFTER_DIR || ptr[rlen] == FN_C_AFTER_DIR_2)
+ && ptr[rlen - 1] == '.')
+ {
+ VOID(strmov(esa,ptr));
+ esa[rlen - 1] = FN_C_AFTER_DIR;
+ esa[rlen] = '\0';
+ return (directory_file_name (dst, esa));
+ }
+ else
+ dst[slen - 1] = ':';
+ }
+ VOID(strmov(dst+slen,"[000000]"));
+ slen += 8;
+ }
+ VOID(strmov(strmov(dst+slen,rptr+1)-1,".DIR.1"));
+ return dst;
+ }
+ VOID(strmov(dst, src));
+ if (dst[slen] == '/' && slen > 1)
+ dst[slen] = 0;
+ return dst;
+#endif /* VMS */
+} /* directory_file_name */
+
+#elif defined(WIN32)
+
+/*
+*****************************************************************************
+** Read long filename using windows rutines
+*****************************************************************************
+*/
+
+MY_DIR *my_dir(path, MyFlags)
+const char *path;
+myf MyFlags;
+{
+ struct fileinfo *fnames;
+ char *buffer, *obuffer, *tempptr;
+ int eof,i,fcnt,firstfcnt,length,maxfcnt;
+ uint size;
+#ifdef __BORLANDC__
+ struct ffblk find;
+#else
+ struct _finddata_t find;
+#endif
+ ushort mode;
+ char tmp_path[FN_REFLEN],*tmp_file,attrib;
+ my_ptrdiff_t diff;
+#ifdef _WIN64
+ __int64 handle;
+#else
+ long handle;
+#endif
+ 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';
+
+#ifdef __BORLANDC__
+ if ((handle= findfirst(tmp_path,&find,0)) == -1L)
+ goto error;
+#else
+ if ((handle=_findfirst(tmp_path,&find)) == -1L)
+ goto error;
+#endif
+
+ size = STARTSIZE;
+ firstfcnt = maxfcnt = (size - sizeof(MY_DIR)) /
+ (sizeof(struct fileinfo) + FN_LEN);
+ if ((buffer = (char *) my_malloc(size, MyFlags)) == 0)
+ goto error;
+ fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR));
+ tempptr = (char *) (fnames + maxfcnt);
+
+ fcnt = 0;
+ for (;;)
+ {
+ do
+ {
+ fnames[fcnt].name = tempptr;
+#ifdef __BORLANDC__
+ tempptr = strmov(tempptr,find.ff_name) + 1;
+ fnames[fcnt].mystat.st_size=find.ff_fsize;
+ fnames[fcnt].mystat.st_uid=fnames[fcnt].mystat.st_gid=0;
+ mode=MY_S_IREAD; attrib=find.ff_attrib;
+#else
+ tempptr = strmov(tempptr,find.name) + 1;
+ fnames[fcnt].mystat.st_size=find.size;
+ fnames[fcnt].mystat.st_uid=fnames[fcnt].mystat.st_gid=0;
+ mode=MY_S_IREAD; attrib=find.attrib;
+#endif
+ if (!(attrib & _A_RDONLY))
+ mode|=MY_S_IWRITE;
+ if (attrib & _A_SUBDIR)
+ mode|=MY_S_IFDIR;
+ fnames[fcnt].mystat.st_mode=mode;
+#ifdef __BORLANDC__
+ fnames[fcnt].mystat.st_mtime=((uint32) find.ff_ftime);
+#else
+ fnames[fcnt].mystat.st_mtime=((uint32) find.time_write);
+#endif
+ ++fcnt;
+#ifdef __BORLANDC__
+ } while ((eof= findnext(&find)) == 0 && fcnt < maxfcnt);
+#else
+ } while ((eof= _findnext(handle,&find)) == 0 && fcnt < maxfcnt);
+#endif
+
+ DBUG_PRINT("test",("eof: %d errno: %d",eof,errno));
+ if (eof)
+ break;
+ size += STARTSIZE; obuffer = buffer;
+ if (!(buffer = (char *) my_realloc((gptr) buffer, size,
+ MyFlags | MY_FREE_ON_ERROR)))
+ goto error;
+ length= sizeof(struct fileinfo ) * firstfcnt;
+ diff= PTR_BYTE_DIFF(buffer , obuffer) +length;
+ fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR));
+ tempptr= ADD_TO_PTR(tempptr,diff,char*);
+ for (i = 0; i < maxfcnt; i++)
+ fnames[i].name = ADD_TO_PTR(fnames[i].name,diff,char*);
+
+ /* move filenames upp a bit */
+ maxfcnt += firstfcnt;
+ bmove_upp(tempptr,ADD_TO_PTR(tempptr,-length,char*),
+ (int) PTR_BYTE_DIFF(tempptr,fnames+maxfcnt));
+ }
+ {
+ MY_DIR * s = (MY_DIR *) buffer;
+ s->number_off_files = (uint) fcnt;
+ s->dir_entry = fnames;
+ }
+ if (!(MyFlags & MY_DONT_SORT))
+ qsort(fnames,fcnt,sizeof(struct fileinfo),(qsort_cmp) comp_names);
+#ifndef __BORLANDC__
+ _findclose(handle);
+#endif
+ DBUG_RETURN((MY_DIR *) buffer);
+
+error:
+ my_errno=errno;
+#ifndef __BORLANDC__
+ if (handle != -1)
+ _findclose(handle);
+#endif
+ if (MyFlags & MY_FAE+MY_WME)
+ my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,errno);
+ 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(path, MyFlags)
+const char *path;
+myf MyFlags;
+{
+ struct fileinfo *fnames;
+ char *buffer, *obuffer, *tempptr;
+ int eof,i,fcnt,firstfcnt,length,maxfcnt;
+ uint size;
+ struct find_t find;
+ ushort mode;
+ char tmp_path[FN_REFLEN],*tmp_file,attrib;
+ my_ptrdiff_t diff;
+ 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;
+
+ size = STARTSIZE;
+ firstfcnt = maxfcnt = (size - sizeof(MY_DIR)) /
+ (sizeof(struct fileinfo) + FN_LEN);
+ if ((buffer = (char *) my_malloc(size, MyFlags)) == 0)
+ goto error;
+ fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR));
+ tempptr = (char *) (fnames + maxfcnt);
+
+ fcnt = 0;
+ for (;;)
+ {
+ do
+ {
+ fnames[fcnt].name = tempptr;
+ tempptr = strmov(tempptr,find.name) + 1;
+ fnames[fcnt].mystat.st_size=find.size;
+ fnames[fcnt].mystat.st_uid=fnames[fcnt].mystat.st_gid=0;
+ mode=MY_S_IREAD; attrib=find.attrib;
+ if (!(attrib & _A_RDONLY))
+ mode|=MY_S_IWRITE;
+ if (attrib & _A_SUBDIR)
+ mode|=MY_S_IFDIR;
+ fnames[fcnt].mystat.st_mode=mode;
+ fnames[fcnt].mystat.st_mtime=((uint32) find.wr_date << 16) +
+ find.wr_time;
+ ++fcnt;
+ } while ((eof= _dos_findnext(&find)) == 0 && fcnt < maxfcnt);
+
+ DBUG_PRINT("test",("eof: %d errno: %d",eof,errno));
+ if (eof)
+ break;
+ size += STARTSIZE; obuffer = buffer;
+ if (!(buffer = (char *) my_realloc((gptr) buffer, size,
+ MyFlags | MY_FREE_ON_ERROR)))
+ goto error;
+ length= sizeof(struct fileinfo ) * firstfcnt;
+ diff= PTR_BYTE_DIFF(buffer , obuffer) +length;
+ fnames= (struct fileinfo *) (buffer + sizeof(MY_DIR));
+ tempptr= ADD_TO_PTR(tempptr,diff,char*);
+ for (i = 0; i < maxfcnt; i++)
+ fnames[i].name = ADD_TO_PTR(fnames[i].name,diff,char*);
+
+ /* move filenames upp a bit */
+ maxfcnt += firstfcnt;
+ bmove_upp(tempptr,ADD_TO_PTR(tempptr,-length,char*),
+ (int) PTR_BYTE_DIFF(tempptr,fnames+maxfcnt));
+ }
+ {
+ MY_DIR * s = (MY_DIR *) buffer;
+ s->number_off_files = (uint) fcnt;
+ s->dir_entry = fnames;
+ }
+ if (!(MyFlags & MY_DONT_SORT))
+ qsort(fnames,fcnt,sizeof(struct fileinfo),(qsort_cmp) comp_names);
+ DBUG_RETURN((MY_DIR *) buffer);
+
+error:
+ 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 */
+
+/****************************************************************************
+** File status
+** Note that MY_STAT is assumed to be same as struct stat
+****************************************************************************/
+
+int my_fstat(int Filedes, MY_STAT *stat_area, myf MyFlags )
+{
+ DBUG_ENTER("my_fstat");
+ DBUG_PRINT("my",("fd: %d MyFlags: %d",Filedes,MyFlags));
+ DBUG_RETURN(fstat(Filedes, (struct stat *) stat_area));
+}
+
+MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
+{
+ int m_used;
+ DBUG_ENTER("my_stat");
+ DBUG_PRINT("my", ("path: '%s', stat_area: %lx, MyFlags: %d", path,
+ (byte *) stat_area, my_flags));
+
+ if ((m_used= (stat_area == NULL)))
+ if (!(stat_area = (MY_STAT *) my_malloc(sizeof(MY_STAT), my_flags)))
+ goto error;
+ if ( ! stat((my_string) path, (struct stat *) stat_area) )
+ DBUG_RETURN(stat_area);
+ my_errno=errno;
+ if (m_used) /* Free if new area */
+ my_free((gptr) stat_area,MYF(0));
+
+error:
+ if (my_flags & (MY_FAE+MY_WME))
+ {
+ my_error(EE_STAT, MYF(ME_BELL+ME_WAITTANG),path,my_errno);
+ DBUG_RETURN((MY_STAT *) NULL);
+ }
+ DBUG_RETURN((MY_STAT *) NULL);
+} /* my_stat */
+
diff --git a/ext/mysql/libmysql/my_list.h b/ext/mysql/libmysql/my_list.h
index d5a28ac139..46a6a8f65f 100644
--- a/ext/mysql/libmysql/my_list.h
+++ b/ext/mysql/libmysql/my_list.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#ifndef _list_h_
#define _list_h_
diff --git a/ext/mysql/libmysql/my_malloc.c b/ext/mysql/libmysql/my_malloc.c
index ca44ae4f64..46c874aa66 100644
--- a/ext/mysql/libmysql/my_malloc.c
+++ b/ext/mysql/libmysql/my_malloc.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */
#undef SAFEMALLOC
diff --git a/ext/mysql/libmysql/my_messnc.c b/ext/mysql/libmysql/my_messnc.c
index 96d90af343..48ed852f39 100644
--- a/ext/mysql/libmysql/my_messnc.c
+++ b/ext/mysql/libmysql/my_messnc.c
@@ -1,9 +1,9 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
-int my_message_no_curses(uint my_error __attribute__((unused)),
+int my_message_no_curses(uint error __attribute__((unused)),
const char *str, myf MyFlags)
{
DBUG_ENTER("my_message_no_curses");
diff --git a/ext/mysql/libmysql/my_net.c b/ext/mysql/libmysql/my_net.c
index 9fb47c50f9..6fad295a22 100644
--- a/ext/mysql/libmysql/my_net.c
+++ b/ext/mysql/libmysql/my_net.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 2000 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* thread safe version of some common functions */
@@ -7,12 +7,18 @@
#include <m_string.h>
/* for thread safe my_inet_ntoa */
-#if !defined(MSDOS) && !defined(__WIN32__)
+#if !defined(MSDOS) && !defined(__WIN__)
#include <netdb.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
-#endif
+#endif
+#endif /* !defined(MSDOS) && !defined(__WIN__) */
#ifndef THREAD
#define pthread_mutex_lock(A)
diff --git a/ext/mysql/libmysql/my_net.h b/ext/mysql/libmysql/my_net.h
index ac4af6595b..143ddd9d65 100644
--- a/ext/mysql/libmysql/my_net.h
+++ b/ext/mysql/libmysql/my_net.h
@@ -1,10 +1,19 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
/* thread safe version of some common functions */
/* for thread safe my_inet_ntoa */
-#if !defined(MSDOS) && !defined(__WIN32__)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(__BEOS__)
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
-#endif
+#endif
+#endif /* !defined(MSDOS) && !defined(__WIN__) */
void my_inet_ntoa(struct in_addr in, char *buf);
diff --git a/ext/mysql/libmysql/my_once.c b/ext/mysql/libmysql/my_once.c
index b03f4df529..99aad4d4e7 100644
--- a/ext/mysql/libmysql/my_once.c
+++ b/ext/mysql/libmysql/my_once.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Not MT-SAFE */
diff --git a/ext/mysql/libmysql/my_open.c b/ext/mysql/libmysql/my_open.c
index 10ddb95388..15b5a047d0 100644
--- a/ext/mysql/libmysql/my_open.c
+++ b/ext/mysql/libmysql/my_open.c
@@ -1,11 +1,11 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#define USES_TYPES
#include "mysys_priv.h"
#include "mysys_err.h"
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN32__)
+#if defined(MSDOS) || defined(__WIN__)
#include <share.h>
#endif
@@ -20,7 +20,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(__WIN32__)
+#if defined(MSDOS) || defined(__WIN__)
if (Flags & O_SHARE)
fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO);
else
@@ -72,7 +72,7 @@ int my_close(File fd, myf MyFlags)
if (MyFlags & (MY_FAE | MY_WME))
my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG),my_filename(fd),errno);
}
- if (fd < MY_NFILE && my_file_info[fd].type != UNOPEN)
+ if ((uint) fd < MY_NFILE && my_file_info[fd].type != UNOPEN)
{
my_file_opened--;
my_free(my_file_info[fd].name, MYF(0));
diff --git a/ext/mysql/libmysql/my_pthread.c b/ext/mysql/libmysql/my_pthread.c
index 2110437a16..00ccb30596 100644
--- a/ext/mysql/libmysql/my_pthread.c
+++ b/ext/mysql/libmysql/my_pthread.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Functions to get threads more portable */
@@ -9,7 +9,7 @@
#include <m_string.h>
#include <thr_alarm.h>
#include <assert.h>
-#if !defined(MSDOS) && !defined(__WIN32__)
+#if !defined(MSDOS) && !defined(__WIN__)
#include <netdb.h>
#endif
@@ -86,7 +86,7 @@ int my_pthread_create_detached=1;
#if defined(HAVE_NONPOSIX_SIGWAIT) || defined(HAVE_DEC_3_2_THREADS)
-int my_sigwait(sigset_t *set,int *sig)
+int my_sigwait(const sigset_t *set,int *sig)
{
int signal=sigwait(set);
if (signal < 0)
@@ -107,7 +107,7 @@ struct tm *localtime_r(const time_t *clock, struct tm *res)
struct tm *tmp;
pthread_mutex_lock(&LOCK_localtime_r);
tmp=localtime(clock);
- memcpy(res,tmp,sizeof(*tmp));
+ *res= *tmp;
pthread_mutex_unlock(&LOCK_localtime_r);
return res;
}
@@ -131,7 +131,7 @@ struct tm *localtime_r(const time_t *clock, struct tm *res)
** Author: Gary Wisniewski <garyw@spidereye.com.au>, much modified by Monty
****************************************************************************/
-#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN32__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS)
+#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS)
#if !defined(DONT_USE_SIGSUSPEND)
@@ -151,7 +151,7 @@ void sigwait_setup(sigset_t *set)
sact.sa_flags = 0;
sact.sa_handler = px_handle_sig;
- memcpy(&sact.sa_mask,set,sizeof(*set)); /* handler isn't thread_safe */
+ memcpy_fixed(&sact.sa_mask,set,sizeof(*set)); /* handler isn't thread_safe */
sigemptyset(&unblock_mask);
pthread_sigmask(SIG_UNBLOCK,(sigset_t*) 0,&rev_sigwait_set);
@@ -177,7 +177,7 @@ void sigwait_setup(sigset_t *set)
}
}
}
- memcpy(&sigwait_set,set,sizeof(*set));
+ memcpy_fixed(&sigwait_set,set,sizeof(*set));
pthread_sigmask(SIG_BLOCK,(sigset_t*) set,(sigset_t*) 0);
pthread_sigmask(SIG_UNBLOCK,&unblock_mask,(sigset_t*) 0);
}
@@ -267,7 +267,7 @@ void *sigwait_thread(void *set_arg)
struct sigaction sact;
sact.sa_flags = 0;
sact.sa_handler = sigwait_handle_sig;
- memcpy(&sact.sa_mask,set,sizeof(*set)); /* handler isn't thread_safe */
+ memcpy_fixed(&sact.sa_mask,set,sizeof(*set)); /* handler isn't thread_safe */
sigemptyset(&pending_set);
for (i = 1; i <= sizeof(pending_set)*8; i++)
@@ -306,7 +306,7 @@ int sigwait(sigset_t *setp, int *sigp)
pthread_cond_init(&COND_sigwait,NULL);
pthread_attr_init(&thr_attr);
- pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM);
+ pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize(&thr_attr,8196);
my_pthread_attr_setprio(&thr_attr,100); /* Very high priority */
diff --git a/ext/mysql/libmysql/my_pthread.h b/ext/mysql/libmysql/my_pthread.h
index ad64c59a50..ea167c2a56 100644
--- a/ext/mysql/libmysql/my_pthread.h
+++ b/ext/mysql/libmysql/my_pthread.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1999 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Defines to make different thread packages compatible */
@@ -11,7 +11,7 @@
#define ETIME ETIMEDOUT /* For FreeBSD */
#endif
-#if defined(__WIN32__)
+#if defined(__WIN__)
typedef CRITICAL_SECTION pthread_mutex_t;
typedef HANDLE pthread_t;
@@ -155,7 +155,7 @@ void * my_pthread_getspecific_imp(pthread_key_t key);
#define pthread_sigmask(A,B,C) thr_sigsetmask((A),(B),(C))
-extern int my_sigwait(sigset_t *set,int *sig);
+extern int my_sigwait(const sigset_t *set,int *sig);
#define pthread_detach_this_thread() pthread_dummy(0)
@@ -185,6 +185,9 @@ extern int my_sigwait(sigset_t *set,int *sig);
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
+#ifdef HAVE_SYNCH_H
+#include <synch.h>
+#endif
#if defined(__EMX__) && (!defined(EMX_PTHREAD_REV) || (EMX_PTHREAD_REV < 2))
#error Requires at least rev 2 of EMX pthreads library.
#endif
@@ -211,8 +214,9 @@ typedef struct st_safe_mutex_t
int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr);
int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line);
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line);
-int safe_mutex_destroy(safe_mutex_t *mp);
-int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file, uint line);
+int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line);
+int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file,
+ uint line);
int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
struct timespec *abstime, const char *file, uint line);
@@ -227,7 +231,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
#define pthread_mutex_init(A,B) safe_mutex_init((A),(B))
#define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__)
#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
-#define pthread_mutex_destroy(A) safe_mutex_destroy((A))
+#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__)
#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__)
#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
#define pthread_mutex_t safe_mutex_t
@@ -249,8 +253,11 @@ extern int my_pthread_create_detached;
#define HAVE_LOCALTIME_R
#undef HAVE_PTHREAD_ATTR_SETSCOPE
#define HAVE_PTHREAD_ATTR_SETSCOPE
+#undef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R /* If we are running linux */
#undef HAVE_RWLOCK_T
#undef HAVE_RWLOCK_INIT
+#undef HAVE_PTHREAD_RWLOCK_RDLOCK
+#undef HAVE_SNPRINTF
#define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
#define signal(A,B) pthread_signal((A),(void (*)(int)) (B))
@@ -288,10 +295,16 @@ extern int my_pthread_cond_init(pthread_cond_t *mp,
#endif
#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
-int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
+int sigwait(const sigset_t *setp, int *sigp); /* Use our implemention */
#endif
#if !defined(HAVE_SIGSET) && !defined(HAVE_mit_thread) && !defined(sigset)
-#define sigset(A,B) signal((A),(B))
+#define sigset(A,B) do { struct sigaction s; sigset_t set; \
+ sigemptyset(&set); \
+ s.sa_handler = (B); \
+ s.sa_mask = set; \
+ s.sa_flags = 0; \
+ sigaction((A), &s, (struct sigaction *) NULL); \
+ } while (0)
#endif
#ifndef my_pthread_setprio
@@ -338,6 +351,7 @@ struct tm *localtime_r(const time_t *clock, struct tm *res);
#define pthread_cond_destroy(A) pthread_dummy(0)
#define pthread_mutex_destroy(A) pthread_dummy(0)
#define pthread_attr_delete(A) pthread_dummy(0)
+#define pthread_condattr_delete(A) pthread_dummy(0)
#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
#define pthread_equal(A,B) ((A) == (B))
#define pthread_cond_timedwait(a,b,c) pthread_cond_wait((a),(b))
@@ -385,14 +399,19 @@ struct hostent *my_gethostbyname_r(const char *name,
#endif /* defined(HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R) */
#else
-#define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
+#ifdef HAVE_GETHOSTBYNAME_R_WITH_HOSTENT_DATA
+#define GETHOSTBYNAME_BUFF_SIZE sizeof(hostent_data)
+#define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(hostent_data*) (C))
+#else
#define GETHOSTBYNAME_BUFF_SIZE 2048
+#define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
+#endif /* HAVE_GETHOSTBYNAME_R_WITH_HOSTENT_DATA */
#endif /* defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R) */
-#endif /* defined(__WIN32__) */
+#endif /* defined(__WIN__) */
/* READ-WRITE thread locking */
-#ifndef HAVE_RWLOCK_INIT
+
#if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS)
/* use these defs for simple mutex locking */
#define rw_lock_t pthread_mutex_t
@@ -408,7 +427,13 @@ struct hostent *my_gethostbyname_r(const char *name,
#define rw_wrlock(A) pthread_rwlock_wrlock(A)
#define rw_unlock(A) pthread_rwlock_unlock(A)
#define rwlock_destroy(A) pthread_rwlock_destroy(A)
+#elif defined(HAVE_RWLOCK_INIT)
+#ifdef HAVE_RWLOCK_T /* For example Solaris 2.6-> */
+#define rw_lock_t rwlock_t
+#endif
+#define my_rwlock_init(A,B) rwlock_init((A),USYNC_THREAD,0)
#else
+/* Use our own version of read/write locks */
typedef struct _my_rw_lock_t {
pthread_mutex_t lock; /* lock for structure */
pthread_cond_t readers; /* waiting readers */
@@ -423,18 +448,12 @@ typedef struct _my_rw_lock_t {
#define rw_unlock(A) my_rw_unlock((A))
#define rwlock_destroy(A) my_rwlock_destroy((A))
-extern int my_rwlock_init( rw_lock_t *, void * );
-extern int my_rwlock_destroy( rw_lock_t * );
-extern int my_rw_rdlock( rw_lock_t * );
-extern int my_rw_wrlock( rw_lock_t * );
-extern int my_rw_unlock( rw_lock_t * );
+extern int my_rwlock_init( my_rw_lock_t *, void * );
+extern int my_rwlock_destroy( my_rw_lock_t * );
+extern int my_rw_rdlock( my_rw_lock_t * );
+extern int my_rw_wrlock( my_rw_lock_t * );
+extern int my_rw_unlock( my_rw_lock_t * );
#endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */
-#else
-#ifdef HAVE_RWLOCK_T /* For example Solaris 2.6-> */
-#define rw_lock_t rwlock_t
-#define my_rwlock_init(A,B) rwlock_init((A),USYNC_THREAD,0)
-#endif
-#endif /* HAVE_RWLOCK_INIT */
#define GETHOSTBYADDR_BUFF_SIZE 2048
@@ -477,18 +496,29 @@ extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
#define my_thread_var (_my_thread_var())
#define my_errno my_thread_var->thr_errno
- /* This is only used for not essential statistic */
+ /* statistics_xxx functions are for not essential statistic */
#ifndef thread_safe_increment
-#ifdef SAFE_STATISTICS
+#ifdef HAVE_ATOMIC_ADD
+#define thread_safe_increment(V,L) atomic_add(1,(atomic_t*) &V);
+#define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V);
+#define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V);
+#define statistic_increment(V,L) thread_safe_increment((V),(L))
+#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
+#else
#define thread_safe_increment(V,L) \
pthread_mutex_lock((L)); (V)++; pthread_mutex_unlock((L));
#define thread_safe_add(V,C,L) \
pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
+#define thread_safe_sub(V,C,L) \
+ pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
+#ifdef SAFE_STATISTICS
+#define statistic_increment(V,L) thread_safe_increment((V),(L))
+#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
#else
-#define thread_safe_increment(V,L) (V)++
-#define thread_safe_add(V,C,L) (V)+=(C)
-#endif
+#define statistic_increment(V,L) (V)++
+#define statistic_add(V,C,L) (V)+=(C)
+#endif /* SAFE_STATISTICS */
+#endif /* HAVE_ATOMIC_ADD */
#endif /* thread_safe_increment */
-
#endif /* _my_ptread_h */
diff --git a/ext/mysql/libmysql/my_read.c b/ext/mysql/libmysql/my_read.c
index b112927a3e..3ca5bfb95a 100644
--- a/ext/mysql/libmysql/my_read.c
+++ b/ext/mysql/libmysql/my_read.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include "mysys_err.h"
diff --git a/ext/mysql/libmysql/my_realloc.c b/ext/mysql/libmysql/my_realloc.c
index 1d26140b01..48df8d3651 100644
--- a/ext/mysql/libmysql/my_realloc.c
+++ b/ext/mysql/libmysql/my_realloc.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */
#undef SAFEMALLOC
diff --git a/ext/mysql/libmysql/my_static.c b/ext/mysql/libmysql/my_static.c
index 93c9b15ef1..bbd3ede0a9 100644
--- a/ext/mysql/libmysql/my_static.c
+++ b/ext/mysql/libmysql/my_static.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
Static variables for mysys library. All definied here for easy making of
@@ -17,7 +17,7 @@ my_string home_dir=0,my_progname=0;
char NEAR curr_dir[FN_REFLEN]= {0},
NEAR home_dir_buff[FN_REFLEN]= {0};
uint my_stream_opened=0,my_file_opened=0;
-int NEAR my_umask=0664;
+int NEAR my_umask=0664, NEAR my_umask_dir=0777;
#ifndef THREAD
int NEAR my_errno=0;
#endif
diff --git a/ext/mysql/libmysql/my_static.h b/ext/mysql/libmysql/my_static.h
index 20d43dca55..299a30daab 100644
--- a/ext/mysql/libmysql/my_static.h
+++ b/ext/mysql/libmysql/my_static.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
Static variables for mysys library. All definied here for easy making of
@@ -63,6 +63,6 @@ extern byte *sf_min_adress,*sf_max_adress;
extern uint cNewCount;
extern struct remember *pRememberRoot;
-#if defined(THREAD) && !defined(__WIN32__)
+#if defined(THREAD) && !defined(__WIN__)
extern sigset_t my_signals; /* signals blocked by mf_brkhant */
#endif
diff --git a/ext/mysql/libmysql/my_sys.h b/ext/mysql/libmysql/my_sys.h
index d7cf699521..8079c450ed 100644
--- a/ext/mysql/libmysql/my_sys.h
+++ b/ext/mysql/libmysql/my_sys.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#ifndef _my_sys_h
#define _my_sys_h
@@ -21,6 +21,12 @@ extern int NEAR my_errno; /* Last error in mysys */
#include <my_pthread.h>
#endif
+#ifndef _m_ctype_h
+#include <m_ctype.h> /* for CHARSET_INFO */
+#endif
+
+#include <stdarg.h>
+
#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(); }
@@ -48,6 +54,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */
#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */
#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */
+#define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
#define MY_GIVE_INFO 2 /* Give time info about process*/
@@ -70,10 +77,18 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_SEEK_CUR 1
#define MY_SEEK_END 2
+ /* My charsets_list flags */
+#define MY_NO_SETS 0
+#define MY_COMPILED_SETS 1 /* show compiled-in sets */
+#define MY_CONFIG_SETS 2 /* sets that have a *.conf file */
+#define MY_INDEX_SETS 4 /* all sets listed in the Index file */
+#define MY_LOADED_SETS 8 /* the sets that are currently loaded */
+
/* Some constants */
#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */
#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */
#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */
+#define KEYCACHE_BLOCK_SIZE 1024
/* defines when allocating data */
@@ -136,11 +151,21 @@ extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
myf MyFlags);
+/* charsets */
+extern uint get_charset_number(const char *cs_name);
+extern const char *get_charset_name(uint cs_number);
+extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
+extern my_bool set_default_charset(uint cs, myf flags);
+extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
+extern my_bool set_default_charset_by_name(const char *cs_name, myf flags);
+extern void free_charsets(void);
+extern char *list_charsets(myf want_flags); /* my_free() this string... */
+
/* statisticts */
extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
_my_cache_read;
-extern uint _my_blocks_used,_my_blocks_changed;
+extern ulong _my_blocks_used,_my_blocks_changed;
extern uint my_file_opened,my_stream_opened;
/* Point to current my_message() */
@@ -150,16 +175,18 @@ extern void (*my_sigtstp_cleanup)(void),
(*my_abort_hook)(int);
/* Executed when comming from shell */
extern int NEAR my_umask, /* Default creation mask */
+ NEAR my_umask_dir,
NEAR my_recived_signals, /* Signals we have got */
NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
NEAR my_dont_interrupt; /* call remember_intr when set */
-extern my_bool NEAR mysys_uses_curses;
+extern my_bool NEAR mysys_uses_curses, my_use_symdir;
extern long lCurMemory,lMaxMemory; /* from safemalloc */
extern ulong my_default_record_cache_size;
extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
NEAR my_disable_flush_key_blocks;
extern char wild_many,wild_one,wild_prefix;
+extern const char *charsets_dir;
typedef struct wild_file_pack /* Struct to hold info when selecting files */
{
@@ -170,12 +197,13 @@ typedef struct wild_file_pack /* Struct to hold info when selecting files */
typedef struct st_typelib { /* Different types saved here */
uint count; /* How many types */
- my_string name; /* Name of typelib */
- my_string *type_names;
+ const char *name; /* Name of typelib */
+ const char **type_names;
} TYPELIB;
enum cache_type {READ_CACHE,WRITE_CACHE,READ_NET,WRITE_NET};
-enum flush_type { FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED};
+enum flush_type { FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED,
+ FLUSH_FORCE_WRITE};
typedef struct st_record_cache /* Used when cacheing records */
{
@@ -229,9 +257,11 @@ typedef struct st_io_cache /* Used when cacheing files */
#endif
enum cache_type type;
int (*read_function)(struct st_io_cache *,byte *,uint);
- char *file_name; /* if used with 'open_cacheed_file' */
+ char *file_name; /* if used with 'open_cached_file' */
} IO_CACHE;
+typedef int (*qsort2_cmp)(const void *, const void *, const void *);
+
/* defines for mf_iocache */
/* Test if buffer is inited */
@@ -327,7 +357,7 @@ extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
extern gptr _mymalloc(uint uSize,const char *sFile,
uint uLine, myf MyFlag);
-extern gptr _myrealloc(my_string pPtr,uint uSize,const char *sFile,
+extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile,
uint uLine, myf MyFlag);
extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
@@ -348,6 +378,9 @@ extern int my_error _VARARGS((int nr,myf MyFlags, ...));
extern int my_printf_error _VARARGS((uint my_err, const char *format,
myf MyFlags, ...)
__attribute__ ((format (printf, 2, 4))));
+extern int my_vsnprintf( char *str, size_t n,
+ const char *format, va_list ap );
+
extern int my_message(uint my_err, const char *str,myf MyFlags);
extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
@@ -389,11 +422,12 @@ extern my_string my_path(my_string to,const char *progname,
extern my_string my_load_path(my_string to, const char *path,
const char *own_path_prefix);
extern int wild_compare(const char *str,const char *wildstr);
-extern my_string strcasestr(const char *src,const char *suffix);
+extern my_string my_strcasestr(const char *src,const char *suffix);
extern int my_strcasecmp(const char *s,const char *t);
extern int my_strsortcmp(const char *s,const char *t);
extern int my_casecmp(const char *s,const char *t,uint length);
extern int my_sortcmp(const char *s,const char *t,uint length);
+extern int my_sortncmp(const char *s,uint s_len, const char *t,uint t_len);
extern WF_PACK *wf_comp(my_string str);
extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
extern void wf_end(struct wild_file_pack *buffer);
@@ -422,6 +456,9 @@ extern sig_handler my_set_alarm_variable(int signo);
extern void my_string_ptr_sort(void *base,uint items,size_s size);
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
size_s size_of_element,uchar *buffer[]);
+extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
+ qsort2_cmp cmp, void *cmp_argument);
+extern qsort2_cmp get_ptr_compare(uint);
extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
enum cache_type type,my_off_t seek_offset,
pbool use_async_io, myf cache_myflags);
@@ -433,13 +470,15 @@ extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_get(IO_CACHE *info);
extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count);
+extern int my_block_write(IO_CACHE *info, const byte *Buffer,
+ uint Count, my_off_t pos);
extern int flush_io_cache(IO_CACHE *info);
extern int end_io_cache(IO_CACHE *info);
-extern my_bool open_cacheed_file(IO_CACHE *cache,const char *dir,
+extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
const char *prefix, uint cache_size,
myf cache_myflags);
extern my_bool real_open_cached_file(IO_CACHE *cache);
-extern void close_cacheed_file(IO_CACHE *cache);
+extern void close_cached_file(IO_CACHE *cache);
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
uint init_alloc,uint alloc_increment);
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element);
@@ -456,7 +495,7 @@ extern void freeze_size(DYNAMIC_ARRAY *array);
extern int find_type(my_string x,TYPELIB *typelib,uint full_name);
extern void make_type(my_string to,uint nr,TYPELIB *typelib);
-extern my_string get_type(TYPELIB *typelib,uint nr);
+extern const char *get_type(TYPELIB *typelib,uint nr);
extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
uint init_alloc,uint alloc_increment);
extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
@@ -488,17 +527,17 @@ my_bool my_uncompress(byte *, ulong *, ulong *);
byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
ulong checksum(const byte *mem, uint count);
-#if defined(_MSC_VER) && !defined(__WIN32__)
+#if defined(_MSC_VER) && !defined(__WIN__)
extern void sleep(int sec);
#endif
-#ifdef __WIN32__
+#ifdef __WIN__
extern my_bool have_tcpip; /* Is set if tcpip is used */
#endif
#ifdef __cplusplus
}
#endif
-#if defined(USE_RAID)
+#ifdef USE_RAID
#include "raid.h"
#endif
#endif /* _my_sys_h */
diff --git a/ext/mysql/libmysql/my_tempnam.c b/ext/mysql/libmysql/my_tempnam.c
index a288ecda4f..f6296398ee 100644
--- a/ext/mysql/libmysql/my_tempnam.c
+++ b/ext/mysql/libmysql/my_tempnam.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include <m_string.h>
diff --git a/ext/mysql/libmysql/my_thr_init.c b/ext/mysql/libmysql/my_thr_init.c
index c515822468..9196d9b7af 100644
--- a/ext/mysql/libmysql/my_thr_init.c
+++ b/ext/mysql/libmysql/my_thr_init.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
** Functions to handle initializating and allocationg of all mysys & debug
@@ -16,11 +16,12 @@ pthread_key(struct st_my_thread_var*, THR_KEY_mysys);
pthread_key(struct st_my_thread_var, THR_KEY_mysys);
#endif
pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache,
- THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_heap,THR_LOCK_net;
+ THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap,
+ THR_LOCK_net, THR_LOCK_charset;
#ifndef HAVE_LOCALTIME_R
pthread_mutex_t LOCK_localtime_r;
#endif
-#ifdef __WIN32__
+#ifdef __WIN__
pthread_mutex_t THR_LOCK_thread;
#endif
@@ -40,9 +41,11 @@ my_bool my_thread_global_init(void)
pthread_mutex_init(&THR_LOCK_keycache,NULL);
pthread_mutex_init(&THR_LOCK_lock,NULL);
pthread_mutex_init(&THR_LOCK_isam,NULL);
+ pthread_mutex_init(&THR_LOCK_myisam,NULL);
pthread_mutex_init(&THR_LOCK_heap,NULL);
pthread_mutex_init(&THR_LOCK_net,NULL);
-#ifdef __WIN32__
+ pthread_mutex_init(&THR_LOCK_charset,NULL);
+#ifdef __WIN__
pthread_mutex_init(&THR_LOCK_thread,NULL);
#endif
#ifndef HAVE_LOCALTIME_R
@@ -64,7 +67,7 @@ my_bool my_thread_init(void)
{
struct st_my_thread_var *tmp;
pthread_mutex_lock(&THR_LOCK_lock);
-#if !defined(__WIN32__) || defined(USE_TLS)
+#if !defined(__WIN__) || defined(USE_TLS)
if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys))
{
pthread_mutex_unlock(&THR_LOCK_lock);
@@ -111,11 +114,11 @@ void my_thread_end(void)
pthread_cond_destroy(&tmp->suspend);
#endif
pthread_mutex_destroy(&tmp->mutex);
-#if !defined(__WIN32__) || defined(USE_TLS)
+#if !defined(__WIN__) || defined(USE_TLS)
free(tmp);
#endif
}
-#if !defined(__WIN32__) || defined(USE_TLS)
+#if !defined(__WIN__) || defined(USE_TLS)
pthread_setspecific(THR_KEY_mysys,0);
#endif
}
@@ -145,7 +148,7 @@ long my_thread_id()
{
#if defined(HAVE_PTHREAD_GETSEQUENCE_NP)
return pthread_getsequence_np(pthread_self());
-#elif defined(__sun) || defined(__sgi) || defined(__linux__)
+#elif (defined(__sun) || defined(__sgi) || defined(__linux__)) && !defined(HAVE_mit_thread)
return pthread_self();
#else
return my_thread_var->id;
diff --git a/ext/mysql/libmysql/my_wincond.c b/ext/mysql/libmysql/my_wincond.c
index f33a197298..179a969119 100644
--- a/ext/mysql/libmysql/my_wincond.c
+++ b/ext/mysql/libmysql/my_wincond.c
@@ -1,16 +1,5 @@
-/* Copyright (C) 2000 Monty Program KB
-
- This software is distributed with NO WARRANTY OF ANY KIND. No author or
- distributor accepts any responsibility for the consequences of using it, or
- for whether it serves any particular purpose or works at all, unless he or
- she says so in writing. Refer to the Free Public License (the "License")
- for full details.
-
- Every copy of this file must include a copy of the License, normally in a
- plain ASCII text file named PUBLIC. The License grants you the right to
- copy, modify and redistribute this file, but only under certain conditions
- described in the License. Among other things, the License requires that
- the copyright notice and this notice be preserved on all copies. */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*****************************************************************************
diff --git a/ext/mysql/libmysql/my_write.c b/ext/mysql/libmysql/my_write.c
index 6ac221c194..ac791ebc2f 100644
--- a/ext/mysql/libmysql/my_write.c
+++ b/ext/mysql/libmysql/my_write.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include "mysys_priv.h"
#include "mysys_err.h"
diff --git a/ext/mysql/libmysql/mysql.h b/ext/mysql/libmysql/mysql.h
index 6f358da110..5b70bb419b 100644
--- a/ext/mysql/libmysql/mysql.h
+++ b/ext/mysql/libmysql/mysql.h
@@ -1,19 +1,24 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* defines for the libmysql library */
#ifndef _mysql_h
#define _mysql_h
+#ifndef MYSQL_SERVER
#ifdef __cplusplus
extern "C" {
#endif
-
+#endif
+
#ifndef _global_h /* If not standard header */
#include <sys/types.h>
typedef char my_bool;
-#if !defined(WIN32)
+#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
+#define __WIN__
+#endif
+#if !defined(__WIN__)
#define STDCALL
#else
#define STDCALL __stdcall
@@ -37,7 +42,7 @@ typedef struct st_mem_root {
#endif
#ifndef my_socket_defined
-#ifdef WIN32
+#ifdef __WIN__
#define my_socket SOCKET
#else
typedef int my_socket;
@@ -71,7 +76,7 @@ typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
#if defined(NO_CLIENT_LONG_LONG)
typedef unsigned long my_ulonglong;
-#elif defined (WIN32)
+#elif defined (__WIN__)
typedef unsigned __int64 my_ulonglong;
#else
typedef unsigned long long my_ulonglong;
@@ -98,7 +103,7 @@ struct st_mysql_options {
my_bool compress,named_pipe;
unsigned int port;
char *host,*init_command,*user,*password,*unix_socket,*db;
- char *my_cnf_file,*my_cnf_group;
+ char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
my_bool use_ssl; /* if to use SSL or not */
char *ssl_key; /* PEM key file */
char *ssl_cert; /* PEM cert file */
@@ -108,7 +113,8 @@ struct st_mysql_options {
enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS,
MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND,
- MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP };
+ MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
+ MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME};
enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,
MYSQL_STATUS_USE_RESULT};
@@ -121,6 +127,7 @@ typedef struct st_mysql {
unsigned int port,client_flag,server_capabilities;
unsigned int protocol_version;
unsigned int field_count;
+ unsigned int server_status;
unsigned long thread_id; /* Id for connection in server */
my_ulonglong affected_rows;
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
@@ -133,6 +140,8 @@ typedef struct st_mysql {
my_bool reconnect; /* set to 1 if automatic reconnect */
struct st_mysql_options options;
char scramble_buff[9];
+ struct charset_info_st *charset;
+ unsigned int server_language;
} MYSQL;
@@ -153,21 +162,23 @@ typedef struct st_mysql_res {
/* Functions to get information from the MYSQL and MYSQL_RES structures */
/* Should definitely be used if one uses shared libraries */
-my_ulonglong mysql_num_rows(MYSQL_RES *res);
-unsigned int mysql_num_fields(MYSQL_RES *res);
-my_bool mysql_eof(MYSQL_RES *res);
-MYSQL_FIELD *mysql_fetch_field_direct(MYSQL_RES *res,unsigned int fieldnr);
-MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *res);
-MYSQL_ROWS *mysql_row_tell(MYSQL_RES *res);
-unsigned int mysql_field_tell(MYSQL_RES *res);
+my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res);
+unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
+my_bool STDCALL mysql_eof(MYSQL_RES *res);
+MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res,
+ unsigned int fieldnr);
+MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res);
+MYSQL_ROWS * STDCALL mysql_row_tell(MYSQL_RES *res);
+unsigned int STDCALL mysql_field_tell(MYSQL_RES *res);
-unsigned int mysql_field_count(MYSQL *mysql);
-my_ulonglong mysql_affected_rows(MYSQL *mysql);
-my_ulonglong mysql_insert_id(MYSQL *mysql);
-unsigned int mysql_errno(MYSQL *mysql);
-char *mysql_error(MYSQL *mysql);
-char *mysql_info(MYSQL *mysql);
-unsigned long mysql_thread_id(MYSQL *mysql);
+unsigned int STDCALL mysql_field_count(MYSQL *mysql);
+my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
+my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
+unsigned int STDCALL mysql_errno(MYSQL *mysql);
+char * STDCALL mysql_error(MYSQL *mysql);
+char * STDCALL mysql_info(MYSQL *mysql);
+unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
+const char * STDCALL mysql_character_set_name(MYSQL *mysql);
MYSQL * STDCALL mysql_init(MYSQL *mysql);
#ifdef HAVE_OPENSSL
@@ -235,8 +246,13 @@ unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result);
MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result);
unsigned long STDCALL mysql_escape_string(char *to,const char *from,
unsigned long from_length);
+unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
+ char *to,const char *from,
+ unsigned long length);
void STDCALL mysql_debug(const char *debug);
-char * STDCALL mysql_odbc_escape_string(char *to, unsigned long to_length,
+char * STDCALL mysql_odbc_escape_string(MYSQL *mysql,
+ char *to,
+ unsigned long to_length,
const char *from,
unsigned long from_length,
void *param,
@@ -244,14 +260,20 @@ char * STDCALL mysql_odbc_escape_string(char *to, unsigned long to_length,
(*extend_buffer)
(void *, char *to,
unsigned long *length));
+void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
+unsigned int STDCALL mysql_thread_safe(void);
+
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
/* new api functions */
#define HAVE_MYSQL_REAL_CONNECT
+#ifndef MYSQL_SERVER
#ifdef __cplusplus
}
#endif
#endif
+
+#endif
diff --git a/ext/mysql/libmysql/mysql_com.h b/ext/mysql/libmysql/mysql_com.h
index c4c0ecfdd7..f443a351e1 100644
--- a/ext/mysql/libmysql/mysql_com.h
+++ b/ext/mysql/libmysql/mysql_com.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
** Common definition between mysql server & client
@@ -8,9 +8,6 @@
#ifndef _mysql_com_h
#define _mysql_com_h
-#ifdef __cplusplus
-extern "C" {
-#endif
#define NAME_LEN 64 /* Field/table name length */
#define HOSTNAME_LENGTH 60
@@ -19,23 +16,23 @@ extern "C" {
#define LOCAL_HOST "localhost"
#define LOCAL_HOST_NAMEDPIPE "."
-#define MYSQL_PORT 3306 /* Alloced by ISI for MySQL */
#if defined(__EMX__) || defined(__OS2__)
#undef MYSQL_UNIX_ADDR
#define MYSQL_OS2_ADDR "\\socket\\MySQL"
#define MYSQL_UNIX_ADDR MYSQL_OS2_ADDR
#endif
-#ifdef WIN32
+#if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
#define MYSQL_NAMEDPIPE "MySQL"
#define MYSQL_SERVICENAME "MySql"
-#endif
+#endif /* __WIN__ */
enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH,
COM_SHUTDOWN,COM_STATISTICS,
COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
COM_DEBUG,COM_PING,COM_TIME,COM_DELAYED_INSERT,
- COM_CHANGE_USER};
+ COM_CHANGE_USER, COM_BINLOG_DUMP,
+ COM_TABLE_DUMP};
#define NOT_NULL_FLAG 1 /* Field can't be NULL */
#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
@@ -59,6 +56,14 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
#define REFRESH_TABLES 4 /* close all tables */
#define REFRESH_HOSTS 8 /* Flush host cache */
#define REFRESH_STATUS 16 /* Flush status variables */
+#define REFRESH_THREADS 32 /* Flush status variables */
+#define REFRESH_SLAVE 64 /* Reset master info and restart slave
+ thread */
+#define REFRESH_MASTER 128 /* Remove all bin logs in the index
+ and truncate the index */
+
+/* The following can't be set with mysql_refresh() */
+#define REFRESH_READ_LOCK 16384 /* Lock tables for read */
#define REFRESH_FAST 32768 /* Intern flag */
#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
@@ -74,6 +79,10 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
#define CLIENT_SSL 2048 /* Switch to SSL after handshake */
#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
+#define CLIENT_TRANSACTIONS 8196 /* Client knows about transactions */
+
+#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
+#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
#define MYSQL_ERRMSG_SIZE 200
#define NET_READ_TIMEOUT 30 /* Timeout on read */
@@ -97,10 +106,15 @@ typedef struct st_net {
unsigned char *buff,*buff_end,*write_pos,*read_pos;
char last_error[MYSQL_ERRMSG_SIZE];
unsigned int last_errno,max_packet,timeout,pkt_nr;
- my_bool error,return_errno,compress;
-
+ unsigned char error;
+ my_bool return_errno,compress;
+ my_bool no_send_ok; /* needed if we are doing several
+ queries in one command ( as in LOAD TABLE ... FROM MASTER ),
+ and do not want to confuse the client with OK at the wrong time
+ */
unsigned long remain_in_buf,length, buf_length, where_b;
- my_bool more;
+ unsigned int *return_status;
+ unsigned char reading_or_writing;
char save_char;
} NET;
@@ -177,6 +191,10 @@ typedef struct st_udf_init
/* Prototypes to password functions */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void randominit(struct rand_struct *,unsigned long seed1,
unsigned long seed2);
double rnd(struct rand_struct *);
@@ -189,6 +207,9 @@ my_bool check_scramble(const char *, const char *message,
unsigned long *salt,my_bool old_ver);
char *get_tty_password(char *opt_message);
void hash_password(unsigned long *result, const char *password);
+#ifdef __cplusplus
+}
+#endif
/* Some other useful functions */
@@ -198,13 +219,10 @@ void load_defaults(const char *conf_file, const char **groups,
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
-#ifdef WIN32
+#ifdef __WIN__
#define socket_errno WSAGetLastError()
#else
#define socket_errno errno
#endif
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/ext/mysql/libmysql/mysql_version.h b/ext/mysql/libmysql/mysql_version.h
index b07e587aff..1f868704fe 100644
--- a/ext/mysql/libmysql/mysql_version.h
+++ b/ext/mysql/libmysql/mysql_version.h
@@ -3,8 +3,18 @@
/* Version numbers for protocol & mysqld */
-#define MYSQL_SERVER_VERSION "3.23.10-alpha"
+#ifdef _CUSTOMCONFIG_
+ #include <custom_conf.h>
+#else
+#define PROTOCOL_VERSION 10
+#define MYSQL_SERVER_VERSION "3.23.22-beta"
#define FRM_VER 6
-#define MYSQL_VERSION_ID 32310
+#define MYSQL_VERSION_ID 32322
+#define MYSQL_PORT 3306
+#define MYSQL_UNIX_ADDR "/tmp/mysql.sock"
+
/* mysqld compile time options */
+#ifndef MYSQL_CHARSET
#define MYSQL_CHARSET "latin1"
+#endif
+#endif
diff --git a/ext/mysql/libmysql/mysqld_error.h b/ext/mysql/libmysql/mysqld_error.h
index da19af6138..d815e61f3b 100644
--- a/ext/mysql/libmysql/mysqld_error.h
+++ b/ext/mysql/libmysql/mysqld_error.h
@@ -176,4 +176,21 @@
#define ER_REQUIRES_PRIMARY_KEY 1173
#define ER_NO_RAID_COMPILED 1174
#define ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175
-#define ER_ERROR_MESSAGES 176
+#define ER_KEY_DOES_NOT_EXITS 1176
+#define ER_CHECK_NO_SUCH_TABLE 1177
+#define ER_CHECK_NOT_IMPLEMENTED 1178
+#define ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179
+#define ER_ERROR_DURING_COMMIT 1180
+#define ER_ERROR_DURING_ROLLBACK 1181
+#define ER_ERROR_DURING_FLUSH_LOGS 1182
+#define ER_ERROR_DURING_CHECKPOINT 1183
+#define ER_NEW_ABORTING_CONNECTION 1184
+#define ER_DUMP_NOT_IMPLEMENTED 1185
+#define ER_FLUSH_MASTER_BINLOG_CLOSED 1186
+#define ER_INDEX_REBUILD 1187
+#define ER_MASTER 1188
+#define ER_MASTER_NET_READ 1189
+#define ER_MASTER_NET_WRITE 1190
+#define ER_FT_MATCHING_KEY_NOT_FOUND 1191
+#define ER_LOCK_OR_ACTIVE_TRANSACTION 1192
+#define ER_ERROR_MESSAGES 193
diff --git a/ext/mysql/libmysql/mysys_err.h b/ext/mysql/libmysql/mysys_err.h
index 7264f21906..8fb9041922 100644
--- a/ext/mysql/libmysql/mysys_err.h
+++ b/ext/mysql/libmysql/mysys_err.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#ifndef _mysys_err_h
#define _mysys_err_h
@@ -8,7 +8,7 @@ extern "C" {
#endif
#define GLOB 0 /* Error maps */
-#define GLOBERRS 22 /* Max number of error messages in map's */
+#define GLOBERRS 23 /* Max number of error messages in map's */
#define EE(X) globerrs[ X ] /* Defines to add error to right map */
extern const char * NEAR globerrs[]; /* my_error_messages is here */
@@ -35,6 +35,7 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */
#define EE_OPEN_WARNING 19
#define EE_DISK_FULL 20
#define EE_CANT_MKDIR 21
+#define EE_UNKNOWN_CHARSET 22
#ifdef __cplusplus
}
diff --git a/ext/mysql/libmysql/mysys_priv.h b/ext/mysql/libmysql/mysys_priv.h
index 86bc74f38b..96e777d854 100644
--- a/ext/mysql/libmysql/mysys_priv.h
+++ b/ext/mysql/libmysql/mysys_priv.h
@@ -1,12 +1,16 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
#include <global.h>
#include <my_sys.h>
+#ifdef USE_SYSTEM_WRAPPERS
+#include "system_wrappers.h"
+#endif
+
#ifdef THREAD
extern pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache,
- THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_net;
+ THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_net,THR_LOCK_charset;
#else /* THREAD */
#define pthread_mutex_lock(A)
#define pthread_mutex_unlock(A)
diff --git a/ext/mysql/libmysql/net.c b/ext/mysql/libmysql/net.c
index 9af0a54c3d..3326851028 100644
--- a/ext/mysql/libmysql/net.c
+++ b/ext/mysql/libmysql/net.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Write and read of logical packets to/from socket
** Writes are cached into net_buffer_length big packets.
@@ -8,7 +8,7 @@
** 3 byte length & 1 byte package-number.
*/
-#ifdef _WIN32
+#ifdef __WIN__
#include <winsock.h>
#endif
#include <global.h>
@@ -16,15 +16,29 @@
#include <my_sys.h>
#include <m_string.h>
#include "mysql.h"
+#include "mysqld_error.h"
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
#include <violite.h>
-#if !defined(__WIN32__) && !defined(MSDOS)
+#ifdef MYSQL_SERVER
+ulong max_allowed_packet=65536;
+extern ulong net_read_timeout,net_write_timeout;
+extern uint test_flags;
+#else
+ulong max_allowed_packet=16*1024*1024L;
+ulong net_read_timeout= NET_READ_TIMEOUT;
+ulong net_write_timeout= NET_WRITE_TIMEOUT;
+#endif
+ulong net_buffer_length=8192; /* Default length. Enlarged if necessary */
+
+#if !defined(__WIN__) && !defined(MSDOS)
#include <sys/socket.h>
+#else
+#undef MYSQL_SERVER // Win32 can't handle interrupts
#endif
-#if !defined(MSDOS) && !defined(__WIN32__) && !defined(HAVE_BROKEN_NETINET_INCLUDES)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__)
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
@@ -41,11 +55,12 @@ void sql_print_error(const char *format,...);
extern ulong mysqld_net_retry_count;
#else
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_end_alarm(A)
-#define thr_alarm(A,B) local_thr_alarm((A),(B))
-static inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)))
+#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)))
{
*A=1;
return 0;
@@ -58,8 +73,8 @@ static inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)))
extern ulong bytes_sent, bytes_received;
extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
#else
-#undef thread_safe_add
-#define thread_safe_add(A,B,C)
+#undef statistic_add
+#define statistic_add(A,B,C)
#endif
/*
@@ -68,14 +83,6 @@ extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
** can't normally do this the client should have a bigger max-buffer.
*/
-#ifdef MYSQL_SERVER
-ulong max_allowed_packet=65536;
-extern uint test_flags;
-#else
-ulong max_allowed_packet=24*1024*1024L;
-#endif
-ulong net_buffer_length=8192; /* Default length. Enlarged if necessary */
-
#define TEST_BLOCKING 8
static int net_write_buff(NET *net,const char *packet,uint len);
@@ -90,19 +97,20 @@ int my_net_init(NET *net, Vio* vio)
max_allowed_packet=net_buffer_length;
net->buff_end=net->buff+(net->max_packet=net_buffer_length);
net->vio = vio;
- net->error=net->return_errno=0;
- net->timeout=NET_READ_TIMEOUT; /* Timeout for read */
+ net->no_send_ok = 0;
+ net->error=0; net->return_errno=0; net->return_status=0;
+ net->timeout=(uint) net_read_timeout; /* Timeout for read */
net->pkt_nr=0;
net->write_pos=net->read_pos = net->buff;
net->last_error[0]=0;
- net->compress=net->more=0;
+ net->compress=0; net->reading_or_writing=0;
net->where_b = net->remain_in_buf=0;
net->last_errno=0;
if (vio != 0) /* If real connection */
{
net->fd = vio_fd(vio); /* For perl DBI/DBD */
-#if defined(MYSQL_SERVER) && !defined(___WIN32__) && !defined(__EMX__)
+#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__)
if (!(test_flags & TEST_BLOCKING))
vio_blocking(vio, FALSE);
#endif
@@ -125,19 +133,12 @@ static my_bool net_realloc(NET *net, ulong length)
ulong pkt_length;
if (length >= max_allowed_packet)
{
- DBUG_PRINT("error",("Packet too large (%ld)", length));
-#ifdef MYSQL_SERVER
- sql_print_error("Packet too large (%ld)\n", length);
-#else
- fprintf(stderr,"Packet too large (%ld)\n", length);
-#endif
+ DBUG_PRINT("error",("Packet too large (%lu)", length));
net->error=1;
-#ifdef MYSQL_SERVER
net->last_errno=ER_NET_PACKET_TOO_LARGE;
-#endif
return 1;
}
- pkt_length = (length+IO_SIZE) & ~(IO_SIZE-1);
+ pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1);
if (!(buff=(uchar*) my_realloc((char*) net->buff, pkt_length, MYF(MY_WME))))
{
net->error=1;
@@ -153,37 +154,40 @@ static my_bool net_realloc(NET *net, ulong length)
/* Remove unwanted characters from connection */
-#ifndef MYSQL_SERVER
void net_clear(NET *net)
{
#ifndef EXTRA_DEBUG
int count;
- vio_blocking(net->vio, FALSE);
+ bool is_blocking=vio_is_blocking(net->vio);
+ if (is_blocking)
+ vio_blocking(net->vio, FALSE);
if (!vio_is_blocking(net->vio)) /* Safety if SSL */
{
while ( (count = vio_read(net->vio, (char*) (net->buff),
net->max_packet)) > 0)
DBUG_PRINT("info",("skipped %d bytes from file: %s",
count,vio_description(net->vio)));
+ if (is_blocking)
+ vio_blocking(net->vio, TRUE);
}
#endif /* EXTRA_DEBUG */
net->pkt_nr=0; /* Ready for new command */
net->write_pos=net->buff;
}
-#endif /* MYSQL_SERVER */
/* Flush write_buffer if not empty. */
int net_flush(NET *net)
{
int error=0;
+ DBUG_ENTER("net_flush");
if (net->buff != net->write_pos)
{
error=net_real_write(net,(char*) net->buff,
(uint) (net->write_pos - net->buff));
net->write_pos=net->buff;
}
- return error;
+ DBUG_RETURN(error);
}
@@ -253,9 +257,17 @@ net_real_write(NET *net,const char *packet,ulong len)
int length;
char *pos,*end;
thr_alarm_t alarmed;
+#if (!defined(__WIN__) && !defined(__EMX__))
+ ALARM alarm_buff;
+#endif
uint retry_count=0;
my_bool net_blocking = vio_is_blocking(net->vio);
+ DBUG_ENTER("net_real_write");
+
+ if (net->error == 2)
+ DBUG_RETURN(-1); /* socket can't be used */
+ net->reading_or_writing=2;
#ifdef HAVE_COMPRESS
if (net->compress)
{
@@ -267,9 +279,10 @@ net_real_write(NET *net,const char *packet,ulong len)
{
#ifdef MYSQL_SERVER
net->last_errno=ER_OUT_OF_RESOURCES;
- net->error=1;
+ net->error=2;
#endif
- return 1;
+ net->reading_or_writing=0;
+ DBUG_RETURN(1);
}
memcpy(b+header_length,packet,len);
@@ -291,7 +304,7 @@ net_real_write(NET *net,const char *packet,ulong len)
#ifdef MYSQL_SERVER
thr_alarm_init(&alarmed);
if (net_blocking)
- thr_alarm(&alarmed,NET_WRITE_TIMEOUT);
+ thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff);
#else
alarmed=0;
#endif /* MYSQL_SERVER */
@@ -302,10 +315,10 @@ net_real_write(NET *net,const char *packet,ulong len)
if ((int) (length=vio_write(net->vio,pos,(size_t) (end-pos))) <= 0)
{
my_bool interrupted = vio_should_retry(net->vio);
-#if (!defined(__WIN32__) && !defined(__EMX__))
+#if (!defined(__WIN__) && !defined(__EMX__))
if ((interrupted || length==0) && !thr_alarm_in_use(alarmed))
{
- if (!thr_alarm(&alarmed,NET_WRITE_TIMEOUT))
+ if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff))
{ /* Always true for client */
if (!vio_is_blocking(net->vio))
{
@@ -318,7 +331,7 @@ net_real_write(NET *net,const char *packet,ulong len)
"%s: my_net_write: fcntl returned error %d, aborting thread\n",
my_progname,vio_errno(net->vio));
#endif /* EXTRA_DEBUG */
- net->error=1; /* Close socket */
+ net->error=2; /* Close socket */
goto end;
}
}
@@ -327,7 +340,7 @@ net_real_write(NET *net,const char *packet,ulong len)
}
}
else
-#endif /* (!defined(__WIN32__) && !defined(__EMX__)) */
+#endif /* (!defined(__WIN__) && !defined(__EMX__)) */
if (thr_alarm_in_use(alarmed) && !thr_got_alarm(alarmed) &&
interrupted)
{
@@ -345,7 +358,7 @@ net_real_write(NET *net,const char *packet,ulong len)
continue;
}
#endif /* defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) */
- net->error=1; /* Close socket */
+ net->error=2; /* Close socket */
#ifdef MYSQL_SERVER
net->last_errno= (interrupted ? ER_NET_WRITE_INTERRUPTED :
ER_NET_ERROR_ON_WRITE);
@@ -353,9 +366,9 @@ net_real_write(NET *net,const char *packet,ulong len)
break;
}
pos+=length;
- thread_safe_add(bytes_sent,length,&LOCK_bytes_sent);
+ statistic_add(bytes_sent,length,&LOCK_bytes_sent);
}
-#ifndef __WIN32__
+#ifndef __WIN__
end:
#endif
#ifdef HAVE_COMPRESS
@@ -367,7 +380,8 @@ net_real_write(NET *net,const char *packet,ulong len)
thr_end_alarm(&alarmed);
vio_blocking(net->vio, net_blocking);
}
- return (int) (pos != end);
+ net->reading_or_writing=0;
+ DBUG_RETURN(((int) (pos != end)));
}
@@ -375,6 +389,43 @@ net_real_write(NET *net,const char *packet,ulong len)
** Read something from server/clinet
*****************************************************************************/
+#ifdef MYSQL_SERVER
+
+/*
+ Help function to clear the commuication buffer when we get a too
+ big packet
+*/
+
+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(alarmed,net->timeout,&alarm_buff) ||
+ (!vio_is_blocking(net->vio) && vio_blocking(net->vio,TRUE) < 0))
+ return; // Can't setup, abort
+ }
+ while (remain > 0)
+ {
+ ulong length;
+ 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)
+ { /* Probably in MIT threads */
+ if (retry_count++ < RETRY_COUNT)
+ continue;
+ }
+ return;
+ }
+ remain -=(ulong) length;
+ statistic_add(bytes_received,(ulong) length,&LOCK_bytes_received);
+ }
+}
+#endif /* MYSQL_SERVER */
+
static uint
my_real_read(NET *net, ulong *complen)
@@ -384,15 +435,19 @@ my_real_read(NET *net, ulong *complen)
uint i,retry_count=0;
ulong len=packet_error;
thr_alarm_t alarmed;
+#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER)
+ ALARM alarm_buff;
+#endif
my_bool net_blocking=vio_is_blocking(net->vio);
ulong remain= (net->compress ? NET_HEADER_SIZE+COMP_HEADER_SIZE :
NET_HEADER_SIZE);
*complen = 0;
+ net->reading_or_writing=1;
thr_alarm_init(&alarmed);
#ifdef MYSQL_SERVER
if (net_blocking)
- thr_alarm(&alarmed,net->timeout);
+ thr_alarm(&alarmed,net->timeout,&alarm_buff);
#endif /* MYSQL_SERVER */
pos = net->buff + net->where_b; /* net->packet -4 */
@@ -407,7 +462,7 @@ my_real_read(NET *net, ulong *complen)
DBUG_PRINT("info",("vio_read returned %d, errno: %d",
length, vio_errno(net->vio)));
-#if (!defined(__WIN32__) && !defined(__EMX__)) || !defined(MYSQL_SERVER)
+#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER)
/*
We got an error that there was no data on the socket. We now set up
an alarm to not 'read forever', change the socket to non blocking
@@ -415,7 +470,7 @@ my_real_read(NET *net, ulong *complen)
*/
if ((interrupted || length == 0) && !thr_alarm_in_use(alarmed))
{
- if (!thr_alarm(&alarmed,net->timeout)) /* Don't wait too long */
+ if (!thr_alarm(&alarmed,net->timeout,&alarm_buff)) /* Don't wait too long */
{
if (!vio_is_blocking(net->vio))
{
@@ -433,7 +488,7 @@ my_real_read(NET *net, ulong *complen)
my_progname,vio_errno(net->vio));
#endif /* EXTRA_DEBUG */
len= packet_error;
- net->error=1; /* Close socket */
+ net->error=2; /* Close socket */
#ifdef MYSQL_SERVER
net->last_errno=ER_NET_FCNTL_ERROR;
#endif
@@ -444,7 +499,7 @@ my_real_read(NET *net, ulong *complen)
continue;
}
}
-#endif /* (!defined(__WIN32__) && !defined(__EMX__)) || !defined(MYSQL_SERVER) */
+#endif /* (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER) */
if (thr_alarm_in_use(alarmed) && !thr_got_alarm(alarmed) &&
interrupted)
{ /* Probably in MIT threads */
@@ -464,7 +519,7 @@ my_real_read(NET *net, ulong *complen)
#endif
DBUG_PRINT("error",("Couldn't read packet: remain: %d errno: %d length: %d alarmed: %d", remain,vio_errno(net->vio),length,alarmed));
len= packet_error;
- net->error=1; /* Close socket */
+ net->error=2; /* Close socket */
#ifdef MYSQL_SERVER
net->last_errno= (interrupted ? ER_NET_READ_INTERRUPTED :
ER_NET_READ_ERROR);
@@ -473,7 +528,7 @@ my_real_read(NET *net, ulong *complen)
}
remain -= (ulong) length;
pos+= (ulong) length;
- thread_safe_add(bytes_received,(ulong) length,&LOCK_bytes_received);
+ statistic_add(bytes_received,(ulong) length,&LOCK_bytes_received);
}
if (i == 0)
{ /* First parts is packet length */
@@ -512,8 +567,13 @@ my_real_read(NET *net, ulong *complen)
/* The necessary size of net->buff */
if (helping >= net->max_packet)
{
- if (net_realloc(net,helping))
+ /* We must allocate one extra byte for the end null */
+ if (net_realloc(net,helping+1))
{
+#ifdef MYSQL_SERVER
+ if (i == 1)
+ my_net_skip_rest(net, len, &alarmed);
+#endif
len= packet_error; /* Return error */
goto end;
}
@@ -529,10 +589,10 @@ end:
thr_end_alarm(&alarmed);
vio_blocking(net->vio, net_blocking);
}
+ net->reading_or_writing=0;
return(len);
}
-
uint
my_net_read(NET *net)
{
@@ -587,7 +647,7 @@ my_net_read(NET *net)
if (my_uncompress((byte*) net->buff + net->where_b, &len, &complen))
{
len= packet_error;
- net->error=1; /* caller will close socket */
+ net->error=2; /* caller will close socket */
#ifdef MYSQL_SERVER
net->last_errno=ER_NET_UNCOMPRESS_ERROR;
#endif
diff --git a/ext/mysql/libmysql/password.c b/ext/mysql/libmysql/password.c
index 46667993d5..eb40825401 100644
--- a/ext/mysql/libmysql/password.c
+++ b/ext/mysql/libmysql/password.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* password checking routines */
/*****************************************************************************
diff --git a/ext/mysql/libmysql/safemalloc.c b/ext/mysql/libmysql/safemalloc.c
index 5a44745bed..db62b7f3e3 100644
--- a/ext/mysql/libmysql/safemalloc.c
+++ b/ext/mysql/libmysql/safemalloc.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
* [This posting refers to an article entitled "oops, corrupted memory
@@ -193,7 +193,7 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
* Free then old memoryblock
*/
-gptr _myrealloc (register my_string pPtr, register uint uSize,
+gptr _myrealloc (register gptr pPtr, register uint uSize,
const char *sFile, uint uLine, myf MyFlags)
{
struct remember *pRec;
@@ -209,7 +209,8 @@ gptr _myrealloc (register my_string pPtr, register uint uSize,
if (check_ptr("Reallocating",(byte*) pPtr,sFile,uLine))
DBUG_RETURN((gptr) NULL);
- pRec = (struct remember *) (pPtr - sizeof (struct irem)-sf_malloc_prehunc);
+ pRec = (struct remember *) ((char*) pPtr - sizeof (struct irem)-
+ sf_malloc_prehunc);
if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc))
!= MAGICKEY)
{
@@ -467,6 +468,7 @@ int _sanity (const char *sFile, uint uLine)
count=cNewCount;
for (pTmp = pRememberRoot; pTmp != NULL && count-- ; pTmp = pTmp -> pNext)
flag+=_checkchunk (pTmp, sFile, uLine);
+ pthread_mutex_unlock(&THR_LOCK_malloc);
if (count || pTmp)
{
const char *format="Safemalloc link list destroyed, discovered at '%s:%d'";
@@ -475,7 +477,6 @@ int _sanity (const char *sFile, uint uLine)
DBUG_PRINT("safe",(format, sFile, uLine));
flag=1;
}
- pthread_mutex_unlock(&THR_LOCK_malloc);
return flag;
} /* _sanity */
diff --git a/ext/mysql/libmysql/str2int.c b/ext/mysql/libmysql/str2int.c
index c6de1a436a..a9cb9911fc 100644
--- a/ext/mysql/libmysql/str2int.c
+++ b/ext/mysql/libmysql/str2int.c
@@ -1,3 +1,6 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
/*
str2int(src, radix, lower, upper, &val)
converts the string pointed to by src to an integer and stores it in
diff --git a/ext/mysql/libmysql/strcend.c b/ext/mysql/libmysql/strcend.c
index f65eb16837..ef4fb95d5c 100644
--- a/ext/mysql/libmysql/strcend.c
+++ b/ext/mysql/libmysql/strcend.c
@@ -1,3 +1,6 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
/* File : strcend.c
Author : Michael Widenius: ifdef MC68000
Updated: 20 April 1984
diff --git a/ext/mysql/libmysql/strcont.c b/ext/mysql/libmysql/strcont.c
index 5ed0738dec..cc75ec450e 100644
--- a/ext/mysql/libmysql/strcont.c
+++ b/ext/mysql/libmysql/strcont.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* File : strcont.c
Author : Monty
diff --git a/ext/mysql/libmysql/strfill.c b/ext/mysql/libmysql/strfill.c
index 6a718db9c1..2a8496b8b1 100644
--- a/ext/mysql/libmysql/strfill.c
+++ b/ext/mysql/libmysql/strfill.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* File : strfill.c
Author : Monty
diff --git a/ext/mysql/libmysql/string.c b/ext/mysql/libmysql/string.c
index a14cc138fa..ef975eb038 100644
--- a/ext/mysql/libmysql/string.c
+++ b/ext/mysql/libmysql/string.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
Code for handling strings with can grow dynamicly.
@@ -19,7 +19,7 @@ my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
if (!alloc_increment)
alloc_increment=128;
length=1;
- if (init_str && (length=strlen(init_str)+1) < init_alloc)
+ if (init_str && (length= (uint) strlen(init_str)+1) < init_alloc)
init_alloc=((length+alloc_increment-1)/alloc_increment)*alloc_increment;
if (!init_alloc)
init_alloc=alloc_increment;
@@ -39,7 +39,7 @@ my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str)
uint length;
DBUG_ENTER("dynstr_set");
- if (init_str && (length=strlen(init_str)+1) > str->max_length)
+ if (init_str && (length= (uint) strlen(init_str)+1) > str->max_length)
{
str->max_length=((length+str->alloc_increment-1)/str->alloc_increment)*
str->alloc_increment;
diff --git a/ext/mysql/libmysql/strinstr.c b/ext/mysql/libmysql/strinstr.c
index 459cfbc3e6..ed165b9ce9 100644
--- a/ext/mysql/libmysql/strinstr.c
+++ b/ext/mysql/libmysql/strinstr.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* File : strinstr.c
Author : Monty & David
diff --git a/ext/mysql/libmysql/strmake.c b/ext/mysql/libmysql/strmake.c
index 65792625ae..789b9c6be9 100644
--- a/ext/mysql/libmysql/strmake.c
+++ b/ext/mysql/libmysql/strmake.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* File : strmake.c
Author : Michael Widenius
diff --git a/ext/mysql/libmysql/strmov.c b/ext/mysql/libmysql/strmov.c
index b41470aef4..66e90a8d6c 100644
--- a/ext/mysql/libmysql/strmov.c
+++ b/ext/mysql/libmysql/strmov.c
@@ -1,3 +1,6 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
/*
strmov(dst, src) moves all the characters of src (including the
closing NUL) to dst, and returns a pointer to the new closing NUL in
@@ -14,11 +17,13 @@
#define strmov strmov_overlapp
#endif
+#ifndef strmov
+
#if !defined(MC68000) && !defined(DS90)
char *strmov(register char *dst, register const char *src)
{
- while (*dst++ = *src++) ;
+ while ((*dst++ = *src++)) ;
return dst-1;
}
@@ -36,3 +41,5 @@ char *strmov(dst, src)
}
#endif
+
+#endif /* strmov */
diff --git a/ext/mysql/libmysql/strnmov.c b/ext/mysql/libmysql/strnmov.c
index 2e93908524..fd521fedea 100644
--- a/ext/mysql/libmysql/strnmov.c
+++ b/ext/mysql/libmysql/strnmov.c
@@ -1,3 +1,6 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
/*
strnmov(dst,src,length) moves length characters, or until end, of src to
dst and appends a closing NUL to dst if src is shorter than length.
diff --git a/ext/mysql/libmysql/strto.c b/ext/mysql/libmysql/strto.c
index a2acd9c786..144ad2f883 100644
--- a/ext/mysql/libmysql/strto.c
+++ b/ext/mysql/libmysql/strto.c
@@ -1,3 +1,6 @@
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
+
/*
strtol,strtoul,strtoll,strtoull
convert string to long, unsigned long, long long or unsigned long long.
diff --git a/ext/mysql/libmysql/strtoll.c b/ext/mysql/libmysql/strtoll.c
index 3b8f9bf368..4dde6e4e87 100644
--- a/ext/mysql/libmysql/strtoll.c
+++ b/ext/mysql/libmysql/strtoll.c
@@ -1,5 +1,5 @@
-/* Copyright (C) 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- For a more info consult the file COPYRIGHT distributed with this file */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* This is defines strtoll() if neaded */
diff --git a/ext/mysql/libmysql/strtoull.c b/ext/mysql/libmysql/strtoull.c
index fbb23e0f20..807449e0af 100644
--- a/ext/mysql/libmysql/strtoull.c
+++ b/ext/mysql/libmysql/strtoull.c
@@ -1,5 +1,5 @@
-/* Copyright (C) 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- For a more info consult the file COPYRIGHT distributed with this file */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* This is defines strtoull() */
diff --git a/ext/mysql/libmysql/strxmov.c b/ext/mysql/libmysql/strxmov.c
index 13811d043f..7ee1d303ee 100644
--- a/ext/mysql/libmysql/strxmov.c
+++ b/ext/mysql/libmysql/strxmov.c
@@ -23,7 +23,7 @@ char *strxmov(char *dst,const char *src, ...)
va_start(pvar,src);
while (src != NullS) {
- while (*dst++ = *src++) ;
+ while ((*dst++ = *src++)) ;
dst--;
src = va_arg(pvar, char *);
}
diff --git a/ext/mysql/libmysql/thr_alarm.h b/ext/mysql/libmysql/thr_alarm.h
index b2c599f697..697d29e04c 100644
--- a/ext/mysql/libmysql/thr_alarm.h
+++ b/ext/mysql/libmysql/thr_alarm.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Prototypes when using thr_alarm library functions */
@@ -9,6 +9,13 @@
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,10 +53,10 @@ typedef struct st_win_timer
#else
-#ifdef __WIN32__
+#ifdef __WIN__
typedef struct st_win_timer
{
- uint crono;
+ rf_SetTimer crono;
} thr_alarm_t;
bool thr_got_alarm(thr_alarm_t *alrm);
@@ -66,9 +73,9 @@ typedef int* thr_alarm_t;
void init_thr_alarm(uint max_alarm);
void thr_alarm_kill(pthread_t thread_id);
sig_handler process_alarm(int);
-#endif /* __WIN32__ */
+#endif /* __WIN__ */
-bool thr_alarm(thr_alarm_t *alarmed,uint sec);
+bool thr_alarm(thr_alarm_t *alarmed,uint sec, ALARM *buff);
void thr_end_alarm(thr_alarm_t *alarmed);
void end_thr_alarm(void);
#endif /* DONT_USE_THR_ALARM */
diff --git a/ext/mysql/libmysql/thr_mutex.c b/ext/mysql/libmysql/thr_mutex.c
index 3ac2013efd..1c900352cf 100644
--- a/ext/mysql/libmysql/thr_mutex.c
+++ b/ext/mysql/libmysql/thr_mutex.c
@@ -1,18 +1,18 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* This makes a wrapper for mutex handling to make it easier to debug mutex */
#include <global.h>
-#ifdef HAVE_LINUXTHREADS /* Some extra safety */
-#define __USE_UNIX98
+#if defined(HAVE_LINUXTHREADS) && !defined (__USE_UNIX98)
+#define __USE_UNIX98 /* To get rw locks under Linux */
#endif
#include <m_string.h>
#if defined(THREAD) && defined(SAFE_MUTEX)
-#undef SAFE_MUTEX /* Avoid safe_mutex redefinitions */
+#undef SAFE_MUTEX /* Avoid safe_mutex redefinitions */
#include <my_pthread.h>
-
+#ifndef DO_NOT_REMOVE_THREAD_WRAPPERS
/* Remove wrappers */
#undef pthread_mutex_init
#undef pthread_mutex_lock
@@ -23,15 +23,17 @@
#ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT
#define pthread_mutex_init(a,b) my_pthread_mutex_init((a),(b))
#endif
+#endif /* DO_NOT_REMOVE_THREAD_WRAPPERS */
-int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr)
+int safe_mutex_init(safe_mutex_t *mp,
+ const pthread_mutexattr_t *attr __attribute__((unused)))
{
bzero((char*) mp,sizeof(*mp));
#ifdef HAVE_LINUXTHREADS /* Some extra safety */
{
pthread_mutexattr_t tmp;
pthread_mutexattr_init(&tmp);
- pthread_mutexattr_settype(&tmp,PTHREAD_MUTEX_ERRORCHECK_NP);
+ pthread_mutexattr_setkind_np(&tmp,PTHREAD_MUTEX_ERRORCHECK_NP);
pthread_mutex_init(&mp->global,&tmp);
pthread_mutex_init(&mp->mutex, &tmp);
pthread_mutexattr_destroy(&tmp);
@@ -183,16 +185,16 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
return error;
}
-int safe_mutex_destroy(safe_mutex_t *mp)
+int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
{
if (mp->count != 0)
{
- fprintf(stderr,"safe_mutex: Trying to destroy a mutex that was locked at %s, line %d\n",
- mp->file,mp->line);
+ fprintf(stderr,"safe_mutex: Trying to destroy a mutex that was locked at %s, line %d at %s, line %d\n",
+ mp->file,mp->line, file, line);
abort();
}
pthread_mutex_destroy(&mp->global);
return pthread_mutex_destroy(&mp->mutex);
}
-#endif /* SAFE_MUTEX */
+#endif /* THREAD && SAFE_MUTEX */
diff --git a/ext/mysql/libmysql/typelib.c b/ext/mysql/libmysql/typelib.c
index 2612d2c9a0..c04c97a28e 100644
--- a/ext/mysql/libmysql/typelib.c
+++ b/ext/mysql/libmysql/typelib.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/* Functions to handle typelib */
@@ -20,7 +20,8 @@
int find_type(my_string x, TYPELIB *typelib, uint full_name)
{
int find,pos,findpos;
- reg1 my_string i,j;
+ reg1 my_string i;
+ reg2 const char *j;
DBUG_ENTER("find_type");
DBUG_PRINT("enter",("x: '%s' lib: %lx",x,typelib));
@@ -83,9 +84,9 @@ void make_type(register my_string to, register uint nr, register TYPELIB *typeli
/* Get type */
/* Warning first type is 0 */
-my_string get_type(TYPELIB *typelib, uint nr)
+const char *get_type(TYPELIB *typelib, uint nr)
{
if (nr < (uint) typelib->count && typelib->type_names)
return(typelib->type_names[nr]);
- return((char*) "?");
+ return "?";
}
diff --git a/ext/mysql/libmysql/violite.c b/ext/mysql/libmysql/violite.c
index 396abfd2db..310703684d 100644
--- a/ext/mysql/libmysql/violite.c
+++ b/ext/mysql/libmysql/violite.c
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 2000 Monty Program KB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
Note that we can't have assertion on file descriptors; The reason for
@@ -25,22 +25,22 @@
#undef HAVE_FCNTL
#endif /* defined(__EMX__) */
-#if defined(MSDOS) || defined(__WIN32__)
-#ifdef __WIN32__
+#if defined(MSDOS) || defined(__WIN__)
+#ifdef __WIN__
#undef errno
#undef EINTR
#undef EAGAIN
#define errno WSAGetLastError()
#define EINTR WSAEINTR
#define EAGAIN WSAEINPROGRESS
-#endif /* __WIN32__ */
+#endif /* __WIN__ */
#define O_NONBLOCK 1 /* For emulation of fcntl() */
#endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK EAGAIN
#endif
-#ifndef __WIN32__
+#ifndef __WIN__
#define HANDLE void *
#endif
@@ -85,11 +85,11 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
{
vio_reset(vio, type, sd, 0, localhost);
sprintf(vio->desc, "socket (%d)", vio->sd);
-#if !defined(___WIN32__) && !defined(__EMX__)
+#if !defined(___WIN__) && !defined(__EMX__)
#if !defined(NO_FCNTL_NONBLOCK)
vio->fcntl_mode = fcntl(sd, F_GETFL);
#endif
-#else /* !defined(__WIN32__) && !defined(__EMX__) */
+#else /* !defined(__WIN__) && !defined(__EMX__) */
{
/* set to blocking mode by default */
ulong arg=0;
@@ -101,7 +101,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
}
-#ifdef __WIN32__
+#ifdef __WIN__
Vio *vio_new_win32pipe(HANDLE hPipe)
{
@@ -140,7 +140,7 @@ int vio_read(Vio * vio, gptr buf, int size)
int r;
DBUG_ENTER("vio_read");
DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
-#ifdef __WIN32__
+#ifdef __WIN__
if (vio->type == VIO_TYPE_NAMEDPIPE)
{
DWORD length;
@@ -152,7 +152,7 @@ int vio_read(Vio * vio, gptr buf, int size)
#else
errno=0; /* For linux */
r = read(vio->sd, buf, size);
-#endif /* __WIN32__ */
+#endif /* __WIN__ */
#ifndef DBUG_OFF
if (r < 0)
{
@@ -169,7 +169,7 @@ int vio_write(Vio * vio, const gptr buf, int size)
int r;
DBUG_ENTER("vio_write");
DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
-#ifdef __WIN32__
+#ifdef __WIN__
if ( vio->type == VIO_TYPE_NAMEDPIPE)
{
DWORD length;
@@ -180,7 +180,7 @@ int vio_write(Vio * vio, const gptr buf, int size)
r = send(vio->sd, buf, size,0);
#else
r = write(vio->sd, buf, size);
-#endif /* __WIN32__ */
+#endif /* __WIN__ */
#ifndef DBUG_OFF
if (r < 0)
{
@@ -198,7 +198,7 @@ int vio_blocking(Vio * vio, my_bool set_blocking_mode)
DBUG_ENTER("vio_blocking");
DBUG_PRINT("enter", ("set_blocking_mode: %d", (int) set_blocking_mode));
-#if !defined(___WIN32__) && !defined(__EMX__)
+#if !defined(___WIN__) && !defined(__EMX__)
#if !defined(NO_FCNTL_NONBLOCK)
if (vio->sd >= 0)
@@ -212,7 +212,7 @@ int vio_blocking(Vio * vio, my_bool set_blocking_mode)
r = fcntl(vio->sd, F_SETFL, vio->fcntl_mode);
}
#endif /* !defined(NO_FCNTL_NONBLOCK) */
-#else /* !defined(__WIN32__) && !defined(__EMX__) */
+#else /* !defined(__WIN__) && !defined(__EMX__) */
#ifndef __EMX__
if (vio->type != VIO_TYPE_NAMEDPIPE)
#endif
@@ -232,7 +232,7 @@ int vio_blocking(Vio * vio, my_bool set_blocking_mode)
if (old_fcntl != vio->fcntl_mode)
r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg));
}
-#endif /* !defined(__WIN32__) && !defined(__EMX__) */
+#endif /* !defined(__WIN__) && !defined(__EMX__) */
DBUG_RETURN(r);
}
@@ -304,7 +304,7 @@ int vio_close(Vio * vio)
{
int r;
DBUG_ENTER("vio_close");
-#ifdef __WIN32__
+#ifdef __WIN__
if (vio->type == VIO_TYPE_NAMEDPIPE)
{
#if defined(__NT__) && defined(MYSQL_SERVER)
@@ -314,7 +314,7 @@ int vio_close(Vio * vio)
r=CloseHandle(vio->hPipe);
}
else if (vio->type != VIO_CLOSED)
-#endif /* __WIN32__ */
+#endif /* __WIN__ */
{
r=0;
if (shutdown(vio->sd,2))
diff --git a/ext/mysql/libmysql/violite.h b/ext/mysql/libmysql/violite.h
index 476e0ea16f..e7fa193673 100644
--- a/ext/mysql/libmysql/violite.h
+++ b/ext/mysql/libmysql/violite.h
@@ -1,5 +1,5 @@
-/* Copyright Abandoned 2000 Monty Program KB
- This file is public domain and comes with NO WARRANTY of any kind */
+/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
+This file is public domain and comes with NO WARRANTY of any kind */
/*
* Vio Lite.
@@ -33,7 +33,7 @@ enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
Vio* vio_new(my_socket sd,
enum enum_vio_type type,
my_bool localhost);
-#ifdef __WIN32__
+#ifdef __WIN__
Vio* vio_new_win32pipe(HANDLE hPipe);
#endif
void vio_delete(Vio* vio);