summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am19
-rw-r--r--include/config-os2.h3
-rw-r--r--include/config-win.h60
-rw-r--r--include/errmsg.h27
-rw-r--r--include/ft_global.h20
-rw-r--r--include/hash.h27
-rw-r--r--include/heap.h61
-rw-r--r--include/keycache.h135
-rw-r--r--include/m_ctype.h449
-rw-r--r--include/m_string.h28
-rw-r--r--include/my_base.h69
-rw-r--r--include/my_bitmap.h33
-rw-r--r--include/my_getopt.h10
-rw-r--r--include/my_global.h76
-rw-r--r--include/my_handler.h66
-rw-r--r--include/my_list.h4
-rw-r--r--include/my_no_pthread.h6
-rw-r--r--include/my_pthread.h20
-rw-r--r--include/my_sys.h129
-rw-r--r--include/my_tree.h27
-rw-r--r--include/my_xml.h67
-rw-r--r--include/myisam.h79
-rw-r--r--include/myisammrg.h1
-rw-r--r--include/myisampack.h2
-rw-r--r--include/mysql.h350
-rw-r--r--include/mysql_com.h222
-rw-r--r--include/mysql_embed.h3
-rw-r--r--include/mysql_version.h.in3
-rw-r--r--include/mysqld_error.h62
-rw-r--r--include/mysys_err.h1
-rw-r--r--include/sql_common.h48
-rw-r--r--include/sql_state.h164
-rw-r--r--include/sslopt-longopts.h12
-rw-r--r--include/thr_lock.h4
-rw-r--r--include/typelib.h33
-rw-r--r--include/violite.h58
36 files changed, 1897 insertions, 481 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 4b881d0e7ed..3adbb31f235 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -16,19 +16,21 @@
# MA 02111-1307, USA
BUILT_SOURCES = mysql_version.h m_ctype.h my_config.h
-pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h \
+pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h my_xml.h \
mysql.h mysql_com.h mysqld_error.h mysql_embed.h \
my_semaphore.h my_pthread.h my_no_pthread.h raid.h \
errmsg.h my_global.h my_net.h my_alloc.h \
- my_getopt.h sslopt-longopts.h my_dir.h \
- sslopt-vars.h sslopt-case.h $(BUILT_SOURCES)
+ my_getopt.h sslopt-longopts.h my_dir.h typelib.h \
+ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
+ sql_state.h $(BUILT_SOURCES)
noinst_HEADERS = config-win.h config-os2.h config-netware.h \
nisam.h heap.h merge.h my_bitmap.h\
myisam.h myisampack.h myisammrg.h ft_global.h\
mysys_err.h my_base.h \
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \
my_aes.h my_tree.h hash.h thr_alarm.h \
- thr_lock.h t_ctype.h violite.h md5.h mysql_version.h.in
+ thr_lock.h t_ctype.h violite.h md5.h \
+ mysql_version.h.in my_handler.h
# mysql_version.h are generated
SUPERCLEANFILES = mysql_version.h my_config.h
@@ -36,16 +38,25 @@ SUPERCLEANFILES = mysql_version.h my_config.h
# Some include files that may be moved and patched by configure
DISTCLEANFILES = sched.h $(SUPERCLEANFILES)
+clean:
+ $(RM) -f readline/*
+distclean:
+ $(RM) -f readline/*
+
all-local: my_config.h
# Since we include my_config.h it better exist from the beginning
link_sources:
$(CP) ../config.h my_config.h
+ $(RM) -f readline/*
+ @readline_h_ln_cmd@
# Keep automake happy
my_config.h: ../config.h
$(CP) ../config.h my_config.h
+ $(RM) -f readline/*
+ @readline_h_ln_cmd@
# These files should not be included in distributions since they are
# generated by configure from the .h.in files
diff --git a/include/config-os2.h b/include/config-os2.h
index 7e9684ae3f5..0402074acc0 100644
--- a/include/config-os2.h
+++ b/include/config-os2.h
@@ -463,6 +463,9 @@ typedef unsigned long long os_off_t;
/* Define if you have the getwd function. */
#define HAVE_GETWD 1
+/* Define to 1 if you have the `gmtime_r' function. */
+#define HAVE_GMTIME_R 1
+
/* Define if you have the index function. */
#define HAVE_INDEX 1
diff --git a/include/config-win.h b/include/config-win.h
index bb6d663bd8d..518f445861a 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -16,6 +16,12 @@
/* Defines for Win32 to make it compatible for MySQL */
+#ifdef __WIN2000__
+/* We have to do this define before including windows.h to get the AWE API
+functions */
+#define _WIN32_WINNT 0x0500
+#endif
+
#include <sys/locking.h>
#include <windows.h>
#include <math.h> /* Because of rint() */
@@ -23,6 +29,8 @@
#include <io.h>
#include <malloc.h>
+#define HAVE_SMEM 1
+
#if defined(__NT__)
#define SYSTEM_TYPE "NT"
#elif defined(__WIN2000__)
@@ -87,6 +95,7 @@
#define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF)
#define ULONGLONG_MAX ((unsigned __int64) 0xFFFFFFFFFFFFFFFF)
#define LL(A) ((__int64) A)
+#define ULL(A) ((unsigned __int64) A)
/* Type information */
@@ -168,7 +177,9 @@ typedef uint rf_SetTimer;
#define access(A,B) _access(A,B)
#endif
-#if defined(__cplusplus)
+#if !defined(__cplusplus)
+#define inline __inline
+#endif /* __cplusplus */
inline double rint(double nr)
{
@@ -191,9 +202,6 @@ inline double ulonglong2double(ulonglong value)
}
#define my_off_t2double(A) ulonglong2double(A)
#endif /* _WIN64 */
-#else
-#define inline __inline
-#endif /* __cplusplus */
#if SIZEOF_OFF_T > 4
#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
@@ -278,10 +286,10 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_CREATESEMAPHORE
#define HAVE_ISNAN
#define HAVE_FINITE
-#define HAVE_ISAM /* We want to have support for ISAM in 4.0 */
#define HAVE_QUERY_CACHE
#define SPRINTF_RETURNS_INT
#define HAVE_SETFILEPOINTER
+#define HAVE_VIO
#ifdef NOT_USED
#define HAVE_SNPRINTF /* Gave link error */
@@ -316,7 +324,7 @@ inline double ulonglong2double(ulonglong value)
#define FN_ROOTDIR "\\"
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
-#define MY_NFILE 2048
+#define OS_FILE_LIMIT 2048
#define DO_NOT_REMOVE_THREAD_WRAPPERS
#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
@@ -333,3 +341,43 @@ inline double ulonglong2double(ulonglong value)
#define statistic_add(V,C,L) (V)+=(C)
#endif
#define statistic_increment(V,L) thread_safe_increment((V),(L))
+
+#define shared_memory_buffer_length 16000
+#define default_shared_memory_base_name "MYSQL"
+#define MYSQL_DEFAULT_CHARSET_NAME "latin1"
+#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
+
+/* Define charsets you want */
+/* #undef HAVE_CHARSET_armscii8 */
+/* #undef HAVE_CHARSET_ascii */
+#define HAVE_CHARSET_big5 1
+#define HAVE_CHARSET_cp1250 1
+/* #undef HAVE_CHARSET_cp1251 */
+/* #undef HAVE_CHARSET_cp1256 */
+/* #undef HAVE_CHARSET_cp1257 */
+/* #undef HAVE_CHARSET_cp850 */
+/* #undef HAVE_CHARSET_cp852 */
+/* #undef HAVE_CHARSET_cp866 */
+/* #undef HAVE_CHARSET_dec8 */
+#define HAVE_CHARSET_euckr 1
+#define HAVE_CHARSET_gb2312 1
+#define HAVE_CHARSET_gbk 1
+/* #undef HAVE_CHARSET_greek */
+/* #undef HAVE_CHARSET_hebrew */
+/* #undef HAVE_CHARSET_hp8 */
+/* #undef HAVE_CHARSET_keybcs2 */
+/* #undef HAVE_CHARSET_koi8r */
+/* #undef HAVE_CHARSET_koi8u */
+#define HAVE_CHARSET_latin1 1
+#define HAVE_CHARSET_latin2 1
+/* #undef HAVE_CHARSET_latin5 */
+/* #undef HAVE_CHARSET_latin7 */
+/* #undef HAVE_CHARSET_macce */
+/* #undef HAVE_CHARSET_macroman */
+#define HAVE_CHARSET_sjis 1
+/* #undef HAVE_CHARSET_swe7 */
+#define HAVE_CHARSET_tis620 1
+#define HAVE_CHARSET_ucs2 1
+#define HAVE_CHARSET_ujis 1
+#define HAVE_CHARSET_utf8 1
+
diff --git a/include/errmsg.h b/include/errmsg.h
index 5136af5b87a..16f220a7ee2 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -30,7 +30,7 @@ extern const char *client_errors[]; /* Error messages */
#define CR_MAX_ERROR 2999
#if defined(OS2) && defined(MYSQL_SERVER)
#define CER(X) client_errors[(X)-CR_MIN_ERROR]
-#else
+#elif !defined(ER)
#define ER(X) client_errors[(X)-CR_MIN_ERROR]
#endif
#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */
@@ -64,3 +64,28 @@ extern const char *client_errors[]; /* Error messages */
#define CR_SSL_CONNECTION_ERROR 2026
#define CR_MALFORMED_PACKET 2027
+/* new 4.1 error codes */
+#define CR_NULL_POINTER 2028
+#define CR_NO_PREPARE_STMT 2029
+#define CR_PARAMS_NOT_BOUND 2030
+#define CR_DATA_TRUNCATED 2031
+#define CR_NO_PARAMETERS_EXISTS 2032
+#define CR_INVALID_PARAMETER_NO 2033
+#define CR_INVALID_BUFFER_USE 2034
+#define CR_UNSUPPORTED_PARAM_TYPE 2035
+
+#define CR_SHARED_MEMORY_CONNECTION 2036
+#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2037
+#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2038
+#define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2039
+#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2040
+#define CR_SHARED_MEMORY_FILE_MAP_ERROR 2041
+#define CR_SHARED_MEMORY_MAP_ERROR 2042
+#define CR_SHARED_MEMORY_EVENT_ERROR 2043
+#define CR_SHARED_MEMORY_CONNECT_ABANDODED_ERROR 2044
+#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2045
+#define CR_CONN_UNKNOW_PROTOCOL 2046
+#define CR_INVALID_CONN_HANDLE 2047
+#define CR_SECURE_AUTH 2048
+#define CR_FETCH_CANCELLED 2049
+#define CR_NO_DATA 2050
diff --git a/include/ft_global.h b/include/ft_global.h
index 9acdf6aaaf3..94f6ad9ef51 100644
--- a/include/ft_global.h
+++ b/include/ft_global.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (C) 2000-2003 MySQL AB
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
@@ -26,8 +26,8 @@
extern "C" {
#endif
-#define FT_QUERY_MAXLEN 1024
-#define HA_FT_MAXLEN 254
+#define HA_FT_MAXBYTELEN 254
+#define HA_FT_MAXCHARLEN (HA_FT_MAXBYTELEN/3)
typedef struct st_ft_info FT_INFO;
struct _ft_vft
@@ -51,15 +51,19 @@ extern const char *ft_precompiled_stopwords[];
extern ulong ft_min_word_len;
extern ulong ft_max_word_len;
-extern ulong ft_max_word_len_for_sort;
-extern const char *ft_boolean_syntax;
+extern ulong ft_query_expansion_limit;
+extern char ft_boolean_syntax[15];
int ft_init_stopwords(void);
void ft_free_stopwords(void);
-#define FT_NL 0
-#define FT_BOOL 1
-FT_INFO *ft_init_search(uint,void *, uint, byte *, uint, my_bool);
+#define FT_NL 0
+#define FT_BOOL 1
+#define FT_SORTED 2
+#define FT_EXPAND 4 /* query expansion */
+
+FT_INFO *ft_init_search(uint,void *, uint, byte *, uint, byte *);
+my_bool ft_boolean_check_syntax_string(const byte *);
#ifdef __cplusplus
}
diff --git a/include/hash.h b/include/hash.h
index e9c8c73c05b..c7cc118b7bd 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -22,17 +22,15 @@
extern "C" {
#endif
+/*
+ Overhead to store an element in hash
+ Can be used to approximate memory consumption for a hash
+ */
+#define HASH_OVERHEAD (sizeof(char*)*2)
+
typedef byte *(*hash_get_key)(const byte *,uint*,my_bool);
typedef void (*hash_free_key)(void *);
- /* flags for hash_init */
-#define HASH_CASE_INSENSITIVE 1
-
-typedef struct st_hash_info {
- uint next; /* index to next key */
- byte *data; /* data for current entry */
-} HASH_LINK;
-
typedef struct st_hash {
uint key_offset,key_length; /* Length of key if const length */
uint records,blength,current_record;
@@ -40,18 +38,19 @@ typedef struct st_hash {
DYNAMIC_ARRAY array; /* Place for hash_keys */
hash_get_key get_key;
void (*free)(void *);
- uint (*calc_hashnr)(const byte *key,uint length);
+ CHARSET_INFO *charset;
} HASH;
-#define hash_init(A,B,C,D,E,F,G) _hash_init(A,B,C,D,E,F,G CALLER_INFO)
-my_bool _hash_init(HASH *hash,uint default_array_elements, uint key_offset,
- uint key_length, hash_get_key get_key,
- void (*free_element)(void*), uint flags CALLER_INFO_PROTO);
+#define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,B,C,D,E,F,G, H CALLER_INFO)
+my_bool _hash_init(HASH *hash, CHARSET_INFO *charset,
+ uint default_array_elements, uint key_offset,
+ uint key_length, hash_get_key get_key,
+ void (*free_element)(void*), uint flags CALLER_INFO_PROTO);
void hash_free(HASH *tree);
byte *hash_element(HASH *hash,uint idx);
gptr hash_search(HASH *info,const byte *key,uint length);
gptr hash_next(HASH *info,const byte *key,uint length);
-my_bool hash_insert(HASH *info,const byte *data);
+my_bool my_hash_insert(HASH *info,const byte *data);
my_bool hash_delete(HASH *hash,byte *record);
my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length);
void hash_replace(HASH *hash, uint idx, byte *new_row);
diff --git a/include/heap.h b/include/heap.h
index ed023133469..c5f2be81fb7 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-/* This file should be included when using heap_database_funktions */
+/* This file should be included when using heap_database_functions */
/* Author: Michael Widenius */
#ifndef _heap_h
@@ -31,6 +31,9 @@ extern "C" {
#include <thr_lock.h>
#endif
+#include "my_handler.h"
+#include "my_tree.h"
+
/* defines used by heap-funktions */
#define HP_MAX_LEVELS 4 /* 128^5 records is enough */
@@ -47,7 +50,7 @@ typedef struct st_heapinfo /* Struct from heap_info */
ulong index_length;
uint reclength; /* Length of one record */
int errkey;
- my_bool implicit_emptied;
+ ulonglong auto_increment;
} HEAPINFO;
@@ -74,22 +77,22 @@ typedef struct st_heap_block /* The data is saved in blocks */
ulong last_allocated; /* Blocks allocated, used by keys */
} HP_BLOCK;
-typedef struct st_hp_keyseg /* Key-portion */
-{
- uint start; /* Start of key in record (from 0) */
- uint length; /* Keylength */
- uint type;
- uint null_bit; /* bit set in row+null_pos */
- uint null_pos;
-} HP_KEYSEG;
+struct st_heap_info; /* For referense */
typedef struct st_hp_keydef /* Key definition with open */
{
uint flag; /* HA_NOSAME | HA_NULL_PART_KEY */
uint keysegs; /* Number of key-segment */
uint length; /* Length of key (automatic) */
- HP_KEYSEG *seg;
+ uint8 algorithm; /* HASH / BTREE */
+ HA_KEYSEG *seg;
HP_BLOCK block; /* Where keys are saved */
+ TREE rb_tree;
+ int (*write_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
+ const byte *record, byte *recpos);
+ int (*delete_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
+ const byte *record, byte *recpos, int flag);
+ uint (*get_key_length)(struct st_hp_keydef *keydef, const byte *key);
} HP_KEYDEF;
typedef struct st_heap_share
@@ -113,6 +116,9 @@ typedef struct st_heap_share
#endif
my_bool delete_on_close;
LIST open_list;
+ uint auto_key;
+ uint auto_key_type; /* real type of the auto key segment */
+ ulonglong auto_increment;
} HP_SHARE;
struct st_hp_hash_info;
@@ -127,6 +133,11 @@ typedef struct st_heap_info
int mode; /* Mode of file (READONLY..) */
uint opt_flag,update;
byte *lastkey; /* Last used key with rkey */
+ byte *recbuf; /* Record buffer for rb-tree keys */
+ enum ha_rkey_function last_find_flag;
+ TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1];
+ TREE_ELEMENT **last_pos;
+ uint lastkey_len;
my_bool implicit_emptied;
#ifdef THREAD
THR_LOCK_DATA lock;
@@ -134,11 +145,16 @@ typedef struct st_heap_info
LIST open_list;
} HP_INFO;
+typedef struct st_heap_create_info
+{
+ uint auto_key;
+ uint auto_key_type;
+ ulonglong auto_increment;
+} HP_CREATE_INFO;
+
/* Prototypes for heap-functions */
-extern HP_INFO* heap_open(const char *name,int mode,uint keys,
- HP_KEYDEF *keydef,uint reclength,
- ulong max_records,ulong min_reloc);
+extern HP_INFO *heap_open(const char *name, int mode);
extern int heap_close(HP_INFO *info);
extern int heap_write(HP_INFO *info,const byte *buff);
extern int heap_update(HP_INFO *info,const byte *old,const byte *newdata);
@@ -147,7 +163,9 @@ extern int heap_scan_init(HP_INFO *info);
extern int heap_scan(register HP_INFO *info, byte *record);
extern int heap_delete(HP_INFO *info,const byte *buff);
extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag);
-extern int heap_create(const char *name);
+extern int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
+ uint reclength, ulong max_records, ulong min_records,
+ HP_CREATE_INFO *create_info);
extern int heap_delete_table(const char *name);
extern int heap_extra(HP_INFO *info,enum ha_extra_function function);
extern int heap_rename(const char *old_name,const char *new_name);
@@ -155,10 +173,17 @@ extern int heap_panic(enum ha_panic_function flag);
extern int heap_rsame(HP_INFO *info,byte *record,int inx);
extern int heap_rnext(HP_INFO *info,byte *record);
extern int heap_rprev(HP_INFO *info,byte *record);
-extern int heap_rfirst(HP_INFO *info,byte *record);
-extern int heap_rlast(HP_INFO *info,byte *record);
+extern int heap_rfirst(HP_INFO *info,byte *record,int inx);
+extern int heap_rlast(HP_INFO *info,byte *record,int inx);
extern void heap_clear(HP_INFO *info);
-extern int heap_rkey(HP_INFO *info,byte *record,int inx,const byte *key);
+extern void heap_update_auto_increment(HP_INFO *info, const byte *record);
+ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, const byte *start_key,
+ uint start_key_len,
+ enum ha_rkey_function start_search_flag,
+ const byte *end_key, uint end_key_len,
+ enum ha_rkey_function end_search_flag);
+int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key,
+ uint key_len, enum ha_rkey_function find_flag);
extern gptr heap_find(HP_INFO *info,int inx,const byte *key);
extern int heap_check_heap(HP_INFO *info, my_bool print_status);
extern byte *heap_position(HP_INFO *info);
diff --git a/include/keycache.h b/include/keycache.h
new file mode 100644
index 00000000000..b882f3127f5
--- /dev/null
+++ b/include/keycache.h
@@ -0,0 +1,135 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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; either version 2 of the License, or
+ (at your option) any later version.
+
+ 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 */
+
+/* Key cache variable structures */
+
+#ifndef _keycache_h
+#define _keycache_h
+C_MODE_START
+
+/* declare structures that is used by st_key_cache */
+
+struct st_block_link;
+typedef struct st_block_link BLOCK_LINK;
+struct st_keycache_page;
+typedef struct st_keycache_page KEYCACHE_PAGE;
+struct st_hash_link;
+typedef struct st_hash_link HASH_LINK;
+
+/* info about requests in a waiting queue */
+typedef struct st_keycache_wqueue
+{
+ struct st_my_thread_var *last_thread; /* circular list of waiting threads */
+} KEYCACHE_WQUEUE;
+
+#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */
+
+/*
+ The key cache structure
+ It also contains read-only statistics parameters.
+*/
+
+typedef struct st_key_cache
+{
+ my_bool key_cache_inited;
+ my_bool resize_in_flush; /* true during flush of resize operation */
+ my_bool can_be_used; /* usage of cache for read/write is allowed */
+ uint key_cache_shift;
+ ulong key_cache_mem_size; /* specified size of the cache memory */
+ uint key_cache_block_size; /* size of the page buffer of a cache block */
+ ulong min_warm_blocks; /* min number of warm blocks; */
+ ulong age_threshold; /* age threshold for hot blocks */
+ ulonglong keycache_time; /* total number of block link operations */
+ uint hash_entries; /* max number of entries in the hash table */
+ int hash_links; /* max number of hash links */
+ int hash_links_used; /* number of hash links currently used */
+ int disk_blocks; /* max number of blocks in the cache */
+ ulong blocks_used; /* number of currently used blocks */
+ ulong blocks_changed; /* number of currently dirty blocks */
+ ulong warm_blocks; /* number of blocks in warm sub-chain */
+ ulong cnt_for_resize_op; /* counter to block resize operation */
+ long blocks_available; /* number of blocks available in the LRU chain */
+ HASH_LINK **hash_root; /* arr. of entries into hash table buckets */
+ HASH_LINK *hash_link_root; /* memory for hash table links */
+ HASH_LINK *free_hash_list; /* list of free hash links */
+ BLOCK_LINK *block_root; /* memory for block links */
+ byte HUGE_PTR *block_mem; /* memory for block buffers */
+ BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
+ BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
+ pthread_mutex_t cache_lock; /* to lock access to the cache structure */
+ KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */
+ KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */
+ KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */
+ BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/
+ BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/
+
+ /*
+ The following variables are and variables used to hold parameters for
+ initializing the key cache.
+ */
+
+ ulonglong param_buff_size; /* size the memory allocated for the cache */
+ ulong param_block_size; /* size of the blocks in the key cache */
+ ulong param_division_limit; /* min. percentage of warm blocks */
+ ulong param_age_threshold; /* determines when hot block is downgraded */
+
+ /* Statistics variables */
+ ulong global_blocks_used; /* number of currently used blocks */
+ ulong global_blocks_changed; /* number of currently dirty blocks */
+ ulong global_cache_w_requests;/* number of write requests (write hits) */
+ ulong global_cache_write; /* number of writes from the cache to files */
+ ulong global_cache_r_requests;/* number of read requests (read hits) */
+ ulong global_cache_read; /* number of reads from files to the cache */
+ int blocks; /* max number of blocks in the cache */
+ my_bool in_init; /* Set to 1 in MySQL during init/resize */
+} KEY_CACHE;
+
+/* The default key cache */
+extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
+
+extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
+ ulong use_mem, uint division_limit,
+ uint age_threshold);
+extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
+ ulong use_mem, uint division_limit,
+ uint age_threshold);
+extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit,
+ uint age_threshold);
+extern byte *key_cache_read(KEY_CACHE *keycache,
+ File file, my_off_t filepos, int level,
+ byte *buff, uint length,
+ uint block_length,int return_buffer);
+extern int key_cache_insert(KEY_CACHE *keycache,
+ File file, my_off_t filepos, int level,
+ byte *buff, uint length);
+extern int key_cache_write(KEY_CACHE *keycache,
+ File file, my_off_t filepos, int level,
+ byte *buff, uint length,
+ uint block_length,int force_write);
+extern int flush_key_blocks(KEY_CACHE *keycache,
+ int file, enum flush_type type);
+extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup);
+
+/* Functions to handle multiple key caches */
+extern my_bool multi_keycache_init(void);
+extern void multi_keycache_free(void);
+extern KEY_CACHE *multi_key_cache_search(byte *key, uint length);
+extern my_bool multi_key_cache_set(const byte *key, uint length,
+ KEY_CACHE *key_cache);
+extern void multi_key_cache_change(KEY_CACHE *old_data,
+ KEY_CACHE *new_data);
+C_MODE_END
+#endif /* _keycache_h */
diff --git a/include/m_ctype.h b/include/m_ctype.h
index b3e50cec58f..a97d25862bd 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -26,68 +26,328 @@
extern "C" {
#endif
+#define MY_CS_NAME_SIZE 32
+#define MY_CS_CTYPE_TABLE_SIZE 257
+#define MY_CS_TO_LOWER_TABLE_SIZE 256
+#define MY_CS_TO_UPPER_TABLE_SIZE 256
+#define MY_CS_SORT_ORDER_TABLE_SIZE 256
+#define MY_CS_TO_UNI_TABLE_SIZE 256
+
#define CHARSET_DIR "charsets/"
+#define my_wc_t ulong
+
+typedef struct unicase_info_st
+{
+ uint16 toupper;
+ uint16 tolower;
+ uint16 sort;
+} MY_UNICASE_INFO;
+
+#define MY_CS_ILSEQ 0
+#define MY_CS_ILUNI 0
+#define MY_CS_TOOSMALL -1
+#define MY_CS_TOOFEW(n) (-1-(n))
+
+#define MY_SEQ_INTTAIL 1
+#define MY_SEQ_SPACES 2
+
+ /* My charsets_list flags */
+#define MY_NO_SETS 0
+#define MY_CS_COMPILED 1 /* compiled-in sets */
+#define MY_CS_CONFIG 2 /* sets that have a *.conf file */
+#define MY_CS_INDEX 4 /* sets listed in the Index file */
+#define MY_CS_LOADED 8 /* sets that are currently loaded */
+#define MY_CS_BINSORT 16 /* if binary sort order */
+#define MY_CS_PRIMARY 32 /* if primary collation */
+#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */
+#define MY_CS_UNICODE 128 /* is a charset is full unicode */
+#define MY_CS_NONTEXT 256 /* if a charset is not sprintf() compatible */
+#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
+
+#define MY_CHARSET_UNDEFINED 0
+
+
+typedef struct my_uni_idx_st
+{
+ uint16 from;
+ uint16 to;
+ uchar *tab;
+} MY_UNI_IDX;
+
+typedef struct
+{
+ uint beg;
+ uint end;
+ uint mblen;
+} my_match_t;
+
+enum my_lex_states
+{
+ MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT,
+ MY_LEX_IDENT_SEP, MY_LEX_IDENT_START,
+ MY_LEX_REAL, MY_LEX_HEX_NUMBER,
+ MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END,
+ MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL,
+ MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE,
+ MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_COLON,
+ MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP,
+ MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR,
+ MY_LEX_IDENT_OR_KEYWORD,
+ MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR,
+ MY_LEX_STRING_OR_DELIMITER
+};
+
+struct charset_info_st;
+
+typedef struct my_collation_handler_st
+{
+ /* Collation routines */
+ int (*strnncoll)(struct charset_info_st *,
+ const uchar *, uint, const uchar *, uint);
+ int (*strnncollsp)(struct charset_info_st *,
+ const uchar *, uint, const uchar *, uint);
+ int (*strnxfrm)(struct charset_info_st *,
+ uchar *, uint, const uchar *, uint);
+ my_bool (*like_range)(struct charset_info_st *,
+ const char *s, uint s_length,
+ pchar w_prefix, pchar w_one, pchar w_many,
+ uint res_length,
+ char *min_str, char *max_str,
+ uint *min_len, uint *max_len);
+ int (*wildcmp)(struct charset_info_st *,
+ const char *str,const char *str_end,
+ const char *wildstr,const char *wildend,
+ int escape,int w_one, int w_many);
+
+ int (*strcasecmp)(struct charset_info_st *, const char *, const char *);
+
+ uint (*instr)(struct charset_info_st *,
+ const char *b, uint b_length,
+ const char *s, uint s_length,
+ my_match_t *match, uint nmatch);
+
+ /* Hash calculation */
+ void (*hash_sort)(struct charset_info_st *cs, const uchar *key, uint len,
+ ulong *nr1, ulong *nr2);
+} MY_COLLATION_HANDLER;
+
+extern MY_COLLATION_HANDLER my_collation_mb_bin_handler;
+extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler;
+extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler;
+
+
+typedef struct my_charset_handler_st
+{
+ /* Multibyte routines */
+ int (*ismbchar)(struct charset_info_st *, const char *, const char *);
+ int (*mbcharlen)(struct charset_info_st *, uint);
+ uint (*numchars)(struct charset_info_st *, const char *b, const char *e);
+ uint (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos);
+ uint (*well_formed_len)(struct charset_info_st *,
+ const char *b,const char *e, uint nchars);
+ uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length);
+
+ /* Unicode convertion */
+ int (*mb_wc)(struct charset_info_st *cs,my_wc_t *wc,
+ const unsigned char *s,const unsigned char *e);
+ int (*wc_mb)(struct charset_info_st *cs,my_wc_t wc,
+ unsigned char *s,unsigned char *e);
+
+ /* Functions for case and sort convertion */
+ void (*caseup_str)(struct charset_info_st *, char *);
+ void (*casedn_str)(struct charset_info_st *, char *);
+ void (*caseup)(struct charset_info_st *, char *, uint);
+ void (*casedn)(struct charset_info_st *, char *, uint);
+
+ /* Charset dependant snprintf() */
+ int (*snprintf)(struct charset_info_st *, char *to, uint n, const char *fmt,
+ ...);
+ int (*long10_to_str)(struct charset_info_st *, char *to, uint n, int radix,
+ long int val);
+ int (*longlong10_to_str)(struct charset_info_st *, char *to, uint n,
+ int radix, longlong val);
+
+ void (*fill)(struct charset_info_st *, char *to, uint len, int fill);
+
+ /* String-to-number convertion routines */
+ long (*strntol)(struct charset_info_st *, const char *s, uint l,
+ int base, char **e, int *err);
+ ulong (*strntoul)(struct charset_info_st *, const char *s, uint l,
+ int base, char **e, int *err);
+ longlong (*strntoll)(struct charset_info_st *, const char *s, uint l,
+ int base, char **e, int *err);
+ ulonglong (*strntoull)(struct charset_info_st *, const char *s, uint l,
+ int base, char **e, int *err);
+ double (*strntod)(struct charset_info_st *, char *s, uint l, char **e,
+ int *err);
+
+ ulong (*scan)(struct charset_info_st *, const char *b, const char *e,
+ int sq);
+} MY_CHARSET_HANDLER;
+
+extern MY_CHARSET_HANDLER my_charset_8bit_handler;
+
+
+
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);
+ uint number;
+ uint primary_number;
+ uint binary_number;
+ uint state;
+ const char *csname;
+ const char *name;
+ const char *comment;
+ uchar *ctype;
+ uchar *to_lower;
+ uchar *to_upper;
+ uchar *sort_order;
+ uint16 *tab_to_uni;
+ MY_UNI_IDX *tab_from_uni;
+ uchar state_map[256];
+ uchar ident_map[256];
+ uint strxfrm_multiply;
+ uint mbminlen;
+ uint mbmaxlen;
+ char max_sort_char; /* For LIKE optimization */
+
+ MY_CHARSET_HANDLER *cset;
+ MY_COLLATION_HANDLER *coll;
+
} 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[];
-extern uint compiled_charset_number(const char *name);
-extern const char *compiled_charset_name(uint charset_number);
-#define MY_CHARSET_UNDEFINED 0
-#define MY_CHARSET_CURRENT (default_charset_info->number)
-
-/* Don't include std ctype.h when this is included */
-#define _CTYPE_H
-#define _CTYPE_H_
-#define _CTYPE_INCLUDED
-#define __CTYPE_INCLUDED
-#define _CTYPE_USING /* Don't put names in global namespace. */
-
-/* Fix things, if ctype.h would have been included before */
-#undef toupper
-#undef _toupper
-#undef _tolower
-#undef toupper
-#undef tolower
-#undef isalpha
-#undef isupper
-#undef islower
-#undef isdigit
-#undef isxdigit
-#undef isalnum
-#undef isspace
-#undef ispunct
-#undef isprint
-#undef isgraph
-#undef iscntrl
-#undef isascii
-#undef toascii
+extern CHARSET_INFO my_charset_bin;
+extern CHARSET_INFO my_charset_big5_chinese_ci;
+extern CHARSET_INFO my_charset_big5_bin;
+extern CHARSET_INFO my_charset_euckr_korean_ci;
+extern CHARSET_INFO my_charset_euckr_bin;
+extern CHARSET_INFO my_charset_gb2312_chinese_ci;
+extern CHARSET_INFO my_charset_gb2312_bin;
+extern CHARSET_INFO my_charset_gbk_chinese_ci;
+extern CHARSET_INFO my_charset_gbk_bin;
+extern CHARSET_INFO my_charset_latin1;
+extern CHARSET_INFO my_charset_latin1_german2_ci;
+extern CHARSET_INFO my_charset_latin1_bin;
+extern CHARSET_INFO my_charset_latin2_czech_ci;
+extern CHARSET_INFO my_charset_sjis_japanese_ci;
+extern CHARSET_INFO my_charset_sjis_bin;
+extern CHARSET_INFO my_charset_tis620_thai_ci;
+extern CHARSET_INFO my_charset_tis620_bin;
+extern CHARSET_INFO my_charset_ucs2_general_ci;
+extern CHARSET_INFO my_charset_ucs2_bin;
+extern CHARSET_INFO my_charset_ujis_japanese_ci;
+extern CHARSET_INFO my_charset_ujis_bin;
+extern CHARSET_INFO my_charset_utf8_general_ci;
+extern CHARSET_INFO my_charset_utf8_bin;
+extern CHARSET_INFO my_charset_cp1250_czech_ci;
+
+
+/* declarations for simple charsets */
+extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *,
+ uint);
+extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint,
+ const uchar *, uint);
+
+extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, uint,
+ const uchar *, uint);
+
+extern void my_hash_sort_simple(CHARSET_INFO *cs,
+ const uchar *key, uint len,
+ ulong *nr1, ulong *nr2);
+
+extern uint my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, uint length);
+
+extern uint my_instr_simple(struct charset_info_st *,
+ const char *b, uint b_length,
+ const char *s, uint s_length,
+ my_match_t *match, uint nmatch);
+
+
+/* Functions for 8bit */
+extern void my_caseup_str_8bit(CHARSET_INFO *, char *);
+extern void my_casedn_str_8bit(CHARSET_INFO *, char *);
+extern void my_caseup_8bit(CHARSET_INFO *, char *, uint);
+extern void my_casedn_8bit(CHARSET_INFO *, char *, uint);
+
+extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *);
+
+int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, const uchar *s,const uchar *e);
+int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e);
+
+ulong my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq);
+
+int my_snprintf_8bit(struct charset_info_st *, char *to, uint n,
+ const char *fmt, ...);
+
+long my_strntol_8bit(CHARSET_INFO *, const char *s, uint l, int base,
+ char **e, int *err);
+ulong my_strntoul_8bit(CHARSET_INFO *, const char *s, uint l, int base,
+ char **e, int *err);
+longlong my_strntoll_8bit(CHARSET_INFO *, const char *s, uint l, int base,
+ char **e, int *err);
+ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, uint l, int base,
+ char **e, int *err);
+double my_strntod_8bit(CHARSET_INFO *, char *s, uint l,char **e,
+ int *err);
+int my_long10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix,
+ long int val);
+int my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix,
+ longlong val);
+
+void my_fill_8bit(CHARSET_INFO *cs, char* to, uint l, int fill);
+
+my_bool my_like_range_simple(CHARSET_INFO *cs,
+ const char *ptr, uint ptr_length,
+ pbool escape, pbool w_one, pbool w_many,
+ uint res_length,
+ char *min_str, char *max_str,
+ uint *min_length, uint *max_length);
+
+
+int my_wildcmp_8bit(CHARSET_INFO *,
+ const char *str,const char *str_end,
+ const char *wildstr,const char *wildend,
+ int escape, int w_one, int w_many);
+
+uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e);
+uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos);
+uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos);
+int my_mbcharlen_8bit(CHARSET_INFO *, uint c);
+
+
+/* Functions for multibyte charsets */
+extern void my_caseup_str_mb(CHARSET_INFO *, char *);
+extern void my_casedn_str_mb(CHARSET_INFO *, char *);
+extern void my_caseup_mb(CHARSET_INFO *, char *, uint);
+extern void my_casedn_mb(CHARSET_INFO *, char *, uint);
+extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *);
+
+int my_wildcmp_mb(CHARSET_INFO *,
+ const char *str,const char *str_end,
+ const char *wildstr,const char *wildend,
+ int escape, int w_one, int w_many);
+uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e);
+uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos);
+uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, uint pos);
+uint my_instr_mb(struct charset_info_st *,
+ const char *b, uint b_length,
+ const char *s, uint s_length,
+ my_match_t *match, uint nmatch);
+
+
+extern my_bool my_parse_charset_xml(const char *bug, uint len,
+ int (*add)(CHARSET_INFO *cs));
+
+#undef _U
+#undef _L
+#undef _NMR
+#undef _SPC
+#undef _PNT
+#undef _CTR
+#undef _B
+#undef _X
#define _U 01 /* Upper case */
#define _L 02 /* Lower case */
@@ -98,34 +358,13 @@ extern const char *compiled_charset_name(uint charset_number);
#define _B 0100 /* Blank */
#define _X 0200 /* heXadecimal digit */
-#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)
-
-#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)]
-#define tolower(c) (char) my_to_lower[(uchar) (c)]
-
-#define isalpha(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L))
-#define isupper(c) ((my_ctype+1)[(uchar) (c)] & _U)
-#define islower(c) ((my_ctype+1)[(uchar) (c)] & _L)
-#define isdigit(c) ((my_ctype+1)[(uchar) (c)] & _NMR)
-#define isxdigit(c) ((my_ctype+1)[(uchar) (c)] & _X)
-#define isalnum(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L | _NMR))
-#define isspace(c) ((my_ctype+1)[(uchar) (c)] & _SPC)
-#define ispunct(c) ((my_ctype+1)[(uchar) (c)] & _PNT)
-#define isprint(c) ((my_ctype+1)[(uchar) (c)] & (_PNT | _U | _L | _NMR | _B))
-#define isgraph(c) ((my_ctype+1)[(uchar) (c)] & (_PNT | _U | _L | _NMR))
-#define iscntrl(c) ((my_ctype+1)[(uchar) (c)] & _CTR)
-#define isascii(c) (!((c) & ~0177))
-#define toascii(c) ((c) & 0177)
-
-#ifdef ctype
-#undef ctype
-#endif /* ctype */
+#define my_isascii(c) (!((c) & ~0177))
+#define my_toascii(c) ((c) & 0177)
+#define my_tocntrl(c) ((c) & 31)
+#define my_toprint(c) ((c) | 64)
+#define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)])
+#define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)])
#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)
@@ -138,25 +377,37 @@ extern const char *compiled_charset_name(uint charset_number);
#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_PNT | _U | _L | _NMR))
#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _CTR)
-#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_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)))
+/* Some macros that should be cleaned up a little */
+#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_')
+#define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_')
-#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)))
+#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT)
+#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM)
+#define my_strnxfrm(s, a, b, c, d) ((s)->coll->strnxfrm((s), (a), (b), (c), (d)))
+#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d)))
+#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
+ ((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
+#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m)))
+#define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b)))
+
+#define use_mb(s) ((s)->cset->ismbchar != NULL)
+#define my_ismbchar(s, a, b) ((s)->cset->ismbchar((s), (a), (b)))
+#ifdef USE_MB
+#define my_mbcharlen(s, a) ((s)->cset->mbcharlen((s),(a)))
+#else
+#define my_mbcharlen(s, a) 1
+#endif
+
+#define my_caseup(s, a, l) ((s)->cset->caseup((s), (a), (l)))
+#define my_casedn(s, a, l) ((s)->cset->casedn((s), (a), (l)))
+#define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a)))
+#define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a)))
+#define my_strntol(s, a, b, c, d, e) ((s)->cset->strntol((s),(a),(b),(c),(d),(e)))
+#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e)))
+#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e)))
+#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e)))
+#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d)))
-/* Some macros that should be cleaned up a little */
-#define isvar(c) (isalnum(c) || (c) == '_')
-#define isvar_start(c) (isalpha(c) || (c) == '_')
-#define tocntrl(c) ((c) & 31)
-#define toprint(c) ((c) | 64)
/* XXX: still need to take care of this one */
#ifdef MY_CHARSET_TIS620
diff --git a/include/m_string.h b/include/m_string.h
index eac1552f8c1..21aa736acd4 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -31,6 +31,9 @@
#include <string.h>
#endif
+/* need by my_vsnprintf */
+#include <stdarg.h>
+
/* Correct some things for UNIXWARE7 */
#ifdef HAVE_UNIXWARE7_THREADS
#undef HAVE_STRINGS_H
@@ -71,14 +74,14 @@
/* Unixware 7 */
#if !defined(HAVE_BFILL)
# define bfill(A,B,C) memset((A),(C),(B))
-# define bmove_allign(A,B,C) memcpy((A),(B),(C))
+# define bmove_align(A,B,C) memcpy((A),(B),(C))
#endif
#if !defined(HAVE_BCMP)
# define bcopy(s, d, n) memcpy((d), (s), (n))
# define bcmp(A,B,C) memcmp((A),(B),(C))
# define bzero(A,B) memset((A),0,(B))
-# define bmove_allign(A,B,C) memcpy((A),(B),(C))
+# define bmove_align(A,B,C) memcpy((A),(B),(C))
#endif
#if defined(__cplusplus) && !defined(OS2)
@@ -108,11 +111,11 @@ extern char NEAR _dig_vec[]; /* Declared in int2str() */
#endif
#ifdef MSDOS
-#undef bmove_allign
-#define bmove512(A,B,C) bmove_allign(A,B,C)
+#undef bmove_align
+#define bmove512(A,B,C) bmove_align(A,B,C)
#define my_itoa(A,B,C) itoa(A,B,C)
#define my_ltoa(A,B,C) ltoa(A,B,C)
-extern void bmove_allign(gptr dst,const gptr src,uint len);
+extern void bmove_align(gptr dst,const gptr src,uint len);
#endif
#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
@@ -123,7 +126,7 @@ extern void bmove_allign(gptr dst,const gptr src,uint len);
#include <assert.h>
#define memcpy_overlap(A,B,C) \
DBUG_ASSERT((A) == (B) || ((A)+(C)) <= (B) || ((B)+(C)) <= (A)); \
-bmove((byte*) key,(byte*) from,(size_t) length);
+bmove((byte*) (A),(byte*) (B),(size_t) (C));
#else
#define memcpy_overlap(A,B,C) memcpy((A), (B), (C))
#endif /* HAVE_purify */
@@ -198,7 +201,7 @@ extern int strcmp(const char *, const char *);
extern size_t strlen(const char *);
#endif
#endif
-#ifndef HAVE_STRNLEN
+#ifndef HAVE_STRNLEN
extern uint strnlen(const char *s, uint n);
#endif
@@ -212,7 +215,9 @@ extern char *strstr(const char *, const char *);
#endif
extern int is_prefix(const char *, const char *);
-/* Conversion rutins */
+/* Conversion routines */
+double my_strtod(const char *str, char **end);
+double my_atof(const char *nptr);
#ifdef USE_MY_ITOA
extern char *my_itoa(int val,char *dst,int radix);
@@ -229,6 +234,7 @@ 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);
+longlong my_strtoll10(const char *nptr, char **endptr, int *error);
#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))
@@ -248,6 +254,12 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);
#endif
#endif
+/* my_vsnprintf.c */
+
+extern int my_vsnprintf( char *str, size_t n,
+ const char *format, va_list ap );
+extern int my_snprintf(char* to, size_t n, const char* fmt, ...);
+
#if defined(__cplusplus) && !defined(OS2)
}
#endif
diff --git a/include/my_base.h b/include/my_base.h
index 5344d876f99..89b46de520f 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -49,29 +49,34 @@
/* The following is parameter to ha_rkey() how to use key */
-/* We define a complete-field prefix of a key value as a prefix where the
-last included field in the prefix contains the full field, not just some bytes
-from the start of the field. A partial-field prefix is allowed to
-contain only a few first bytes from the last included field.
-
-Below HA_READ_KEY_EXACT, ..., HA_READ_BEFORE_KEY can take a
-complete-field prefix of a key value as the search key. HA_READ_PREFIX
-and HA_READ_PREFIX_LAST could also take a partial-field prefix, but
-currently (4.0.10) they are only used with complete-field prefixes. MySQL uses
-a padding trick to implement LIKE 'abc%' queries.
-
-NOTE that in InnoDB HA_READ_PREFIX_LAST will NOT work with a partial-field
-prefix because InnoDB currently strips spaces from the end of varchar
-fields! */
+/*
+ We define a complete-field prefix of a key value as a prefix where
+ the last included field in the prefix contains the full field, not
+ just some bytes from the start of the field. A partial-field prefix
+ is allowed to contain only a few first bytes from the last included
+ field.
+
+ Below HA_READ_KEY_EXACT, ..., HA_READ_BEFORE_KEY can take a
+ complete-field prefix of a key value as the search
+ key. HA_READ_PREFIX and HA_READ_PREFIX_LAST could also take a
+ partial-field prefix, but currently (4.0.10) they are only used with
+ complete-field prefixes. MySQL uses a padding trick to implement
+ LIKE 'abc%' queries.
+
+ NOTE that in InnoDB HA_READ_PREFIX_LAST will NOT work with a
+ partial-field prefix because InnoDB currently strips spaces from the
+ end of varchar fields!
+*/
enum ha_rkey_function {
- HA_READ_KEY_EXACT, /* Find first record else error */
- HA_READ_KEY_OR_NEXT, /* Record or next record */
- HA_READ_KEY_OR_PREV, /* Record or previous */
- HA_READ_AFTER_KEY, /* Find next rec. after key-record */
- HA_READ_BEFORE_KEY, /* Find next rec. before key-record */
- HA_READ_PREFIX, /* Key which as same prefix */
- HA_READ_PREFIX_LAST, /* Last key with the same prefix */
+ HA_READ_KEY_EXACT, /* Find first record else error */
+ HA_READ_KEY_OR_NEXT, /* Record or next record */
+ HA_READ_KEY_OR_PREV, /* Record or previous */
+ HA_READ_AFTER_KEY, /* Find next rec. after key-record */
+ HA_READ_BEFORE_KEY, /* Find next rec. before key-record */
+ HA_READ_PREFIX, /* Key which as same prefix */
+ HA_READ_PREFIX_LAST, /* Last key with the same prefix */
+ HA_READ_PREFIX_LAST_OR_PREV, /* Last or prev key with the same prefix */
HA_READ_MBR_CONTAIN,
HA_READ_MBR_INTERSECT,
HA_READ_MBR_WITHIN,
@@ -81,7 +86,7 @@ enum ha_rkey_function {
/* Key algorithm types */
-enum ha_key_alg {
+enum ha_key_alg {
HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */
HA_KEY_ALG_BTREE= 1, /* B-tree, default one */
HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */
@@ -120,9 +125,14 @@ enum ha_extra_function {
HA_EXTRA_RESET_STATE, /* Reset positions */
HA_EXTRA_IGNORE_DUP_KEY, /* Dup keys don't rollback everything*/
HA_EXTRA_NO_IGNORE_DUP_KEY,
- HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE, /* Cursor will not be used for update */
+ /*
+ Instructs InnoDB to retrieve all columns, not just those where
+ field->query_id is the same as the current query id
+ */
+ HA_EXTRA_RETRIEVE_ALL_COLS,
HA_EXTRA_PREPARE_FOR_DELETE,
- HA_EXTRA_PREPARE_FOR_UPDATE /* Remove read cache if problems */
+ HA_EXTRA_PREPARE_FOR_UPDATE, /* Remove read cache if problems */
+ HA_EXTRA_PRELOAD_BUFFER_SIZE /* Set buffer size for preloading */
};
/* The following is parameter to ha_panic() */
@@ -163,9 +173,9 @@ enum ha_base_keytype {
#define HA_PACK_KEY 2 /* Pack string key to previous key */
#define HA_AUTO_KEY 16
#define HA_BINARY_PACK_KEY 32 /* Packing of all keys to prev key */
-#define HA_FULLTEXT 128 /* SerG: for full-text search */
+#define HA_FULLTEXT 128 /* For full-text search */
#define HA_UNIQUE_CHECK 256 /* Check the key for uniqueness */
-#define HA_SPATIAL 1024 /* Alex Barkov: for spatial search */
+#define HA_SPATIAL 1024 /* For spatial search */
#define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */
@@ -221,7 +231,7 @@ enum ha_base_keytype {
/* Bits in flag to _status */
#define HA_STATUS_POS 1 /* Return position */
-#define HA_STATUS_NO_LOCK 2 /* Don't use external lock */
+#define HA_STATUS_NO_LOCK 2 /* Don't use external lock */
#define HA_STATUS_TIME 4 /* Return update time */
#define HA_STATUS_CONST 8 /* Return constants values */
#define HA_STATUS_VARIABLE 16
@@ -262,6 +272,7 @@ enum ha_base_keytype {
#define HA_ERR_NO_REFERENCED_ROW 151 /* Cannot add a child row */
#define HA_ERR_ROW_IS_REFERENCED 152 /* Cannot delete a parent row */
#define HA_ERR_NO_SAVEPOINT 153 /* No savepoint with that name */
+#define HA_ERR_NON_UNIQUE_BLOCK_SIZE 154 /* Non unique key block size */
/* Other constants */
@@ -295,7 +306,7 @@ enum ha_base_keytype {
#define READ_CHECK_USED 4
#define KEY_READ_USED 8
#define WRITE_CACHE_USED 16
-#define OPT_NO_ROWS 32
+#define OPT_NO_ROWS 32
/* bits in update */
#define HA_STATE_CHANGED 1 /* Database has changed */
@@ -327,7 +338,7 @@ enum data_file_type {
typedef my_off_t ha_rows;
#else
#define rows2double(A) (double) (A)
-typedef ulong ha_rows;
+typedef ulong ha_rows;
#endif
#define HA_POS_ERROR (~ (ha_rows) 0)
diff --git a/include/my_bitmap.h b/include/my_bitmap.h
index ca0037addfb..5b3da011f54 100644
--- a/include/my_bitmap.h
+++ b/include/my_bitmap.h
@@ -25,29 +25,36 @@ typedef struct st_bitmap
{
uchar *bitmap;
uint bitmap_size;
- my_bool thread_safe; /* set if several threads access the bitmap */
/*
mutex will be acquired for the duration of each bitmap operation if
- thread_safe flag is set. Otherwise, we optimize by not acquiring the
- mutex
+ thread_safe flag in bitmap_init was set. Otherwise, we optimize by not
+ acquiring the mutex
*/
#ifdef THREAD
- pthread_mutex_t mutex;
+ pthread_mutex_t *mutex;
#endif
} MY_BITMAP;
#ifdef __cplusplus
extern "C" {
#endif
- extern my_bool bitmap_init(MY_BITMAP *bitmap, uint bitmap_size,
- my_bool thread_safe);
- extern void bitmap_free(MY_BITMAP *bitmap);
- extern void bitmap_set_bit(MY_BITMAP *bitmap, uint bitmap_bit);
- extern uint bitmap_set_next(MY_BITMAP *bitmap);
- extern void bitmap_set_all(MY_BITMAP* bitmap);
- extern my_bool bitmap_is_set(MY_BITMAP* bitmap, uint bitmap_bit);
- extern void bitmap_clear_all(MY_BITMAP* bitmap);
- extern void bitmap_clear_bit(MY_BITMAP *bitmap, uint bitmap_bit);
+extern my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2);
+extern my_bool bitmap_init(MY_BITMAP *map, uchar *buf, uint bitmap_size, my_bool thread_safe);
+extern my_bool bitmap_is_clear_all(const MY_BITMAP *map);
+extern my_bool bitmap_is_prefix(const MY_BITMAP *map, uint prefix_size);
+extern my_bool bitmap_is_set(const MY_BITMAP *map, uint bitmap_bit);
+extern my_bool bitmap_is_set_all(const MY_BITMAP *map);
+extern my_bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2);
+extern uint bitmap_set_next(MY_BITMAP *map);
+extern void bitmap_clear_all(MY_BITMAP *map);
+extern void bitmap_clear_bit(MY_BITMAP *map, uint bitmap_bit);
+extern void bitmap_free(MY_BITMAP *map);
+extern void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2);
+extern void bitmap_set_all(MY_BITMAP *map);
+extern void bitmap_set_bit(MY_BITMAP *map, uint bitmap_bit);
+extern void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size);
+extern void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2);
+extern void bitmap_union(MY_BITMAP *map, const MY_BITMAP *map2);
#ifdef __cplusplus
}
#endif
diff --git a/include/my_getopt.h b/include/my_getopt.h
index 3b4551b445e..5f4025efa0e 100644
--- a/include/my_getopt.h
+++ b/include/my_getopt.h
@@ -17,7 +17,13 @@
C_MODE_START
enum get_opt_var_type { GET_NO_ARG, GET_BOOL, GET_INT, GET_UINT, GET_LONG,
- GET_ULONG, GET_LL, GET_ULL, GET_STR, GET_STR_ALLOC };
+ GET_ULONG, GET_LL, GET_ULL, GET_STR, GET_STR_ALLOC,
+ GET_DISABLED
+ };
+
+#define GET_ASK_ADDR 128
+#define GET_TYPE_MASK 127
+
enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
struct my_option
@@ -48,6 +54,8 @@ extern int handle_options (int *argc, char ***argv,
char *));
extern void my_print_help(const struct my_option *options);
extern void my_print_variables(const struct my_option *options);
+extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint,
+ const struct my_option *));
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp);
my_bool getopt_compare_strings(const char *s, const char *t, uint length);
diff --git a/include/my_global.h b/include/my_global.h
index e4c0fb44337..4a56741ddbc 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -114,6 +114,26 @@
#define __STDC_EXT__ 1 /* To get large file support on hpux */
#endif
+#ifdef HPUX11
+/*
+ Fix warnings on HPUX11
+ There is something really strange with HPUX11 include files as you get
+ error about wrongly declared symbols or missing defines if you don't
+ do the following:
+ */
+#if !defined(_XOPEN_SOURCE_EXTENDED) && ! defined(__cplusplus)
+#define _XOPEN_SOURCE_EXTENDED 1
+#endif
+
+/* Fix type of socklen as this is depending on the above define */
+#undef SOCKET_SIZE_TYPE
+#ifdef _XOPEN_SOURCE_EXTENDED
+#define SOCKET_SIZE_TYPE socklen_t
+#else
+#define SOCKET_SIZE_TYPE int
+#endif /* _XOPEN_SOURCE_EXTENDED */
+#endif /* HPUX11 */
+
#if defined(THREAD) && !defined(__WIN__) && !defined(OS2)
#ifndef _POSIX_PTHREAD_SEMANTICS
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
@@ -364,8 +384,8 @@ typedef unsigned short ushort;
#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
#define swap(t,a,b) { register t dummy; dummy = a; a = b; b = dummy; }
#define test(a) ((a) ? 1 : 0)
-#define set_if_bigger(a,b) { if ((a) < (b)) (a)=(b); }
-#define set_if_smaller(a,b) { if ((a) > (b)) (a)=(b); }
+#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
+#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
#define test_all_bits(a,b) (((a) & (b)) == (b))
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
@@ -504,7 +524,7 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define FN_EXTCHAR '.'
#define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */
#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */
-#define FN_PARENTDIR ".." /* Parentdirectory; Must be a string */
+#define FN_PARENTDIR ".." /* Parent directory; Must be a string */
#define FN_DEVCHAR ':'
#ifndef FN_LIBCHAR
@@ -515,7 +535,10 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define FN_LIBCHAR '/'
#define FN_ROOTDIR "/"
#endif
-#define MY_NFILE 1024 /* This is only used to save filenames */
+#endif
+#define MY_NFILE 64 /* This is only used to save filenames */
+#ifndef OS_FILE_LIMIT
+#define OS_FILE_LIMIT 65535
#endif
/* #define EXT_IN_LIBNAME */
@@ -543,6 +566,9 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
/* Typical key cash */
#define KEY_CACHE_SIZE (uint) (8*1024*1024-MALLOC_OVERHEAD)
+ /* Default size of a key cache block */
+#define KEY_CACHE_BLOCK_SIZE (uint) 1024
+
/* Some things that this system doesn't have */
@@ -560,14 +586,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
/* Some defines of functions for portability */
-#ifndef HAVE_ATOD
-#define atod atof
-#endif
-#ifdef USE_MY_ATOF
-#define atof my_atof
-extern void init_my_atof(void);
-extern double my_atof(const char*);
-#endif
#undef remove /* Crashes MySQL on SCO 5.0.0 */
#ifndef __WIN__
#ifdef OS2
@@ -656,6 +674,10 @@ extern double my_atof(const char*);
#define FLT_MAX ((float)3.40282346638528860e+38)
#endif
+#ifndef HAVE_ISINF
+#define isinf(X) 0
+#endif
+
/*
Max size that must be added to a so that we know Size to make
adressable obj.
@@ -670,7 +692,7 @@ typedef long long my_ptrdiff_t;
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
/* Size to make adressable obj. */
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
- /* Offset of filed f in structure t */
+ /* Offset of field f in structure t */
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
@@ -685,7 +707,8 @@ typedef long long my_ptrdiff_t;
#endif
#endif
#if defined(__IBMC__) || defined(__IBMCPP__)
-#define STDCALL _System _Export
+/* This was _System _Export but caused a lot of warnings on _AIX43 */
+#define STDCALL
#elif !defined( STDCALL)
#define STDCALL
#endif
@@ -734,8 +757,13 @@ typedef long longlong;
#endif
#endif
-/* typedef used for length of string; Should be unsigned! */
-typedef ulong size_str;
+#if defined(NO_CLIENT_LONG_LONG)
+typedef unsigned long my_ulonglong;
+#elif defined (__WIN__)
+typedef unsigned __int64 my_ulonglong;
+#else
+typedef unsigned long long my_ulonglong;
+#endif
#ifdef USE_RAID
/*
@@ -814,6 +842,14 @@ typedef char bool; /* Ordinary boolean values 0 1 */
#endif
#endif
+#ifndef ULL
+#ifdef HAVE_LONG_LONG
+#define ULL(A) A ## ULL
+#else
+#define ULL(A) A ## UL
+#endif
+#endif
+
/*
Defines to make it possible to prioritize register assignments. No
longer that important with modern compilers.
@@ -1135,4 +1171,12 @@ typedef union {
#endif
#endif
+#ifdef HAVE_CHARSET_utf8
+#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
+#else
+#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
+#endif
+
+#define HAVE_SPATIAL
+#define HAVE_RTREE_KEYS
#endif /* my_global_h */
diff --git a/include/my_handler.h b/include/my_handler.h
new file mode 100644
index 00000000000..618d1df1a6e
--- /dev/null
+++ b/include/my_handler.h
@@ -0,0 +1,66 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+#ifndef _my_handler_h
+#define _my_handler_h
+
+#include "my_global.h"
+#include "my_base.h"
+#include "m_ctype.h"
+#include "myisampack.h"
+
+typedef struct st_HA_KEYSEG /* Key-portion */
+{
+ 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 */
+ uint16 flag;
+ uint16 length; /* Keylength */
+ uint32 start; /* Start of key in record */
+ uint32 null_pos; /* position to NULL indicator */
+ CHARSET_INFO *charset;
+} HA_KEYSEG;
+
+#define get_key_length(length,key) \
+{ if ((uchar) *(key) != 255) \
+ length= (uint) (uchar) *((key)++); \
+ else \
+ { length=mi_uint2korr((key)+1); (key)+=3; } \
+}
+
+#define get_key_length_rdonly(length,key) \
+{ if ((uchar) *(key) != 255) \
+ length= ((uint) (uchar) *((key))); \
+ else \
+ { length=mi_uint2korr((key)+1); } \
+}
+
+#define get_key_pack_length(length,length_pack,key) \
+{ if ((uchar) *(key) != 255) \
+ { length= (uint) (uchar) *((key)++); length_pack=1; }\
+ else \
+ { length=mi_uint2korr((key)+1); (key)+=3; length_pack=3; } \
+}
+
+extern int mi_compare_text(CHARSET_INFO *, uchar *, uint, uchar *, uint ,
+ my_bool);
+extern int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
+ register uchar *b, uint key_length, uint nextflag,
+ uint *diff_pos);
+
+#endif /* _my_handler_h */
diff --git a/include/my_list.h b/include/my_list.h
index 0f56d4c532b..789bbb50f97 100644
--- a/include/my_list.h
+++ b/include/my_list.h
@@ -32,8 +32,8 @@ extern LIST *list_add(LIST *root,LIST *element);
extern LIST *list_delete(LIST *root,LIST *element);
extern LIST *list_cons(void *data,LIST *root);
extern LIST *list_reverse(LIST *root);
-extern void list_free(LIST *root,pbool free_data);
-extern uint list_length(LIST *list);
+extern void list_free(LIST *root,unsigned int free_data);
+extern unsigned int list_length(LIST *list);
extern int list_walk(LIST *list,list_walk_action action,gptr argument);
#define rest(a) ((a)->next)
diff --git a/include/my_no_pthread.h b/include/my_no_pthread.h
index 0a034f78192..2c9cde65e78 100644
--- a/include/my_no_pthread.h
+++ b/include/my_no_pthread.h
@@ -27,5 +27,9 @@
#define pthread_mutex_lock(A)
#define pthread_mutex_unlock(A)
#define pthread_mutex_destroy(A)
-
+#define my_rwlock_init(A,B)
+#define rw_rdlock(A)
+#define rw_wrlock(A)
+#define rw_unlock(A)
+#define rwlock_destroy(A)
#endif
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 40302f48bd5..602a4439575 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -99,6 +99,8 @@ int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
int pthread_attr_setprio(pthread_attr_t *connect_att,int priority);
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); /* was #define pthread_exit(A) ExitThread(A)*/
@@ -278,6 +280,8 @@ extern int my_pthread_create_detached;
#define USE_ALARM_THREAD
#undef HAVE_LOCALTIME_R
#define HAVE_LOCALTIME_R
+#undef HAVE_GMTIME_R
+#define HAVE_GMTIME_R
#undef HAVE_PTHREAD_ATTR_SETSCOPE
#define HAVE_PTHREAD_ATTR_SETSCOPE
#undef HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE /* If we are running linux */
@@ -378,6 +382,10 @@ void *my_pthread_getspecific_imp(pthread_key_t key);
struct tm *localtime_r(const time_t *clock, struct tm *res);
#endif
+#ifndef HAVE_GMTIME_R
+struct tm *gmtime_r(const time_t *clock, struct tm *res);
+#endif
+
#ifdef HAVE_PTHREAD_CONDATTR_CREATE
/* DCE threads on HPUX 10.20 */
#define pthread_condattr_init pthread_condattr_create
@@ -468,7 +476,7 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
typedef struct st_safe_mutex_t
{
pthread_mutex_t global,mutex;
- char *file;
+ const char *file;
uint line,count;
pthread_t thread;
#ifdef SAFE_MUTEX_DETECT_DESTROY
@@ -487,7 +495,7 @@ typedef struct st_safe_mutex_info_t
{
struct st_safe_mutex_info_t *next;
struct st_safe_mutex_info_t *prev;
- char *init_file;
+ const char *init_file;
uint32 init_line;
} safe_mutex_info_t;
#endif /* SAFE_MUTEX_DETECT_DESTROY */
@@ -631,7 +639,7 @@ extern int pthread_dummy(int);
*/
#define DEFAULT_THREAD_STACK (192*1024L)
#else
-#define DEFAULT_THREAD_STACK (192*1024L)
+#define DEFAULT_THREAD_STACK (192*1024)
#endif
struct st_my_thread_var
@@ -646,6 +654,8 @@ struct st_my_thread_var
int cmp_length;
int volatile abort;
my_bool init;
+ struct st_my_thread_var *next,**prev;
+ void *opt_info;
#ifndef DBUG_OFF
gptr dbug;
char name[THREAD_NAME_SIZE+1];
@@ -668,8 +678,6 @@ extern pthread_t shutdown_th, main_th, signal_th;
#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));
@@ -677,6 +685,7 @@ extern pthread_t shutdown_th, main_th, signal_th;
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));
+#endif /* HAVE_ATOMIC_ADD */
#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))
@@ -684,7 +693,6 @@ extern pthread_t shutdown_th, main_th, signal_th;
#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 */
#ifdef __cplusplus
diff --git a/include/my_sys.h b/include/my_sys.h
index 8f0040055d6..a97ddcce40d 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (C) 2000-2003 MySQL AB
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
@@ -37,6 +37,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#endif
#include <stdarg.h>
+#include <typelib.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;}
@@ -106,26 +107,21 @@ 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 DEFAULT_KEYCACHE_BLOCK_SIZE 1024
-#define MAX_KEYCACHE_BLOCK_SIZE 16384
+#define DFLT_INIT_HITS 3
/* root_alloc flags */
#define MY_KEEP_PREALLOC 1
#define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */
- /* defines when allocating data */
+ /* Internal error numbers (for assembler functions) */
+#define MY_ERRNO_EDOM 33
+#define MY_ERRNO_ERANGE 34
+ /* defines when allocating data */
#ifdef SAFEMALLOC
#define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG )
#define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG )
@@ -164,7 +160,7 @@ extern char *my_strdup_with_length(const byte *from, uint length,
#endif
#ifdef HAVE_ALLOCA
-#if defined(_AIX) && !defined(__GNUC__)
+#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
#pragma alloca
#endif /* _AIX */
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
@@ -206,26 +202,19 @@ 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,
myf MyFlags);
+extern uint my_file_limit;
/* 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... */
-extern char *get_charsets_dir(char *buf);
-
+extern CHARSET_INFO *default_charset_info;
+extern CHARSET_INFO *all_charsets[256];
+extern CHARSET_INFO compiled_charsets[];
/* statistics */
-extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
- _my_cache_read;
-extern ulong _my_blocks_used,_my_blocks_changed;
-extern uint key_cache_block_size;
+extern ulong my_cache_w_requests, my_cache_write, my_cache_r_requests,
+ my_cache_read;
+extern ulong my_blocks_used, my_blocks_changed;
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
-extern my_bool key_cache_inited, my_init_done;
+extern my_bool my_init_done;
/* Point to current my_message() */
extern void (*my_sigtstp_cleanup)(void),
@@ -255,12 +244,6 @@ typedef struct wild_file_pack /* Struct to hold info when selecting files */
my_string *wild; /* Pointer to wildcards */
} WF_PACK;
-typedef struct st_typelib { /* Different types saved here */
- uint count; /* How many types */
- const char *name; /* Name of typelib */
- const char **type_names;
-} TYPELIB;
-
enum cache_type
{
READ_CACHE,WRITE_CACHE,
@@ -292,15 +275,25 @@ enum file_type
FILE_BY_MKSTEMP, FILE_BY_DUP
};
-extern struct my_file_info
+struct st_my_file_info
{
my_string name;
enum file_type type;
#if defined(THREAD) && !defined(HAVE_PREAD)
pthread_mutex_t mutex;
#endif
-} my_file_info[MY_NFILE];
+};
+extern struct st_my_file_info *my_file_info;
+
+typedef struct st_my_tmpdir
+{
+ char **list;
+ uint cur, max;
+#ifdef THREAD
+ pthread_mutex_t mutex;
+#endif
+} MY_TMPDIR;
typedef struct st_dynamic_array
{
@@ -498,6 +491,8 @@ my_off_t my_b_append_tell(IO_CACHE* info);
#define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \
*(info)->current_pos)
+typedef uint32 ha_checksum;
+
#include <my_alloc.h>
/* Prototypes for mysys and my_func functions */
@@ -510,6 +505,8 @@ extern int my_setwd(const char *dir,myf MyFlags);
extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
extern gptr my_once_alloc(uint Size,myf MyFlags);
extern void my_once_free(void);
+extern char *my_once_strdup(const char *src,myf myflags);
+extern char *my_once_memdup(const char *src, uint len, myf myflags);
extern my_string my_tempnam(const char *dir,const char *pfx,myf MyFlags);
extern File my_open(const char *FileName,int Flags,myf MyFlags);
extern File my_register_filename(File fd, const char *FileName,
@@ -558,6 +555,7 @@ extern char *_my_strdup_with_length(const byte *from, uint length,
const char *sFile, uint uLine,
myf MyFlag);
+
#ifndef TERMINATE
extern void TERMINATE(FILE *file);
#endif
@@ -571,9 +569,6 @@ 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_snprintf(char* to, size_t n, const char* fmt, ...);
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);
@@ -591,12 +586,11 @@ extern void allow_break(void);
#define allow_break()
#endif
+extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist);
+extern char *my_tmpdir(MY_TMPDIR *tmpdir);
+extern void free_tmpdir(MY_TMPDIR *tmpdir);
+
extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
-extern void caseup(my_string str,uint length);
-extern void casedn(my_string str,uint length);
-extern void caseup_str(my_string str);
-extern void casedn_str(my_string str);
-extern void case_sort(my_string str,uint length);
extern uint dirname_part(my_string to,const char *name);
extern uint dirname_length(const char *name);
#define base_name(A) (A+dirname_length(A))
@@ -620,19 +614,13 @@ extern my_string my_path(my_string to,const char *progname,
const char *own_pathname_part);
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 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 int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern);
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);
extern size_s strip_sp(my_string str);
extern void get_date(my_string to,int timeflag,time_t use_time);
-extern void soundex(my_string out_pntr, my_string in_pntr,pbool remove_garbage);
+extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr,pbool remove_garbage);
extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
uint reclength,enum cache_type type,
pbool use_async_io);
@@ -644,14 +632,7 @@ extern int flush_write_cache(RECORD_CACHE *info);
extern long my_clock(void);
extern sig_handler sigtstp_handler(int signal_number);
extern void handle_recived_signals(void);
-extern int init_key_cache(ulong use_mem);
-extern int resize_key_cache(ulong use_mem);
-extern byte *key_cache_read(File file,my_off_t filepos,byte* buff,uint length,
- uint block_length,int return_buffer);
-extern int key_cache_write(File file,my_off_t filepos,byte* buff,uint length,
- uint block_length,int force_write);
-extern int flush_key_blocks(int file, enum flush_type type);
-extern void end_key_cache(void);
+
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,
@@ -715,10 +696,8 @@ extern void freeze_size(DYNAMIC_ARRAY *array);
#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
#define push_dynamic(A,B) insert_dynamic(A,B)
+#define reset_dynamic(array) ((array)->elements= 0)
-extern int find_type(my_string x,TYPELIB *typelib,uint full_name);
-extern void make_type(my_string to,uint nr,TYPELIB *typelib);
-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);
@@ -735,6 +714,7 @@ extern void my_free_lock(byte *ptr,myf flags);
#define my_free_lock(A,B) my_free((A),(B))
#endif
#define alloc_root_inited(A) ((A)->min_malloc != 0)
+#define clear_alloc_root(A) bzero((void *) (A), sizeof(MEM_ROOT))
extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size);
extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
@@ -752,10 +732,31 @@ extern void print_defaults(const char *conf_file, const char **groups);
extern my_bool my_compress(byte *, ulong *, ulong *);
extern my_bool my_uncompress(byte *, ulong *, ulong *);
extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
-extern ulong checksum(const byte *mem, uint count);
+extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count);
extern uint my_bit_log2(ulong value);
-uint my_count_bits(ulonglong v);
+extern uint my_count_bits(ulonglong v);
extern void my_sleep(ulong m_seconds);
+extern ulong crc32(ulong crc, const uchar *buf, uint len);
+extern uint my_set_max_open_files(uint files);
+void my_free_open_file_info(void);
+
+ulonglong my_getsystime(void);
+my_bool my_gethwaddr(uchar *to);
+
+/* character sets */
+extern uint get_charset_number(const char *cs_name, uint cs_flags);
+extern uint get_collation_number(const char *name);
+extern const char *get_charset_name(uint cs_number);
+
+extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
+extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
+extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
+ uint cs_flags, myf my_flags);
+extern void free_charsets(void);
+extern char *get_charsets_dir(char *buf);
+extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
+extern my_bool init_compiled_charsets(myf flags);
+extern void add_compiled_collation(CHARSET_INFO *cs);
#ifdef __WIN__
extern my_bool have_tcpip; /* Is set if tcpip is used */
diff --git a/include/my_tree.h b/include/my_tree.h
index 6aec50215ca..0159dc891e5 100644
--- a/include/my_tree.h
+++ b/include/my_tree.h
@@ -20,6 +20,8 @@
extern "C" {
#endif
+#include "my_base.h" /* get 'enum ha_rkey_function' */
+
/* Worst case tree is half full. This gives use 2^(MAX_TREE_HIGHT/2) leafs */
#define MAX_TREE_HIGHT 64
@@ -29,6 +31,8 @@ extern "C" {
#define tree_set_pointer(element,ptr) *((byte **) (element+1))=((byte*) (ptr))
+#define TREE_NO_DUPS 1
+
typedef enum { left_root_right, right_root_left } TREE_WALK;
typedef uint32 element_count;
typedef int (*tree_walk_action)(void *,element_count,void *);
@@ -50,15 +54,18 @@ typedef struct st_tree_element {
} TREE_ELEMENT;
#endif /* MSDOS */
+#define ELEMENT_CHILD(element, offs) (*(TREE_ELEMENT**)((char*)element + offs))
+
typedef struct st_tree {
TREE_ELEMENT *root,null_element;
- TREE_ELEMENT **parents[MAX_TREE_HIGHT];
+ TREE_ELEMENT **parents[MAX_TREE_HEIGHT];
uint offset_to_key,elements_in_tree,size_of_element,memory_limit,allocated;
qsort_cmp2 compare;
- void* custom_arg;
+ void *custom_arg;
MEM_ROOT mem_root;
my_bool with_delete;
tree_element_free free;
+ uint flag;
} TREE;
/* Functions on whole tree */
@@ -72,11 +79,21 @@ void reset_tree(TREE*);
#define is_tree_inited(tree) ((tree)->root != 0)
/* Functions on leafs */
-TREE_ELEMENT *tree_insert(TREE *tree,void *key,uint key_size);
-void *tree_search(TREE *tree,void *key);
+TREE_ELEMENT *tree_insert(TREE *tree,void *key, uint key_size,
+ void *custom_arg);
+void *tree_search(TREE *tree, void *key, void *custom_arg);
int tree_walk(TREE *tree,tree_walk_action action,
void *argument, TREE_WALK visit);
-int tree_delete(TREE *tree,void *key);
+int tree_delete(TREE *tree, void *key, void *custom_arg);
+void *tree_search_key(TREE *tree, const void *key,
+ TREE_ELEMENT **parents, TREE_ELEMENT ***last_pos,
+ enum ha_rkey_function flag, void *custom_arg);
+void *tree_search_edge(TREE *tree, TREE_ELEMENT **parents,
+ TREE_ELEMENT ***last_pos, int child_offs);
+void *tree_search_next(TREE *tree, TREE_ELEMENT ***last_pos, int l_offs,
+ int r_offs);
+ha_rows tree_record_pos(TREE *tree, const void *key,
+ enum ha_rkey_function search_flag, void *custom_arg);
#define TREE_ELEMENT_EXTRA_SIZE (sizeof(TREE_ELEMENT) + sizeof(void*))
diff --git a/include/my_xml.h b/include/my_xml.h
new file mode 100644
index 00000000000..82de995e700
--- /dev/null
+++ b/include/my_xml.h
@@ -0,0 +1,67 @@
+/* Copyright (C) 2000 MySQL AB
+
+ 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; either version 2 of the License, or
+ (at your option) any later version.
+
+ 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 */
+
+
+#ifndef _my_xml_h
+#define _my_xml_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define MY_XML_OK 0
+#define MY_XML_ERROR 1
+
+typedef struct xml_stack_st
+{
+ char errstr[128];
+ char attr[128];
+ char *attrend;
+ const char *beg;
+ const char *cur;
+ const char *end;
+ void *user_data;
+ int (*enter)(struct xml_stack_st *st,const char *val, uint len);
+ int (*value)(struct xml_stack_st *st,const char *val, uint len);
+ int (*leave_xml)(struct xml_stack_st *st,const char *val, uint len);
+} MY_XML_PARSER;
+
+void my_xml_parser_create(MY_XML_PARSER *st);
+void my_xml_parser_free(MY_XML_PARSER *st);
+int my_xml_parse(MY_XML_PARSER *st,const char *str, uint len);
+
+void my_xml_set_value_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
+ const char *,
+ uint len));
+void my_xml_set_enter_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
+ const char *,
+ uint len));
+void my_xml_set_leave_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
+ const char *,
+ uint len));
+void my_xml_set_user_data(MY_XML_PARSER *st, void *);
+
+uint my_xml_error_pos(MY_XML_PARSER *st);
+uint my_xml_error_lineno(MY_XML_PARSER *st);
+
+const char *my_xml_error_string(MY_XML_PARSER *st);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _my_xml_h */
diff --git a/include/myisam.h b/include/myisam.h
index 87a40b50c73..ed4f4aff8fe 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -28,13 +28,17 @@ extern "C" {
#ifndef _m_ctype_h
#include <m_ctype.h>
#endif
+#ifndef _keycache_h
+#include "keycache.h"
+#endif
+#include "my_handler.h"
/* defines used by myisam-funktions */
/* The following defines can be increased if necessary */
#define MI_MAX_KEY 32 /* Max allowed keys */
#define MI_MAX_KEY_SEG 16 /* Max segments for key */
-#define MI_MAX_KEY_LENGTH 500
+#define MI_MAX_KEY_LENGTH 1000
#define MI_MAX_KEY_BUFF (MI_MAX_KEY_LENGTH+MI_MAX_KEY_SEG*6+8+8)
#define MI_MAX_POSSIBLE_KEY_BUFF (1024+6+6) /* For myisam_chk */
@@ -52,8 +56,6 @@ extern "C" {
#define mi_portable_sizeof_char_ptr 8
-typedef uint32 ha_checksum;
-
/* Param to/from mi_info */
typedef struct st_mi_isaminfo /* Struct from h_info */
@@ -106,20 +108,6 @@ typedef struct st_mi_create_info
struct st_myisam_info; /* For referense */
typedef struct st_myisam_info MI_INFO;
-typedef struct st_mi_keyseg /* Key-portion */
-{
- 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 */
- uint16 flag;
- uint16 length; /* Keylength */
- uint32 start; /* Start of key in record */
- uint32 null_pos; /* position to NULL indicator */
- CHARSET_INFO *charset;
-} MI_KEYSEG;
-
-
struct st_mi_s_param;
typedef struct st_mi_keydef /* Key definition with open & info */
@@ -136,7 +124,7 @@ typedef struct st_mi_keydef /* Key definition with open & info */
uint16 block_size; /* block_size (auto) */
uint32 version; /* For concurrent read/write */
- MI_KEYSEG *seg,*end;
+ HA_KEYSEG *seg,*end;
int (*bin_search)(struct st_myisam_info *info,struct st_mi_keydef *keyinfo,
uchar *page,uchar *key,
uint key_len,uint comp_flag,uchar * *ret_pos,
@@ -148,6 +136,8 @@ typedef struct st_mi_keydef /* Key definition with open & info */
struct st_mi_s_param *s_temp);
void (*store_key)(struct st_mi_keydef *keyinfo, uchar *key_pos,
struct st_mi_s_param *s_temp);
+ int (*ck_insert)(struct st_myisam_info *inf, uint k_nr, uchar *k, uint klen);
+ int (*ck_delete)(struct st_myisam_info *inf, uint k_nr, uchar *k, uint klen);
} MI_KEYDEF;
@@ -158,7 +148,7 @@ typedef struct st_unique_def /* Segment definition of unique */
uint16 keysegs; /* Number of key-segment */
uchar key; /* Mapped to which key */
uint8 null_are_equal;
- MI_KEYSEG *seg,*end;
+ HA_KEYSEG *seg,*end;
} MI_UNIQUEDEF;
typedef struct st_mi_decode_tree /* Decode huff-table */
@@ -322,11 +312,13 @@ typedef struct st_sort_key_blocks /* Used when sorting */
int inited;
} SORT_KEY_BLOCKS;
+
typedef struct st_mi_check_param
{
ulonglong auto_increment_value;
ulonglong max_data_file_length;
ulonglong keys_in_use;
+ ulonglong max_record_length;
my_off_t search_after_block;
my_off_t new_file_pos,key_file_blocks;
my_off_t keydata,totaldata,key_blocks,start_check_pos;
@@ -336,11 +328,12 @@ typedef struct st_mi_check_param
sort_buffer_length,sort_key_blocks;
uint out_flag,warning_printed,error_printed,verbose;
uint opt_sort_key,total_files,max_level;
- uint testflag;
+ uint testflag, key_cache_block_size;
uint8 language;
my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
my_bool retry_repair, force_sort, calc_checksum;
- char temp_filename[FN_REFLEN],*isam_file_name,*tmpdir;
+ char temp_filename[FN_REFLEN],*isam_file_name;
+ MY_TMPDIR *tmpdir;
int tmpfile_createflag;
myf myf_rw;
IO_CACHE read_cache;
@@ -352,6 +345,12 @@ typedef struct st_mi_check_param
char *op_name;
} MI_CHECK;
+typedef struct st_sort_ft_buf
+{
+ uchar *buf, *end;
+ int count;
+ uchar lastkey[MI_MAX_KEY_BUFF];
+} SORT_FT_BUF;
typedef struct st_sort_info
{
@@ -364,7 +363,8 @@ typedef struct st_sort_info
MI_CHECK *param;
char *buff;
SORT_KEY_BLOCKS *key_block,*key_block_end;
- /* sync things*/
+ SORT_FT_BUF *ft_buf;
+ /* sync things */
uint got_error, threads_running;
#ifdef THREAD
pthread_mutex_t mutex;
@@ -372,33 +372,6 @@ typedef struct st_sort_info
#endif
} SORT_INFO;
-
-typedef struct st_mi_sort_param
-{
-#ifdef THREAD
- pthread_t thr;
-#endif
- IO_CACHE read_cache, tempfile, tempfile_for_exceptions;
- DYNAMIC_ARRAY buffpek;
- ulonglong unique[MI_MAX_KEY_SEG+1];
- my_off_t pos,max_pos,filepos,start_recpos;
- uint key, key_length,real_key_length,sortbuff_size;
- uint maxbuffers, keys, find_length, sort_keys_length;
- my_bool fix_datafile, master;
- MI_KEYDEF *keyinfo;
- SORT_INFO *sort_info;
- uchar **sort_keys;
- byte *rec_buff;
- void *wordlist, *wordptr;
- char *record;
- char *tmpdir;
- int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *);
- int (*key_read)(struct st_mi_sort_param *,void *);
- int (*key_write)(struct st_mi_sort_param *, const void *);
- void (*lock_in_memory)(MI_CHECK *);
-} MI_SORT_PARAM;
-
-
/* functions in mi_check */
void myisamchk_init(MI_CHECK *param);
int chk_status(MI_CHECK *param, MI_INFO *info);
@@ -419,7 +392,6 @@ int change_to_newfile(const char * filename, const char * old_ext,
int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type,
const char *filetype, const char *filename);
void lock_memory(MI_CHECK *param);
-int flush_blocks(MI_CHECK *param, File file);
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
my_bool repair);
int update_state_info(MI_CHECK *param, MI_INFO *info,uint update);
@@ -429,9 +401,7 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
my_off_t length, const char *type);
int movepoint(MI_INFO *info,byte *record,my_off_t oldpos,
my_off_t newpos, uint prot_key);
-int sort_write_record(MI_SORT_PARAM *sort_param);
int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile);
-int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong);
int test_if_almost_full(MI_INFO *info);
int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename);
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows);
@@ -441,6 +411,11 @@ my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ulonglong key_map,
int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows);
void mi_flush_bulk_insert(MI_INFO *info, uint inx);
void mi_end_bulk_insert(MI_INFO *info);
+int mi_assign_to_key_cache(MI_INFO *info, ulonglong key_map,
+ KEY_CACHE *key_cache);
+void mi_change_key_cache(KEY_CACHE *old_key_cache,
+ KEY_CACHE *new_key_cache);
+int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves);
#ifdef __cplusplus
}
diff --git a/include/myisammrg.h b/include/myisammrg.h
index ea882450eef..8b09e1a9231 100644
--- a/include/myisammrg.h
+++ b/include/myisammrg.h
@@ -86,6 +86,7 @@ extern int myrg_rfirst(MYRG_INFO *file,byte *buf,int inx);
extern int myrg_rlast(MYRG_INFO *file,byte *buf,int inx);
extern int myrg_rnext(MYRG_INFO *file,byte *buf,int inx);
extern int myrg_rprev(MYRG_INFO *file,byte *buf,int inx);
+extern int myrg_rnext_same(MYRG_INFO *file,byte *buf);
extern int myrg_rkey(MYRG_INFO *file,byte *buf,int inx,const byte *key,
uint key_len, enum ha_rkey_function search_flag);
extern int myrg_rrnd(MYRG_INFO *file,byte *buf,ulonglong pos);
diff --git a/include/myisampack.h b/include/myisampack.h
index 6004177cfb0..95793e2aaeb 100644
--- a/include/myisampack.h
+++ b/include/myisampack.h
@@ -214,7 +214,7 @@
#ifdef BIG_TABLES
#define mi_rowstore(T,A) mi_int8store(T,A)
-#define mi_rowkorr(T) mi_uint8korr(T)
+#define mi_rowkorr(T) mi_uint8korr(T)
#else
#define mi_rowstore(T,A) { mi_int4store(T,0); mi_int4store(((T)+4),A); }
#define mi_rowkorr(T) mi_uint4korr((T)+4)
diff --git a/include/mysql.h b/include/mysql.h
index 3ffc014c449..1bcc2a58534 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -56,6 +56,9 @@ typedef int my_socket;
#include "mysql_com.h"
#include "mysql_version.h"
+#include "typelib.h"
+
+#include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */
extern unsigned int mysql_port;
extern char *mysql_unix_port;
@@ -74,22 +77,35 @@ extern char *mysql_unix_port;
#define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG)
#define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR)
+#define HAVE_DEPRECATED_411_API 1
+
typedef struct st_mysql_field {
- char *name; /* Name of column */
- char *table; /* Table of column if column was a field */
- char *org_table; /* Org table name if table was an alias */
- char *db; /* Database for table */
- char *def; /* Default value (set by mysql_list_fields) */
- unsigned long length; /* Width of column */
- unsigned long max_length; /* Max width of selected set */
- unsigned int flags; /* Div flags */
- unsigned int decimals; /* Number of decimals in field */
- enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
+ char *name; /* Name of column */
+ char *org_name; /* Original column name, if an alias */
+ char *table; /* Table of column if column was a field */
+ char *org_table; /* Org table name, if table was an alias */
+ char *db; /* Database for table */
+ char *catalog; /* Catalog for table */
+ char *def; /* Default value (set by mysql_list_fields) */
+ unsigned long length; /* Width of column */
+ unsigned long max_length; /* Max width of selected set */
+ unsigned int name_length;
+ unsigned int org_name_length;
+ unsigned int table_length;
+ unsigned int org_table_length;
+ unsigned int db_length;
+ unsigned int catalog_length;
+ unsigned int def_length;
+ unsigned int flags; /* Div flags */
+ unsigned int decimals; /* Number of decimals in field */
+ unsigned int charsetnr; /* Character set */
+ enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
} MYSQL_FIELD;
typedef char **MYSQL_ROW; /* return data as array of strings */
typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
+#ifndef _global_h
#if defined(NO_CLIENT_LONG_LONG)
typedef unsigned long my_ulonglong;
#elif defined (__WIN__)
@@ -97,6 +113,7 @@ typedef unsigned __int64 my_ulonglong;
#else
typedef unsigned long long my_ulonglong;
#endif
+#endif
#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
@@ -114,18 +131,35 @@ typedef struct st_mysql_data {
unsigned int fields;
MYSQL_ROWS *data;
MEM_ROOT alloc;
+#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
+ MYSQL_ROWS **prev_ptr;
+#endif
} MYSQL_DATA;
+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_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
+ MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
+ MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT,
+ MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
+ MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH
+};
+
struct st_mysql_options {
- unsigned int connect_timeout,client_flag;
- unsigned int port;
- char *host,*init_command,*user,*password,*unix_socket,*db;
+ unsigned int connect_timeout, read_timeout, write_timeout;
+ unsigned int port, protocol;
+ unsigned long client_flag;
+ char *host,*user,*password,*unix_socket,*db;
+ struct st_dynamic_array *init_commands;
char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
char *ssl_key; /* PEM key file */
char *ssl_cert; /* PEM cert file */
char *ssl_ca; /* PEM CA file */
char *ssl_capath; /* PEM directory of CA-s? */
char *ssl_cipher; /* cipher to use */
+ char *shared_memory_base_name;
unsigned long max_allowed_packet;
my_bool use_ssl; /* if to use SSL or not */
my_bool compress,named_pipe;
@@ -144,31 +178,43 @@ struct st_mysql_options {
a read that is replication-aware
*/
my_bool no_master_reads;
+#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
+ my_bool separate_thread;
+#endif
+ enum mysql_option methods_to_use;
+ char *client_ip;
+ /* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */
+ my_bool secure_auth;
};
-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_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME,
- MYSQL_OPT_LOCAL_INFILE};
-
-enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,
- MYSQL_STATUS_USE_RESULT};
+enum mysql_status
+{
+ MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT
+};
+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 };
+enum mysql_rpl_type
+{
+ MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
+};
+struct st_mysql_methods;
-typedef struct st_mysql {
+typedef struct st_mysql
+{
NET net; /* Communication parameters */
gptr connector_fd; /* ConnectorFd for SSL */
- char *host,*user,*passwd,*unix_socket,*server_version,*host_info,
- *info,*db;
+ char *host,*user,*passwd,*unix_socket,*server_version,*host_info,*info;
+ char *db;
struct charset_info_st *charset;
MYSQL_FIELD *fields;
MEM_ROOT field_alloc;
@@ -177,16 +223,20 @@ typedef struct st_mysql {
my_ulonglong extra_info; /* Used by mysqlshow */
unsigned long thread_id; /* Id for connection in server */
unsigned long packet_length;
- unsigned int port,client_flag,server_capabilities;
+ unsigned int port;
+ unsigned long client_flag,server_capabilities;
unsigned int protocol_version;
unsigned int field_count;
unsigned int server_status;
unsigned int server_language;
+ unsigned int warning_count;
struct st_mysql_options options;
enum mysql_status status;
my_bool free_me; /* If free in mysql_close */
my_bool reconnect; /* set to 1 if automatic reconnect */
- char scramble_buff[9];
+
+ /* session-wide random string */
+ char scramble[SCRAMBLE_LENGTH+1];
/*
Set if this is the original connection, not a master or a slave we have
@@ -202,8 +252,16 @@ typedef struct st_mysql {
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;
-} MYSQL;
+ LIST *stmts; /* list of all statements */
+ const struct st_mysql_methods *methods;
+ void *thd;
+ /*
+ Points to boolean flag in MYSQL_RES or MYSQL_STMT. We set this flag
+ from mysql_stmt_close if close had to cancel result set of this object.
+ */
+ my_bool *unbuffered_fetch_owner;
+} MYSQL;
typedef struct st_mysql_res {
my_ulonglong row_count;
@@ -217,6 +275,9 @@ typedef struct st_mysql_res {
MYSQL_ROW row; /* If unbuffered read */
MYSQL_ROW current_row; /* buffer to current row */
my_bool eof; /* Used by mysql_fetch_row */
+ /* mysql_stmt_close() had to cancel this result */
+ my_bool unbuffered_fetch_cancelled;
+ const struct st_mysql_methods *methods;
} MYSQL_RES;
#define MAX_MYSQL_MANAGER_ERR 256
@@ -228,6 +289,10 @@ typedef struct st_mysql_res {
#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
@@ -280,12 +345,14 @@ my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
unsigned int STDCALL mysql_errno(MYSQL *mysql);
const char * STDCALL mysql_error(MYSQL *mysql);
+const char *STDCALL mysql_sqlstate(MYSQL *mysql);
+unsigned int STDCALL mysql_warning_count(MYSQL *mysql);
const 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);
-int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
+my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
const char *cert, const char *ca,
const char *capath, const char *cipher);
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
@@ -296,25 +363,26 @@ MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
const char *db,
unsigned int port,
const char *unix_socket,
- unsigned int clientflag);
-void STDCALL mysql_close(MYSQL *sock);
+ unsigned long clientflag);
int STDCALL mysql_select_db(MYSQL *mysql, const char *db);
int STDCALL mysql_query(MYSQL *mysql, const char *q);
int STDCALL mysql_send_query(MYSQL *mysql, const char *q,
unsigned long length);
-int STDCALL mysql_read_query_result(MYSQL *mysql);
int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
unsigned long length);
+MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
+MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql);
+
/* perform query on master */
-int STDCALL mysql_master_query(MYSQL *mysql, const char *q,
- unsigned long length);
-int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
- unsigned long length);
+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 */
-int STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
- unsigned long length);
-int STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
- unsigned long length);
+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);
/*
enable/disable parsing of all queries to decide if they go on master or
@@ -329,12 +397,12 @@ int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql);
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 */
-int STDCALL mysql_reads_from_master_enabled(MYSQL* mysql);
+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 */
-int STDCALL mysql_rpl_probe(MYSQL* mysql);
+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,
@@ -351,20 +419,20 @@ int STDCALL mysql_dump_debug_info(MYSQL *mysql);
int STDCALL mysql_refresh(MYSQL *mysql,
unsigned int refresh_options);
int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid);
+int STDCALL mysql_set_server_option(MYSQL *mysql,
+ enum enum_mysql_set_option
+ option);
int STDCALL mysql_ping(MYSQL *mysql);
const char * STDCALL mysql_stat(MYSQL *mysql);
const char * STDCALL mysql_get_server_info(MYSQL *mysql);
const char * STDCALL mysql_get_client_info(void);
unsigned long STDCALL mysql_get_client_version(void);
const char * STDCALL mysql_get_host_info(MYSQL *mysql);
+unsigned long STDCALL mysql_get_server_version(MYSQL *mysql);
unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql);
MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild);
MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild);
-MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
- const char *wild);
MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql);
-MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
-MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql);
int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option,
const char *arg);
void STDCALL mysql_free_result(MYSQL_RES *result);
@@ -377,6 +445,8 @@ MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result,
MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result);
unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result);
MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result);
+MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
+ const char *wild);
unsigned long STDCALL mysql_escape_string(char *to,const char *from,
unsigned long from_length);
unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
@@ -407,6 +477,184 @@ int STDCALL mysql_manager_command(MYSQL_MANAGER* con,
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);
+
+
+/*
+ The following definitions are added for the enhanced
+ client-server protocol
+*/
+
+/* statement state */
+enum enum_mysql_stmt_state
+{
+ MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE,
+ MYSQL_STMT_FETCH_DONE
+};
+
+/*
+ client TIME structure to handle TIME, DATE and TIMESTAMP directly in
+ binary protocol
+*/
+enum mysql_st_timestamp_type { MYSQL_TIMESTAMP_NONE, MYSQL_TIMESTAMP_DATE,
+ MYSQL_TIMESTAMP_FULL, MYSQL_TIMESTAMP_TIME };
+
+typedef struct mysql_st_time
+{
+ unsigned int year,month,day,hour,minute,second;
+ unsigned long second_part;
+ my_bool neg;
+
+ enum mysql_st_timestamp_type time_type;
+
+} MYSQL_TIME;
+
+
+/* bind structure */
+typedef struct st_mysql_bind
+{
+ unsigned long *length; /* output length pointer */
+ my_bool *is_null; /* Pointer to null indicators */
+ char *buffer; /* buffer to get/put data */
+ enum enum_field_types buffer_type; /* buffer type */
+ unsigned long buffer_length; /* buffer length, must be set for str/binary */
+
+ /* Following are for internal use. Set by mysql_bind_param */
+ unsigned char *inter_buffer; /* for the current data position */
+ unsigned long offset; /* offset position for char/binary fetch */
+ unsigned long internal_length; /* Used if length is 0 */
+ unsigned int param_number; /* For null count and error messages */
+ my_bool long_data_used; /* If used with mysql_send_long_data */
+ my_bool binary_data; /* data buffer is binary */
+ my_bool null_field; /* NULL data cache flag */
+ my_bool internal_is_null; /* Used if is_null is 0 */
+ void (*store_param_func)(NET *net, struct st_mysql_bind *param);
+ void (*fetch_result)(struct st_mysql_bind *, unsigned char **row);
+} MYSQL_BIND;
+
+
+/* statement handler */
+typedef struct st_mysql_stmt
+{
+ MEM_ROOT mem_root; /* root allocations */
+ LIST list; /* list to keep track of all stmts */
+ MYSQL *mysql; /* connection handle */
+ MYSQL_BIND *params; /* input parameters */
+ MYSQL_BIND *bind; /* output parameters */
+ MYSQL_FIELD *fields; /* result set metadata */
+ MYSQL_RES *result; /* cached result set */
+ /* copy of mysql->affected_rows after statement execution */
+ my_ulonglong affected_rows;
+ /*
+ mysql_stmt_fetch() calls this function to fetch one row (it's different
+ for buffered, unbuffered and cursor fetch).
+ */
+ int (*read_row_func)(struct st_mysql_stmt *stmt,
+ unsigned char **row);
+ unsigned long stmt_id; /* Id for prepared statement */
+ unsigned int last_errno; /* error code */
+ unsigned int param_count; /* inpute parameters count */
+ unsigned int field_count; /* number of columns in result set */
+ enum enum_mysql_stmt_state state; /* statement state */
+ char last_error[MYSQL_ERRMSG_SIZE]; /* error message */
+ char sqlstate[SQLSTATE_LENGTH+1];
+ /* Types of input parameters should be sent to server */
+ my_bool send_types_to_server;
+ my_bool bind_param_done; /* input buffers were supplied */
+ my_bool bind_result_done; /* output buffers were supplied */
+ /* mysql_stmt_close() had to cancel this result */
+ my_bool unbuffered_fetch_cancelled;
+} MYSQL_STMT;
+
+
+typedef struct st_mysql_methods
+{
+ my_bool (*read_query_result)(MYSQL *mysql);
+ my_bool (*advanced_command)(MYSQL *mysql,
+ enum enum_server_command command,
+ const char *header,
+ unsigned long header_length,
+ const char *arg,
+ unsigned long arg_length,
+ my_bool skip_check);
+ MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
+ unsigned int fields);
+ MYSQL_RES * (*use_result)(MYSQL *mysql);
+ void (*fetch_lengths)(unsigned long *to,
+ MYSQL_ROW column, unsigned int field_count);
+#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
+ MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
+ my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
+ int (*stmt_execute)(MYSQL_STMT *stmt);
+ MYSQL_DATA *(*read_binary_rows)(MYSQL_STMT *stmt);
+ int (*unbuffered_fetch)(MYSQL *mysql, char **row);
+ void (*free_embedded_thd)(MYSQL *mysql);
+ const char *(*read_statistics)(MYSQL *mysql);
+ int (*next_result)(MYSQL *mysql);
+ int (*read_change_user_result)(MYSQL *mysql, char *buff, const char *passwd);
+#endif
+} MYSQL_METHODS;
+
+#ifdef HAVE_DEPRECATED_411_API
+/* Deprecated calls (since MySQL 4.1.2) */
+
+/* Use mysql_stmt_init + mysql_stmt_prepare instead */
+MYSQL_STMT * STDCALL mysql_prepare(MYSQL * mysql, const char *query,
+ unsigned long length);
+#define mysql_execute mysql_stmt_execute
+#define mysql_fetch mysql_stmt_fetch
+#define mysql_fetch_column mysql_stmt_fetch_column
+#define mysql_bind_param mysql_stmt_bind_param
+#define mysql_bind_result mysql_stmt_bind_result
+#define mysql_param_count mysql_stmt_param_count
+#define mysql_param_result mysql_stmt_param_metadata
+#define mysql_get_metadata mysql_stmt_result_metadata
+#define mysql_send_long_data mysql_stmt_send_long_data
+
+#endif /* HAVE_DEPRECATED_411_API */
+
+MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql);
+int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,
+ unsigned long length);
+int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
+ unsigned int column,
+ unsigned long offset);
+int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
+unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt);
+my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
+my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
+my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
+my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt);
+my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt);
+my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt,
+ unsigned int param_number,
+ const char *data,
+ unsigned long length);
+MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt);
+MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt);
+unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt);
+const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt);
+const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt);
+MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt,
+ MYSQL_ROW_OFFSET offset);
+MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt);
+void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset);
+my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt);
+my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
+
+my_bool STDCALL mysql_commit(MYSQL * mysql);
+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);
+void STDCALL mysql_close(MYSQL *sock);
+
+
+/* status return codes */
+#define MYSQL_NO_DATA 100
+
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
#ifdef USE_OLD_FUNCTIONS
@@ -423,12 +671,10 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
They are not for general usage
*/
-int simple_command(MYSQL *mysql,enum enum_server_command command,
- const char *arg, unsigned long length, my_bool skipp_check);
+#define simple_command(mysql, command, arg, length, skip_check) \
+ (*(mysql)->methods->advanced_command)(mysql, command, \
+ NullS, 0, arg, length, skip_check)
unsigned long net_safe_read(MYSQL* mysql);
-int mysql_once_init(void);
-
-extern my_bool server_inited;
#ifdef __NETWARE__
#pragma pack(pop) /* restore alignment */
diff --git a/include/mysql_com.h b/include/mysql_com.h
index e183a0ed423..d4c1ac5440a 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -25,24 +25,41 @@
#define HOSTNAME_LENGTH 60
#define USERNAME_LENGTH 16
#define SERVER_VERSION_LENGTH 60
+#define SQLSTATE_LENGTH 5
#define LOCAL_HOST "localhost"
#define LOCAL_HOST_NAMEDPIPE "."
+
#if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
#define MYSQL_NAMEDPIPE "MySQL"
#define MYSQL_SERVICENAME "MySQL"
#endif /* __WIN__ */
-enum enum_server_command {
+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_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_BINLOG_DUMP,
- COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
- COM_END /* Must be last! */
+ COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
+ COM_PREPARE, COM_EXECUTE, COM_LONG_DATA, COM_CLOSE_STMT,
+ COM_RESET_STMT, COM_SET_OPTION,
+ COM_END /* Must be last */
};
+
+/*
+ Length of random string sent by server on handshake; this is also length of
+ obfuscated password, recieved from client
+*/
+#define SCRAMBLE_LENGTH 20
+#define SCRAMBLE_LENGTH_323 8
+/* length of password stored in the db: new passwords are preceeded with '*' */
+#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
+#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
+
+
#define NOT_NULL_FLAG 1 /* Field can't be NULL */
#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
@@ -50,7 +67,8 @@ enum enum_server_command {
#define BLOB_FLAG 16 /* Field is a blob */
#define UNSIGNED_FLAG 32 /* Field is unsigned */
#define ZEROFILL_FLAG 64 /* Field is zerofill */
-#define BINARY_FLAG 128
+#define BINARY_FLAG 128 /* Field is binary */
+
/* The following are only sent to new clients */
#define ENUM_FLAG 256 /* field is an enum */
#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
@@ -91,15 +109,25 @@ enum enum_server_command {
#define CLIENT_ODBC 64 /* Odbc client */
#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
+#define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */
#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_SSL 2048 /* Switch to SSL after handshake */
+#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
#define CLIENT_TRANSACTIONS 8192 /* 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 CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */
+#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
+#define CLIENT_MULTI_STATEMENTS 65536 /* Enable/disable multi-stmt support */
+#define CLIENT_MULTI_RESULTS 131072 /* Enable/disable multi-results */
+#define CLIENT_REMEMBER_OPTIONS ((ulong) (1L << 31))
+
+#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
+#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
+#define SERVER_STATUS_MORE_RESULTS 4 /* More results on server */
+#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
+#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
+#define SERVER_QUERY_NO_INDEX_USED 32
+
+#define MYSQL_ERRMSG_SIZE 512
#define NET_READ_TIMEOUT 30 /* Timeout on read */
#define NET_WRITE_TIMEOUT 60 /* Timeout on write */
#define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
@@ -111,16 +139,15 @@ typedef struct st_vio Vio;
#define MAX_BLOB_WIDTH 8192 /* Default width for blob */
typedef struct st_net {
+#if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
Vio* vio;
unsigned char *buff,*buff_end,*write_pos,*read_pos;
my_socket fd; /* For Perl DBI/dbd */
unsigned long max_packet,max_packet_size;
- unsigned int last_errno,pkt_nr,compress_pkt_nr;
+ unsigned int pkt_nr,compress_pkt_nr;
unsigned int write_timeout, read_timeout, retry_count;
int fcntl;
- char last_error[MYSQL_ERRMSG_SIZE];
- unsigned char error;
- my_bool return_errno,compress;
+ my_bool compress;
/*
The following variable is set if we are doing several queries in one
command ( as in LOAD TABLE ... FROM MASTER ),
@@ -131,32 +158,87 @@ typedef struct st_net {
unsigned char reading_or_writing;
char save_char;
my_bool no_send_ok;
+ /*
+ Pointer to query object in query cache, do not equal NULL (0) for
+ queries in cache that have not stored its results yet
+ */
+#endif
+ char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1];
+ unsigned int last_errno;
+ unsigned char error;
gptr query_cache_query;
+ my_bool report_error; /* We should report error (we have unreported error) */
+ my_bool return_errno;
} NET;
#define packet_error (~(unsigned long) 0)
-enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
- FIELD_TYPE_SHORT, FIELD_TYPE_LONG,
- FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE,
- FIELD_TYPE_NULL, FIELD_TYPE_TIMESTAMP,
- FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
- FIELD_TYPE_DATE, FIELD_TYPE_TIME,
- FIELD_TYPE_DATETIME, FIELD_TYPE_YEAR,
- FIELD_TYPE_NEWDATE,
- FIELD_TYPE_ENUM=247,
- FIELD_TYPE_SET=248,
- FIELD_TYPE_TINY_BLOB=249,
- FIELD_TYPE_MEDIUM_BLOB=250,
- FIELD_TYPE_LONG_BLOB=251,
- FIELD_TYPE_BLOB=252,
- FIELD_TYPE_VAR_STRING=253,
- FIELD_TYPE_STRING=254,
- FIELD_TYPE_GEOMETRY=255
+enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
+ MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
+ MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
+ MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
+ MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
+ MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
+ MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
+ MYSQL_TYPE_NEWDATE,
+ MYSQL_TYPE_ENUM=247,
+ MYSQL_TYPE_SET=248,
+ MYSQL_TYPE_TINY_BLOB=249,
+ MYSQL_TYPE_MEDIUM_BLOB=250,
+ MYSQL_TYPE_LONG_BLOB=251,
+ MYSQL_TYPE_BLOB=252,
+ MYSQL_TYPE_VAR_STRING=253,
+ MYSQL_TYPE_STRING=254,
+ MYSQL_TYPE_GEOMETRY=255
+
};
-#define FIELD_TYPE_CHAR FIELD_TYPE_TINY /* For compability */
-#define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM /* For compability */
+/* For backward compatibility */
+#define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
+#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
+#define FIELD_TYPE_TINY MYSQL_TYPE_TINY
+#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
+#define FIELD_TYPE_LONG MYSQL_TYPE_LONG
+#define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT
+#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
+#define FIELD_TYPE_NULL MYSQL_TYPE_NULL
+#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
+#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
+#define FIELD_TYPE_INT24 MYSQL_TYPE_INT24
+#define FIELD_TYPE_DATE MYSQL_TYPE_DATE
+#define FIELD_TYPE_TIME MYSQL_TYPE_TIME
+#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
+#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
+#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
+#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
+#define FIELD_TYPE_SET MYSQL_TYPE_SET
+#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
+#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
+#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
+#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
+#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
+#define FIELD_TYPE_STRING MYSQL_TYPE_STRING
+#define FIELD_TYPE_CHAR MYSQL_TYPE_TINY
+#define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM
+#define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY
+
+#if TO_BE_INCLUDED_LATER
+/* For bind applications, to indicate unsigned buffers */
+#define MYSQL_TYPE_UTINY -10
+#define MYSQL_TYPE_USHORT -9
+#define MYSQL_TYPE_ULONG -8
+#define MYSQL_TYPE_UFLOAT -7
+#define MYSQL_TYPE_UDOUBLE -6
+#define MYSQL_TYPE_ULONGLONG -5
+#define MYSQL_TYPE_UINT24 -4
+#endif
+
+/* options for mysql_set_option */
+enum enum_mysql_set_option
+{
+ MYSQL_OPTION_MULTI_STATEMENTS_ON,
+ MYSQL_OPTION_MULTI_STATEMENTS_OFF
+};
#define net_new_transaction(net) ((net)->pkt_nr=0)
@@ -164,18 +246,29 @@ enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
extern "C" {
#endif
-int my_net_init(NET *net, Vio* vio);
+my_bool my_net_init(NET *net, Vio* vio);
void my_net_local_init(NET *net);
void net_end(NET *net);
void net_clear(NET *net);
-int net_flush(NET *net);
-int my_net_write(NET *net,const char *packet,unsigned long len);
-int net_write_command(NET *net,unsigned char command,const char *packet,
- unsigned long len);
+my_bool net_realloc(NET *net, unsigned long length);
+
+#ifndef EMBEDDED_LIBRARY /* To be removed by HF */
+my_bool net_flush(NET *net);
+#else
+#define net_flush(A)
+#endif
+
+my_bool my_net_write(NET *net,const char *packet,unsigned long len);
+my_bool net_write_command(NET *net,unsigned char command,
+ const char *header, unsigned long head_len,
+ const char *packet, unsigned long len);
int net_real_write(NET *net,const char *packet,unsigned long len);
unsigned long my_net_read(NET *net);
-/* The following function is not meant for normal usage */
+/*
+ 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);
@@ -191,7 +284,7 @@ struct rand_struct {
/* The following is for user defined functions */
-enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT};
+enum Item_result {STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT};
typedef struct st_udf_args
{
@@ -226,18 +319,35 @@ extern "C" {
extern unsigned long max_allowed_packet;
extern unsigned long net_buffer_length;
-void randominit(struct rand_struct *,unsigned long seed1,
- unsigned long seed2);
+/*
+ These functions are used for authentication by client and server and
+ implemented in sql/password.c
+*/
+
+void randominit(struct rand_struct *, unsigned long seed1,
+ unsigned long seed2);
double my_rnd(struct rand_struct *);
-void make_scrambled_password(char *to,const char *password);
-void get_salt_from_password(unsigned long *res,const char *password);
-void make_password_from_salt(char *to, unsigned long *hash_res);
-char *scramble(char *to,const char *message,const char *password,
- my_bool old_ver);
-my_bool check_scramble(const char *, const char *message,
- unsigned long *salt,my_bool old_ver);
+void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
+
+void hash_password(unsigned long *to, const char *password, unsigned int password_len);
+void make_scrambled_password_323(char *to, const char *password);
+void scramble_323(char *to, const char *message, const char *password);
+my_bool check_scramble_323(const char *, const char *message,
+ unsigned long *salt);
+void get_salt_from_password_323(unsigned long *res, const char *password);
+void make_password_from_salt_323(char *to, const unsigned long *salt);
+
+void make_scrambled_password(char *to, const char *password);
+void scramble(char *to, const char *message, const char *password);
+my_bool check_scramble(const char *reply, const char *message,
+ const unsigned char *hash_stage2);
+void get_salt_from_password(unsigned char *res, const char *password);
+void make_password_from_salt(char *to, const unsigned char *hash_stage2);
+
+/* end of password.c */
+
char *get_tty_password(char *opt_message);
-void hash_password(unsigned long *result, const char *password);
+const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
/* Some other useful functions */
@@ -247,10 +357,18 @@ int load_defaults(const char *conf_file, const char **groups,
my_bool my_thread_init(void);
void my_thread_end(void);
+#ifdef _global_h
+ulong STDCALL net_field_length(uchar **packet);
+my_ulonglong net_field_length_ll(uchar **packet);
+char *net_store_length(char *pkg, ulonglong length);
+#endif
+
#ifdef __cplusplus
}
#endif
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
+#define MYSQL_STMT_HEADER 4
+#define MYSQL_LONG_DATA_HEADER 6
#endif
diff --git a/include/mysql_embed.h b/include/mysql_embed.h
index bc75c3fbcb8..7a169d4133e 100644
--- a/include/mysql_embed.h
+++ b/include/mysql_embed.h
@@ -19,12 +19,13 @@
#ifdef EMBEDDED_LIBRARY
/* Things we don't need in the embedded version of MySQL */
+/* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */
#undef HAVE_PSTACK /* No stacktrace */
#undef HAVE_DLOPEN /* No udf functions */
#undef HAVE_OPENSSL
-#undef HAVE_VIO
#undef HAVE_ISAM
+#undef HAVE_SMEM /* No shared memory */
#define DONT_USE_RAID
diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in
index 41d4ce081fb..095531d527d 100644
--- a/include/mysql_version.h.in
+++ b/include/mysql_version.h.in
@@ -22,8 +22,5 @@
#define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@"
/* mysqld compile time options */
-#ifndef MYSQL_CHARSET
-#define MYSQL_CHARSET "@default_charset@"
-#endif /* MYSQL_CHARSET */
#endif /* _CUSTOMCONFIG_ */
#endif /* _mysql_version_h */
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index acc9b5961c6..77164e637cb 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -109,7 +109,7 @@
#define ER_CANT_REMOVE_ALL_FIELDS 1090
#define ER_CANT_DROP_FIELD_OR_KEY 1091
#define ER_INSERT_INFO 1092
-#define ER_INSERT_TABLE_USED 1093
+#define ER_UPDATE_TABLE_USED 1093
#define ER_NO_SUCH_THREAD 1094
#define ER_KILL_DENIED_ERROR 1095
#define ER_NO_TABLES_USED 1096
@@ -230,7 +230,7 @@
#define ER_NO_PERMISSION_TO_CREATE_USER 1211
#define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212
#define ER_LOCK_DEADLOCK 1213
-#define ER_TABLE_CANT_HANDLE_FULLTEXT 1214
+#define ER_TABLE_CANT_HANDLE_FT 1214
#define ER_CANNOT_ADD_FOREIGN 1215
#define ER_NO_REFERENCED_ROW 1216
#define ER_ROW_IS_REFERENCED 1217
@@ -253,6 +253,60 @@
#define ER_CANT_USE_OPTION_HERE 1234
#define ER_NOT_SUPPORTED_YET 1235
#define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
-#define ER_SLAVE_IGNORED_TABLE 1237 /* only the slave SQL thread can be sent this */
+#define ER_SLAVE_IGNORED_TABLE 1237
#define ER_INCORRECT_GLOBAL_LOCAL_VAR 1238
-#define ER_ERROR_MESSAGES 239
+#define ER_WRONG_FK_DEF 1239
+#define ER_KEY_REF_DO_NOT_MATCH_TABLE_REF 1240
+#define ER_OPERAND_COLUMNS 1241
+#define ER_SUBQUERY_NO_1_ROW 1242
+#define ER_UNKNOWN_STMT_HANDLER 1243
+#define ER_CORRUPT_HELP_DB 1244
+#define ER_CYCLIC_REFERENCE 1245
+#define ER_AUTO_CONVERT 1246
+#define ER_ILLEGAL_REFERENCE 1247
+#define ER_DERIVED_MUST_HAVE_ALIAS 1248
+#define ER_SELECT_REDUCED 1249
+#define ER_TABLENAME_NOT_ALLOWED_HERE 1250
+#define ER_NOT_SUPPORTED_AUTH_MODE 1251
+#define ER_SPATIAL_CANT_HAVE_NULL 1252
+#define ER_COLLATION_CHARSET_MISMATCH 1253
+#define ER_SLAVE_WAS_RUNNING 1254
+#define ER_SLAVE_WAS_NOT_RUNNING 1255
+#define ER_TOO_BIG_FOR_UNCOMPRESS 1256
+#define ER_ZLIB_Z_MEM_ERROR 1257
+#define ER_ZLIB_Z_BUF_ERROR 1258
+#define ER_ZLIB_Z_DATA_ERROR 1259
+#define ER_CUT_VALUE_GROUP_CONCAT 1260
+#define ER_WARN_TOO_FEW_RECORDS 1261
+#define ER_WARN_TOO_MANY_RECORDS 1262
+#define ER_WARN_NULL_TO_NOTNULL 1263
+#define ER_WARN_DATA_OUT_OF_RANGE 1264
+#define ER_WARN_DATA_TRUNCATED 1265
+#define ER_WARN_USING_OTHER_HANDLER 1266
+#define ER_CANT_AGGREGATE_2COLLATIONS 1267
+#define ER_DROP_USER 1268
+#define ER_REVOKE_GRANTS 1269
+#define ER_CANT_AGGREGATE_3COLLATIONS 1270
+#define ER_CANT_AGGREGATE_NCOLLATIONS 1271
+#define ER_VARIABLE_IS_NOT_STRUCT 1272
+#define ER_UNKNOWN_COLLATION 1273
+#define ER_SLAVE_IGNORED_SSL_PARAMS 1274
+#define ER_SERVER_IS_IN_SECURE_AUTH_MODE 1275
+#define ER_WARN_FIELD_RESOLVED 1276
+#define ER_BAD_SLAVE_UNTIL_COND 1277
+#define ER_MISSING_SKIP_SLAVE 1278
+#define ER_UNTIL_COND_IGNORED 1279
+#define ER_WRONG_NAME_FOR_INDEX 1280
+#define ER_WRONG_NAME_FOR_CATALOG 1281
+#define ER_WARN_QC_RESIZE 1282
+#define ER_BAD_FT_COLUMN 1283
+#define ER_UNKNOWN_KEY_CACHE 1284
+#define ER_WARN_HOSTNAME_WONT_WORK 1285
+#define ER_UNKNOWN_STORAGE_ENGINE 1286
+#define ER_WARN_DEPRECATED_SYNTAX 1287
+#define ER_NON_UPDATABLE_TABLE 1288
+#define ER_FEATURE_DISABLED 1289
+#define ER_OPTION_PREVENTS_STATEMENT 1290
+#define ER_DUPLICATED_VALUE_IN_TYPE 1291
+#define ER_TRUNCATED_WRONG_VALUE 1292
+#define ER_ERROR_MESSAGES 293
diff --git a/include/mysys_err.h b/include/mysys_err.h
index 0ee89e91ee4..230be5f4720 100644
--- a/include/mysys_err.h
+++ b/include/mysys_err.h
@@ -68,6 +68,7 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */
#define EXIT_UNKNOWN_SUFFIX 9
#define EXIT_NO_PTR_TO_VARIABLE 10
#define EXIT_CANNOT_CONNECT_TO_SERVICE 11
+#define EXIT_OPTION_DISABLED 12
#ifdef __cplusplus
diff --git a/include/sql_common.h b/include/sql_common.h
new file mode 100644
index 00000000000..3f50008a922
--- /dev/null
+++ b/include/sql_common.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ 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; either version 2 of the License, or
+ (at your option) any later version.
+
+ 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 */
+
+
+extern const char *unknown_sqlstate;
+extern const char *not_error_sqlstate;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+MYSQL_FIELD *unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
+ my_bool default_value, uint server_capabilities);
+void free_rows(MYSQL_DATA *cur);
+void flush_use_result(MYSQL *mysql);
+my_bool mysql_autenticate(MYSQL *mysql, const char *passwd);
+void free_old_query(MYSQL *mysql);
+void end_server(MYSQL *mysql);
+my_bool mysql_reconnect(MYSQL *mysql);
+void mysql_read_default_options(struct st_mysql_options *options,
+ const char *filename,const char *group);
+my_bool
+cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
+ const char *header, ulong header_length,
+ const char *arg, ulong arg_length, my_bool skip_check);
+
+void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
+ const char *sqlstate);
+void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
+#ifdef __cplusplus
+}
+#endif
+
+#define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41)
+
diff --git a/include/sql_state.h b/include/sql_state.h
new file mode 100644
index 00000000000..5c4b1c50745
--- /dev/null
+++ b/include/sql_state.h
@@ -0,0 +1,164 @@
+/* Copyright (C) 2000-2003 MySQL AB
+
+ 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; either version 2 of the License, or
+ (at your option) any later version.
+
+ 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 */
+
+/*
+ This file includes a mapping from mysql_errno.h to sql_state (as used by
+ MyODBC) and jdbc_state.
+ It's suitable to include into a C struct for further processing
+
+ The first column is the mysqld server error (declared in mysqld_error.h),
+ the second column is the ODBC state (which the 4.1 server sends out by
+ default) and the last is the state used by the JDBC driver.
+ If the last column is "" then it means that the JDBC driver is using the
+ ODBC state
+
+ The errors in this file is sorted in the same order as in mysqld_error.h
+ to allow on to do binary searches for the sqlstate.
+*/
+
+ER_DUP_KEY, "23000", "",
+ER_OUTOFMEMORY, "HY001", "S1001",
+ER_OUT_OF_SORTMEMORY, "HY001", "S1001",
+ER_CON_COUNT_ERROR, "08004", "",
+ER_BAD_HOST_ERROR, "08S01", "",
+ER_HANDSHAKE_ERROR, "08S01", "",
+ER_DBACCESS_DENIED_ERROR, "42000", "",
+ER_ACCESS_DENIED_ERROR, "28000", "",
+ER_NO_DB_ERROR, "3D000", "",
+ER_UNKNOWN_COM_ERROR, "08S01", "",
+ER_BAD_NULL_ERROR, "23000", "",
+ER_BAD_DB_ERROR, "42000", "",
+ER_TABLE_EXISTS_ERROR, "42S01", "",
+ER_BAD_TABLE_ERROR, "42S02", "",
+ER_NON_UNIQ_ERROR, "23000", "",
+ER_SERVER_SHUTDOWN, "08S01", "",
+ER_BAD_FIELD_ERROR, "42S22", "S0022",
+ER_WRONG_FIELD_WITH_GROUP, "42000", "S1009",
+ER_WRONG_GROUP_FIELD, "42000", "S1009",
+ER_WRONG_SUM_SELECT, "42000", "S1009",
+ER_WRONG_VALUE_COUNT, "21S01", "",
+ER_TOO_LONG_IDENT, "42000", "S1009",
+ER_DUP_FIELDNAME, "42S21", "S1009",
+ER_DUP_KEYNAME, "42000", "S1009",
+ER_DUP_ENTRY, "23000", "S1009",
+ER_WRONG_FIELD_SPEC, "42000", "S1009",
+ER_PARSE_ERROR, "42000", "",
+ER_EMPTY_QUERY, "42000" , "",
+ER_NONUNIQ_TABLE, "42000", "S1009",
+ER_INVALID_DEFAULT, "42000", "S1009",
+ER_MULTIPLE_PRI_KEY, "42000", "S1009",
+ER_TOO_MANY_KEYS, "42000", "S1009",
+ER_TOO_MANY_KEY_PARTS, "42000", "S1009",
+ER_TOO_LONG_KEY, "42000", "S1009",
+ER_KEY_COLUMN_DOES_NOT_EXITS, "42000", "S1009",
+ER_BLOB_USED_AS_KEY, "42000", "S1009",
+ER_TOO_BIG_FIELDLENGTH, "42000", "S1009",
+ER_WRONG_AUTO_KEY, "42000", "S1009",
+ER_FORCING_CLOSE, "08S01", "",
+ER_IPSOCK_ERROR, "08S01", "",
+ER_NO_SUCH_INDEX, "42S12", "S1009",
+ER_WRONG_FIELD_TERMINATORS, "42000", "S1009",
+ER_BLOBS_AND_NO_TERMINATED, "42000", "S1009",
+ER_CANT_REMOVE_ALL_FIELDS, "42000", "",
+ER_CANT_DROP_FIELD_OR_KEY, "42000", "",
+ER_BLOB_CANT_HAVE_DEFAULT, "42000", "",
+ER_WRONG_DB_NAME, "42000", "",
+ER_WRONG_TABLE_NAME, "42000", "",
+ER_TOO_BIG_SELECT, "42000", "",
+ER_UNKNOWN_PROCEDURE, "42000", "",
+ER_WRONG_PARAMCOUNT_TO_PROCEDURE, "42000", "",
+ER_UNKNOWN_TABLE, "42S02", "",
+ER_FIELD_SPECIFIED_TWICE, "42000", "",
+ER_UNSUPPORTED_EXTENSION, "42000", "",
+ER_TABLE_MUST_HAVE_COLUMNS, "42000", "",
+ER_UNKNOWN_CHARACTER_SET, "42000", "",
+ER_TOO_BIG_ROWSIZE, "42000", "",
+ER_WRONG_OUTER_JOIN, "42000", "",
+ER_NULL_COLUMN_IN_INDEX, "42000", "",
+ER_PASSWORD_ANONYMOUS_USER, "42000", "",
+ER_PASSWORD_NOT_ALLOWED, "42000", "",
+ER_PASSWORD_NO_MATCH, "42000", "",
+ER_WRONG_VALUE_COUNT_ON_ROW, "21S01", "",
+ER_INVALID_USE_OF_NULL, "42000", "",
+ER_REGEXP_ERROR, "42000", "",
+ER_MIX_OF_GROUP_FUNC_AND_FIELDS,"42000", "",
+ER_NONEXISTING_GRANT, "42000", "",
+ER_TABLEACCESS_DENIED_ERROR, "42000", "",
+ER_COLUMNACCESS_DENIED_ERROR, "42000", "",
+ER_ILLEGAL_GRANT_FOR_TABLE, "42000", "",
+ER_GRANT_WRONG_HOST_OR_USER, "42000", "",
+ER_NO_SUCH_TABLE, "42S02", "",
+ER_NONEXISTING_TABLE_GRANT, "42000", "",
+ER_NOT_ALLOWED_COMMAND, "42000", "",
+ER_SYNTAX_ERROR, "42000", "",
+ER_ABORTING_CONNECTION, "08S01", "",
+ER_NET_PACKET_TOO_LARGE, "08S01", "",
+ER_NET_READ_ERROR_FROM_PIPE, "08S01", "",
+ER_NET_FCNTL_ERROR, "08S01", "",
+ER_NET_PACKETS_OUT_OF_ORDER, "08S01", "",
+ER_NET_UNCOMPRESS_ERROR, "08S01", "",
+ER_NET_READ_ERROR, "08S01", "",
+ER_NET_READ_INTERRUPTED, "08S01", "",
+ER_NET_ERROR_ON_WRITE, "08S01", "",
+ER_NET_WRITE_INTERRUPTED, "08S01", "",
+ER_TOO_LONG_STRING, "42000", "",
+ER_TABLE_CANT_HANDLE_BLOB, "42000", "",
+ER_TABLE_CANT_HANDLE_AUTO_INCREMENT, "42000", "",
+ER_WRONG_COLUMN_NAME, "42000", "",
+ER_WRONG_KEY_COLUMN, "42000", "",
+ER_DUP_UNIQUE, "23000", "",
+ER_BLOB_KEY_WITHOUT_LENGTH, "42000", "",
+ER_PRIMARY_CANT_HAVE_NULL, "42000", "",
+ER_TOO_MANY_ROWS, "42000", "",
+ER_REQUIRES_PRIMARY_KEY, "42000", "",
+ER_CHECK_NO_SUCH_TABLE, "42000", "",
+ER_CHECK_NOT_IMPLEMENTED, "42000", "",
+ER_CANT_DO_THIS_DURING_AN_TRANSACTION, "25000", "",
+ER_NEW_ABORTING_CONNECTION, "08S01", "",
+ER_MASTER_NET_READ, "08S01", "",
+ER_MASTER_NET_WRITE, "08S01", "",
+ER_TOO_MANY_USER_CONNECTIONS, "42000", "",
+ER_READ_ONLY_TRANSACTION, "25000", "",
+ER_NO_PERMISSION_TO_CREATE_USER,"42000", "",
+ER_LOCK_DEADLOCK, "40001", "",
+ER_NO_REFERENCED_ROW, "23000", "",
+ER_ROW_IS_REFERENCED, "23000", "",
+ER_CONNECT_TO_MASTER, "08S01", "",
+ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT,"21000", "",
+ER_USER_LIMIT_REACHED, "42000", "",
+ER_NO_DEFAULT, "42000", "",
+ER_WRONG_VALUE_FOR_VAR, "42000", "",
+ER_WRONG_TYPE_FOR_VAR, "42000", "",
+ER_CANT_USE_OPTION_HERE, "42000", "",
+ER_NOT_SUPPORTED_YET, "42000", "",
+ER_WRONG_FK_DEF, "42000", "",
+ER_OPERAND_COLUMNS, "21000", "",
+ER_SUBQUERY_NO_1_ROW, "21000", "",
+ER_ILLEGAL_REFERENCE, "42S22", "",
+ER_DERIVED_MUST_HAVE_ALIAS, "42000", "",
+ER_SELECT_REDUCED, "01000", "",
+ER_TABLENAME_NOT_ALLOWED_HERE, "42000", "",
+ER_NOT_SUPPORTED_AUTH_MODE, "08004", "",
+ER_SPATIAL_CANT_HAVE_NULL, "42000", "",
+ER_COLLATION_CHARSET_MISMATCH, "42000", "",
+ER_WARN_TOO_FEW_RECORDS, "01000", "",
+ER_WARN_TOO_MANY_RECORDS, "01000", "",
+ER_WARN_NULL_TO_NOTNULL, "01000", "",
+ER_WARN_DATA_OUT_OF_RANGE, "01000", "",
+ER_WARN_DATA_TRUNCATED, "01000", "",
+ER_WRONG_NAME_FOR_INDEX, "42000", "",
+ER_WRONG_NAME_FOR_CATALOG, "42000", "",
+ER_UNKNOWN_STORAGE_ENGINE, "42000", "",
diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h
index 397d8baa9d6..dc3b0922327 100644
--- a/include/sslopt-longopts.h
+++ b/include/sslopt-longopts.h
@@ -17,24 +17,24 @@
#ifdef HAVE_OPENSSL
{"ssl", OPT_SSL_SSL,
- "Enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl",
+ "Enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl.",
(gptr*) &opt_use_ssl, (gptr*) &opt_use_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0},
- {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl)",
+ {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl).",
(gptr*) &opt_ssl_key, (gptr*) &opt_ssl_key, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
- {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format (implies --ssl)",
+ {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format (implies --ssl).",
(gptr*) &opt_ssl_cert, (gptr*) &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"ssl-ca", OPT_SSL_CA,
- "CA file in PEM format (check OpenSSL docs, implies --ssl)",
+ "CA file in PEM format (check OpenSSL docs, implies --ssl).",
(gptr*) &opt_ssl_ca, (gptr*) &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"ssl-capath", OPT_SSL_CAPATH,
- "CA directory (check OpenSSL docs, implies --ssl)",
+ "CA directory (check OpenSSL docs, implies --ssl).",
(gptr*) &opt_ssl_capath, (gptr*) &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
- {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use (implies --ssl)",
+ {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use (implies --ssl).",
(gptr*) &opt_ssl_cipher, (gptr*) &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
diff --git a/include/thr_lock.h b/include/thr_lock.h
index f1bda0ce6b4..947b17bf2b6 100644
--- a/include/thr_lock.h
+++ b/include/thr_lock.h
@@ -74,6 +74,7 @@ typedef struct st_thr_lock_data {
enum thr_lock_type type;
ulong thread_id;
void *status_param; /* Param to status functions */
+ void *debug_print_param;
} THR_LOCK_DATA;
struct st_lock_list {
@@ -97,6 +98,9 @@ typedef struct st_thr_lock {
} THR_LOCK;
+extern LIST *thr_lock_thread_list;
+extern pthread_mutex_t THR_LOCK_lock;
+
my_bool init_thr_lock(void); /* Must be called once/thread */
void thr_lock_init(THR_LOCK *lock);
void thr_lock_delete(THR_LOCK *lock);
diff --git a/include/typelib.h b/include/typelib.h
new file mode 100644
index 00000000000..1b049d19a11
--- /dev/null
+++ b/include/typelib.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000 MySQL AB
+
+ 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; either version 2 of the License, or
+ (at your option) any later version.
+
+ 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 */
+
+
+#ifndef _typelib_h
+#define _typelib_h
+
+typedef struct st_typelib { /* Different types saved here */
+ unsigned int count; /* How many types */
+ const char *name; /* Name of typelib */
+ const char **type_names;
+} TYPELIB;
+
+extern int find_type(char *x,TYPELIB *typelib,unsigned int full_name);
+extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
+extern const char *get_type(TYPELIB *typelib,unsigned int nr);
+
+extern TYPELIB sql_protocol_typelib;
+
+#endif /* _typelib_h */
diff --git a/include/violite.h b/include/violite.h
index 18f862d4b77..e8f30288d34 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -31,17 +31,28 @@
extern "C" {
#endif /* __cplusplus */
-enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
- VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
-
-#ifndef __WIN__
-#define HANDLE void *
-#endif
+enum enum_vio_type
+{
+ VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE,
+ VIO_TYPE_SSL, VIO_TYPE_SHARED_MEMORY
+};
Vio* vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost);
#ifdef __WIN__
Vio* vio_new_win32pipe(HANDLE hPipe);
-#endif
+Vio* vio_new_win32shared_memory(NET *net,HANDLE handle_file_map,
+ HANDLE handle_map,
+ HANDLE event_server_wrote,
+ HANDLE event_server_read,
+ HANDLE event_client_wrote,
+ HANDLE event_client_read);
+int vio_read_pipe(Vio *vio, gptr buf, int size);
+int vio_write_pipe(Vio *vio, const gptr buf, int size);
+int vio_close_pipe(Vio * vio);
+#else
+#define HANDLE void *
+#endif /* __WIN__ */
+
void vio_delete(Vio* vio);
int vio_close(Vio* vio);
@@ -67,15 +78,15 @@ const char* vio_description(Vio *vio);
/* Return the type of the connection */
enum enum_vio_type vio_type(Vio* vio);
/* Return last error number */
-int vio_errno(Vio*vio);
+int vio_errno(Vio*vio);
/* Get socket number */
my_socket vio_fd(Vio*vio);
/* Remote peer's address and name in text form */
-my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port);
+my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port);
/* Remotes in_addr */
-void vio_in_addr(Vio *vio, struct in_addr *in);
-my_bool vio_poll_read(Vio *vio,uint timeout);
-void vio_timeout(Vio *vio,uint timeout);
+void vio_in_addr(Vio *vio, struct in_addr *in);
+my_bool vio_poll_read(Vio *vio,uint timeout);
+void vio_timeout(Vio *vio,uint timeout);
#ifdef HAVE_OPENSSL
#define HEADER_DES_LOCL_H dummy_something
@@ -109,6 +120,12 @@ struct st_VioSSLAcceptorFd
const char *ca_file,const char *ca_path,
const char *cipher);
Vio *new_VioSSL(struct st_VioSSLAcceptorFd *fd, Vio *sd, int state);
+#endif /* HAVE_OPENSSL */
+
+#ifdef HAVE_SMEM
+int vio_read_shared_memory(Vio *vio, gptr buf, int size);
+int vio_write_shared_memory(Vio *vio, const gptr buf, int size);
+int vio_close_shared_memory(Vio * vio);
#endif
#ifdef __cplusplus
@@ -142,7 +159,8 @@ enum SSL_type
SSL_TYPE_SPECIFIED
};
-#ifndef EMBEDDED_LIBRARY
+
+/* HFTODO - hide this if we don't want client in embedded server */
/* This structure is for every connection on both sides */
struct st_vio
{
@@ -159,7 +177,7 @@ struct st_vio
void (*viodelete)(Vio*);
int (*vioerrno)(Vio*);
int (*read)(Vio*, gptr, int);
- int (*write)(Vio*, gptr, int);
+ int (*write)(Vio*, const gptr, int);
int (*vioblocking)(Vio*, my_bool, my_bool *);
my_bool (*is_blocking)(Vio*);
int (*viokeepalive)(Vio*, my_bool);
@@ -170,7 +188,17 @@ struct st_vio
int (*vioclose)(Vio*);
void (*timeout)(Vio*, unsigned int timeout);
void *ssl_arg;
+#ifdef HAVE_SMEM
+ HANDLE handle_file_map;
+ char *handle_map;
+ HANDLE event_server_wrote;
+ HANDLE event_server_read;
+ HANDLE event_client_wrote;
+ HANDLE event_client_read;
+ long shared_memory_remain;
+ char *shared_memory_pos;
+ NET *net;
+#endif /* HAVE_SMEM */
#endif /* HAVE_VIO */
};
-#endif /* EMBEDDED_LIBRARY */
#endif /* vio_violite_h_ */