summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am5
-rw-r--r--include/atomic/gcc_builtins.h5
-rw-r--r--include/atomic/nolock.h4
-rw-r--r--include/atomic/rwlock.h4
-rw-r--r--include/atomic/x86-gcc.h4
-rw-r--r--include/config-win.h21
-rw-r--r--include/errmsg.h7
-rw-r--r--include/hash.h34
-rw-r--r--include/help_end.h4
-rw-r--r--include/help_start.h4
-rw-r--r--include/m_ctype.h5
-rw-r--r--include/m_string.h10
-rw-r--r--include/my_aes.h5
-rw-r--r--include/my_atomic.h4
-rw-r--r--include/my_base.h12
-rw-r--r--include/my_bit.h5
-rw-r--r--include/my_dbug.h184
-rw-r--r--include/my_dir.h4
-rw-r--r--include/my_global.h46
-rw-r--r--include/my_handler.h2
-rw-r--r--include/my_libwrap.h4
-rw-r--r--include/my_md5.h5
-rw-r--r--include/my_no_pthread.h8
-rw-r--r--include/my_pthread.h37
-rw-r--r--include/my_sys.h67
-rw-r--r--include/my_uctype.h4
-rw-r--r--include/myisam.h4
-rw-r--r--include/myisampack.h4
-rw-r--r--include/mysql.h136
-rw-r--r--include/mysql.h.pp83
-rw-r--r--include/mysql/plugin.h80
-rw-r--r--include/mysql/plugin.h.pp45
-rw-r--r--include/mysql/service_my_snprintf.h98
-rw-r--r--include/mysql/service_thd_alloc.h128
-rw-r--r--include/mysql/services.h30
-rw-r--r--include/mysql_com.h29
-rw-r--r--include/mysql_embed.h4
-rw-r--r--include/rijndael.h5
-rw-r--r--include/service_versions.h24
-rw-r--r--include/sha1.h5
-rw-r--r--include/sql_common.h4
-rw-r--r--include/sslopt-case.h4
-rw-r--r--include/sslopt-longopts.h4
-rw-r--r--include/sslopt-vars.h4
44 files changed, 697 insertions, 488 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index dd6f53f7ca2..0a7a35bd6fa 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -21,7 +21,8 @@ HEADERS_GEN_MAKE = my_config.h
HEADERS_ABI = mysql.h mysql_com.h mysql_time.h \
my_list.h my_alloc.h typelib.h mysql/plugin.h
pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
- my_xml.h mysql_embed.h \
+ my_xml.h mysql_embed.h mysql/services.h \
+ mysql/service_my_snprintf.h mysql/service_thd_alloc.h \
my_pthread.h my_no_pthread.h \
decimal.h errmsg.h my_global.h my_net.h \
my_getopt.h sslopt-longopts.h my_dir.h \
@@ -36,7 +37,7 @@ noinst_HEADERS = config-win.h config-netware.h my_bit.h \
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \
my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
thr_lock.h t_ctype.h violite.h my_md5.h base64.h \
- my_handler.h my_time.h \
+ my_handler.h my_time.h service_versions.h \
my_vle.h my_user.h my_atomic.h atomic/nolock.h \
atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \
atomic/solaris.h \
diff --git a/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h
index 509701b30a5..01ebc38707e 100644
--- a/include/atomic/gcc_builtins.h
+++ b/include/atomic/gcc_builtins.h
@@ -1,3 +1,6 @@
+#ifndef ATOMIC_GCC_BUILTINS_INCLUDED
+#define ATOMIC_GCC_BUILTINS_INCLUDED
+
/* Copyright (C) 2008 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -31,3 +34,5 @@
#define make_atomic_store_body(S) \
(void) __sync_lock_test_and_set(a, v);
#endif
+
+#endif /* ATOMIC_GCC_BUILTINS_INCLUDED */
diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h
index 0e6c8089b84..d7d87167ade 100644
--- a/include/atomic/nolock.h
+++ b/include/atomic/nolock.h
@@ -1,3 +1,6 @@
+#ifndef ATOMIC_NOLOCK_INCLUDED
+#define ATOMIC_NOLOCK_INCLUDED
+
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -59,3 +62,4 @@ typedef struct { } my_atomic_rwlock_t;
#endif
+#endif /* ATOMIC_NOLOCK_INCLUDED */
diff --git a/include/atomic/rwlock.h b/include/atomic/rwlock.h
index 18b77e93d80..0ff4d16c545 100644
--- a/include/atomic/rwlock.h
+++ b/include/atomic/rwlock.h
@@ -1,3 +1,6 @@
+#ifndef ATOMIC_RWLOCK_INCLUDED
+#define ATOMIC_RWLOCK_INCLUDED
+
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -46,3 +49,4 @@ typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t;
#define make_atomic_load_body(S) ret= *a;
#define make_atomic_store_body(S) *a= v;
+#endif /* ATOMIC_RWLOCK_INCLUDED */
diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h
index 726c98213fb..c3029f9c1b4 100644
--- a/include/atomic/x86-gcc.h
+++ b/include/atomic/x86-gcc.h
@@ -1,3 +1,6 @@
+#ifndef ATOMIC_X86_GCC_INCLUDED
+#define ATOMIC_X86_GCC_INCLUDED
+
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -56,3 +59,4 @@
asm volatile ("; xchg %0, %1;" : "+m" (*a) : "r" (v))
#endif
+#endif /* ATOMIC_X86_GCC_INCLUDED */
diff --git a/include/config-win.h b/include/config-win.h
index af4915440b1..364c4f92134 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -1,3 +1,6 @@
+#ifndef CONFIG_WIN_INCLUDED
+#define CONFIG_WIN_INCLUDED
+
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
@@ -27,6 +30,9 @@
#include <fcntl.h>
#include <io.h>
#include <malloc.h>
+#include <sys/stat.h>
+#include <process.h> /* getpid()*/
+
#define HAVE_SMEM 1
@@ -65,7 +71,6 @@
#endif
/* File and lock constants */
-#define O_SHARE 0x1000 /* Open file in sharing mode */
#ifdef __BORLANDC__
#define F_RDLCK LK_NBLCK /* read lock */
#define F_WRLCK LK_NBRLCK /* write lock */
@@ -175,7 +180,7 @@ typedef uint rf_SetTimer;
#define SIZEOF_CHARP 4
#endif
#define HAVE_BROKEN_NETINET_INCLUDES
-#ifdef __NT__
+#ifdef _WIN32
#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
#endif
@@ -288,11 +293,6 @@ inline ulonglong double2ulonglong(double d)
#define strcasecmp stricmp
#define strncasecmp strnicmp
-#ifndef __NT__
-#undef FILE_SHARE_DELETE
-#define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */
-#endif
-
#ifdef NOT_USED
#define HAVE_SNPRINTF /* Gave link error */
#define _snprintf snprintf
@@ -336,13 +336,13 @@ inline ulonglong double2ulonglong(double d)
#define FN_DEVCHAR ':'
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
-#define OS_FILE_LIMIT 2048
+#define OS_FILE_LIMIT UINT_MAX /* No limit*/
#define DO_NOT_REMOVE_THREAD_WRAPPERS
#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
/* The following is only used for statistics, so it should be good enough */
-#ifdef __NT__ /* This should also work on Win98 but .. */
+#ifdef _WIN32
#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
#endif
@@ -356,7 +356,6 @@ inline ulonglong double2ulonglong(double d)
#define HAVE_OPENSSL 1
#define HAVE_YASSL 1
-#define COMMUNITY_SERVER 1
#define ENABLED_PROFILING 1
/*
@@ -410,3 +409,5 @@ inline ulonglong double2ulonglong(double d)
#define HAVE_UCA_COLLATIONS 1
#define HAVE_BOOL 1
+
+#endif /* CONFIG_WIN_INCLUDED */
diff --git a/include/errmsg.h b/include/errmsg.h
index a6d8c770de8..c55c94af169 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -1,3 +1,6 @@
+#ifndef ERRMSG_INCLUDED
+#define ERRMSG_INCLUDED
+
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -97,6 +100,8 @@ extern const char *client_errors[]; /* Error messages */
#define CR_SERVER_LOST_EXTENDED 2055
#define CR_STMT_CLOSED 2056
#define CR_NEW_STMT_METADATA 2057
-#define CR_ERROR_LAST /*Copy last error nr:*/ 2057
+#define CR_ALREADY_CONNECTED 2058
+#define CR_ERROR_LAST /*Copy last error nr:*/ 2058
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
+#endif /* ERRMSG_INCLUDED */
diff --git a/include/hash.h b/include/hash.h
index 629b404e8a7..d870e17c341 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -22,40 +22,6 @@ extern "C" {
#endif
/*
- There was a problem on MacOSX with a shared object ha_example.so.
- It used hash_search(). During build of ha_example.so no libmysys
- was specified. Since MacOSX had a hash_search() in the system
- library, it built the shared object so that the dynamic linker
- linked hash_search() to the system library, which caused a crash
- when called. To come around this, we renamed hash_search() to
- my_hash_search(), as we did long ago with hash_insert() and
- hash_reset(). However, this time we made the move complete with
- all names. To keep compatibility, we redefine the old names.
- Since every C and C++ file, that uses HASH, needs to include
- this file, the change is complete. Both names could be used
- in the code, but the my_* versions are recommended now.
-*/
-#define hash_get_key my_hash_get_key
-#define hash_free_key my_hash_free_key
-#define hash_init my_hash_init
-#define hash_init2 my_hash_init2
-#define _hash_init _my_hash_init
-#define hash_free my_hash_free
-#define hash_reset my_hash_reset
-#define hash_element my_hash_element
-#define hash_search my_hash_search
-#define hash_first my_hash_first
-#define hash_next my_hash_next
-#define hash_insert my_hash_insert
-#define hash_delete my_hash_delete
-#define hash_update my_hash_update
-#define hash_replace my_hash_replace
-#define hash_check my_hash_check
-#define hash_clear my_hash_clear
-#define hash_inited my_hash_inited
-#define hash_init_opt my_hash_init_opt
-
-/*
Overhead to store an element in hash
Can be used to approximate memory consumption for a hash
*/
diff --git a/include/help_end.h b/include/help_end.h
index 4426cb80bce..92953efe35a 100644
--- a/include/help_end.h
+++ b/include/help_end.h
@@ -1,3 +1,6 @@
+#ifndef HELP_END_INCLUDED
+#define HELP_END_INCLUDED
+
/* Copyright (C) 2004-2005 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -20,3 +23,4 @@
#undef fputc
#undef putchar
#endif
+#endif /* HELP_END_INCLUDED */
diff --git a/include/help_start.h b/include/help_start.h
index 3ae20eea7d7..414f7ec93a0 100644
--- a/include/help_start.h
+++ b/include/help_start.h
@@ -1,3 +1,6 @@
+#ifndef HELP_START_INCLUDED
+#define HELP_START_INCLUDED
+
/* Copyright (C) 2004-2005 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -22,3 +25,4 @@
#define fputc(s,f) consoleprintf("%c", s)
#define putchar(s) consoleprintf("%c", s)
#endif
+#endif /* HELP_START_INCLUDED */
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 451c8db549b..700f373d677 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -87,6 +87,7 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
#define MY_CS_CSSORT 1024 /* if case sensitive sort order */
#define MY_CS_HIDDEN 2048 /* don't display in SHOW */
#define MY_CS_PUREASCII 4096 /* if a charset is pure ascii */
+#define MY_CS_NONASCII 8192 /* if not ASCII-compatible */
#define MY_CHARSET_UNDEFINED 0
/* Character repertoire flags */
@@ -474,6 +475,10 @@ my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs);
uint my_charset_repertoire(CHARSET_INFO *cs);
+my_bool my_charset_is_ascii_compatible(CHARSET_INFO *cs);
+
+extern size_t my_vsnprintf_ex(CHARSET_INFO *cs, char *to, size_t n,
+ const char* fmt, va_list ap);
#define _MY_U 01 /* Upper case */
#define _MY_L 02 /* Lower case */
diff --git a/include/m_string.h b/include/m_string.h
index c24bfd7aa6c..3c4c6ea088a 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -250,16 +250,10 @@ extern size_t my_snprintf(char *to, size_t n, const char *fmt, ...)
/*
LEX_STRING -- a pair of a C-string and its length.
+ (it's part of the plugin API as a MYSQL_LEX_STRING)
*/
-#ifndef _my_plugin_h
-/* This definition must match the one given in mysql/plugin.h */
-struct st_mysql_lex_string
-{
- char *str;
- size_t length;
-};
-#endif
+#include <mysql/plugin.h>
typedef struct st_mysql_lex_string LEX_STRING;
#define STRING_WITH_LEN(X) (X), ((size_t) (sizeof(X) - 1))
diff --git a/include/my_aes.h b/include/my_aes.h
index 1bbdf5663ea..2e2a66b4968 100644
--- a/include/my_aes.h
+++ b/include/my_aes.h
@@ -1,3 +1,6 @@
+#ifndef MY_AES_INCLUDED
+#define MY_AES_INCLUDED
+
/* Copyright (C) 2002 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -63,3 +66,5 @@ int my_aes_decrypt(const char *source, int source_length, char *dest,
int my_aes_get_size(int source_length);
C_MODE_END
+
+#endif /* MY_AES_INCLUDED */
diff --git a/include/my_atomic.h b/include/my_atomic.h
index 03f7d081981..f5da6e6a0d9 100644
--- a/include/my_atomic.h
+++ b/include/my_atomic.h
@@ -1,3 +1,6 @@
+#ifndef MY_ATOMIC_INCLUDED
+#define MY_ATOMIC_INCLUDED
+
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -150,3 +153,4 @@ extern int my_atomic_initialize();
#endif
+#endif /* MY_ATOMIC_INCLUDED */
diff --git a/include/my_base.h b/include/my_base.h
index a01b2ec9b82..70bd9b5e073 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -255,7 +255,17 @@ enum ha_base_keytype {
HA_BINARY_PACK_KEY | HA_FULLTEXT | HA_UNIQUE_CHECK | \
HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
-#define HA_KEY_HAS_PART_KEY_SEG 65536 /* Key contains partial segments */
+/*
+ Key contains partial segments.
+
+ This flag is internal to the MySQL server by design. It is not supposed
+ neither to be saved in FRM-files, nor to be passed to storage engines.
+ It is intended to pass information into internal static sort_keys(KEY *,
+ KEY *) function.
+
+ This flag can be calculated -- it's based on key lengths comparison.
+*/
+#define HA_KEY_HAS_PART_KEY_SEG 65536
/* Automatic bits in key-flag */
diff --git a/include/my_bit.h b/include/my_bit.h
index 2e464e89049..5cbf4f8b83e 100644
--- a/include/my_bit.h
+++ b/include/my_bit.h
@@ -1,3 +1,6 @@
+#ifndef MY_BIT_INCLUDED
+#define MY_BIT_INCLUDED
+
/*
Some useful bit functions
*/
@@ -107,3 +110,5 @@ extern uint my_count_bits(ulonglong v);
extern uint my_count_bits_ushort(ushort v);
#endif /* HAVE_INLINE */
C_MODE_END
+
+#endif /* MY_BIT_INCLUDED */
diff --git a/include/my_dbug.h b/include/my_dbug.h
index 0ba72b2210d..956a5504e86 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -16,101 +16,64 @@
#ifndef _dbug_h
#define _dbug_h
-#if defined(__cplusplus) && !defined(DBUG_OFF)
-class Dbug_violation_helper
-{
-public:
- inline Dbug_violation_helper() :
- _entered(TRUE)
- { }
-
- inline ~Dbug_violation_helper()
- {
- assert(!_entered);
- }
-
- inline void leave()
- {
- _entered= FALSE;
- }
-
-private:
- bool _entered;
-};
-#endif /* C++ */
-
-#ifdef __cplusplus
+#ifdef __cplusplus
extern "C" {
#endif
#if !defined(DBUG_OFF) && !defined(_lint)
-struct _db_code_state_;
-extern int _db_keyword_(struct _db_code_state_ *cs, const char *keyword);
-extern int _db_strict_keyword_(const char *keyword);
+
+struct _db_stack_frame_ {
+ const char *func; /* function name of the previous stack frame */
+ const char *file; /* filename of the function of previous frame */
+ uint level; /* this nesting level, highest bit enables tracing */
+ struct _db_stack_frame_ *prev; /* pointer to the previous frame */
+};
+
+struct _db_code_state_;
+extern my_bool _dbug_on_;
+extern my_bool _db_keyword_(struct _db_code_state_ *, const char *, int);
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
extern int _db_explain_init_(char *buf, size_t len);
-extern void _db_setjmp_(void);
-extern void _db_longjmp_(void);
+extern int _db_is_pushed_(void);
+extern void _db_setjmp_(void);
+extern void _db_longjmp_(void);
extern void _db_process_(const char *name);
-extern void _db_push_(const char *control);
-extern void _db_pop_(void);
-extern void _db_set_(struct _db_code_state_ *cs, const char *control);
+extern void _db_push_(const char *control);
+extern void _db_pop_(void);
+extern void _db_set_(const char *control);
extern void _db_set_init_(const char *control);
-extern void _db_enter_(const char *_func_,const char *_file_,uint _line_,
- const char **_sfunc_,const char **_sfile_,
- uint *_slevel_, char ***);
-extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
- uint *_slevel_);
-extern void _db_pargs_(uint _line_,const char *keyword);
-extern void _db_doprnt_ _VARARGS((const char *format,...))
+extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
+ struct _db_stack_frame_ *_stack_frame_);
+extern void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_);
+extern void _db_pargs_(uint _line_,const char *keyword);
+extern void _db_doprnt_ _VARARGS((const char *format,...))
ATTRIBUTE_FORMAT(printf, 1, 2);
-extern void _db_dump_(uint _line_,const char *keyword,
+extern void _db_dump_(uint _line_,const char *keyword,
const unsigned char *memory, size_t length);
-extern void _db_end_(void);
-extern void _db_lock_file_(void);
-extern void _db_unlock_file_(void);
-extern FILE *_db_fp_(void);
-
-#ifdef __cplusplus
-
-#define DBUG_ENTER(a) \
- const char *_db_func_, *_db_file_; \
- uint _db_level_; \
- char **_db_framep_; \
- Dbug_violation_helper dbug_violation_helper; \
- _db_enter_ (a, __FILE__, __LINE__, &_db_func_, &_db_file_, \
- &_db_level_, &_db_framep_)
-#define DBUG_VIOLATION_HELPER_LEAVE dbug_violation_helper.leave()
-
-#else /* C */
-
-#define DBUG_ENTER(a) \
- const char *_db_func_, *_db_file_; \
- uint _db_level_; \
- char **_db_framep_; \
- _db_enter_ (a, __FILE__, __LINE__, &_db_func_, &_db_file_, \
- &_db_level_, &_db_framep_)
-#define DBUG_VIOLATION_HELPER_LEAVE do { } while(0)
-
-#endif /* C++ */
-
-#define DBUG_LEAVE \
- DBUG_VIOLATION_HELPER_LEAVE; \
- _db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_)
+extern void _db_end_(void);
+extern void _db_lock_file_(void);
+extern void _db_unlock_file_(void);
+extern FILE *_db_fp_(void);
+extern void _db_flush_();
+extern const char* _db_get_func_(void);
+
+#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \
+ _db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
+#define DBUG_LEAVE _db_return_ (__LINE__, &_db_stack_frame_)
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
#define DBUG_EXECUTE(keyword,a1) \
- do {if (_db_keyword_(0, (keyword))) { a1 }} while(0)
+ do {if (_db_keyword_(0, (keyword), 0)) { a1 }} while(0)
#define DBUG_EXECUTE_IF(keyword,a1) \
- do {if (_db_strict_keyword_ (keyword)) { a1 } } while(0)
+ do {if (_db_keyword_(0, (keyword), 1)) { a1 }} while(0)
#define DBUG_EVALUATE(keyword,a1,a2) \
- (_db_keyword_(0,(keyword)) ? (a1) : (a2))
+ (_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
- (_db_strict_keyword_((keyword)) ? (a1) : (a2))
+ (_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
#define DBUG_PRINT(keyword,arglist) \
do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
#define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ ()
-#define DBUG_SET(a1) _db_set_ (0, (a1))
+#define DBUG_SET(a1) _db_set_ (a1)
#define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
#define DBUG_PROCESS(a1) _db_process_(a1)
#define DBUG_FILE _db_fp_()
@@ -123,37 +86,66 @@ extern FILE *_db_fp_(void);
#define DBUG_ASSERT(A) assert(A)
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
-#define IF_DBUG(A) A
-#else /* No debugger */
+#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
+#define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
+#ifndef __WIN__
+#define DBUG_ABORT() (_db_flush_(), abort())
+#else
+/*
+ Avoid popup with abort/retry/ignore buttons. When BUG#31745 is fixed we can
+ call abort() instead of _exit(3) (now it would cause a "test signal" popup).
+*/
+#include <crtdbg.h>
+#define DBUG_ABORT() (_db_flush_(),\
+ (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE),\
+ (void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR),\
+ _exit(3))
+#endif
+#define DBUG_CHECK_CRASH(func, op) \
+ do { char _dbuf_[255]; strxnmov(_dbuf_, sizeof(_dbuf_)-1, (func), (op)); \
+ DBUG_EXECUTE_IF(_dbuf_, DBUG_ABORT()); } while(0)
+#define DBUG_CRASH_ENTER(func) \
+ DBUG_ENTER(func); DBUG_CHECK_CRASH(func, "_crash_enter")
+#define DBUG_CRASH_RETURN(val) \
+ DBUG_CHECK_CRASH(_db_get_func_(), "_crash_return")
+#define DBUG_CRASH_VOID_RETURN \
+ DBUG_CHECK_CRASH (_db_get_func_(), "_crash_return")
+
+#else /* No debugger */
#define DBUG_ENTER(a1)
#define DBUG_LEAVE
-#define DBUG_VIOLATION_HELPER_LEAVE
-#define DBUG_RETURN(a1) do { return(a1); } while(0)
-#define DBUG_VOID_RETURN do { return; } while(0)
-#define DBUG_EXECUTE(keyword,a1) do { } while(0)
-#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
+#define DBUG_RETURN(a1) do { return(a1); } while(0)
+#define DBUG_VOID_RETURN do { return; } while(0)
+#define DBUG_EXECUTE(keyword,a1) do { } while(0)
+#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
-#define DBUG_PRINT(keyword,arglist) do { } while(0)
-#define DBUG_PUSH(a1)
-#define DBUG_SET(a1) do { } while(0)
-#define DBUG_SET_INITIAL(a1) do { } while(0)
-#define DBUG_POP()
-#define DBUG_PROCESS(a1)
+#define DBUG_PRINT(keyword,arglist) do { } while(0)
+#define DBUG_PUSH(a1) do { } while(0)
+#define DBUG_SET(a1) do { } while(0)
+#define DBUG_SET_INITIAL(a1) do { } while(0)
+#define DBUG_POP() do { } while(0)
+#define DBUG_PROCESS(a1) do { } while(0)
#define DBUG_SETJMP(a1) setjmp(a1)
#define DBUG_LONGJMP(a1) longjmp(a1)
-#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
-#define DBUG_END()
-#define DBUG_ASSERT(A) do { } while(0)
-#define DBUG_LOCK_FILE
+#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
+#define DBUG_END() do { } while(0)
+#define DBUG_ASSERT(A) do { } while(0)
+#define DBUG_LOCK_FILE do { } while(0)
#define DBUG_FILE (stderr)
-#define DBUG_UNLOCK_FILE
+#define DBUG_UNLOCK_FILE do { } while(0)
#define DBUG_EXPLAIN(buf,len)
#define DBUG_EXPLAIN_INITIAL(buf,len)
-#define IF_DBUG(A)
+#define DEBUGGER_OFF do { } while(0)
+#define DEBUGGER_ON do { } while(0)
+#define DBUG_ABORT() abort()
+#define DBUG_CRASH_ENTER(func)
+#define DBUG_CRASH_RETURN(val) do { return(val); } while(0)
+#define DBUG_CRASH_VOID_RETURN do { return; } while(0)
+
#endif
-#ifdef __cplusplus
+#ifdef __cplusplus
}
#endif
#endif
diff --git a/include/my_dir.h b/include/my_dir.h
index 06509a3af19..90d708ac811 100644
--- a/include/my_dir.h
+++ b/include/my_dir.h
@@ -69,7 +69,11 @@ typedef struct my_stat
#else
+#if(_MSC_VER)
+#define MY_STAT struct _stati64 /* 64 bit file size */
+#else
#define MY_STAT struct stat /* Orginal struct have what we need */
+#endif
#endif /* USE_MY_STAT_STRUCT */
diff --git a/include/my_global.h b/include/my_global.h
index 0f312f13bf0..f6d1592fc6f 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -410,6 +410,7 @@ C_MODE_END
#ifndef stdin
#include <stdio.h>
#endif
+#include <stdarg.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
@@ -648,8 +649,6 @@ C_MODE_END
# endif
#endif
-#include <my_dbug.h>
-
#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/
#define ASCII_BITS_USED 8 /* Bit char used */
#define NEAR_F /* No near function handling */
@@ -749,7 +748,41 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define FN_LIBCHAR '/'
#define FN_ROOTDIR "/"
#endif
-#define MY_NFILE 64 /* This is only used to save filenames */
+
+/*
+ MY_FILE_MIN is Windows speciality and is used to quickly detect
+ the mismatch of CRT and mysys file IO usage on Windows at runtime.
+ CRT file descriptors can be in the range 0-2047, whereas descriptors returned
+ by my_open() will start with 2048. If a file descriptor with value less then
+ MY_FILE_MIN is passed to mysys IO function, chances are it stemms from
+ open()/fileno() and not my_open()/my_fileno.
+
+ For Posix, mysys functions are light wrappers around libc, and MY_FILE_MIN
+ is logically 0.
+*/
+
+#ifdef _WIN32
+#define MY_FILE_MIN 2048
+#else
+#define MY_FILE_MIN 0
+#endif
+
+/*
+ MY_NFILE is the default size of my_file_info array.
+
+ It is larger on Windows, because it all file handles are stored in my_file_info
+ Default size is 16384 and this should be enough for most cases.If it is not
+ enough, --max-open-files with larger value can be used.
+
+ For Posix , my_file_info array is only used to store filenames for
+ error reporting and its size is not a limitation for number of open files.
+*/
+#ifdef _WIN32
+#define MY_NFILE (16384 + MY_FILE_MIN)
+#else
+#define MY_NFILE 64
+#endif
+
#ifndef OS_FILE_LIMIT
#define OS_FILE_LIMIT 65535
#endif
@@ -786,9 +819,8 @@ typedef SOCKET_SIZE_TYPE size_socket;
/* Some things that this system doesn't have */
#define NO_HASH /* Not needed anymore */
-#ifdef __WIN__
-#define NO_DIR_LIBRARY /* Not standar dir-library */
-#define USE_MY_STAT_STRUCT /* For my_lib */
+#ifdef _WIN32
+#define NO_DIR_LIBRARY /* Not standard dir-library */
#endif
/* Some defines of functions for portability */
@@ -1143,6 +1175,8 @@ typedef char bool; /* Ordinary boolean values 0 1 */
#define reg16 register
#endif
+#include <my_dbug.h>
+
/*
Sometimes we want to make sure that the variable is not put into
a register in debugging mode so we can see its value in the core
diff --git a/include/my_handler.h b/include/my_handler.h
index a3376cb74a2..ae56331df86 100644
--- a/include/my_handler.h
+++ b/include/my_handler.h
@@ -53,8 +53,8 @@ typedef struct st_HA_KEYSEG /* Key-portion */
uint16 bit_pos; /* Position to bit part */
uint16 flag;
uint16 length; /* Keylength */
+ uint16 language;
uint8 type; /* Type of key (for sort) */
- uint8 language;
uint8 null_bit; /* bitmask to test for NULL */
uint8 bit_start,bit_end; /* if bit field */
uint8 bit_length; /* Length of bit part */
diff --git a/include/my_libwrap.h b/include/my_libwrap.h
index 9a8579475fb..8235c00d8f3 100644
--- a/include/my_libwrap.h
+++ b/include/my_libwrap.h
@@ -1,3 +1,6 @@
+#ifndef MY_LIBWRAP_INCLUDED
+#define MY_LIBWRAP_INCLUDED
+
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -25,3 +28,4 @@ extern int my_hosts_access(struct request_info *req);
extern char *my_eval_client(struct request_info *req);
#endif /* HAVE_LIBWRAP */
+#endif /* MY_LIBWRAP_INCLUDED */
diff --git a/include/my_md5.h b/include/my_md5.h
index 6458f27c5cc..782bef8a27a 100644
--- a/include/my_md5.h
+++ b/include/my_md5.h
@@ -1,3 +1,6 @@
+#ifndef MY_MD5_INCLUDED
+#define MY_MD5_INCLUDED
+
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -52,3 +55,5 @@ do { \
my_MD5Update (&ctx, buf, len); \
my_MD5Final (digest, &ctx); \
} while (0)
+
+#endif /* MY_MD__INCLUDED */
diff --git a/include/my_no_pthread.h b/include/my_no_pthread.h
index b11dbff42f0..31c1bf2b6ac 100644
--- a/include/my_no_pthread.h
+++ b/include/my_no_pthread.h
@@ -1,3 +1,6 @@
+#ifndef MY_NO_PTHREAD_INCLUDED
+#define MY_NO_PTHREAD_INCLUDED
+
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -14,9 +17,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#if !defined(_my_no_pthread_h) && !defined(THREAD)
-#define _my_no_pthread_h
-
+#ifndef THREAD
/*
This block is to access some thread-related type definitions
@@ -48,3 +49,4 @@
#define rwlock_destroy(A)
#endif
+#endif /* MY_NO_PTHREAD_INCLUDED */
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 9e2c2111b8e..b6d9feae067 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -31,7 +31,7 @@ extern "C" {
#if defined(__WIN__)
typedef CRITICAL_SECTION pthread_mutex_t;
-typedef HANDLE pthread_t;
+typedef DWORD pthread_t;
typedef struct thread_attr {
DWORD dwStackSize ;
DWORD dwCreatingFlag ;
@@ -64,8 +64,7 @@ typedef struct {
typedef int pthread_mutexattr_t;
-#define win_pthread_self my_thread_var->pthread_self
-#define pthread_self() win_pthread_self
+#define pthread_self() GetCurrentThreadId()
#define pthread_handler_t EXTERNC void * __cdecl
typedef void * (__cdecl *pthread_handler)(void *);
@@ -99,8 +98,7 @@ struct timespec {
(ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \
}
-void win_pthread_init(void);
-int win_pthread_setspecific(void *A,void *B,uint length);
+
int win_pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
@@ -117,42 +115,25 @@ int pthread_attr_destroy(pthread_attr_t *connect_att);
struct tm *localtime_r(const time_t *timep,struct tm *tmp);
struct tm *gmtime_r(const time_t *timep,struct tm *tmp);
+void pthread_exit(void *a);
+int pthread_join(pthread_t thread, void **value_ptr);
-void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#define ETIMEDOUT 145 /* Win32 doesn't have this */
-#define getpid() GetCurrentThreadId()
#define HAVE_LOCALTIME_R 1
#define _REENTRANT 1
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
-/*
- Windows has two ways to use thread local storage. The most efficient
- is using __declspec(thread), but that does not work properly when
- used in a .dll that is loaded at runtime, after program load. So for
- libmysql.dll and libmysqld.dll we define USE_TLS in order to use the
- TlsXxx() API instead, which works in all cases.
-*/
-#ifdef USE_TLS /* For LIBMYSQL.DLL */
+
#undef SAFE_MUTEX /* This will cause conflicts */
#define pthread_key(T,V) DWORD V
#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
#define pthread_key_delete(A) TlsFree(A)
+#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V)))
+#define pthread_setspecific(A,B) (!TlsSetValue((A),(B)))
#define pthread_getspecific(A) (TlsGetValue(A))
#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V))
-#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V)))
-#define pthread_setspecific(A,B) (!TlsSetValue((A),(B)))
-#else
-#define pthread_key(T,V) __declspec(thread) T V
-#define pthread_key_create(A,B) pthread_dummy(0)
-#define pthread_key_delete(A) pthread_dummy(0)
-#define pthread_getspecific(A) (&(A))
-#define my_pthread_getspecific(T,A) (&(A))
-#define my_pthread_getspecific_ptr(T,V) (V)
-#define my_pthread_setspecific_ptr(T,V) ((T)=(V),0)
-#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A))
-#endif /* USE_TLS */
#define pthread_equal(A,B) ((A) == (B))
#define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0)
@@ -163,7 +144,6 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
-#define pthread_join(A,B) (WaitForSingleObject((A), INFINITE) != WAIT_OBJECT_0)
/* Dummy defines for easier code */
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
@@ -690,6 +670,7 @@ struct st_my_thread_var
};
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
+extern void **my_thread_var_dbug();
extern uint my_thread_end_wait_time;
#define my_thread_var (_my_thread_var())
#define my_errno my_thread_var->thr_errno
diff --git a/include/my_sys.h b/include/my_sys.h
index b4aac3a17bd..9121f0f249e 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -39,6 +39,17 @@ extern int NEAR my_errno; /* Last error in mysys */
#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(); }
+/**
+ Max length of an error message generated by mysys utilities.
+ Some mysys functions produce error messages. These mostly go
+ to stderr.
+ This constant defines the size of the buffer used to format
+ the message. It should be kept in sync with MYSQL_ERRMSG_SIZE,
+ since sometimes mysys errors are stored in the server diagnostics
+ area, and we would like to avoid unexpected truncation.
+*/
+#define MYSYS_ERRMSG_SIZE (512)
+
#define MY_FILE_ERROR ((size_t) -1)
/* General bitmaps for my_func's */
@@ -90,8 +101,6 @@ extern int NEAR my_errno; /* Last error in mysys */
#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
#define ME_FATALERROR 1024 /* Fatal statement error */
-#define ME_NO_WARNING_FOR_ERROR 2048 /* Don't push a warning for error */
-#define ME_NO_SP_HANDLER 4096 /* Don't call stored routine error handlers */
/* Bits in last argument to fn_format */
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
@@ -220,8 +229,8 @@ extern int errno; /* declare errno */
extern char *home_dir; /* Home directory for user */
extern const char *my_progname; /* program-name (printed in errors) */
extern char NEAR curr_dir[]; /* Current directory for user */
-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,
+extern void (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
+extern void (*fatal_error_handler_hook)(uint my_err, const char *str,
myf MyFlags);
extern uint my_file_limit;
extern ulong my_thread_stack_size;
@@ -232,8 +241,9 @@ extern uint my_large_page_size;
#endif
/* charsets */
+#define MY_ALL_CHARSETS_SIZE 2048
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *default_charset_info;
-extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *all_charsets[256];
+extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *all_charsets[MY_ALL_CHARSETS_SIZE];
extern CHARSET_INFO compiled_charsets[];
/* statistics */
@@ -321,9 +331,13 @@ enum file_type
struct st_my_file_info
{
- char * name;
- enum file_type type;
-#if defined(THREAD) && !defined(HAVE_PREAD)
+ char *name;
+#ifdef _WIN32
+ HANDLE fhandle; /* win32 file handle */
+ int oflag; /* open flags, e.g O_APPEND */
+#endif
+ enum file_type type;
+#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
pthread_mutex_t mutex;
#endif
};
@@ -628,43 +642,55 @@ extern void *my_memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);
-#ifdef __WIN__
-extern int my_access(const char *path, int amode);
-extern File my_sopen(const char *path, int oflag, int shflag, int pmode);
+#ifdef _WIN32
+extern int my_access(const char *path, int amode);
#else
#define my_access access
#endif
+
extern int check_if_legal_filename(const char *path);
extern int check_if_legal_tablename(const char *path);
-#if defined(__WIN__) && defined(__NT__)
+#ifdef _WIN32
extern int nt_share_delete(const char *name,myf MyFlags);
#define my_delete_allow_opened(fname,flags) nt_share_delete((fname),(flags))
#else
#define my_delete_allow_opened(fname,flags) my_delete((fname),(flags))
#endif
+#ifdef _WIN32
+/* Windows-only functions (CRT equivalents)*/
+extern File my_sopen(const char *path, int oflag, int shflag, int pmode);
+extern HANDLE my_get_osfhandle(File fd);
+extern void my_osmaperr(unsigned long last_error);
+#endif
+
#ifndef TERMINATE
extern void TERMINATE(FILE *file, uint flag);
#endif
extern void init_glob_errs(void);
+extern const char** get_global_errmsgs();
extern void wait_for_free_space(const char *filename, int errors);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
extern int my_fclose(FILE *fd,myf MyFlags);
+extern File my_fileno(FILE *fd);
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
extern int my_sync(File fd, myf my_flags);
extern int my_sync_dir(const char *dir_name, myf my_flags);
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
-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_error_register(const char **errmsgs, int first, int last);
+extern void my_error _VARARGS((int nr,myf MyFlags, ...));
+extern void my_printf_error _VARARGS((uint my_err, const char *format,
+ myf MyFlags, ...))
+ ATTRIBUTE_FORMAT(printf, 2, 4);
+extern void my_printv_error(uint error, const char *format, myf MyFlags,
+ va_list ap);
+extern int my_error_register(const char** (*get_errmsgs) (),
+ int first, int last);
extern const char **my_error_unregister(int first, int last);
-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);
+extern void my_message(uint my_err, const char *str,myf MyFlags);
+extern void my_message_no_curses(uint my_err, const char *str,myf MyFlags);
+extern void my_message_curses(uint my_err, const char *str,myf MyFlags);
extern my_bool my_init(void);
extern void my_end(int infoflag);
extern int my_redel(const char *from, const char *to, int MyFlags);
@@ -853,6 +879,7 @@ extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
extern int get_defaults_options(int argc, char **argv,
char **defaults, char **extra_defaults,
char **group_suffix);
+extern const char *args_separator;
extern int my_load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv, const char ***);
extern int load_defaults(const char *conf_file, const char **groups,
diff --git a/include/my_uctype.h b/include/my_uctype.h
index 9aaf478810c..580eb646e11 100644
--- a/include/my_uctype.h
+++ b/include/my_uctype.h
@@ -1,3 +1,6 @@
+#ifndef MY_UCTYPE_INCLUDED
+#define MY_UCTYPE_INCLUDED
+
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -1477,3 +1480,4 @@ MY_UNI_CTYPE my_uni_ctype[256]={
};
+#endif /* MY_UCTYPE_INCLUDED */
diff --git a/include/myisam.h b/include/myisam.h
index 19b35538c65..2df7ccf6dfa 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -162,7 +162,7 @@ typedef struct st_mi_create_info
ulonglong data_file_length;
ulonglong key_file_length;
uint old_options;
- uint8 language;
+ uint16 language;
my_bool with_auto_increment;
} MI_CREATE_INFO;
@@ -410,7 +410,7 @@ typedef struct st_mi_check_param
uint out_flag,warning_printed,error_printed,verbose;
uint opt_sort_key,total_files,max_level;
uint testflag, key_cache_block_size;
- uint8 language;
+ uint16 language;
my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
my_bool retry_repair, force_sort;
char temp_filename[FN_REFLEN],*isam_file_name;
diff --git a/include/myisampack.h b/include/myisampack.h
index 7d4871bd1cb..ecf35520a88 100644
--- a/include/myisampack.h
+++ b/include/myisampack.h
@@ -1,3 +1,6 @@
+#ifndef MYISAMPACK_INCLUDED
+#define MYISAMPACK_INCLUDED
+
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -236,3 +239,4 @@
mi_int4store(((T) + 4), A); }}
#define mi_sizekorr(T) mi_uint4korr((uchar*) (T) + 4)
#endif
+#endif /* MYISAMPACK_INCLUDED */
diff --git a/include/mysql.h b/include/mysql.h
index d114afb6c93..452b4374cf7 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -86,9 +86,11 @@ extern char *mysql_unix_port;
#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
#define IS_BLOB(n) ((n) & BLOB_FLAG)
-#define IS_NUM(t) ((t) <= MYSQL_TYPE_INT24 || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL)
-#define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG)
-#define INTERNAL_NUM_FIELD(f) (((f)->type <= MYSQL_TYPE_INT24 && ((f)->type != MYSQL_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == MYSQL_TYPE_YEAR)
+/**
+ Returns true if the value is a number which does not need quotes for
+ the sql_lex.cc parser to parse correctly.
+*/
+#define IS_NUM(t) (((t) <= MYSQL_TYPE_INT24 && (t) != MYSQL_TYPE_TIMESTAMP) || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL)
#define IS_LONGDATA(t) ((t) >= MYSQL_TYPE_TINY_BLOB && (t) <= MYSQL_TYPE_STRING)
@@ -186,24 +188,10 @@ struct st_mysql_options {
unsigned long max_allowed_packet;
my_bool use_ssl; /* if to use SSL or not */
my_bool compress,named_pipe;
- /*
- On connect, find out the replication role of the server, and
- establish connections to all the peers
- */
- my_bool rpl_probe;
- /*
- Each call to mysql_real_query() will parse it to tell if it is a read
- or a write, and direct it to the slave or the master
- */
- my_bool rpl_parse;
- /*
- If set, never read from a master, only from slave, when doing
- a read that is replication-aware
- */
- my_bool no_master_reads;
-#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
- my_bool separate_thread;
-#endif
+ my_bool unused1;
+ my_bool unused2;
+ my_bool unused3;
+ my_bool unused4;
enum mysql_option methods_to_use;
char *client_ip;
/* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */
@@ -230,15 +218,6 @@ enum mysql_protocol_type
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
};
-/*
- There are three types of queries - the ones that have to go to
- the master, the ones that go to a slave, and the adminstrative
- type which must happen on the pivot connectioin
-*/
-enum mysql_rpl_type
-{
- MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
-};
typedef struct character_set
{
@@ -283,21 +262,8 @@ typedef struct st_mysql
/* session-wide random string */
char scramble[SCRAMBLE_LENGTH+1];
-
- /*
- Set if this is the original connection, not a master or a slave we have
- added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave()
- */
- my_bool rpl_pivot;
- /*
- Pointers to the master, and the next slave connections, points to
- itself if lone connection.
- */
- struct st_mysql* master, *next_slave;
-
- struct st_mysql* last_used_slave; /* needed for round-robin slave pick */
- /* needed for send/read/store/use result to work correctly with replication */
- struct st_mysql* last_used_con;
+ my_bool unused1;
+ void *unused2, *unused3, *unused4, *unused5;
LIST *stmts; /* list of all statements */
const struct st_mysql_methods *methods;
@@ -331,35 +297,12 @@ typedef struct st_mysql_res {
void *extension;
} MYSQL_RES;
-#define MAX_MYSQL_MANAGER_ERR 256
-#define MAX_MYSQL_MANAGER_MSG 256
-
-#define MANAGER_OK 200
-#define MANAGER_INFO 250
-#define MANAGER_ACCESS 401
-#define MANAGER_CLIENT_ERR 450
-#define MANAGER_INTERNAL_ERR 500
#if !defined(MYSQL_SERVER) && !defined(MYSQL_CLIENT)
#define MYSQL_CLIENT
#endif
-typedef struct st_mysql_manager
-{
- NET net;
- char *host, *user, *passwd;
- char *net_buf, *net_buf_pos, *net_data_end;
- unsigned int port;
- int cmd_status;
- int last_errno;
- int net_buf_size;
- my_bool free_me;
- my_bool eof;
- char last_error[MAX_MYSQL_MANAGER_ERR];
- void *extension;
-} MYSQL_MANAGER;
-
typedef struct st_mysql_parameters
{
unsigned long *p_max_allowed_packet;
@@ -452,16 +395,6 @@ int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql);
-/* perform query on master */
-my_bool STDCALL mysql_master_query(MYSQL *mysql, const char *q,
- unsigned long length);
-my_bool STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
- unsigned long length);
-/* perform query on slave */
-my_bool STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
- unsigned long length);
-my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
- unsigned long length);
void STDCALL mysql_get_character_set_info(MYSQL *mysql,
MY_CHARSET_INFO *charset);
@@ -483,37 +416,6 @@ mysql_set_local_infile_handler(MYSQL *mysql,
void
mysql_set_local_infile_default(MYSQL *mysql);
-
-/*
- enable/disable parsing of all queries to decide if they go on master or
- slave
-*/
-void STDCALL mysql_enable_rpl_parse(MYSQL* mysql);
-void STDCALL mysql_disable_rpl_parse(MYSQL* mysql);
-/* get the value of the parse flag */
-int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql);
-
-/* enable/disable reads from master */
-void STDCALL mysql_enable_reads_from_master(MYSQL* mysql);
-void STDCALL mysql_disable_reads_from_master(MYSQL* mysql);
-/* get the value of the master read flag */
-my_bool STDCALL mysql_reads_from_master_enabled(MYSQL* mysql);
-
-enum mysql_rpl_type STDCALL mysql_rpl_query_type(const char* q, int len);
-
-/* discover the master and its slaves */
-my_bool STDCALL mysql_rpl_probe(MYSQL* mysql);
-
-/* set the master, close/free the old one, if it is not a pivot */
-int STDCALL mysql_set_master(MYSQL* mysql, const char* host,
- unsigned int port,
- const char* user,
- const char* passwd);
-int STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
- unsigned int port,
- const char* user,
- const char* passwd);
-
int STDCALL mysql_shutdown(MYSQL *mysql,
enum mysql_enum_shutdown_level
shutdown_level);
@@ -560,18 +462,6 @@ void STDCALL mysql_debug(const char *debug);
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
unsigned int STDCALL mysql_thread_safe(void);
my_bool STDCALL mysql_embedded(void);
-MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con);
-MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
- const char* host,
- const char* user,
- const char* passwd,
- unsigned int port);
-void STDCALL mysql_manager_close(MYSQL_MANAGER* con);
-int STDCALL mysql_manager_command(MYSQL_MANAGER* con,
- const char* cmd, int cmd_len);
-int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con,
- char* res_buf,
- int res_buf_size);
my_bool STDCALL mysql_read_query_result(MYSQL *mysql);
@@ -766,7 +656,7 @@ typedef struct st_mysql_methods
MYSQL_RES * (*use_result)(MYSQL *mysql);
void (*fetch_lengths)(unsigned long *to,
MYSQL_ROW column, unsigned int field_count);
- void (*flush_use_result)(MYSQL *mysql);
+ void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
@@ -826,6 +716,7 @@ my_bool STDCALL mysql_rollback(MYSQL * mysql);
my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
my_bool STDCALL mysql_more_results(MYSQL *mysql);
int STDCALL mysql_next_result(MYSQL *mysql);
+int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt);
void STDCALL mysql_close(MYSQL *sock);
@@ -840,7 +731,6 @@ MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
const char *user, const char *passwd);
int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
-#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
#endif
#define HAVE_MYSQL_REAL_CONNECT
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index 633cde41130..0ea1d0974c2 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -28,15 +28,15 @@ typedef struct st_net {
unsigned int *return_status;
unsigned char reading_or_writing;
char save_char;
- my_bool unused0;
- my_bool unused;
- my_bool compress;
my_bool unused1;
- unsigned char *query_cache_query;
+ my_bool unused2;
+ my_bool compress;
+ my_bool unused3;
+ unsigned char *unused;
unsigned int last_errno;
unsigned char error;
- my_bool unused2;
- my_bool return_errno;
+ my_bool unused4;
+ my_bool unused5;
char last_error[512];
char sqlstate[5 +1];
void *extension;
@@ -277,10 +277,10 @@ struct st_mysql_options {
unsigned long max_allowed_packet;
my_bool use_ssl;
my_bool compress,named_pipe;
- my_bool rpl_probe;
- my_bool rpl_parse;
- my_bool no_master_reads;
- my_bool separate_thread;
+ my_bool unused1;
+ my_bool unused2;
+ my_bool unused3;
+ my_bool unused4;
enum mysql_option methods_to_use;
char *client_ip;
my_bool secure_auth;
@@ -301,10 +301,6 @@ enum mysql_protocol_type
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
};
-enum mysql_rpl_type
-{
- MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
-};
typedef struct character_set
{
unsigned int number;
@@ -344,10 +340,8 @@ typedef struct st_mysql
my_bool free_me;
my_bool reconnect;
char scramble[20 +1];
- my_bool rpl_pivot;
- struct st_mysql* master, *next_slave;
- struct st_mysql* last_used_slave;
- struct st_mysql* last_used_con;
+ my_bool unused1;
+ void *unused2, *unused3, *unused4, *unused5;
LIST *stmts;
const struct st_mysql_methods *methods;
void *thd;
@@ -371,20 +365,6 @@ typedef struct st_mysql_res {
my_bool unbuffered_fetch_cancelled;
void *extension;
} MYSQL_RES;
-typedef struct st_mysql_manager
-{
- NET net;
- char *host, *user, *passwd;
- char *net_buf, *net_buf_pos, *net_data_end;
- unsigned int port;
- int cmd_status;
- int last_errno;
- int net_buf_size;
- my_bool free_me;
- my_bool eof;
- char last_error[256];
- void *extension;
-} MYSQL_MANAGER;
typedef struct st_mysql_parameters
{
unsigned long *p_max_allowed_packet;
@@ -437,14 +417,6 @@ int mysql_real_query(MYSQL *mysql, const char *q,
unsigned long length);
MYSQL_RES * mysql_store_result(MYSQL *mysql);
MYSQL_RES * mysql_use_result(MYSQL *mysql);
-my_bool mysql_master_query(MYSQL *mysql, const char *q,
- unsigned long length);
-my_bool mysql_master_send_query(MYSQL *mysql, const char *q,
- unsigned long length);
-my_bool mysql_slave_query(MYSQL *mysql, const char *q,
- unsigned long length);
-my_bool mysql_slave_send_query(MYSQL *mysql, const char *q,
- unsigned long length);
void mysql_get_character_set_info(MYSQL *mysql,
MY_CHARSET_INFO *charset);
void
@@ -459,22 +431,6 @@ mysql_set_local_infile_handler(MYSQL *mysql,
void *);
void
mysql_set_local_infile_default(MYSQL *mysql);
-void mysql_enable_rpl_parse(MYSQL* mysql);
-void mysql_disable_rpl_parse(MYSQL* mysql);
-int mysql_rpl_parse_enabled(MYSQL* mysql);
-void mysql_enable_reads_from_master(MYSQL* mysql);
-void mysql_disable_reads_from_master(MYSQL* mysql);
-my_bool mysql_reads_from_master_enabled(MYSQL* mysql);
-enum mysql_rpl_type mysql_rpl_query_type(const char* q, int len);
-my_bool mysql_rpl_probe(MYSQL* mysql);
-int mysql_set_master(MYSQL* mysql, const char* host,
- unsigned int port,
- const char* user,
- const char* passwd);
-int mysql_add_slave(MYSQL* mysql, const char* host,
- unsigned int port,
- const char* user,
- const char* passwd);
int mysql_shutdown(MYSQL *mysql,
enum mysql_enum_shutdown_level
shutdown_level);
@@ -521,18 +477,6 @@ void mysql_debug(const char *debug);
void myodbc_remove_escape(MYSQL *mysql,char *name);
unsigned int mysql_thread_safe(void);
my_bool mysql_embedded(void);
-MYSQL_MANAGER* mysql_manager_init(MYSQL_MANAGER* con);
-MYSQL_MANAGER* mysql_manager_connect(MYSQL_MANAGER* con,
- const char* host,
- const char* user,
- const char* passwd,
- unsigned int port);
-void mysql_manager_close(MYSQL_MANAGER* con);
-int mysql_manager_command(MYSQL_MANAGER* con,
- const char* cmd, int cmd_len);
-int mysql_manager_fetch_line(MYSQL_MANAGER* con,
- char* res_buf,
- int res_buf_size);
my_bool mysql_read_query_result(MYSQL *mysql);
enum enum_mysql_stmt_state
{
@@ -616,7 +560,7 @@ typedef struct st_mysql_methods
MYSQL_RES * (*use_result)(MYSQL *mysql);
void (*fetch_lengths)(unsigned long *to,
MYSQL_ROW column, unsigned int field_count);
- void (*flush_use_result)(MYSQL *mysql);
+ void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
int (*stmt_execute)(MYSQL_STMT *stmt);
@@ -671,4 +615,5 @@ my_bool mysql_rollback(MYSQL * mysql);
my_bool mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
my_bool mysql_more_results(MYSQL *mysql);
int mysql_next_result(MYSQL *mysql);
+int mysql_stmt_next_result(MYSQL_STMT *stmt);
void mysql_close(MYSQL *sock);
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 2e59262d061..f158dc20999 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 MySQL AB
+/* Copyright (C) 2005 MySQL AB, 2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,7 +16,6 @@
#ifndef _my_plugin_h
#define _my_plugin_h
-
/*
On Windows, exports from DLL need to be declared
*/
@@ -34,15 +33,7 @@ class Item;
#define MYSQL_THD void*
#endif
-#ifndef _m_string_h
-/* This definition must match the one given in m_string.h */
-struct st_mysql_lex_string
-{
- char *str;
- unsigned int length;
-};
-#endif /* _m_string_h */
-typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+#include <mysql/services.h>
#define MYSQL_XIDDATASIZE 128
/**
@@ -65,7 +56,7 @@ typedef struct st_mysql_xid MYSQL_XID;
Plugin API. Common for all plugin types.
*/
-#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0100
+#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0101
/*
The allowable types of plugins
@@ -75,7 +66,8 @@ typedef struct st_mysql_xid MYSQL_XID;
#define MYSQL_FTPARSER_PLUGIN 2 /* Full-text parser plugin */
#define MYSQL_DAEMON_PLUGIN 3 /* The daemon/raw plugin type */
#define MYSQL_INFORMATION_SCHEMA_PLUGIN 4 /* The I_S plugin type */
-#define MYSQL_MAX_PLUGIN_TYPE_NUM 5 /* The number of plugin types */
+#define MYSQL_REPLICATION_PLUGIN 5 /* The replication plugin type */
+#define MYSQL_MAX_PLUGIN_TYPE_NUM 6 /* The number of plugin types */
/* We use the following strings to define licenses for plugins */
#define PLUGIN_LICENSE_PROPRIETARY 0
@@ -120,7 +112,8 @@ enum enum_mysql_show_type
{
SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
- SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
+ SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
+ SHOW_always_last
};
struct st_mysql_show_var {
@@ -650,6 +643,17 @@ struct st_mysql_information_schema
int interface_version;
};
+/*
+ API for Replication plugin. (MYSQL_REPLICATION_PLUGIN)
+*/
+ #define MYSQL_REPLICATION_INTERFACE_VERSION 0x0100
+
+ /**
+ Replication plugin descriptor
+ */
+ struct Mysql_replication {
+ int interface_version;
+ };
/*
st_mysql_value struct for reading values from mysqld.
@@ -733,54 +737,6 @@ int thd_killed(const MYSQL_THD thd);
*/
unsigned long thd_get_thread_id(const MYSQL_THD thd);
-
-/**
- Allocate memory in the connection's local memory pool
-
- @details
- When properly used in place of @c my_malloc(), this can significantly
- improve concurrency. Don't use this or related functions to allocate
- large chunks of memory. Use for temporary storage only. The memory
- will be freed automatically at the end of the statement; no explicit
- code is required to prevent memory leaks.
-
- @see alloc_root()
-*/
-void *thd_alloc(MYSQL_THD thd, unsigned int size);
-/**
- @see thd_alloc()
-*/
-void *thd_calloc(MYSQL_THD thd, unsigned int size);
-/**
- @see thd_alloc()
-*/
-char *thd_strdup(MYSQL_THD thd, const char *str);
-/**
- @see thd_alloc()
-*/
-char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size);
-/**
- @see thd_alloc()
-*/
-void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
-
-/**
- Create a LEX_STRING in this connection's local memory pool
-
- @param thd user thread connection handle
- @param lex_str pointer to LEX_STRING object to be initialized
- @param str initializer to be copied into lex_str
- @param size length of str, in bytes
- @param allocate_lex_string flag: if TRUE, allocate new LEX_STRING object,
- instead of using lex_str value
- @return NULL on failure, or pointer to the LEX_STRING object
-
- @see thd_alloc()
-*/
-MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
- int allocate_lex_string);
-
/**
Get the XID for this connection's transaction
diff --git a/include/mysql/plugin.h.pp b/include/mysql/plugin.h.pp
index 50511f515ab..b7dd7bc0032 100644
--- a/include/mysql/plugin.h.pp
+++ b/include/mysql/plugin.h.pp
@@ -1,9 +1,38 @@
+#include <mysql/services.h>
+#include <mysql/service_my_snprintf.h>
+#include <stdarg.h>
+#include <stdlib.h>
+extern struct my_snprintf_service_st {
+ size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
+ size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
+} *my_snprintf_service;
+size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
+size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
+#include <mysql/service_thd_alloc.h>
+#include <stdlib.h>
struct st_mysql_lex_string
{
char *str;
- unsigned int length;
+ size_t length;
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+extern struct thd_alloc_service_st {
+ void *(*thd_alloc_func)(void*, unsigned int);
+ void *(*thd_calloc_func)(void*, unsigned int);
+ char *(*thd_strdup_func)(void*, const char *);
+ char *(*thd_strmake_func)(void*, const char *, unsigned int);
+ void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ const char *, unsigned int, int);
+} *thd_alloc_service;
+void *thd_alloc(void* thd, unsigned int size);
+void *thd_calloc(void* thd, unsigned int size);
+char *thd_strdup(void* thd, const char *str);
+char *thd_strmake(void* thd, const char *str, unsigned int size);
+void *thd_memdup(void* thd, const void* str, unsigned int size);
+MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
+ const char *str, unsigned int size,
+ int allocate_lex_string);
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -15,7 +44,8 @@ enum enum_mysql_show_type
{
SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
- SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
+ SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
+ SHOW_always_last
};
struct st_mysql_show_var {
const char *name;
@@ -105,6 +135,9 @@ struct st_mysql_information_schema
{
int interface_version;
};
+ struct Mysql_replication {
+ int interface_version;
+ };
struct st_mysql_value
{
int (*value_type)(struct st_mysql_value *);
@@ -125,14 +158,6 @@ void thd_inc_row_count(void* thd);
int mysql_tmpfile(const char *prefix);
int thd_killed(const void* thd);
unsigned long thd_get_thread_id(const void* thd);
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
- int allocate_lex_string);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
void mysql_query_cache_invalidate4(void* thd,
const char *key, unsigned int key_length,
diff --git a/include/mysql/service_my_snprintf.h b/include/mysql/service_my_snprintf.h
new file mode 100644
index 00000000000..ad344864c34
--- /dev/null
+++ b/include/mysql/service_my_snprintf.h
@@ -0,0 +1,98 @@
+#ifndef MYSQL_SERVICE_MY_SNPRINTF_INCLUDED
+/* Copyright (C) 2009 Sun Microsystems, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/**
+ @file
+ my_snprintf service
+
+ Portable and limited vsnprintf() implementation.
+
+ This is a portable, limited vsnprintf() implementation, with some
+ extra features. "Portable" means that it'll produce identical result
+ on all platforms (for example, on Windows and Linux system printf %e
+ formats the exponent differently, on different systems %p either
+ prints leading 0x or not, %s may accept null pointer or crash on
+ it). "Limited" means that it does not support all the C89 features.
+ But it supports few extensions, not in any standard.
+
+ my_vsnprintf(to, n, fmt, ap)
+
+ @param[out] to A buffer to store the result in
+ @param[in] n Store up to n-1 characters, followed by an end 0
+ @param[in] fmt printf-like format string
+ @param[in] ap Arguments
+
+ @return a number of bytes written to a buffer *excluding* terminating '\0'
+
+ @post
+ The syntax of a format string is generally the same:
+ % <flag> <width> <precision> <length modifier> <format>
+ where everithing but the format is optional.
+
+ Three one-character flags are recognized:
+ '0' has the standard zero-padding semantics;
+ '-' is parsed, but silently ignored;
+ '`' (backtick) is only supported for strings (%s) and means that the
+ string will be quoted according to MySQL identifier quoting rules.
+
+ Both <width> and <precision> can be specified as numbers or '*'.
+
+ <length modifier> can be 'l', 'll', or 'z'.
+
+ Supported formats are 's' (null pointer is accepted, printed as
+ "(null)"), 'b' (extension, see below), 'c', 'd', 'u', 'x',
+ 'X', 'p' (works as 0x%x).
+
+ Standard syntax for positional arguments $n is supported.
+
+ Extensions:
+
+ Flag '`' (backtick): see above.
+
+ Format 'b': binary buffer, prints exactly <precision> bytes from the
+ argument, without stopping at '\0'.
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdarg.h>
+#include <stdlib.h>
+extern struct my_snprintf_service_st {
+ size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
+ size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
+} *my_snprintf_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define my_vsnprintf my_snprintf_service->my_vsnprintf_type
+#define my_snprintf my_snprintf_service->my_snprintf_type
+
+#else
+
+size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
+size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_MY_SNPRINTF_INCLUDED
+#endif
+
diff --git a/include/mysql/service_thd_alloc.h b/include/mysql/service_thd_alloc.h
new file mode 100644
index 00000000000..86158ba1359
--- /dev/null
+++ b/include/mysql/service_thd_alloc.h
@@ -0,0 +1,128 @@
+#ifndef MYSQL_SERVICE_THD_ALLOC_INCLUDED
+/* Copyright (C) 2009 Sun Microsystems, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/**
+ @file
+ This service provdes functions to allocate memory in a connection local
+ memory pool. The memory allocated there will be automatically freed at the
+ end of the statement, don't use it for allocations that should live longer
+ than that. For short living allocations this is more efficient than
+ using my_malloc and friends, and automatic "garbage collection" allows not
+ to think about memory leaks.
+
+ The pool is best for small to medium objects, don't use it for large
+ allocations - they are better served with my_malloc.
+*/
+
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct st_mysql_lex_string
+{
+ char *str;
+ size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+
+extern struct thd_alloc_service_st {
+ void *(*thd_alloc_func)(MYSQL_THD, unsigned int);
+ void *(*thd_calloc_func)(MYSQL_THD, unsigned int);
+ char *(*thd_strdup_func)(MYSQL_THD, const char *);
+ char *(*thd_strmake_func)(MYSQL_THD, const char *, unsigned int);
+ void *(*thd_memdup_func)(MYSQL_THD, const void*, unsigned int);
+ MYSQL_LEX_STRING *(*thd_make_lex_string_func)(MYSQL_THD, MYSQL_LEX_STRING *,
+ const char *, unsigned int, int);
+} *thd_alloc_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define thd_alloc(thd,size) (thd_alloc_service->thd_alloc_func((thd), (size)))
+
+#define thd_calloc(thd,size) (thd_alloc_service->thd_calloc_func((thd), (size)))
+
+#define thd_strdup(thd,str) (thd_alloc_service->thd_strdup_func((thd), (str)))
+
+#define thd_strmake(thd,str,size) \
+ (thd_alloc_service->thd_strmake_func((thd), (str), (size)))
+
+#define thd_memdup(thd,str,size) \
+ (thd_alloc_service->thd_memdup_func((thd), (str), (size)))
+
+#define thd_make_lex_string(thd, lex_str, str, size, allocate_lex_string) \
+ (thd_alloc_service->thd_make_lex_string_func((thd), (lex_str), (str), \
+ (size), (allocate_lex_string)))
+
+#else
+
+/**
+ Allocate memory in the connection's local memory pool
+
+ @details
+ When properly used in place of @c my_malloc(), this can significantly
+ improve concurrency. Don't use this or related functions to allocate
+ large chunks of memory. Use for temporary storage only. The memory
+ will be freed automatically at the end of the statement; no explicit
+ code is required to prevent memory leaks.
+
+ @see alloc_root()
+*/
+void *thd_alloc(MYSQL_THD thd, unsigned int size);
+/**
+ @see thd_alloc()
+*/
+void *thd_calloc(MYSQL_THD thd, unsigned int size);
+/**
+ @see thd_alloc()
+*/
+char *thd_strdup(MYSQL_THD thd, const char *str);
+/**
+ @see thd_alloc()
+*/
+char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size);
+/**
+ @see thd_alloc()
+*/
+void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
+
+/**
+ Create a LEX_STRING in this connection's local memory pool
+
+ @param thd user thread connection handle
+ @param lex_str pointer to LEX_STRING object to be initialized
+ @param str initializer to be copied into lex_str
+ @param size length of str, in bytes
+ @param allocate_lex_string flag: if TRUE, allocate new LEX_STRING object,
+ instead of using lex_str value
+ @return NULL on failure, or pointer to the LEX_STRING object
+
+ @see thd_alloc()
+*/
+MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
+ const char *str, unsigned int size,
+ int allocate_lex_string);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_THD_ALLOC_INCLUDED
+#endif
+
diff --git a/include/mysql/services.h b/include/mysql/services.h
new file mode 100644
index 00000000000..19003e66b96
--- /dev/null
+++ b/include/mysql/services.h
@@ -0,0 +1,30 @@
+#ifndef MYSQL_SERVICES_INCLUDED
+/* Copyright (C) 2009 Sun Microsystems, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <mysql/service_my_snprintf.h>
+#include <mysql/service_thd_alloc.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICES_INCLUDED
+#endif
+
diff --git a/include/mysql_com.h b/include/mysql_com.h
index db5a5eb8741..345ecd5dd93 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -27,6 +27,8 @@
#define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
+#define MYSQL_AUTODETECT_CHARSET_NAME "auto"
+
#define SERVER_VERSION_LENGTH 60
#define SQLSTATE_LENGTH 5
@@ -144,6 +146,7 @@ enum enum_server_command
#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
#define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */
+#define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
@@ -167,6 +170,7 @@ enum enum_server_command
CLIENT_SECURE_CONNECTION | \
CLIENT_MULTI_STATEMENTS | \
CLIENT_MULTI_RESULTS | \
+ CLIENT_PS_MULTI_RESULTS | \
CLIENT_SSL_VERIFY_SERVER_CERT | \
CLIENT_REMEMBER_OPTIONS)
@@ -203,6 +207,12 @@ enum enum_server_command
number of result set columns.
*/
#define SERVER_STATUS_METADATA_CHANGED 1024
+#define SERVER_QUERY_WAS_SLOW 2048
+
+/**
+ To mark ResultSet containing output parameter values.
+*/
+#define SERVER_PS_OUT_PARAMS 4096
/**
Server status flags that must be cleared when starting
@@ -254,24 +264,23 @@ typedef struct st_net {
unsigned int *return_status;
unsigned char reading_or_writing;
char save_char;
- my_bool unused0; /* Please remove with the next incompatible ABI change. */
- my_bool unused; /* Please remove with the next incompatible ABI change */
- my_bool compress;
my_bool unused1; /* Please remove with the next incompatible ABI change. */
+ my_bool unused2; /* Please remove with the next incompatible ABI change */
+ my_bool compress;
+ my_bool unused3; /* Please remove with the next incompatible ABI change. */
/*
Pointer to query object in query cache, do not equal NULL (0) for
queries in cache that have not stored its results yet
*/
#endif
/*
- 'query_cache_query' should be accessed only via query cache
- functions and methods to maintain proper locking.
+ Unused, please remove with the next incompatible ABI change.
*/
- unsigned char *query_cache_query;
+ unsigned char *unused;
unsigned int last_errno;
unsigned char error;
- my_bool unused2; /* Please remove with the next incompatible ABI change. */
- my_bool return_errno;
+ my_bool unused4; /* Please remove with the next incompatible ABI change. */
+ my_bool unused5; /* Please remove with the next incompatible ABI change. */
/** Client library error message buffer. Actually belongs to struct MYSQL. */
char last_error[MYSQL_ERRMSG_SIZE];
/** Client library sqlstate buffer. Set along with the error message. */
@@ -409,10 +418,6 @@ void my_net_set_write_timeout(NET *net, uint timeout);
void my_net_set_read_timeout(NET *net, uint timeout);
#endif
-/*
- The following function is not meant for normal usage
- Currently it's used internally by manager.c
-*/
struct sockaddr;
int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
unsigned int timeout);
diff --git a/include/mysql_embed.h b/include/mysql_embed.h
index 4a7fd3ef63c..0e5a360585e 100644
--- a/include/mysql_embed.h
+++ b/include/mysql_embed.h
@@ -1,3 +1,6 @@
+#ifndef MYSQL_EMBED_INCLUDED
+#define MYSQL_EMBED_INCLUDED
+
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -28,3 +31,4 @@
#define DONT_USE_RAID
#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_EMBED_INCLUDED */
diff --git a/include/rijndael.h b/include/rijndael.h
index 89963a85c99..71df1c48dbf 100644
--- a/include/rijndael.h
+++ b/include/rijndael.h
@@ -1,3 +1,6 @@
+#ifndef RIJNDAEL_INCLUDED
+#define RIJNDAEL_INCLUDED
+
/* Copyright (C) 2002 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -39,3 +42,5 @@ void rijndaelEncrypt(const uint32 rk[/*4*(Nr + 1)*/], int Nr,
const uint8 pt[16], uint8 ct[16]);
void rijndaelDecrypt(const uint32 rk[/*4*(Nr + 1)*/], int Nr,
const uint8 ct[16], uint8 pt[16]);
+
+#endif /* RIJNDAEL_INCLUDED */
diff --git a/include/service_versions.h b/include/service_versions.h
new file mode 100644
index 00000000000..114957cdd86
--- /dev/null
+++ b/include/service_versions.h
@@ -0,0 +1,24 @@
+/* Copyright (C) 2009 Sun Microsystems, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifdef _WIN32
+#define SERVICE_VERSION __declspec(dllexport) void *
+#else
+#define SERVICE_VERSION void *
+#endif
+
+#define VERSION_my_snprintf 0x0100
+#define VERSION_thd_alloc 0x0100
+
diff --git a/include/sha1.h b/include/sha1.h
index e476456a9bd..5b4dc5d46ed 100644
--- a/include/sha1.h
+++ b/include/sha1.h
@@ -1,3 +1,6 @@
+#ifndef SHA1_INCLUDED
+#define SHA1_INCLUDED
+
/* Copyright (C) 2002, 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -64,3 +67,5 @@ int mysql_sha1_input(SHA1_CONTEXT*, const uint8 *, unsigned int);
int mysql_sha1_result(SHA1_CONTEXT* , uint8 Message_Digest[SHA1_HASH_SIZE]);
C_MODE_END
+
+#endif /* SHA__INCLUDED */
diff --git a/include/sql_common.h b/include/sql_common.h
index 9e43d076ba9..5fd8778d62b 100644
--- a/include/sql_common.h
+++ b/include/sql_common.h
@@ -1,3 +1,6 @@
+#ifndef SQL_COMMON_INCLUDED
+#define SQL_COMMON_INCLUDED
+
/* Copyright (C) 2003-2004, 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -48,3 +51,4 @@ void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
#define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41)
+#endif /* SQL_COMMON_INCLUDED */
diff --git a/include/sslopt-case.h b/include/sslopt-case.h
index adb9a28503b..ce46cf65cc9 100644
--- a/include/sslopt-case.h
+++ b/include/sslopt-case.h
@@ -1,3 +1,6 @@
+#ifndef SSLOPT_CASE_INCLUDED
+#define SSLOPT_CASE_INCLUDED
+
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -26,3 +29,4 @@
opt_use_ssl= 1;
break;
#endif
+#endif /* SSLOPT_CASE_INCLUDED */
diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h
index c76b5dcd252..eae1424238b 100644
--- a/include/sslopt-longopts.h
+++ b/include/sslopt-longopts.h
@@ -1,3 +1,6 @@
+#ifndef SSLOPT_LONGOPTS_INCLUDED
+#define SSLOPT_LONGOPTS_INCLUDED
+
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -43,3 +46,4 @@
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
#endif /* HAVE_OPENSSL */
+#endif /* SSLOPT_LONGOPTS_INCLUDED */
diff --git a/include/sslopt-vars.h b/include/sslopt-vars.h
index 3369f870db2..4493fbc59ab 100644
--- a/include/sslopt-vars.h
+++ b/include/sslopt-vars.h
@@ -1,3 +1,6 @@
+#ifndef SSLOPT_VARS_INCLUDED
+#define SSLOPT_VARS_INCLUDED
+
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -29,3 +32,4 @@ SSL_STATIC char *opt_ssl_key = 0;
SSL_STATIC my_bool opt_ssl_verify_server_cert= 0;
#endif
#endif
+#endif /* SSLOPT_VARS_INCLUDED */