summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am19
-rw-r--r--include/config-netware.h4
-rw-r--r--include/config-os2.h3
-rw-r--r--include/config-win.h88
-rw-r--r--include/errmsg.h32
-rw-r--r--include/ft_global.h20
-rw-r--r--include/hash.h28
-rw-r--r--include/heap.h121
-rw-r--r--include/help_end.h1
-rw-r--r--include/help_start.h2
-rw-r--r--include/keycache.h139
-rw-r--r--include/m_ctype.h527
-rw-r--r--include/m_string.h44
-rw-r--r--include/my_base.h105
-rw-r--r--include/my_bitmap.h39
-rw-r--r--include/my_dbug.h4
-rw-r--r--include/my_getopt.h6
-rw-r--r--include/my_global.h323
-rw-r--r--include/my_handler.h66
-rw-r--r--include/my_list.h6
-rw-r--r--include/my_no_pthread.h6
-rw-r--r--include/my_pthread.h37
-rw-r--r--include/my_sys.h157
-rw-r--r--include/my_time.h80
-rw-r--r--include/my_tree.h31
-rw-r--r--include/my_xml.h67
-rw-r--r--include/myisam.h90
-rw-r--r--include/myisammrg.h6
-rw-r--r--include/myisampack.h360
-rw-r--r--include/mysql.h391
-rw-r--r--include/mysql_com.h248
-rw-r--r--include/mysql_embed.h4
-rw-r--r--include/mysql_time.h56
-rw-r--r--include/mysql_version.h.in3
-rw-r--r--include/mysqld_error.h72
-rw-r--r--include/mysys_err.h4
-rw-r--r--include/raid.h7
-rw-r--r--include/sql_common.h46
-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.h34
-rw-r--r--include/violite.h80
43 files changed, 2683 insertions, 853 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index bd1492766b1..0c845900a4f 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 mysql_time.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 help_start.h help_end.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 my_time.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) -fr readline
+distclean:
+ $(RM) -fr 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) -fr readline
+ @readline_h_ln_cmd@
# Keep automake happy
my_config.h: ../config.h
$(CP) ../config.h my_config.h
+ -$(RM) -fr 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-netware.h b/include/config-netware.h
index 3e145f566a1..c8eba43b86f 100644
--- a/include/config-netware.h
+++ b/include/config-netware.h
@@ -45,6 +45,7 @@ extern "C" {
#undef HAVE_SCHED_H
#undef HAVE_SYS_MMAN_H
#undef HAVE_SYNCH_H
+#undef HAVE_RINT
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
#define HAVE_PTHREAD_SIGMASK 1
#define HAVE_PTHREAD_YIELD_ZERO_ARG 1
@@ -79,6 +80,9 @@ extern "C" {
/* On NetWare, stack grows towards lower address*/
#define STACK_DIRECTION -1
+/* On NetWare, to fix the problem with the deletion of open files */
+#define CANT_DELETE_OPEN_FILES 1
+
/* default directory information */
#define DEFAULT_MYSQL_HOME "sys:/mysql"
#define PACKAGE "mysql"
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 42aa23c3afe..86704c4740b 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(_WIN64) || defined(WIN64)
#define SYSTEM_TYPE "Win64"
#elif defined(_WIN32) || defined(WIN32)
@@ -94,23 +102,37 @@
#define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF)
#define ULONGLONG_MAX ((unsigned __int64) 0xFFFFFFFFFFFFFFFF)
#define LL(A) ((__int64) A)
+#define ULL(A) ((unsigned __int64) A)
/* Type information */
+#if defined(__EMX__) || !defined(HAVE_UINT)
+#undef HAVE_UINT
+#define HAVE_UINT
typedef unsigned short ushort;
typedef unsigned int uint;
+#endif /* defined(__EMX__) || !defined(HAVE_UINT) */
+
typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
typedef __int64 longlong;
+#ifndef HAVE_SIGSET_T
typedef int sigset_t;
+#endif
#define longlong_defined
-/* off_t should not be __int64 because of conflicts in header files;
- Use my_off_t or os_off_t instead */
+/*
+ off_t should not be __int64 because of conflicts in header files;
+ Use my_off_t or os_off_t instead
+*/
+#ifndef HAVE_OFF_T
typedef long off_t;
+#endif
typedef __int64 os_off_t;
#ifdef _WIN64
typedef UINT_PTR rf_SetTimer;
#else
+#ifndef HAVE_SIZE_T
typedef unsigned int size_t;
+#endif
typedef uint rf_SetTimer;
#endif
@@ -148,6 +170,9 @@ typedef uint rf_SetTimer;
#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
#endif
+/* ERROR is defined in wingdi.h */
+#undef ERROR
+
/* We need to close files to break connections on shutdown */
#ifndef SIGNAL_WITH_VIO_CLOSE
#define SIGNAL_WITH_VIO_CLOSE
@@ -170,12 +195,16 @@ typedef uint rf_SetTimer;
#define sigset(A,B) signal((A),(B))
#define finite(A) _finite(A)
#define sleep(A) Sleep((A)*1000)
+#define popen(A) popen(A,B) _popen((A),(B))
+#define pclose(A) _pclose(A)
#ifndef __BORLANDC__
#define access(A,B) _access(A,B)
#endif
-#if defined(__cplusplus)
+#if !defined(__cplusplus)
+#define inline __inline
+#endif /* __cplusplus */
inline double rint(double nr)
{
@@ -198,9 +227,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))
@@ -257,6 +283,7 @@ inline double ulonglong2double(ulonglong value)
#define doublestore(T,V) { *((long *) T) = *((long*) &V); \
*(((long *) T)+1) = *(((long*) &V)+1); }
#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
+#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float))
#define float8get(V,M) doubleget((V),(M))
#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
#define float8store(V,M) doublestore((V),(M))
@@ -291,10 +318,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 */
@@ -329,7 +356,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))
@@ -346,3 +373,48 @@ 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 HAVE_SPATIAL 1
+#define HAVE_RTREE_KEYS 1
+
+/* 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 */
+#define HAVE_CHARSET_cp932 1
+/* #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
+#define HAVE_UCA_COLLATIONS 1
+
diff --git a/include/errmsg.h b/include/errmsg.h
index 24ebe24d786..96977227666 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -14,8 +14,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-/* Error messages for mysql clients */
-/* error messages for the demon is in share/language/errmsg.sys */
+/* Error messages for MySQL clients */
+/* (Error messages for the daemon are in share/language/errmsg.sys) */
#ifdef __cplusplus
extern "C" {
@@ -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() */
@@ -65,3 +65,29 @@ extern const char *client_errors[]; /* Error messages */
#define CR_MALFORMED_PACKET 2027
#define CR_WRONG_LICENSE 2028
+/* new 4.1 error codes */
+#define CR_NULL_POINTER 2029
+#define CR_NO_PREPARE_STMT 2030
+#define CR_PARAMS_NOT_BOUND 2031
+#define CR_DATA_TRUNCATED 2032
+#define CR_NO_PARAMETERS_EXISTS 2033
+#define CR_INVALID_PARAMETER_NO 2034
+#define CR_INVALID_BUFFER_USE 2035
+#define CR_UNSUPPORTED_PARAM_TYPE 2036
+
+#define CR_SHARED_MEMORY_CONNECTION 2037
+#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2038
+#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2039
+#define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2040
+#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2041
+#define CR_SHARED_MEMORY_FILE_MAP_ERROR 2042
+#define CR_SHARED_MEMORY_MAP_ERROR 2043
+#define CR_SHARED_MEMORY_EVENT_ERROR 2044
+#define CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR 2045
+#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2046
+#define CR_CONN_UNKNOW_PROTOCOL 2047
+#define CR_INVALID_CONN_HANDLE 2048
+#define CR_SECURE_AUTH 2049
+#define CR_FETCH_CANCELED 2050
+#define CR_NO_DATA 2051
+#define CR_NO_STMT_METADATA 2052
diff --git a/include/ft_global.h b/include/ft_global.h
index 9acdf6aaaf3..c3f60d13a7a 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,CHARSET_INFO *, byte *);
+my_bool ft_boolean_check_syntax_string(const byte *);
#ifdef __cplusplus
}
diff --git a/include/hash.h b/include/hash.h
index e9c8c73c05b..9a6d91036e1 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,20 @@ 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);
+void my_hash_reset(HASH *hash);
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..badec9ce2ef 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (C) 2000,2004 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
@@ -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;
@@ -60,36 +63,71 @@ typedef struct st_heap_ptrs
struct st_level_info
{
- uint free_ptrs_in_block,records_under_level;
- HP_PTRS *last_blocks; /* pointers to HP_PTRS or records */
+ /* Number of unused slots in *last_blocks HP_PTRS block (0 for 0th level) */
+ uint free_ptrs_in_block;
+
+ /*
+ Maximum number of records that can be 'contained' inside of each element
+ of last_blocks array. For level 0 - 1, for level 1 - HP_PTRS_IN_NOD, for
+ level 2 - HP_PTRS_IN_NOD^2 and so forth.
+ */
+ uint records_under_level;
+
+ /*
+ Ptr to last allocated HP_PTRS (or records buffer for level 0) on this
+ level.
+ */
+ HP_PTRS *last_blocks;
};
-typedef struct st_heap_block /* The data is saved in blocks */
+
+/*
+ Heap table records and hash index entries are stored in HP_BLOCKs.
+ HP_BLOCK is used as a 'growable array' of fixed-size records. Size of record
+ is recbuffer bytes.
+ The internal representation is as follows:
+ HP_BLOCK is a hierarchical structure of 'blocks'.
+ A block at level 0 is an array records_in_block records.
+ A block at higher level is an HP_PTRS structure with pointers to blocks at
+ lower levels.
+ At the highest level there is one top block. It is stored in HP_BLOCK::root.
+
+ See hp_find_block for a description of how record pointer is obtained from
+ its index.
+ See hp_get_new_block
+*/
+
+typedef struct st_heap_block
{
- HP_PTRS *root;
+ HP_PTRS *root; /* Top-level block */
struct st_level_info level_info[HP_MAX_LEVELS+1];
- uint levels;
- uint records_in_block; /* Records in a heap-block */
+ uint levels; /* number of used levels */
+ uint records_in_block; /* Records in one heap-block */
uint recbuffer; /* Length of one saved record */
- ulong last_allocated; /* Blocks allocated, used by keys */
+ ulong last_allocated; /* number of records there is allocated space for */
} 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 */
+ /*
+ Number of buckets used in hash table. Used only to provide
+ #records estimates for heap key scans.
+ */
+ ha_rows hash_buckets;
+ 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
@@ -97,13 +135,14 @@ typedef struct st_heap_share
HP_BLOCK block;
HP_KEYDEF *keydef;
ulong min_records,max_records; /* Params to open */
- ulong data_length,index_length;
+ ulong data_length,index_length,max_table_size;
uint records; /* records */
- uint blength;
+ uint blength; /* records rounded up to 2^n */
uint deleted; /* Deleted records in database */
uint reclength; /* Length of one record */
uint changed;
uint keys,max_key_length;
+ uint currently_disabled_keys; /* saved value from "keys" when disabled */
uint open_count;
byte *del_link; /* Link to next block with del. rec */
my_string name; /* Name of "memory-file" */
@@ -113,6 +152,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 +169,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 +181,19 @@ typedef struct st_heap_info
LIST open_list;
} HP_INFO;
+
+typedef struct st_heap_create_info
+{
+ uint auto_key; /* keynr [1 - maxkey] for auto key */
+ uint auto_key_type;
+ ulong max_table_size;
+ ulonglong auto_increment;
+ my_bool with_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 +202,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 +212,18 @@ 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_clear_keys(HP_INFO *info);
+extern int heap_disable_indexes(HP_INFO *info);
+extern int heap_enable_indexes(HP_INFO *info);
+extern int heap_indexes_are_disabled(HP_INFO *info);
+extern void heap_update_auto_increment(HP_INFO *info, const byte *record);
+ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key,
+ key_range *max_key);
+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/help_end.h b/include/help_end.h
index a63d9e7ca9f..3bd16c09e3b 100644
--- a/include/help_end.h
+++ b/include/help_end.h
@@ -2,5 +2,6 @@
#undef printf
#undef puts
#undef fputs
+#undef fputc
#undef putchar
#endif
diff --git a/include/help_start.h b/include/help_start.h
index 38bb91f7655..7ffde1ab803 100644
--- a/include/help_start.h
+++ b/include/help_start.h
@@ -4,4 +4,6 @@
#define printf consoleprintf
#define puts(s) consoleprintf("%s\n",s)
#define fputs(s,f) puts(s)
+#define fputc(s,f) consoleprintf("%c", s)
+#define putchar(s) consoleprintf("%c", s)
#endif
diff --git a/include/keycache.h b/include/keycache.h
new file mode 100644
index 00000000000..a292a69b0a3
--- /dev/null
+++ b/include/keycache.h
@@ -0,0 +1,139 @@
+/* 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; /* maximum number of concurrently used blocks */
+ ulong blocks_unused; /* number of currently unused 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 *free_block_list; /* list of free blocks */
+ 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. These are reset in reset_key_cache_counters(). */
+ 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);
+extern int reset_key_cache_counters(const char *name,
+ KEY_CACHE *key_cache);
+C_MODE_END
+#endif /* _keycache_h */
diff --git a/include/m_ctype.h b/include/m_ctype.h
index b3e50cec58f..ab63a1e0db1 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -26,137 +26,420 @@
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_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_READY 256 /* if a charset is initialized */
+#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
+#define MY_CS_CSSORT 1024 /* if case sensitive sort order */
+#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_SEMICOLON,
+ 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
+{
+ my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint));
+ /* Collation routines */
+ int (*strnncoll)(struct charset_info_st *,
+ const uchar *, uint, const uchar *, uint, my_bool);
+ 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;
+extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler;
+
+
+typedef struct my_charset_handler_st
+{
+ my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint));
+ /* 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, int *error);
+ uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length);
+ uint (*numcells)(struct charset_info_st *, const char *b, const char *e);
+
+ /* 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);
+ longlong (*my_strtoll10)(struct charset_info_st *cs,
+ const char *nptr, char **endptr, int *error);
+ 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;
+extern MY_CHARSET_HANDLER my_charset_ucs2_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;
+ const char *tailoring;
+ uchar *ctype;
+ uchar *to_lower;
+ uchar *to_upper;
+ uchar *sort_order;
+ uint16 *contractions;
+ uint16 **sort_order_big;
+ uint16 *tab_to_uni;
+ MY_UNI_IDX *tab_from_uni;
+ uchar *state_map;
+ uchar *ident_map;
+ uint strxfrm_multiply;
+ uint mbminlen;
+ uint mbmaxlen;
+ uint16 min_sort_char;
+ uint16 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
-
-#define _U 01 /* Upper case */
-#define _L 02 /* Lower case */
-#define _NMR 04 /* Numeral (digit) */
-#define _SPC 010 /* Spacing character */
-#define _PNT 020 /* Punctuation */
-#define _CTR 040 /* Control character */
-#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_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_U | _L))
-#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _U)
-#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _L)
-#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _NMR)
-#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _X)
-#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_U | _L | _NMR))
-#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _SPC)
-#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _PNT)
-#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_PNT | _U | _L | _NMR | _B))
-#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)))
-
-#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)))
+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_cp932_japanese_ci;
+extern CHARSET_INFO my_charset_cp932_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_ucs2_general_uca;
+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, my_bool);
+
+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);
+
+longlong my_strtoll10_8bit(CHARSET_INFO *cs,
+ const char *nptr, char **endptr, int *error);
+longlong my_strtoll10_ucs2(CHARSET_INFO *cs,
+ const char *nptr, char **endptr, int *error);
+
+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);
+
+my_bool my_like_range_mb(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);
+
+my_bool my_like_range_ucs2(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_numcells_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 *error);
+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_numcells_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, int *error);
+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);
+
+int my_wildcmp_unicode(CHARSET_INFO *cs,
+ const char *str, const char *str_end,
+ const char *wildstr, const char *wildend,
+ int escape, int w_one, int w_many,
+ MY_UNICASE_INFO **weights);
+
+extern my_bool my_parse_charset_xml(const char *bug, uint len,
+ int (*add)(CHARSET_INFO *cs));
+
+#define _MY_U 01 /* Upper case */
+#define _MY_L 02 /* Lower case */
+#define _MY_NMR 04 /* Numeral (digit) */
+#define _MY_SPC 010 /* Spacing character */
+#define _MY_PNT 020 /* Punctuation */
+#define _MY_CTR 040 /* Control character */
+#define _MY_B 0100 /* Blank */
+#define _MY_X 0200 /* heXadecimal digit */
+
+
+#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)] & (_MY_U | _MY_L))
+#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_U)
+#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_L)
+#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_NMR)
+#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X)
+#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR))
+#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_SPC)
+#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_PNT)
+#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B))
+#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR))
+#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_CTR)
/* 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)
+#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_')
+#define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_')
+
+#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), 0))
+#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 my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num))
+
+
+#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)))
+
/* 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 419e70d93bf..d3465363beb 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)
@@ -92,7 +95,9 @@ extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
#endif
#endif
-extern char NEAR _dig_vec[]; /* Declared in int2str() */
+/* Declared in int2str() */
+extern char NEAR _dig_vec_upper[];
+extern char NEAR _dig_vec_lower[];
#ifdef BAD_STRING_COMPILER
#define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
@@ -108,11 +113,9 @@ extern char NEAR _dig_vec[]; /* Declared in int2str() */
#endif
#ifdef MSDOS
-#undef bmove_allign
-#define bmove512(A,B,C) bmove_allign(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);
+#undef bmove_align
+#define bmove512(A,B,C) bmove_align(A,B,C)
+extern void bmove_align(gptr dst,const gptr src,uint len);
#endif
#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
@@ -120,10 +123,9 @@ extern void bmove_allign(gptr dst,const gptr src,uint len);
#endif
#ifdef HAVE_purify
-#include <assert.h>
#define memcpy_overlap(A,B,C) \
DBUG_ASSERT((A) <= (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 +200,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,12 +214,9 @@ extern char *strstr(const char *, const char *);
#endif
extern int is_prefix(const char *, const char *);
-/* Conversion rutins */
-
-#ifdef USE_MY_ITOA
-extern char *my_itoa(int val,char *dst,int radix);
-extern char *my_ltoa(long val,char *dst,int radix);
-#endif
+/* Conversion routines */
+double my_strtod(const char *str, char **end, int *error);
+double my_atof(const char *nptr);
extern char *llstr(longlong value,char *buff);
#ifndef HAVE_STRTOUL
@@ -225,12 +224,13 @@ extern long strtol(const char *str, char **ptr, int base);
extern ulong strtoul(const char *str, char **ptr, int base);
#endif
-extern char *int2str(long val,char *dst,int radix);
+extern char *int2str(long val, char *dst, int radix, int upcase);
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 longlong2str(A,B,C) int2str((A),(B),(C),1)
#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
#undef strtoll
#define strtoll(A,B,C) strtol((A),(B),(C))
@@ -252,6 +252,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..d702ec45140 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -28,6 +28,11 @@
#include <my_sys.h>
#include <m_string.h>
#include <errno.h>
+
+#ifndef EOVERFLOW
+#define EOVERFLOW 84
+#endif
+
#ifdef MSDOS
#include <share.h> /* Neaded for sopen() */
#endif
@@ -49,29 +54,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 +91,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 */
@@ -95,8 +105,8 @@ enum ha_extra_function {
HA_EXTRA_NORMAL=0, /* Optimize for space (def) */
HA_EXTRA_QUICK=1, /* Optimize for speed */
HA_EXTRA_RESET=2, /* Reset database to after open */
- HA_EXTRA_CACHE=3, /* Cash record in HA_rrnd() */
- HA_EXTRA_NO_CACHE=4, /* End cacheing of records (def) */
+ HA_EXTRA_CACHE=3, /* Cache record in HA_rrnd() */
+ HA_EXTRA_NO_CACHE=4, /* End caching of records (def) */
HA_EXTRA_NO_READCHECK=5, /* No readcheck on update */
HA_EXTRA_READCHECK=6, /* Use readcheck (def) */
HA_EXTRA_KEYREAD=7, /* Read only key to database */
@@ -120,9 +130,23 @@ 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 (except in key read), not just
+ those where field->query_id is the same as the current query id
+ */
+ HA_EXTRA_RETRIEVE_ALL_COLS,
+ /*
+ Instructs InnoDB to retrieve at least all the primary key columns
+ */
+ HA_EXTRA_RETRIEVE_PRIMARY_KEY,
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 */
+ /*
+ On-the-fly switching between unique and non-unique key inserting.
+ */
+ HA_EXTRA_CHANGE_KEY_TO_UNIQUE,
+ HA_EXTRA_CHANGE_KEY_TO_DUP
};
/* The following is parameter to ha_panic() */
@@ -163,11 +187,11 @@ 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 */
-
+#define HA_GENERATED_KEY 8192 /* Automaticly generated key */
/* Automatic bits in key-flag */
@@ -217,11 +241,12 @@ enum ha_base_keytype {
#define HA_CREATE_TMP_TABLE 4
#define HA_CREATE_CHECKSUM 8
#define HA_CREATE_DELAY_KEY_WRITE 64
+#define HA_CREATE_FROM_ENGINE 128
/* 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 +287,11 @@ 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 */
+#define HA_ERR_NO_SUCH_TABLE 155 /* The table does not exist in engine */
+#define HA_ERR_TABLE_EXIST 156 /* The table existed in storage engine */
+#define HA_ERR_NO_CONNECTION 157 /* Could not connect to storage engine */
+#define HA_ERR_NULL_IN_SPATIAL 158 /* NULLs are not supported in spatial index */
/* Other constants */
@@ -295,7 +325,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 */
@@ -310,6 +340,7 @@ enum ha_base_keytype {
#define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */
#define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */
#define HA_STATE_EXTEND_BLOCK 2048
+#define HA_STATE_RNEXT_SAME 4096 /* rnext_same was called */
enum en_fieldtype {
FIELD_LAST=-1,FIELD_NORMAL,FIELD_SKIP_ENDSPACE,FIELD_SKIP_PRESPACE,
@@ -321,13 +352,23 @@ enum data_file_type {
STATIC_RECORD,DYNAMIC_RECORD,COMPRESSED_RECORD
};
+/* For key ranges */
+
+typedef struct st_key_range
+{
+ const byte *key;
+ uint length;
+ enum ha_rkey_function flag;
+} key_range;
+
+
/* For number of records */
#ifdef BIG_TABLES
#define rows2double(A) ulonglong2double(A)
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..a4511bf3414 100644
--- a/include/my_bitmap.h
+++ b/include/my_bitmap.h
@@ -25,29 +25,42 @@ 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);
+
+/* Fast, not thread safe, bitmap functions */
+#define bitmap_fast_set_bit(MAP, BIT) (MAP)->bitmap[(BIT) / 8] |= (1 << ((BIT) & 7))
+#define bitmap_fast_clear_bit(MAP, BIT) (MAP)->bitmap[(BIT) / 8] &= ~ (1 << ((BIT) & 7))
+#define bitmap_fast_is_set(MAP, BIT) (MAP)->bitmap[(BIT) / 8] & (1 << ((BIT) & 7))
+
#ifdef __cplusplus
}
#endif
diff --git a/include/my_dbug.h b/include/my_dbug.h
index 5c88e2e42db..711ece4335c 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -16,6 +16,7 @@
#ifndef _dbug_h
#define _dbug_h
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -37,6 +38,7 @@ extern void _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_ _VARARGS((const char *format,...));
extern void _db_dump_(uint _line_,const char *keyword,const char *memory,
uint length);
+extern void _db_output_();
extern void _db_lock_file();
extern void _db_unlock_file();
@@ -65,6 +67,7 @@ extern void _db_unlock_file();
#define DEBUGGER_ON _no_db_=0
#define DBUG_LOCK_FILE { _db_lock_file(); }
#define DBUG_UNLOCK_FILE { _db_unlock_file(); }
+#define DBUG_OUTPUT(A) { _db_output_(A); }
#define DBUG_ASSERT(A) assert(A)
#else /* No debugger */
@@ -85,6 +88,7 @@ extern void _db_unlock_file();
#define DEBUGGER_ON
#define DBUG_LOCK_FILE
#define DBUG_UNLOCK_FILE
+#define DBUG_OUTPUT(A)
#define DBUG_ASSERT(A) {}
#endif
#ifdef __cplusplus
diff --git a/include/my_getopt.h b/include/my_getopt.h
index e602773e181..e6ca1130f85 100644
--- a/include/my_getopt.h
+++ b/include/my_getopt.h
@@ -29,6 +29,10 @@ C_MODE_START
#define GET_ULL 8
#define GET_STR 9
#define GET_STR_ALLOC 10
+#define GET_DISABLED 11
+
+#define GET_ASK_ADDR 128
+#define GET_TYPE_MASK 127
enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
@@ -61,6 +65,8 @@ extern int handle_options (int *argc, char ***argv,
const struct my_option *longopts, my_get_one_option);
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 e2a97667a1f..be6e667057d 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -43,6 +43,11 @@
#define HAVE_ERRNO_AS_DEFINE
#endif /* __CYGWIN__ */
+/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
+#ifdef USE_PRAGMA_IMPLEMENTATION
+#define USE_PRAGMA_INTERFACE
+#endif
+
#if defined(i386) && !defined(__i386__)
#define __i386__
#endif
@@ -97,7 +102,7 @@
/* Fix problem with S_ISLNK() on Linux */
-#if defined(HAVE_LINUXTHREADS)
+#if defined(TARGET_OS_LINUX)
#undef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
@@ -107,6 +112,7 @@
#undef THREAD
#undef HAVE_mit_thread
#undef HAVE_LINUXTHREADS
+#undef HAVE_NPTL
#undef HAVE_UNIXWARE7_THREADS
#endif
@@ -135,7 +141,13 @@
#ifdef HAVE_UNIXWARE7_THREADS
#include <thread.h>
#else
+#if defined(HPUX10) || defined(HPUX11)
+C_MODE_START /* HPUX needs this, signal.h bug */
+#include <pthread.h>
+C_MODE_END
+#else
#include <pthread.h> /* AIX must have this included first */
+#endif
#endif /* HAVE_UNIXWARE7_THREADS */
#endif /* HAVE_mit_thread */
#if !defined(SCO) && !defined(_REENTRANT)
@@ -193,7 +205,11 @@ C_MODE_END
/* Fix problem when linking c++ programs with gcc 3.x */
#ifdef DEFINE_CXA_PURE_VIRTUAL
-#define FIX_GCC_LINKING_PROBLEM extern "C" { int __cxa_pure_virtual() {return 0;} }
+#define FIX_GCC_LINKING_PROBLEM \
+C_MODE_START int __cxa_pure_virtual() {\
+ DBUG_ASSERT("Pure virtual method called." == "Aborted");\
+ return 0;\
+} C_MODE_END
#else
#define FIX_GCC_LINKING_PROBLEM
#endif
@@ -258,10 +274,8 @@ C_MODE_END
#include <alloca.h>
#endif
#ifdef HAVE_ATOMIC_ADD
-#if defined(__ia64__)
#define new my_arg_new
#define need_to_restore_new 1
-#endif
C_MODE_START
#include <asm/atomic.h>
C_MODE_END
@@ -276,6 +290,13 @@ C_MODE_END
#include <crypt.h>
#endif
+/*
+ A lot of our programs uses asserts, so better to always include it
+ This also fixes a problem when people uses DBUG_ASSERT without including
+ assert.h
+*/
+#include <assert.h>
+
/* Go around some bugs in different OS and compilers */
#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
#include <sys/stream.h> /* HPUX 10.20 defines ulong here. UGLY !!! */
@@ -297,6 +318,11 @@ C_MODE_END
#undef HAVE_FINITE
#undef LONGLONG_MIN /* These get wrongly defined in QNX 6.2 */
#undef LONGLONG_MAX /* standard system library 'limits.h' */
+#ifdef __cplusplus
+#define HAVE_RINT /* rint() and isnan() functions are not */
+#define rint(a) std::rint(a) /* visible in C++ scope due to an error */
+#define isnan(a) std::isnan(a) /* in the usr/include/math.h on QNX */
+#endif
#endif
/* We can not live without the following defines */
@@ -342,26 +368,31 @@ int __void__;
#define LINT_INIT(var)
#endif
+#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_purify)
+#define PURIFY_OR_LINT_INIT(var) var=0
+#else
+#define PURIFY_OR_LINT_INIT(var)
+#endif
+
/* Define some useful general macros */
-#if defined(__cplusplus) && defined(__GNUC__)
-#define max(a, b) ((a) >? (b))
-#define min(a, b) ((a) <? (b))
-#elif !defined(max)
+#if !defined(max)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
#if defined(__EMX__) || !defined(HAVE_UINT)
+#undef HAVE_UINT
+#define HAVE_UINT
typedef unsigned int uint;
typedef unsigned short ushort;
#endif
#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
#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 swap_variables(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])))
@@ -499,11 +530,15 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define FN_LEN 256 /* Max file name len */
#define FN_HEADLEN 253 /* Max length of filepart of file name */
#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
+#ifdef PATH_MAX
+#define FN_REFLEN PATH_MAX/* Max length of full path-name */
+#else
#define FN_REFLEN 512 /* Max length of full path-name */
+#endif
#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
@@ -514,7 +549,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 */
@@ -542,6 +580,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 */
@@ -551,22 +592,8 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define USE_MY_STAT_STRUCT /* For my_lib */
#endif
-/* Some things that this system does have */
-
-#ifndef HAVE_ITOA
-#define USE_MY_ITOA /* There is no itoa */
-#endif
-
/* 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
@@ -649,6 +676,10 @@ extern double my_atof(const char*);
#define FLT_MAX ((float)3.40282346638528860e+38)
#endif
+#if !defined(HAVE_ISINF) && !defined(isinf)
+#define isinf(X) 0
+#endif
+
/*
Max size that must be added to a so that we know Size to make
adressable obj.
@@ -663,7 +694,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))
@@ -678,7 +709,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
@@ -691,7 +723,7 @@ typedef void *gptr; /* Generic pointer */
typedef char *gptr; /* Generic pointer */
#endif
#ifndef HAVE_INT_8_16_32
-typedef char int8; /* Signed integer >= 8 bits */
+typedef signed char int8; /* Signed integer >= 8 bits */
typedef short int16; /* Signed integer >= 16 bits */
#endif
#ifndef HAVE_UCHAR
@@ -714,7 +746,7 @@ typedef unsigned long uint32; /* Short for unsigned integer >= 32 bits */
error "Neither int or long is of 4 bytes width"
#endif
-#if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC)
+#if !defined(HAVE_ULONG) && !defined(TARGET_OS_LINUX) && !defined(__USE_MISC)
typedef unsigned long ulong; /* Short for unsigned long */
#endif
#ifndef longlong_defined
@@ -727,8 +759,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
/*
@@ -760,7 +797,7 @@ typedef off_t os_off_t;
#define socket_errno WSAGetLastError()
#define SOCKET_EINTR WSAEINTR
#define SOCKET_EAGAIN WSAEINPROGRESS
-#define SOCKET_EWOULDBLOCK WSAEINPROGRESS
+#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
#define SOCKET_ENFILE ENFILE
#define SOCKET_EMFILE EMFILE
#elif defined(OS2)
@@ -807,6 +844,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.
@@ -897,19 +942,19 @@ typedef char bool; /* Ordinary boolean values 0 1 */
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16) +\
(((uint32) ((uchar) (A)[3])) << 24)) +\
- (((ulonglong) ((uchar) (A)[4])) << 32))
+ (((ulonglong) ((uchar) (A)[4])) << 32))
#define uint8korr(A) (*((ulonglong *) (A)))
#define sint8korr(A) (*((longlong *) (A)))
#define int2store(T,A) *((uint16*) (T))= (uint16) (A)
-#define int3store(T,A) { *(T)= (uchar) ((A));\
- *(T+1)=(uchar) (((uint) (A) >> 8));\
- *(T+2)=(uchar) (((A) >> 16)); }
+#define int3store(T,A) do { *(T)= (uchar) ((A));\
+ *(T+1)=(uchar) (((uint) (A) >> 8));\
+ *(T+2)=(uchar) (((A) >> 16)); } while (0)
#define int4store(T,A) *((long *) (T))= (long) (A)
-#define int5store(T,A) { *(T)= (uchar)((A));\
- *((T)+1)=(uchar) (((A) >> 8));\
- *((T)+2)=(uchar) (((A) >> 16));\
- *((T)+3)=(uchar) (((A) >> 24)); \
- *((T)+4)=(uchar) (((A) >> 32)); }
+#define int5store(T,A) do { *(T)= (uchar)((A));\
+ *((T)+1)=(uchar) (((A) >> 8));\
+ *((T)+2)=(uchar) (((A) >> 16));\
+ *((T)+3)=(uchar) (((A) >> 24)); \
+ *((T)+4)=(uchar) (((A) >> 32)); } while(0)
#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
typedef union {
@@ -917,19 +962,26 @@ typedef union {
long m[2];
} doubleget_union;
#define doubleget(V,M) \
-{ doubleget_union _tmp; \
- _tmp.m[0] = *((long*)(M)); \
- _tmp.m[1] = *(((long*) (M))+1); \
- (V) = _tmp.v; }
-#define doublestore(T,V) { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
- *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; }
-#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
+do { doubleget_union _tmp; \
+ _tmp.m[0] = *((long*)(M)); \
+ _tmp.m[1] = *(((long*) (M))+1); \
+ (V) = _tmp.v; } while(0)
+#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
+ *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
+ } while (0)
+#define float4get(V,M) do { *((long *) &(V)) = *((long*) (M)); } while(0)
#define float8get(V,M) doubleget((V),(M))
#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
+#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V),sizeof(float))
+#define floatget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(float))
#define float8store(V,M) doublestore((V),(M))
#endif /* __i386__ */
#ifndef sint2korr
+/*
+ We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
+ were done before)
+*/
#define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\
((int16) ((int16) (A)[1]) << 8))
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
@@ -958,7 +1010,7 @@ typedef union {
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16) +\
(((uint32) ((uchar) (A)[3])) << 24)) +\
- (((ulonglong) ((uchar) (A)[4])) << 32))
+ (((ulonglong) ((uchar) (A)[4])) << 32))
#define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16) +\
@@ -967,50 +1019,50 @@ typedef union {
(((uint32) ((uchar) (A)[5])) << 8) +\
(((uint32) ((uchar) (A)[6])) << 16) +\
(((uint32) ((uchar) (A)[7])) << 24))) <<\
- 32))
-#define int2store(T,A) { uint def_temp= (uint) (A) ;\
- *((uchar*) (T))= (uchar)(def_temp); \
- *((uchar*) (T+1))=(uchar)((def_temp >> 8)); }
-#define int3store(T,A) { /*lint -save -e734 */\
- *((uchar*)(T))=(uchar) ((A));\
- *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
- *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
- /*lint -restore */}
-#define int4store(T,A) { *(T)=(char) ((A));\
- *((T)+1)=(char) (((A) >> 8));\
- *((T)+2)=(char) (((A) >> 16));\
- *((T)+3)=(char) (((A) >> 24)); }
-#define int5store(T,A) { *(T)=((A));\
- *((T)+1)=(((A) >> 8));\
- *((T)+2)=(((A) >> 16));\
- *((T)+3)=(((A) >> 24)); \
- *((T)+4)=(((A) >> 32)); }
-#define int8store(T,A) { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
- int4store((T),def_temp); \
- int4store((T+4),def_temp2); \
- }
+ 32))
+#define int2store(T,A) do { uint def_temp= (uint) (A) ;\
+ *((uchar*) (T))= (uchar)(def_temp); \
+ *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
+ } while(0)
+#define int3store(T,A) do { /*lint -save -e734 */\
+ *((uchar*)(T))=(uchar) ((A));\
+ *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
+ *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
+ /*lint -restore */} while(0)
+#define int4store(T,A) do { *((char *)(T))=(char) ((A));\
+ *(((char *)(T))+1)=(char) (((A) >> 8));\
+ *(((char *)(T))+2)=(char) (((A) >> 16));\
+ *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
+#define int5store(T,A) do { *((char *)(T))=((A));\
+ *(((char *)(T))+1)=(((A) >> 8));\
+ *(((char *)(T))+2)=(((A) >> 16));\
+ *(((char *)(T))+3)=(((A) >> 24)); \
+ *(((char *)(T))+4)=(((A) >> 32)); } while(0)
+#define int8store(T,A) do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
+ int4store((T),def_temp); \
+ int4store((T+4),def_temp2); } while(0)
#ifdef WORDS_BIGENDIAN
-#define float4store(T,A) { *(T)= ((byte *) &A)[3];\
+#define float4store(T,A) do { *(T)= ((byte *) &A)[3];\
*((T)+1)=(char) ((byte *) &A)[2];\
*((T)+2)=(char) ((byte *) &A)[1];\
- *((T)+3)=(char) ((byte *) &A)[0]; }
+ *((T)+3)=(char) ((byte *) &A)[0]; } while(0)
-#define float4get(V,M) { float def_temp;\
+#define float4get(V,M) do { float def_temp;\
((byte*) &def_temp)[0]=(M)[3];\
((byte*) &def_temp)[1]=(M)[2];\
((byte*) &def_temp)[2]=(M)[1];\
((byte*) &def_temp)[3]=(M)[0];\
- (V)=def_temp; }
-#define float8store(T,V) { *(T)= ((byte *) &V)[7];\
+ (V)=def_temp; } while(0)
+#define float8store(T,V) do { *(T)= ((byte *) &V)[7];\
*((T)+1)=(char) ((byte *) &V)[6];\
*((T)+2)=(char) ((byte *) &V)[5];\
*((T)+3)=(char) ((byte *) &V)[4];\
*((T)+4)=(char) ((byte *) &V)[3];\
*((T)+5)=(char) ((byte *) &V)[2];\
*((T)+6)=(char) ((byte *) &V)[1];\
- *((T)+7)=(char) ((byte *) &V)[0]; }
+ *((T)+7)=(char) ((byte *) &V)[0]; } while(0)
-#define float8get(V,M) { double def_temp;\
+#define float8get(V,M) do { double def_temp;\
((byte*) &def_temp)[0]=(M)[7];\
((byte*) &def_temp)[1]=(M)[6];\
((byte*) &def_temp)[2]=(M)[5];\
@@ -1019,21 +1071,22 @@ typedef union {
((byte*) &def_temp)[5]=(M)[2];\
((byte*) &def_temp)[6]=(M)[1];\
((byte*) &def_temp)[7]=(M)[0];\
- (V) = def_temp; }
+ (V) = def_temp; } while(0)
#else
#define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float))
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
-#define doublestore(T,V) { *(T)= ((byte *) &V)[4];\
- *((T)+1)=(char) ((byte *) &V)[5];\
- *((T)+2)=(char) ((byte *) &V)[6];\
- *((T)+3)=(char) ((byte *) &V)[7];\
- *((T)+4)=(char) ((byte *) &V)[0];\
- *((T)+5)=(char) ((byte *) &V)[1];\
- *((T)+6)=(char) ((byte *) &V)[2];\
- *((T)+7)=(char) ((byte *) &V)[3]; }
-#define doubleget(V,M) { double def_temp;\
+#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((byte *) &V)[4];\
+ *(((char*)T)+1)=(char) ((byte *) &V)[5];\
+ *(((char*)T)+2)=(char) ((byte *) &V)[6];\
+ *(((char*)T)+3)=(char) ((byte *) &V)[7];\
+ *(((char*)T)+4)=(char) ((byte *) &V)[0];\
+ *(((char*)T)+5)=(char) ((byte *) &V)[1];\
+ *(((char*)T)+6)=(char) ((byte *) &V)[2];\
+ *(((char*)T)+7)=(char) ((byte *) &V)[3]; }\
+ while(0)
+#define doubleget(V,M) do { double def_temp;\
((byte*) &def_temp)[0]=(M)[4];\
((byte*) &def_temp)[1]=(M)[5];\
((byte*) &def_temp)[2]=(M)[6];\
@@ -1042,7 +1095,7 @@ typedef union {
((byte*) &def_temp)[5]=(M)[1];\
((byte*) &def_temp)[6]=(M)[2];\
((byte*) &def_temp)[7]=(M)[3];\
- (V) = def_temp; }
+ (V) = def_temp; } while(0)
#endif /* __FLOAT_WORD_ORDER */
#define float8get(V,M) doubleget((V),(M))
@@ -1052,6 +1105,14 @@ typedef union {
#endif /* sint2korr */
/*
+ Macro for reading 32-bit integer from network byte order (big-endian)
+ from unaligned memory location.
+*/
+#define int4net(A) (int32) (((uint32) ((uchar) (A)[3])) |\
+ (((uint32) ((uchar) (A)[2])) << 8) |\
+ (((uint32) ((uchar) (A)[1])) << 16) |\
+ (((uint32) ((uchar) (A)[0])) << 24))
+/*
Define-funktions for reading and storing in machine format from/to
short/long to/from some place in memory V should be a (not
register) variable, M is a pointer to byte
@@ -1059,43 +1120,49 @@ typedef union {
#ifdef WORDS_BIGENDIAN
-#define ushortget(V,M) { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
- ((uint16) ((uint16) (M)[0]) << 8)); }
-#define shortget(V,M) { V = (short) (((short) ((uchar) (M)[1]))+\
- ((short) ((short) (M)[0]) << 8)); }
-#define longget(V,M) { int32 def_temp;\
- ((byte*) &def_temp)[0]=(M)[0];\
- ((byte*) &def_temp)[1]=(M)[1];\
- ((byte*) &def_temp)[2]=(M)[2];\
- ((byte*) &def_temp)[3]=(M)[3];\
- (V)=def_temp; }
-#define ulongget(V,M) { uint32 def_temp;\
- ((byte*) &def_temp)[0]=(M)[0];\
- ((byte*) &def_temp)[1]=(M)[1];\
- ((byte*) &def_temp)[2]=(M)[2];\
- ((byte*) &def_temp)[3]=(M)[3];\
- (V)=def_temp; }
-#define shortstore(T,A) { uint def_temp=(uint) (A) ;\
- *(T+1)=(char)(def_temp); \
- *(T+0)=(char)(def_temp >> 8); }
-#define longstore(T,A) { *((T)+3)=((A));\
- *((T)+2)=(((A) >> 8));\
- *((T)+1)=(((A) >> 16));\
- *((T)+0)=(((A) >> 24)); }
-
-#define doubleget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(double))
-#define doublestore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(double))
-#define longlongget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(ulonglong))
-#define longlongstore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(ulonglong))
+#define ushortget(V,M) do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
+ ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
+#define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\
+ ((short) ((short) (M)[0]) << 8)); } while(0)
+#define longget(V,M) do { int32 def_temp;\
+ ((byte*) &def_temp)[0]=(M)[0];\
+ ((byte*) &def_temp)[1]=(M)[1];\
+ ((byte*) &def_temp)[2]=(M)[2];\
+ ((byte*) &def_temp)[3]=(M)[3];\
+ (V)=def_temp; } while(0)
+#define ulongget(V,M) do { uint32 def_temp;\
+ ((byte*) &def_temp)[0]=(M)[0];\
+ ((byte*) &def_temp)[1]=(M)[1];\
+ ((byte*) &def_temp)[2]=(M)[2];\
+ ((byte*) &def_temp)[3]=(M)[3];\
+ (V)=def_temp; } while(0)
+#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
+ *(((char*)T)+1)=(char)(def_temp); \
+ *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
+#define longstore(T,A) do { *(((char*)T)+3)=((A));\
+ *(((char*)T)+2)=(((A) >> 8));\
+ *(((char*)T)+1)=(((A) >> 16));\
+ *(((char*)T)+0)=(((A) >> 24)); } while(0)
+
+#define floatget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
+#define floatstore(T,V) memcpy_fixed((byte*) (T),(byte*)(&V),sizeof(float))
+#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
+#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
+#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
+#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
#else
-#define ushortget(V,M) { V = uint2korr(M); }
-#define shortget(V,M) { V = sint2korr(M); }
-#define longget(V,M) { V = sint4korr(M); }
-#define ulongget(V,M) { V = uint4korr(M); }
+#define ushortget(V,M) do { V = uint2korr(M); } while(0)
+#define shortget(V,M) do { V = sint2korr(M); } while(0)
+#define longget(V,M) do { V = sint4korr(M); } while(0)
+#define ulongget(V,M) do { V = uint4korr(M); } while(0)
#define shortstore(T,V) int2store(T,V)
#define longstore(T,V) int4store(T,V)
+#ifndef floatstore
+#define floatstore(T,V) memcpy_fixed((byte*) (T),(byte*) (&V),sizeof(float))
+#define floatget(V,M) memcpy_fixed((byte*) &V, (byte*) (M), sizeof(float))
+#endif
#ifndef doubleget
#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
@@ -1124,4 +1191,14 @@ typedef union {
#define statistic_add(V,C,L) (V)+=(C)
#endif
+#ifdef HAVE_CHARSET_utf8
+#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
+#else
+#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
+#endif
+
+#if defined(EMBEDDED_LIBRARY) && !defined(HAVE_EMBEDDED_PRIVILEGE_CONTROL)
+#define NO_EMBEDDED_ACCESS_CHECKS
+#endif
+
#endif /* my_global_h */
diff --git a/include/my_handler.h b/include/my_handler.h
new file mode 100644
index 00000000000..18a6234d3f6
--- /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, 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..f786621e311 100644
--- a/include/my_list.h
+++ b/include/my_list.h
@@ -32,9 +32,9 @@ 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 int list_walk(LIST *list,list_walk_action action,gptr argument);
+extern void list_free(LIST *root,unsigned int free_data);
+extern unsigned int list_length(LIST *);
+extern int list_walk(LIST *,list_walk_action action,gptr argument);
#define rest(a) ((a)->next)
#define list_push(a,b) (a)=list_cons((b),(a))
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 7620b46e08b..fde62655c5f 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)*/
@@ -232,7 +234,6 @@ extern int my_sigwait(const sigset_t *set,int *sig);
#include <signal.h>
#undef sigwait
#endif
-#undef _REENTRANT /* Fix if _REENTRANT is in pthread.h */
#include <pthread.h>
#ifndef _REENTRANT
#define _REENTRANT
@@ -278,6 +279,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 +381,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 +475,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 +494,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 */
@@ -597,19 +604,19 @@ extern int my_rw_trywrlock(my_rw_lock_t *);
#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
#endif
-/* Define mutex types */
+/* Define mutex types, see my_thr_init.c */
#define MY_MUTEX_INIT_SLOW NULL
-#define MY_MUTEX_INIT_FAST NULL
-#define MY_MUTEX_INIT_ERRCHK NULL
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
extern pthread_mutexattr_t my_fast_mutexattr;
-#undef MY_MUTEX_INIT_FAST
#define MY_MUTEX_INIT_FAST &my_fast_mutexattr
+#else
+#define MY_MUTEX_INIT_FAST NULL
#endif
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
-extern pthread_mutexattr_t my_errchk_mutexattr;
-#undef MY_INIT_MUTEX_ERRCHK
-#define MY_INIT_MUTEX_ERRCHK &my_errchk_mutexattr
+extern pthread_mutexattr_t my_errorcheck_mutexattr;
+#define MY_MUTEX_INIT_ERRCHK &my_errorcheck_mutexattr
+#else
+#define MY_MUTEX_INIT_ERRCHK NULL
#endif
extern my_bool my_thread_global_init(void);
@@ -630,9 +637,9 @@ extern int pthread_dummy(int);
MySQL can survive with 32K, but some glibc libraries require > 128K stack
To resolve hostnames
*/
-#define DEFAULT_THREAD_STACK (192*1024L)
+#define DEFAULT_THREAD_STACK (256*1024L)
#else
-#define DEFAULT_THREAD_STACK (192*1024L)
+#define DEFAULT_THREAD_STACK (192*1024)
#endif
#endif
@@ -648,6 +655,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];
@@ -670,8 +679,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));
@@ -679,6 +686,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))
@@ -686,7 +694,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 d6104a6a3a9..e56f07a8140 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,9 +160,13 @@ 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(__MWERKS__)
+#undef alloca
+#define alloca _alloca
+#endif /* __MWERKS__ */
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
#define alloca __builtin_alloca
#endif /* GNUC */
@@ -208,26 +208,20 @@ 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 uint mysys_usage_id;
+extern my_bool my_init_done;
/* Point to current my_message() */
extern void (*my_sigtstp_cleanup)(void),
@@ -257,12 +251,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 loglevel {
ERROR_LEVEL,
WARNING_LEVEL,
@@ -300,15 +288,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
{
@@ -427,6 +425,11 @@ typedef struct st_io_cache /* Used when cacheing files */
IO_CACHE_CALLBACK pre_read;
IO_CACHE_CALLBACK post_read;
IO_CACHE_CALLBACK pre_close;
+ /*
+ Counts the number of times, when we were forced to use disk. We use it to
+ increase the binlog_cache_disk_use status variable.
+ */
+ ulong disk_writes;
void* arg; /* for use by pre/post_read */
char *file_name; /* if used with 'open_cached_file' */
char *dir,*prefix;
@@ -506,6 +509,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 */
@@ -518,6 +523,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,
@@ -566,6 +573,13 @@ extern char *_my_strdup_with_length(const byte *from, uint length,
const char *sFile, uint uLine,
myf MyFlag);
+#ifdef __WIN__
+extern int my_access(const char *path, int amode);
+#else
+#define my_access access
+#endif
+extern int check_if_legal_filename(const char *path);
+
#ifndef TERMINATE
extern void TERMINATE(FILE *file);
#endif
@@ -579,9 +593,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);
@@ -599,16 +610,16 @@ 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))
extern int test_if_hard_path(const char *dir_name);
+extern my_bool has_path(const char *name);
extern char *convert_dirname(char *to, const char *from, const char *from_end);
extern void to_unix_path(my_string name);
extern my_string fn_ext(const char *name);
@@ -629,18 +640,12 @@ extern my_string my_path(my_string to,const char *progname,
extern my_string my_load_path(my_string to, const char *path,
const char *own_path_prefix);
extern int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern);
-extern my_string my_strcasestr(const char *src,const char *suffix);
-extern int my_strcasecmp(const char *s,const char *t);
-extern int my_strsortcmp(const char *s,const char *t);
-extern int my_casecmp(const char *s,const char *t,uint length);
-extern int my_sortcmp(const char *s,const char *t,uint length);
-extern int my_sortncmp(const char *s,uint s_len, const char *t,uint t_len);
extern WF_PACK *wf_comp(my_string str);
extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
extern void wf_end(struct wild_file_pack *buffer);
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);
@@ -652,14 +657,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,
@@ -724,10 +722,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);
@@ -744,6 +740,8 @@ 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 ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
+#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
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);
@@ -754,6 +752,8 @@ extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
extern char *strdup_root(MEM_ROOT *root,const char *str);
extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
+extern void get_defaults_files(int argc, char **argv,
+ char **defaults, char **extra_defaults);
extern int load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv);
extern void free_defaults(char **argv);
@@ -761,13 +761,44 @@ 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);
+extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
+ const char *from, ulong length);
#ifdef __WIN__
extern my_bool have_tcpip; /* Is set if tcpip is used */
+
+/* implemented in my_windac.c */
+
+int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
+ DWORD owner_rights, DWORD everybody_rights);
+
+void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
+
#endif
#ifdef __NETWARE__
void netware_reg_user(const char *ip, const char *user,
diff --git a/include/my_time.h b/include/my_time.h
new file mode 100644
index 00000000000..94701e159c4
--- /dev/null
+++ b/include/my_time.h
@@ -0,0 +1,80 @@
+/* Copyright (C) 2004 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 */
+
+/*
+ This is a private header of sql-common library, containing
+ declarations for my_time.c
+*/
+
+#ifndef _my_time_h_
+#define _my_time_h_
+#include "my_global.h"
+#include "mysql_time.h"
+
+C_MODE_START
+
+extern ulonglong log_10_int[20];
+extern uchar days_in_month[];
+
+/*
+ Portable time_t replacement.
+ Should be signed and hold seconds for 1902-2038 range.
+*/
+typedef long my_time_t;
+
+#define MY_TIME_T_MAX LONG_MAX
+#define MY_TIME_T_MIN LONG_MIN
+
+#define YY_PART_YEAR 70
+
+/* Flags to str_to_datetime */
+#define TIME_FUZZY_DATE 1
+#define TIME_DATETIME_ONLY 2
+
+enum enum_mysql_timestamp_type
+str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
+ uint flags, int *was_cut);
+
+bool str_to_time(const char *str,uint length, MYSQL_TIME *l_time,
+ int *was_cut);
+
+long calc_daynr(uint year,uint month,uint day);
+
+void init_time(void);
+
+my_time_t
+my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap);
+
+void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type);
+
+/*
+ Required buffer length for my_time_to_str, my_date_to_str,
+ my_datetime_to_str and TIME_to_string functions. Note, that the
+ caller is still responsible to check that given TIME structure
+ has values in valid ranges, otherwise size of the buffer could
+ be not enough. We also rely on the fact that even wrong values
+ sent using binary protocol fit in this buffer.
+*/
+#define MAX_DATE_STRING_REP_LENGTH 30
+
+int my_time_to_str(const MYSQL_TIME *l_time, char *to);
+int my_date_to_str(const MYSQL_TIME *l_time, char *to);
+int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
+int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
+
+C_MODE_END
+
+#endif /* _my_time_h_ */
diff --git a/include/my_tree.h b/include/my_tree.h
index 6aec50215ca..14d8593b6dc 100644
--- a/include/my_tree.h
+++ b/include/my_tree.h
@@ -20,8 +20,10 @@
extern "C" {
#endif
-/* Worst case tree is half full. This gives use 2^(MAX_TREE_HIGHT/2) leafs */
-#define MAX_TREE_HIGHT 64
+#include "my_base.h" /* get 'enum ha_rkey_function' */
+
+/* Worst case tree is half full. This gives use 2^(MAX_TREE_HEIGHT/2) leafs */
+#define MAX_TREE_HEIGHT 64
#define ELEMENT_KEY(tree,element)\
(tree->offset_to_key ? (void*)((byte*) element+tree->offset_to_key) :\
@@ -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 cad48e2d331..6d097770646 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 64 /* 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 */
@@ -43,7 +47,7 @@ extern "C" {
#define MI_NAME_IEXT ".MYI"
#define MI_NAME_DEXT ".MYD"
/* Max extra space to use when sorting keys */
-#define MI_MAX_TEMP_LENGTH 256*1024L*1024L
+#define MI_MAX_TEMP_LENGTH 2*1024L*1024L*1024L
/* Possible values for myisam_block_size (must be power of 2) */
#define MI_KEY_BLOCK_LENGTH 1024 /* default key block length */
@@ -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 */
@@ -107,20 +109,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 */
@@ -137,7 +125,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,
@@ -149,6 +137,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;
@@ -159,7 +149,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 */
@@ -203,7 +193,7 @@ extern uint myisam_block_size;
extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user;
extern my_bool myisam_concurrent_insert;
extern my_off_t myisam_max_temp_length,myisam_max_extra_temp_length;
-extern ulong myisam_bulk_insert_tree_size;
+extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size;
/* Prototypes for myisam-functions */
@@ -242,10 +232,7 @@ extern int mi_extra(struct st_myisam_info *file,
enum ha_extra_function function,
void *extra_arg);
extern ha_rows mi_records_in_range(struct st_myisam_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);
+ key_range *min_key, key_range *max_key);
extern int mi_log(int activate_log);
extern int mi_is_changed(struct st_myisam_info *info);
extern int mi_delete_all_rows(struct st_myisam_info *info);
@@ -323,11 +310,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;
@@ -337,11 +326,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;
@@ -353,6 +343,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
{
@@ -365,7 +361,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;
@@ -373,33 +370,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);
@@ -420,7 +390,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);
@@ -430,9 +399,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);
@@ -442,6 +409,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..de8a36c2d0a 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);
@@ -100,10 +101,7 @@ extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function,
void *extra_arg);
extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv);
extern ha_rows myrg_records_in_range(MYRG_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);
+ key_range *min_key, key_range *max_key);
extern ulonglong myrg_position(MYRG_INFO *info);
#ifdef __cplusplus
diff --git a/include/myisampack.h b/include/myisampack.h
index 6004177cfb0..c92429e4c01 100644
--- a/include/myisampack.h
+++ b/include/myisampack.h
@@ -21,209 +21,219 @@
better compression
*/
-#define mi_sint2korr(A) (int16) (((int16) ((uchar) (A)[1])) +\
- ((int16) ((int16) (A)[0]) << 8))
-#define mi_sint3korr(A) ((int32) ((((uchar) (A)[0]) & 128) ? \
- (((uint32) 255L << 24) | \
- (((uint32) (uchar) (A)[0]) << 16) |\
- (((uint32) (uchar) (A)[1]) << 8) | \
- ((uint32) (uchar) (A)[2])) : \
- (((uint32) (uchar) (A)[0]) << 16) |\
- (((uint32) (uchar) (A)[1]) << 8) | \
- ((uint32) (uchar) (A)[2])))
-#define mi_sint4korr(A) (int32) (((int32) ((uchar) (A)[3])) +\
- (((int32) ((uchar) (A)[2]) << 8)) +\
- (((int32) ((uchar) (A)[1]) << 16)) +\
- (((int32) ((int16) (A)[0]) << 24)))
-#define mi_sint8korr(A) (longlong) mi_uint8korr(A)
-#define mi_uint2korr(A) (uint16) (((uint16) ((uchar) (A)[1])) +\
- ((uint16) ((uchar) (A)[0]) << 8))
-#define mi_uint3korr(A) (uint32) (((uint32) ((uchar) (A)[2])) +\
- (((uint32) ((uchar) (A)[1])) << 8) +\
- (((uint32) ((uchar) (A)[0])) << 16))
-#define mi_uint4korr(A) (uint32) (((uint32) ((uchar) (A)[3])) +\
- (((uint32) ((uchar) (A)[2])) << 8) +\
- (((uint32) ((uchar) (A)[1])) << 16) +\
- (((uint32) ((uchar) (A)[0])) << 24))
-#define mi_uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[4])) +\
- (((uint32) ((uchar) (A)[3])) << 8) +\
- (((uint32) ((uchar) (A)[2])) << 16) +\
- (((uint32) ((uchar) (A)[1])) << 24)) +\
- (((ulonglong) ((uchar) (A)[0])) << 32))
-#define mi_uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[5])) +\
- (((uint32) ((uchar) (A)[4])) << 8) +\
- (((uint32) ((uchar) (A)[3])) << 16) +\
- (((uint32) ((uchar) (A)[2])) << 24)) +\
- (((ulonglong) (((uint32) ((uchar) (A)[1])) +\
- (((uint32) ((uchar) (A)[0]) << 8)))) <<\
- 32))
-#define mi_uint7korr(A) ((ulonglong)(((uint32) ((uchar) (A)[6])) +\
- (((uint32) ((uchar) (A)[5])) << 8) +\
- (((uint32) ((uchar) (A)[4])) << 16) +\
- (((uint32) ((uchar) (A)[3])) << 24)) +\
- (((ulonglong) (((uint32) ((uchar) (A)[2])) +\
- (((uint32) ((uchar) (A)[1])) << 8) +\
- (((uint32) ((uchar) (A)[0])) << 16))) <<\
- 32))
-#define mi_uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[7])) +\
- (((uint32) ((uchar) (A)[6])) << 8) +\
- (((uint32) ((uchar) (A)[5])) << 16) +\
- (((uint32) ((uchar) (A)[4])) << 24)) +\
- (((ulonglong) (((uint32) ((uchar) (A)[3])) +\
- (((uint32) ((uchar) (A)[2])) << 8) +\
- (((uint32) ((uchar) (A)[1])) << 16) +\
- (((uint32) ((uchar) (A)[0])) << 24))) <<\
- 32))
-
-#define mi_int2store(T,A) { uint def_temp= (uint) (A) ;\
- *((uchar*) ((T)+1))= (uchar)(def_temp); \
- *((uchar*) ((T)+0))= (uchar)(def_temp >> 8); }
-#define mi_int3store(T,A) { /*lint -save -e734 */\
- ulong def_temp= (ulong) (A);\
- *(((T)+2))=(char) (def_temp);\
- *((T)+1)= (char) (def_temp >> 8);\
- *((T)+0)= (char) (def_temp >> 16);\
- /*lint -restore */}
-#define mi_int4store(T,A) { ulong def_temp= (ulong) (A);\
- *((T)+3)=(char) (def_temp);\
- *((T)+2)=(char) (def_temp >> 8);\
- *((T)+1)=(char) (def_temp >> 16);\
- *((T)+0)=(char) (def_temp >> 24); }
-#define mi_int5store(T,A) { ulong def_temp= (ulong) (A),\
- def_temp2= (ulong) ((A) >> 32);\
- *((T)+4)=(char) (def_temp);\
- *((T)+3)=(char) (def_temp >> 8);\
- *((T)+2)=(char) (def_temp >> 16);\
- *((T)+1)=(char) (def_temp >> 24);\
- *((T)+0)=(char) (def_temp2); }
-#define mi_int6store(T,A) { ulong def_temp= (ulong) (A),\
- def_temp2= (ulong) ((A) >> 32);\
- *((T)+5)=(char) (def_temp);\
- *((T)+4)=(char) (def_temp >> 8);\
- *((T)+3)=(char) (def_temp >> 16);\
- *((T)+2)=(char) (def_temp >> 24);\
- *((T)+1)=(char) (def_temp2);\
- *((T)+0)=(char) (def_temp2 >> 8); }
-#define mi_int7store(T,A) { ulong def_temp= (ulong) (A),\
- def_temp2= (ulong) ((A) >> 32);\
- *((T)+6)=(char) (def_temp);\
- *((T)+5)=(char) (def_temp >> 8);\
- *((T)+4)=(char) (def_temp >> 16);\
- *((T)+3)=(char) (def_temp >> 24);\
- *((T)+2)=(char) (def_temp2);\
- *((T)+1)=(char) (def_temp2 >> 8);\
- *((T)+0)=(char) (def_temp2 >> 16); }
-#define mi_int8store(T,A) { ulong def_temp3= (ulong) (A), \
- def_temp4= (ulong) ((A) >> 32); \
- mi_int4store((T),def_temp4); \
- mi_int4store((T+4),def_temp3); \
- }
+/* these two are for uniformity */
+#define mi_sint1korr(A) ((int8)(*A))
+#define mi_uint1korr(A) ((uint8)(*A))
+
+#define mi_sint2korr(A) ((int16) (((int16) (((uchar*) (A))[1])) +\
+ ((int16) ((int16) ((char*) (A))[0]) << 8)))
+#define mi_sint3korr(A) ((int32) (((((uchar*) (A))[0]) & 128) ? \
+ (((uint32) 255L << 24) | \
+ (((uint32) ((uchar*) (A))[0]) << 16) |\
+ (((uint32) ((uchar*) (A))[1]) << 8) | \
+ ((uint32) ((uchar*) (A))[2])) : \
+ (((uint32) ((uchar*) (A))[0]) << 16) |\
+ (((uint32) ((uchar*) (A))[1]) << 8) | \
+ ((uint32) ((uchar*) (A))[2])))
+#define mi_sint4korr(A) ((int32) (((int32) (((uchar*) (A))[3])) +\
+ ((int32) (((uchar*) (A))[2]) << 8) +\
+ ((int32) (((uchar*) (A))[1]) << 16) +\
+ ((int32) ((int16) ((char*) (A))[0]) << 24)))
+#define mi_sint8korr(A) ((longlong) mi_uint8korr(A))
+#define mi_uint2korr(A) ((uint16) (((uint16) (((uchar*) (A))[1])) +\
+ ((uint16) (((uchar*) (A))[0]) << 8)))
+#define mi_uint3korr(A) ((uint32) (((uint32) (((uchar*) (A))[2])) +\
+ (((uint32) (((uchar*) (A))[1])) << 8) +\
+ (((uint32) (((uchar*) (A))[0])) << 16)))
+#define mi_uint4korr(A) ((uint32) (((uint32) (((uchar*) (A))[3])) +\
+ (((uint32) (((uchar*) (A))[2])) << 8) +\
+ (((uint32) (((uchar*) (A))[1])) << 16) +\
+ (((uint32) (((uchar*) (A))[0])) << 24)))
+#define mi_uint5korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[4])) +\
+ (((uint32) (((uchar*) (A))[3])) << 8) +\
+ (((uint32) (((uchar*) (A))[2])) << 16) +\
+ (((uint32) (((uchar*) (A))[1])) << 24)) +\
+ (((ulonglong) (((uchar*) (A))[0])) << 32))
+#define mi_uint6korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[5])) +\
+ (((uint32) (((uchar*) (A))[4])) << 8) +\
+ (((uint32) (((uchar*) (A))[3])) << 16) +\
+ (((uint32) (((uchar*) (A))[2])) << 24)) +\
+ (((ulonglong) (((uint32) (((uchar*) (A))[1])) +\
+ (((uint32) (((uchar*) (A))[0]) << 8)))) <<\
+ 32))
+#define mi_uint7korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[6])) +\
+ (((uint32) (((uchar*) (A))[5])) << 8) +\
+ (((uint32) (((uchar*) (A))[4])) << 16) +\
+ (((uint32) (((uchar*) (A))[3])) << 24)) +\
+ (((ulonglong) (((uint32) (((uchar*) (A))[2])) +\
+ (((uint32) (((uchar*) (A))[1])) << 8) +\
+ (((uint32) (((uchar*) (A))[0])) << 16))) <<\
+ 32))
+#define mi_uint8korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[7])) +\
+ (((uint32) (((uchar*) (A))[6])) << 8) +\
+ (((uint32) (((uchar*) (A))[5])) << 16) +\
+ (((uint32) (((uchar*) (A))[4])) << 24)) +\
+ (((ulonglong) (((uint32) (((uchar*) (A))[3])) +\
+ (((uint32) (((uchar*) (A))[2])) << 8) +\
+ (((uint32) (((uchar*) (A))[1])) << 16) +\
+ (((uint32) (((uchar*) (A))[0])) << 24))) <<\
+ 32))
+
+/* This one is for uniformity */
+#define mi_int1store(T,A) *((uchar*)(T))= (uchar) (A)
+
+#define mi_int2store(T,A) { uint def_temp= (uint) (A) ;\
+ ((uchar*) (T))[1]= (uchar) (def_temp);\
+ ((uchar*) (T))[0]= (uchar) (def_temp >> 8); }
+#define mi_int3store(T,A) { /*lint -save -e734 */\
+ ulong def_temp= (ulong) (A);\
+ ((uchar*) (T))[2]= (uchar) (def_temp);\
+ ((uchar*) (T))[1]= (uchar) (def_temp >> 8);\
+ ((uchar*) (T))[0]= (uchar) (def_temp >> 16);\
+ /*lint -restore */}
+#define mi_int4store(T,A) { ulong def_temp= (ulong) (A);\
+ ((uchar*) (T))[3]= (uchar) (def_temp);\
+ ((uchar*) (T))[2]= (uchar) (def_temp >> 8);\
+ ((uchar*) (T))[1]= (uchar) (def_temp >> 16);\
+ ((uchar*) (T))[0]= (uchar) (def_temp >> 24); }
+#define mi_int5store(T,A) { ulong def_temp= (ulong) (A),\
+ def_temp2= (ulong) ((A) >> 32);\
+ ((uchar*) (T))[4]= (uchar) (def_temp);\
+ ((uchar*) (T))[3]= (uchar) (def_temp >> 8);\
+ ((uchar*) (T))[2]= (uchar) (def_temp >> 16);\
+ ((uchar*) (T))[1]= (uchar) (def_temp >> 24);\
+ ((uchar*) (T))[0]= (uchar) (def_temp2); }
+#define mi_int6store(T,A) { ulong def_temp= (ulong) (A),\
+ def_temp2= (ulong) ((A) >> 32);\
+ ((uchar*) (T))[5]= (uchar) (def_temp);\
+ ((uchar*) (T))[4]= (uchar) (def_temp >> 8);\
+ ((uchar*) (T))[3]= (uchar) (def_temp >> 16);\
+ ((uchar*) (T))[2]= (uchar) (def_temp >> 24);\
+ ((uchar*) (T))[1]= (uchar) (def_temp2);\
+ ((uchar*) (T))[0]= (uchar) (def_temp2 >> 8); }
+#define mi_int7store(T,A) { ulong def_temp= (ulong) (A),\
+ def_temp2= (ulong) ((A) >> 32);\
+ ((uchar*) (T))[6]= (uchar) (def_temp);\
+ ((uchar*) (T))[5]= (uchar) (def_temp >> 8);\
+ ((uchar*) (T))[4]= (uchar) (def_temp >> 16);\
+ ((uchar*) (T))[3]= (uchar) (def_temp >> 24);\
+ ((uchar*) (T))[2]= (uchar) (def_temp2);\
+ ((uchar*) (T))[1]= (uchar) (def_temp2 >> 8);\
+ ((uchar*) (T))[0]= (uchar) (def_temp2 >> 16); }
+#define mi_int8store(T,A) { ulong def_temp3= (ulong) (A),\
+ def_temp4= (ulong) ((A) >> 32);\
+ mi_int4store((uchar*) (T) + 0, def_temp4);\
+ mi_int4store((uchar*) (T) + 4, def_temp3); }
#ifdef WORDS_BIGENDIAN
-#define mi_float4store(T,A) { *(T)= ((byte *) &A)[0];\
- *((T)+1)=(char) ((byte *) &A)[1];\
- *((T)+2)=(char) ((byte *) &A)[2];\
- *((T)+3)=(char) ((byte *) &A)[3]; }
+#define mi_float4store(T,A) { ((uchar*) (T))[0]= ((uchar*) &A)[0];\
+ ((uchar*) (T))[1]= ((uchar*) &A)[1];\
+ ((uchar*) (T))[2]= ((uchar*) &A)[2];\
+ ((uchar*) (T))[3]= ((uchar*) &A)[3]; }
#define mi_float4get(V,M) { float def_temp;\
- ((byte*) &def_temp)[0]=(M)[0];\
- ((byte*) &def_temp)[1]=(M)[1];\
- ((byte*) &def_temp)[2]=(M)[2];\
- ((byte*) &def_temp)[3]=(M)[3];\
- (V)=def_temp; }
-
-#define mi_float8store(T,V) { *(T)= ((byte *) &V)[0];\
- *((T)+1)=(char) ((byte *) &V)[1];\
- *((T)+2)=(char) ((byte *) &V)[2];\
- *((T)+3)=(char) ((byte *) &V)[3];\
- *((T)+4)=(char) ((byte *) &V)[4];\
- *((T)+5)=(char) ((byte *) &V)[5];\
- *((T)+6)=(char) ((byte *) &V)[6];\
- *((T)+7)=(char) ((byte *) &V)[7]; }
+ ((uchar*) &def_temp)[0]= ((uchar*) (M))[0];\
+ ((uchar*) &def_temp)[1]= ((uchar*) (M))[1];\
+ ((uchar*) &def_temp)[2]= ((uchar*) (M))[2];\
+ ((uchar*) &def_temp)[3]= ((uchar*) (M))[3];\
+ (V)= def_temp; }
+
+#define mi_float8store(T,V) { ((uchar*) (T))[0]= ((uchar*) &V)[0];\
+ ((uchar*) (T))[1]= ((uchar*) &V)[1];\
+ ((uchar*) (T))[2]= ((uchar*) &V)[2];\
+ ((uchar*) (T))[3]= ((uchar*) &V)[3];\
+ ((uchar*) (T))[4]= ((uchar*) &V)[4];\
+ ((uchar*) (T))[5]= ((uchar*) &V)[5];\
+ ((uchar*) (T))[6]= ((uchar*) &V)[6];\
+ ((uchar*) (T))[7]= ((uchar*) &V)[7]; }
#define mi_float8get(V,M) { double def_temp;\
- ((byte*) &def_temp)[0]=(M)[0];\
- ((byte*) &def_temp)[1]=(M)[1];\
- ((byte*) &def_temp)[2]=(M)[2];\
- ((byte*) &def_temp)[3]=(M)[3];\
- ((byte*) &def_temp)[4]=(M)[4];\
- ((byte*) &def_temp)[5]=(M)[5];\
- ((byte*) &def_temp)[6]=(M)[6];\
- ((byte*) &def_temp)[7]=(M)[7]; \
- (V)=def_temp; }
+ ((uchar*) &def_temp)[0]= ((uchar*) (M))[0];\
+ ((uchar*) &def_temp)[1]= ((uchar*) (M))[1];\
+ ((uchar*) &def_temp)[2]= ((uchar*) (M))[2];\
+ ((uchar*) &def_temp)[3]= ((uchar*) (M))[3];\
+ ((uchar*) &def_temp)[4]= ((uchar*) (M))[4];\
+ ((uchar*) &def_temp)[5]= ((uchar*) (M))[5];\
+ ((uchar*) &def_temp)[6]= ((uchar*) (M))[6];\
+ ((uchar*) &def_temp)[7]= ((uchar*) (M))[7]; \
+ (V)= def_temp; }
#else
-#define mi_float4store(T,A) { *(T)= ((byte *) &A)[3];\
- *((T)+1)=(char) ((byte *) &A)[2];\
- *((T)+2)=(char) ((byte *) &A)[1];\
- *((T)+3)=(char) ((byte *) &A)[0]; }
+#define mi_float4store(T,A) { ((uchar*) (T))[0]= ((uchar*) &A)[3];\
+ ((uchar*) (T))[1]= ((uchar*) &A)[2];\
+ ((uchar*) (T))[2]= ((uchar*) &A)[1];\
+ ((uchar*) (T))[3]= ((uchar*) &A)[0]; }
#define mi_float4get(V,M) { float def_temp;\
- ((byte*) &def_temp)[0]=(M)[3];\
- ((byte*) &def_temp)[1]=(M)[2];\
- ((byte*) &def_temp)[2]=(M)[1];\
- ((byte*) &def_temp)[3]=(M)[0];\
- (V)=def_temp; }
+ ((uchar*) &def_temp)[0]= ((uchar*) (M))[3];\
+ ((uchar*) &def_temp)[1]= ((uchar*) (M))[2];\
+ ((uchar*) &def_temp)[2]= ((uchar*) (M))[1];\
+ ((uchar*) &def_temp)[3]= ((uchar*) (M))[0];\
+ (V)= def_temp; }
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
-#define mi_float8store(T,V) { *(T)= ((byte *) &V)[3];\
- *((T)+1)=(char) ((byte *) &V)[2];\
- *((T)+2)=(char) ((byte *) &V)[1];\
- *((T)+3)=(char) ((byte *) &V)[0];\
- *((T)+4)=(char) ((byte *) &V)[7];\
- *((T)+5)=(char) ((byte *) &V)[6];\
- *((T)+6)=(char) ((byte *) &V)[5];\
- *((T)+7)=(char) ((byte *) &V)[4];}
+#define mi_float8store(T,V) { ((uchar*) (T))[0]= ((uchar*) &V)[3];\
+ ((uchar*) (T))[1]= ((uchar*) &V)[2];\
+ ((uchar*) (T))[2]= ((uchar*) &V)[1];\
+ ((uchar*) (T))[3]= ((uchar*) &V)[0];\
+ ((uchar*) (T))[4]= ((uchar*) &V)[7];\
+ ((uchar*) (T))[5]= ((uchar*) &V)[6];\
+ ((uchar*) (T))[6]= ((uchar*) &V)[5];\
+ ((uchar*) (T))[7]= ((uchar*) &V)[4];}
#define mi_float8get(V,M) { double def_temp;\
- ((byte*) &def_temp)[0]=(M)[3];\
- ((byte*) &def_temp)[1]=(M)[2];\
- ((byte*) &def_temp)[2]=(M)[1];\
- ((byte*) &def_temp)[3]=(M)[0];\
- ((byte*) &def_temp)[4]=(M)[7];\
- ((byte*) &def_temp)[5]=(M)[6];\
- ((byte*) &def_temp)[6]=(M)[5];\
- ((byte*) &def_temp)[7]=(M)[4];\
- (V)=def_temp; }
+ ((uchar*) &def_temp)[0]= ((uchar*) (M))[3];\
+ ((uchar*) &def_temp)[1]= ((uchar*) (M))[2];\
+ ((uchar*) &def_temp)[2]= ((uchar*) (M))[1];\
+ ((uchar*) &def_temp)[3]= ((uchar*) (M))[0];\
+ ((uchar*) &def_temp)[4]= ((uchar*) (M))[7];\
+ ((uchar*) &def_temp)[5]= ((uchar*) (M))[6];\
+ ((uchar*) &def_temp)[6]= ((uchar*) (M))[5];\
+ ((uchar*) &def_temp)[7]= ((uchar*) (M))[4];\
+ (V)= def_temp; }
#else
-#define mi_float8store(T,V) { *(T)= ((byte *) &V)[7];\
- *((T)+1)=(char) ((byte *) &V)[6];\
- *((T)+2)=(char) ((byte *) &V)[5];\
- *((T)+3)=(char) ((byte *) &V)[4];\
- *((T)+4)=(char) ((byte *) &V)[3];\
- *((T)+5)=(char) ((byte *) &V)[2];\
- *((T)+6)=(char) ((byte *) &V)[1];\
- *((T)+7)=(char) ((byte *) &V)[0];}
+#define mi_float8store(T,V) { ((uchar*) (T))[0]= ((uchar*) &V)[7];\
+ ((uchar*) (T))[1]= ((uchar*) &V)[6];\
+ ((uchar*) (T))[2]= ((uchar*) &V)[5];\
+ ((uchar*) (T))[3]= ((uchar*) &V)[4];\
+ ((uchar*) (T))[4]= ((uchar*) &V)[3];\
+ ((uchar*) (T))[5]= ((uchar*) &V)[2];\
+ ((uchar*) (T))[6]= ((uchar*) &V)[1];\
+ ((uchar*) (T))[7]= ((uchar*) &V)[0];}
#define mi_float8get(V,M) { double def_temp;\
- ((byte*) &def_temp)[0]=(M)[7];\
- ((byte*) &def_temp)[1]=(M)[6];\
- ((byte*) &def_temp)[2]=(M)[5];\
- ((byte*) &def_temp)[3]=(M)[4];\
- ((byte*) &def_temp)[4]=(M)[3];\
- ((byte*) &def_temp)[5]=(M)[2];\
- ((byte*) &def_temp)[6]=(M)[1];\
- ((byte*) &def_temp)[7]=(M)[0];\
- (V)=def_temp; }
+ ((uchar*) &def_temp)[0]= ((uchar*) (M))[7];\
+ ((uchar*) &def_temp)[1]= ((uchar*) (M))[6];\
+ ((uchar*) &def_temp)[2]= ((uchar*) (M))[5];\
+ ((uchar*) &def_temp)[3]= ((uchar*) (M))[4];\
+ ((uchar*) &def_temp)[4]= ((uchar*) (M))[3];\
+ ((uchar*) &def_temp)[5]= ((uchar*) (M))[2];\
+ ((uchar*) &def_temp)[6]= ((uchar*) (M))[1];\
+ ((uchar*) &def_temp)[7]= ((uchar*) (M))[0];\
+ (V)= def_temp; }
#endif /* __FLOAT_WORD_ORDER */
#endif /* WORDS_BIGENDIAN */
/* Fix to avoid warnings when sizeof(ha_rows) == sizeof(long) */
#ifdef BIG_TABLES
-#define mi_rowstore(T,A) mi_int8store(T,A)
-#define mi_rowkorr(T) mi_uint8korr(T)
+#define mi_rowstore(T,A) mi_int8store(T, A)
+#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)
+#define mi_rowstore(T,A) { mi_int4store(T, 0);\
+ mi_int4store(((uchar*) (T) + 4), A); }
+#define mi_rowkorr(T) mi_uint4korr((uchar*) (T) + 4)
#endif
#if SIZEOF_OFF_T > 4
-#define mi_sizestore(T,A) mi_int8store(T,A)
-#define mi_sizekorr(T) mi_uint8korr(T)
+#define mi_sizestore(T,A) mi_int8store(T, A)
+#define mi_sizekorr(T) mi_uint8korr(T)
#else
-#define mi_sizestore(T,A) { if ((A) == HA_OFFSET_ERROR) bfill((char*) (T),8,255); else { mi_int4store((T),0); mi_int4store(((T)+4),A); }}
-#define mi_sizekorr(T) mi_uint4korr((T)+4)
+#define mi_sizestore(T,A) { if ((A) == HA_OFFSET_ERROR)\
+ bfill((char*) (T), 8, 255);\
+ else { mi_int4store((T), 0);\
+ mi_int4store(((T) + 4), A); }}
+#define mi_sizekorr(T) mi_uint4korr((uchar*) (T) + 4)
#endif
diff --git a/include/mysql.h b/include/mysql.h
index 08ea2da2e58..0949937814c 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -55,7 +55,11 @@ typedef int my_socket;
#endif /* _global_h */
#include "mysql_com.h"
+#include "mysql_time.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 +78,34 @@ 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)
+
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 (create length) */
+ unsigned long max_length; /* Max width for 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. See 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,12 +113,14 @@ typedef unsigned __int64 my_ulonglong;
#else
typedef unsigned long long my_ulonglong;
#endif
+#endif
#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
typedef struct st_mysql_rows {
struct st_mysql_rows *next; /* list of rows */
MYSQL_ROW data;
+ unsigned long length;
} MYSQL_ROWS;
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
@@ -114,18 +132,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;
@@ -140,35 +175,54 @@ struct st_mysql_options {
*/
my_bool rpl_parse;
/*
- If set, never read from a master,only from slave, when doing
+ If set, never read from a master, only from slave, when doing
a read that is replication-aware
*/
my_bool no_master_reads;
+#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
+ my_bool separate_thread;
+#endif
+ 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;
+
+ /* function pointers for local infile support */
+ int (*local_infile_init)(void **, const char *, void *);
+ int (*local_infile_read)(void *, char *, unsigned int);
+ void (*local_infile_end)(void *);
+ int (*local_infile_error)(void *, char *, unsigned int);
+ void *local_infile_userdata;
};
-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 +231,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 +260,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 +283,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 +297,9 @@ 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
@@ -262,6 +334,17 @@ typedef struct st_mysql_parameters
*/
int STDCALL mysql_server_init(int argc, char **argv, char **groups);
void STDCALL mysql_server_end(void);
+/*
+ mysql_server_init/end need to be called when using libmysqld or
+ libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
+ you don't need to call it explicitely; but you need to call
+ mysql_server_end() to free memory). The names are a bit misleading
+ (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general
+ names which suit well whether you're using libmysqld or libmysqlclient. We
+ intend to promote these aliases over the mysql_server* ones.
+*/
+#define mysql_library_init mysql_server_init
+#define mysql_library_end mysql_server_end
MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void);
@@ -293,12 +376,15 @@ 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);
+int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname);
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,
@@ -309,25 +395,45 @@ 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);
+
+/* local infile support */
+
+#define LOCAL_INFILE_ERROR_LEN 512
+
+void
+mysql_set_local_infile_handler(MYSQL *mysql,
+ int (*local_infile_init)(void **, const char *,
+ void *),
+ int (*local_infile_read)(void *, char *,
+ unsigned int),
+ void (*local_infile_end)(void *),
+ int (*local_infile_error)(void *, char*,
+ unsigned int),
+ void *);
+
+void
+mysql_set_local_infile_default(MYSQL *mysql);
+
/*
enable/disable parsing of all queries to decide if they go on master or
@@ -342,12 +448,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,
@@ -359,25 +465,27 @@ int STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
const char* user,
const char* passwd);
-int STDCALL mysql_shutdown(MYSQL *mysql);
+int STDCALL mysql_shutdown(MYSQL *mysql,
+ enum mysql_enum_shutdown_level
+ shutdown_level);
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);
@@ -390,6 +498,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_hex_string(char *to,const char *from,
@@ -410,6 +520,7 @@ char * STDCALL mysql_odbc_escape_string(MYSQL *mysql,
unsigned long *length));
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
unsigned int STDCALL mysql_thread_safe(void);
+my_bool STDCALL mysql_embedded(void);
MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con);
MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
const char* host,
@@ -422,6 +533,180 @@ 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
+};
+
+
+/* bind structure */
+typedef struct st_mysql_bind
+{
+ unsigned long *length; /* output length pointer */
+ my_bool *is_null; /* Pointer to null indicator */
+ void *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_stmt_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 */
+ unsigned int pack_length; /* Internal length for packed data */
+ my_bool is_unsigned; /* set if integer type is unsigned */
+ my_bool long_data_used; /* If used with mysql_send_long_data */
+ 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);
+ void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *,
+ 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_DATA result; /* cached result set */
+ MYSQL_ROWS *data_cursor; /* current row in cached result */
+ /* copy of mysql->affected_rows after statement execution */
+ my_ulonglong affected_rows;
+ my_ulonglong insert_id; /* copy of mysql->insert_id */
+ /*
+ 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; /* input parameter 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;
+ /*
+ Is set to true if we need to calculate field->max_length for
+ metadata fields when doing mysql_stmt_store_result.
+ */
+ my_bool update_max_length;
+} MYSQL_STMT;
+
+enum enum_stmt_attr_type
+{
+ /*
+ When doing mysql_stmt_store_result calculate max_length attribute
+ of statement metadata. This is to be consistent with the old API,
+ where this was done automatically.
+ In the new API we do that only by request because it slows down
+ mysql_stmt_store_result sufficiently.
+ */
+ STMT_ATTR_UPDATE_MAX_LENGTH
+};
+
+
+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);
+ void (*flush_use_result)(MYSQL *mysql);
+#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);
+ int (*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);
+ my_bool (*next_result)(MYSQL *mysql);
+ int (*read_change_user_result)(MYSQL *mysql, char *buff, const char *passwd);
+#endif
+} MYSQL_METHODS;
+
+
+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_attr_set(MYSQL_STMT *stmt,
+ enum enum_stmt_attr_type attr_type,
+ const void *attr);
+my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
+ enum enum_stmt_attr_type attr_type,
+ void *attr);
+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_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt);
+unsigned int STDCALL mysql_stmt_field_count(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
@@ -438,12 +723,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 94b864375ba..56c7f7d2ab5 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -25,24 +25,44 @@
#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,
+ /* don't forget to update const char *command_name[] in sql_parse.cc */
+
+ /* Must be last */
+ COM_END
};
+
+/*
+ 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 +70,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 */
@@ -60,6 +81,7 @@ enum enum_server_command {
#define PART_KEY_FLAG 16384 /* Intern; Part of some key */
#define GROUP_FLAG 32768 /* Intern: Group field */
#define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */
+#define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */
#define REFRESH_GRANT 1 /* Refresh grant tables */
#define REFRESH_LOG 2 /* Start on new log file */
@@ -91,15 +113,26 @@ 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) 1) << 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 SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */
+
+#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 */
@@ -107,20 +140,24 @@ enum enum_server_command {
struct st_vio; /* Only C */
typedef struct st_vio Vio;
+#define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */
+#define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */
+#define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */
+#define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */
+#define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */
#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */
#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 +168,109 @@ 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
+
+
+/* Shutdown/kill enums and constants */
+
+/* Bits for THD::killable. */
+#define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
+#define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
+#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
+#define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
+
+enum mysql_enum_shutdown_level {
+ /*
+ We want levels to be in growing order of hardness (because we use number
+ comparisons). Note that DEFAULT does not respect the growing property, but
+ it's ok.
+ */
+ SHUTDOWN_DEFAULT = 0,
+ /* wait for existing connections to finish */
+ SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
+ /* wait for existing trans to finish */
+ SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
+ /* wait for existing updates to finish (=> no partial MyISAM update) */
+ SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
+ /* flush InnoDB buffers and other storage engines' buffers*/
+ SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
+ /* don't flush InnoDB buffers, flush other storage engines' buffers*/
+ SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
+ /* Now the 2 levels of the KILL command */
+#if MYSQL_VERSION_ID >= 50000
+ KILL_QUERY= 254,
+#endif
+ KILL_CONNECTION= 255
+};
+
+/* 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 +278,23 @@ 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);
+my_bool net_flush(NET *net);
+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 +310,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
{
@@ -223,18 +342,35 @@ typedef struct st_udf_init
extern "C" {
#endif
-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 */
@@ -244,10 +380,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 a061e68a974..603af8e83b8 100644
--- a/include/mysql_embed.h
+++ b/include/mysql_embed.h
@@ -19,12 +19,14 @@
#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 */
+#undef HAVE_NDBCLUSTER_DB /* No NDB cluster */
#define DONT_USE_RAID
diff --git a/include/mysql_time.h b/include/mysql_time.h
new file mode 100644
index 00000000000..5f4fc12c005
--- /dev/null
+++ b/include/mysql_time.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 2004 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 */
+
+#ifndef _mysql_time_h_
+#define _mysql_time_h_
+
+/*
+ Time declarations shared between the server and client API:
+ you should not add anything to this header unless it's used
+ (and hence should be visible) in mysql.h.
+ If you're looking for a place to add new time-related declaration,
+ it's most likely my_time.h. See also "C API Handling of Date
+ and Time Values" chapter in documentation.
+*/
+
+enum enum_mysql_timestamp_type
+{
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+
+
+/*
+ Structure which is used to represent datetime values inside MySQL.
+
+ We assume that values in this structure are normalized, i.e. year <= 9999,
+ month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions
+ in server such as my_system_gmt_sec() or make_time() family of functions
+ rely on this (actually now usage of make_*() family relies on a bit weaker
+ restriction). Also functions that produce MYSQL_TIME as result ensure this.
+ There is one exception to this rule though if this structure holds time
+ value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold
+ bigger values.
+*/
+typedef struct st_mysql_time
+{
+ unsigned int year, month, day, hour, minute, second;
+ unsigned long second_part;
+ my_bool neg;
+ enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+
+#endif /* _mysql_time_h_ */
diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in
index c15318424b1..dac7ca661d1 100644
--- a/include/mysql_version.h.in
+++ b/include/mysql_version.h.in
@@ -20,9 +20,6 @@
#define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@"
/* mysqld compile time options */
-#ifndef MYSQL_CHARSET
-#define MYSQL_CHARSET "@default_charset@"
-#endif /* MYSQL_CHARSET */
#endif /* _CUSTOMCONFIG_ */
#ifndef LICENSE
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index acc9b5961c6..776869ff045 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,70 @@
#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_TOO_MUCH_AUTO_TIMESTAMP_COLS 1293
+#define ER_INVALID_ON_UPDATE 1294
+#define ER_UNSUPPORTED_PS 1295
+#define ER_GET_ERRMSG 1296
+#define ER_GET_TEMPORARY_ERRMSG 1297
+#define ER_UNKNOWN_TIME_ZONE 1298
+#define ER_WARN_INVALID_TIMESTAMP 1299
+#define ER_INVALID_CHARACTER_STRING 1300
+#define ER_WARN_ALLOWED_PACKET_OVERFLOWED 1301
+#define ER_CONFLICTING_DECLARATIONS 1302
+#define ER_ERROR_MESSAGES 303
diff --git a/include/mysys_err.h b/include/mysys_err.h
index 0ee89e91ee4..19106dc3553 100644
--- a/include/mysys_err.h
+++ b/include/mysys_err.h
@@ -21,7 +21,7 @@ extern "C" {
#endif
#define GLOB 0 /* Error maps */
-#define GLOBERRS 28 /* Max number of error messages in map's */
+#define GLOBERRS 29 /* Max number of error messages in map's */
#define EE(X) globerrs[ X ] /* Defines to add error to right map */
extern const char * NEAR globerrs[]; /* my_error_messages is here */
@@ -54,6 +54,7 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */
#define EE_CANT_SYMLINK 25
#define EE_REALPATH 26
#define EE_SYNC 27
+#define EE_UNKNOWN_COLLATION 28
/* exit codes for all MySQL programs */
@@ -68,6 +69,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/raid.h b/include/raid.h
index b5a5e665824..c840afcbaab 100644
--- a/include/raid.h
+++ b/include/raid.h
@@ -32,9 +32,6 @@ C_MODE_END
#endif
#if defined(USE_RAID)
-#ifdef __GNUC__
-#pragma interface /* gcc class implementation */
-#endif
#include "my_dir.h"
/* Trap all occurences of my_...() in source and use our wrapper around this function */
@@ -92,6 +89,10 @@ extern "C" {
#ifdef __cplusplus
}
+#ifdef USE_PRAGMA_INTERFACE
+#pragma interface /* gcc class implementation */
+#endif
+
class RaidName {
public:
RaidName(const char *FileName);
diff --git a/include/sql_common.h b/include/sql_common.h
new file mode 100644
index 00000000000..c07a4a831bb
--- /dev/null
+++ b/include/sql_common.h
@@ -0,0 +1,46 @@
+/* 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 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..52a359405e1
--- /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 are sorted in the same order as in mysqld_error.h
+ to allow one 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 1062a49472b..7459ab7aefc 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..4d6a90ad51e
--- /dev/null
+++ b/include/typelib.h
@@ -0,0 +1,34 @@
+/* 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;
+ unsigned int *type_lengths;
+} 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 6c4a42b1a53..4b644051dd2 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -31,27 +31,33 @@
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
-void vio_delete(Vio* vio);
-int vio_close(Vio* vio);
-
-#ifdef EMBEDDED_LIBRARY
-void vio_reset(Vio *vio);
+Vio* vio_new_win32pipe(HANDLE hPipe);
+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,
+ HANDLE event_conn_closed);
+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
-void vio_reset(Vio* vio, enum enum_vio_type type,
- my_socket sd, HANDLE hPipe, my_bool localhost);
-#endif
+#define HANDLE void *
+#endif /* __WIN__ */
+void vio_delete(Vio* vio);
+int vio_close(Vio* vio);
+void vio_reset(Vio* vio, enum enum_vio_type type,
+ my_socket sd, HANDLE hPipe, my_bool localhost);
int vio_read(Vio *vio, gptr buf, int size);
int vio_write(Vio *vio, const gptr buf, int size);
int vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode);
@@ -67,15 +73,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 which, uint timeout);
#ifdef HAVE_OPENSSL
#include <openssl/opensslv.h>
@@ -117,6 +123,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
@@ -126,8 +138,8 @@ Vio *new_VioSSL(struct st_VioSSLAcceptorFd *fd, Vio *sd, int state);
#if defined(HAVE_VIO) && !defined(DONT_MAP_VIO)
#define vio_delete(vio) (vio)->viodelete(vio)
#define vio_errno(vio) (vio)->vioerrno(vio)
-#define vio_read(vio, buf, size) (vio)->read(vio,buf,size)
-#define vio_write(vio, buf, size) (vio)->write(vio, buf, size)
+#define vio_read(vio, buf, size) ((vio)->read)(vio,buf,size)
+#define vio_write(vio, buf, size) ((vio)->write)(vio, buf, size)
#define vio_blocking(vio, set_blocking_mode, old_mode)\
(vio)->vioblocking(vio, set_blocking_mode, old_mode)
#define vio_is_blocking(vio) (vio)->is_blocking(vio)
@@ -137,7 +149,7 @@ Vio *new_VioSSL(struct st_VioSSLAcceptorFd *fd, Vio *sd, int state);
#define vio_close(vio) ((vio)->vioclose)(vio)
#define vio_peer_addr(vio, buf, prt) (vio)->peer_addr(vio, buf, prt)
#define vio_in_addr(vio, in) (vio)->in_addr(vio, in)
-#define vio_timeout(vio, seconds) (vio)->timeout(vio, seconds)
+#define vio_timeout(vio, which, seconds) (vio)->timeout(vio, which, seconds)
#endif /* defined(HAVE_VIO) && !defined(DONT_MAP_VIO) */
/* This enumerator is used in parser - should be always visible */
@@ -150,7 +162,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
{
@@ -167,7 +180,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);
@@ -176,9 +189,20 @@ struct st_vio
void (*in_addr)(Vio*, struct in_addr*);
my_bool (*should_retry)(Vio*);
int (*vioclose)(Vio*);
- void (*timeout)(Vio*, unsigned int timeout);
+ void (*timeout)(Vio*, unsigned int which, 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;
+ HANDLE event_conn_closed;
+ long shared_memory_remain;
+ char *shared_memory_pos;
+ NET *net;
+#endif /* HAVE_SMEM */
#endif /* HAVE_VIO */
};
-#endif /* EMBEDDED_LIBRARY */
#endif /* vio_violite_h_ */