diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/errmsg.h | 8 | ||||
-rw-r--r-- | include/ft_global.h | 12 | ||||
-rw-r--r-- | include/global.h | 13 | ||||
-rw-r--r-- | include/heap.h | 3 | ||||
-rw-r--r-- | include/my_base.h | 5 | ||||
-rw-r--r-- | include/my_pthread.h | 1 | ||||
-rw-r--r-- | include/my_sys.h | 15 | ||||
-rw-r--r-- | include/my_tree.h | 21 | ||||
-rw-r--r-- | include/myisam.h | 17 | ||||
-rw-r--r-- | include/mysql.h | 122 | ||||
-rw-r--r-- | include/mysql_com.h | 24 | ||||
-rw-r--r-- | include/mysqld_error.h | 11 | ||||
-rw-r--r-- | include/violite.h | 168 |
13 files changed, 345 insertions, 75 deletions
diff --git a/include/errmsg.h b/include/errmsg.h index 8087c526937..ecc9761a391 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -57,3 +57,11 @@ extern const char *client_errors[]; /* Error messages */ #define CR_NAMEDPIPESETSTATE_ERROR 2018 #define CR_CANT_READ_CHARSET 2019 #define CR_NET_PACKET_TOO_LARGE 2020 +#define CR_EMBEDDED_CONNECTION 2021 +#define CR_PROBE_SLAVE_STATUS 2022 +#define CR_PROBE_SLAVE_HOSTS 2023 +#define CR_PROBE_SLAVE_CONNECT 2024 +#define CR_PROBE_MASTER_CONNECT 2025 + + + diff --git a/include/ft_global.h b/include/ft_global.h index 3937bd87c7f..415c0884989 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -27,6 +27,7 @@ extern "C" { #endif #define FT_QUERY_MAXLEN 1024 +#define HA_FT_MAXLEN 254 typedef struct ft_doc_rec { my_off_t dpos; @@ -42,14 +43,19 @@ typedef struct st_ft_doclist { extern const char *ft_precompiled_stopwords[]; +extern uint ft_min_word_len; +extern uint ft_max_word_len; +extern uint ft_max_word_len_for_sort; + int ft_init_stopwords(const char **); void ft_free_stopwords(void); FT_DOCLIST * ft_init_search(void *, uint, byte *, uint, my_bool); int ft_read_next(FT_DOCLIST *, char *); -#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0)) -#define ft_get_relevance(handler) ((handler)->doc[(handler)->curdoc].weight) -#define ft_reinit_search(handler) (((FT_DOCLIST *)(handler))->curdoc=-1) +#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0)) +#define ft_get_relevance(handler) ((handler)->doc[(handler)->curdoc].weight) +#define ft_get_docid(handler) ((handler)->doc[(handler)->curdoc].dpos) +#define ft_reinit_search(handler) (((FT_DOCLIST *)(handler))->curdoc=-1) #ifdef __cplusplus } diff --git a/include/global.h b/include/global.h index f10411af0aa..0915047fddb 100644 --- a/include/global.h +++ b/include/global.h @@ -189,7 +189,13 @@ # endif #endif /* TIME_WITH_SYS_TIME */ #ifdef HAVE_UNISTD_H +#ifdef HAVE_OPENSSL +#define crypt dummy +#endif #include <unistd.h> +#ifdef HAVE_OPENSSL +#undef crypt +#endif #endif #if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA) #undef HAVE_ALLOCA @@ -351,6 +357,7 @@ typedef int pshort; /* Mixed prototypes can't take short int */ typedef double pfloat; /* Mixed prototypes can't take float */ #endif typedef int (*qsort_cmp)(const void *,const void *); +typedef int (*qsort_cmp2)(void*, const void *,const void *); #ifdef HAVE_mit_thread #define qsort_t void #undef QSORT_TYPE_IS_VOID @@ -799,9 +806,9 @@ typedef union { *((uchar*) (T))= (uchar)(def_temp); \ *((uchar*) (T+1))=(uchar)((def_temp >> 8)); } #define int3store(T,A) { /*lint -save -e734 */\ - *((T))=(char) ((A));\ - *((T)+1)=(char) (((A) >> 8));\ - *((T)+2)=(char) (((A) >> 16)); \ + *((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));\ diff --git a/include/heap.h b/include/heap.h index 14698810297..813df2a7ddd 100644 --- a/include/heap.h +++ b/include/heap.h @@ -109,6 +109,7 @@ typedef struct st_heap_share THR_LOCK lock; pthread_mutex_t intern_lock; /* Locking for use with _locking */ #endif + my_bool delete_on_close; LIST open_list; } HP_SHARE; @@ -144,7 +145,7 @@ 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_delete_all(const char *name); +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); extern int heap_panic(enum ha_panic_function flag); diff --git a/include/my_base.h b/include/my_base.h index bb2e4128195..e677f448c57 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -91,7 +91,10 @@ 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 */ + HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE, /* Cursor will not be used for update */ + HA_EXTRA_BULK_INSERT_BEGIN, + HA_EXTRA_BULK_INSERT_END, + HA_EXTRA_PREPARE_FOR_DELETE }; /* The following is parameter to ha_panic() */ diff --git a/include/my_pthread.h b/include/my_pthread.h index 33ad9ec0401..14ccd93a96c 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -622,5 +622,4 @@ extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const)); #ifdef __cplusplus } #endif - #endif /* _my_ptread_h */ diff --git a/include/my_sys.h b/include/my_sys.h index 5b45f6a91e5..b70d123a66a 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -110,7 +110,8 @@ extern int NEAR my_errno; /* Last error in mysys */ /* 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 */ #ifdef SAFEMALLOC @@ -246,7 +247,8 @@ typedef struct st_record_cache /* Used when cacheing records */ } RECORD_CACHE; enum file_type { UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, - STREAM_BY_FOPEN, STREAM_BY_FDOPEN, FILE_BY_MKSTEMP }; + STREAM_BY_FOPEN, STREAM_BY_FDOPEN, FILE_BY_MKSTEMP, + FILE_BY_DUP }; extern struct my_file_info { @@ -270,12 +272,19 @@ typedef struct st_dynamic_string { uint length,max_length,alloc_increment; } DYNAMIC_STRING; +struct st_io_cache; +typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*); typedef struct st_io_cache /* Used when cacheing files */ { my_off_t pos_in_file,end_of_file; byte *rc_pos,*rc_end,*buffer,*rc_request_pos; int (*read_function)(struct st_io_cache *,byte *,uint); + /* callbacks when the actual read I/O happens */ + IO_CACHE_CALLBACK pre_read; + IO_CACHE_CALLBACK post_read; + IO_CACHE_CALLBACK pre_close; + void* arg; /* for use by pre/post_read */ char *file_name; /* if used with 'open_cached_file' */ char *dir,*prefix; File file; @@ -380,6 +389,7 @@ extern File my_register_filename(File fd, const char *FileName, extern File my_create(const char *FileName,int CreateFlags, int AccsesFlags, myf MyFlags); extern int my_close(File Filedes,myf MyFlags); +extern File my_dup(File file, myf MyFlags); extern int my_mkdir(const char *dir, int Flags, myf MyFlags); extern int my_readlink(char *to, const char *filename, myf MyFlags); extern int my_realpath(char *to, const char *filename, myf MyFlags); @@ -581,6 +591,7 @@ extern void my_free_lock(byte *ptr,myf flags); void init_alloc_root(MEM_ROOT *mem_root, uint block_size, uint pre_alloc_size); gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); void free_root(MEM_ROOT *root, myf MyFLAGS); +void set_prealloc_root(MEM_ROOT *root, char *ptr); char *strdup_root(MEM_ROOT *root,const char *str); char *memdup_root(MEM_ROOT *root,const char *str,uint len); void load_defaults(const char *conf_file, const char **groups, diff --git a/include/my_tree.h b/include/my_tree.h index 0a227ea3944..d3adbe17e6f 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -32,6 +32,9 @@ typedef enum { left_root_right, right_root_left } TREE_WALK; typedef uint32 element_count; typedef int (*tree_walk_action)(void *,element_count,void *); +typedef enum { free_init, free_free, free_end } TREE_FREE; +typedef void (*tree_element_free)(void*, TREE_FREE, void *); + #ifdef MSDOS typedef struct st_tree_element { struct st_tree_element *left,*right; @@ -49,18 +52,22 @@ typedef struct st_tree_element { typedef struct st_tree { TREE_ELEMENT *root,null_element; TREE_ELEMENT **parents[MAX_TREE_HIGHT]; - uint offset_to_key,elements_in_tree,size_of_element; - qsort_cmp compare; + uint offset_to_key,elements_in_tree,size_of_element,memory_limit,allocated; + qsort_cmp2 compare; + void* custom_arg; MEM_ROOT mem_root; my_bool with_delete; - void (*free)(void *); + tree_element_free free; } TREE; - /* Functions on hole tree */ -void init_tree(TREE *tree,uint default_alloc_size, int element_size, - qsort_cmp compare, my_bool with_delete, - void (*free_element)(void*)); + /* Functions on whole tree */ +void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit, + int size, qsort_cmp2 compare, my_bool with_delete, + tree_element_free free_element, void *custom_arg); void delete_tree(TREE*); +void reset_tree(TREE*); + /* similar to delete tree, except we do not my_free() blocks in mem_root + */ #define is_tree_inited(tree) ((tree)->root != 0) /* Functions on leafs */ diff --git a/include/myisam.h b/include/myisam.h index 9b006467ac8..d2cf3822575 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -1,15 +1,15 @@ /* 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, @@ -68,6 +68,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */ ulong mean_reclength; /* Mean recordlength (if packed) */ ulonglong auto_increment; ulonglong key_map; /* Which keys are used */ + char *data_file_name, *index_file_name; uint keys; /* Number of keys in use */ uint options; /* HA_OPTIONS_... used */ int errkey, /* With key was dupplicated on err */ @@ -86,6 +87,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */ typedef struct st_mi_create_info { + char *index_file_name, *data_file_name; /* If using symlinks */ ha_rows max_rows; ha_rows reloc_rows; ulonglong auto_increment; @@ -187,9 +189,10 @@ typedef struct st_columndef /* column information */ extern my_string myisam_log_filename; /* Name of logfile */ extern uint myisam_block_size; -extern my_bool myisam_flush,myisam_delay_key_write; +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 uint myisam_bulk_insert_tree_size; /* Prototypes for myisam-functions */ @@ -219,7 +222,7 @@ extern my_off_t mi_position(struct st_myisam_info *file); extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint flag); extern int mi_lock_database(struct st_myisam_info *file,int lock_type); extern int mi_create(const char *name,uint keys,MI_KEYDEF *keydef, - uint columns, MI_COLUMNDEF *columndef, + uint columns, MI_COLUMNDEF *columndef, uint uniques, MI_UNIQUEDEF *uniquedef, MI_CREATE_INFO *create_info, uint flags); extern int mi_delete_table(const char *name); @@ -295,17 +298,17 @@ typedef struct st_sort_info { struct st_mi_check_param *param; enum data_file_type new_data_file_type; SORT_KEY_BLOCKS *key_block,*key_block_end; - uint key,find_length; + uint key,find_length,real_key_length; my_off_t pos,max_pos,filepos,start_recpos,filelength,dupp,buff_length; ha_rows max_records; ulonglong unique[MI_MAX_KEY_SEG+1]; my_bool fix_datafile; char *record,*buff; + void *wordlist, *wordptr; MI_KEYDEF *keyinfo; MI_KEYSEG *keyseg; } SORT_INFO; - typedef struct st_mi_check_param { ulonglong auto_increment_value; diff --git a/include/mysql.h b/include/mysql.h index b5d918a98af..7db907fb0f3 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -15,8 +15,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -/* defines for the libmysql library */ - #ifndef _mysql_h #define _mysql_h @@ -126,15 +124,30 @@ typedef struct st_mysql_data { struct st_mysql_options { unsigned int connect_timeout,client_flag; - my_bool compress,named_pipe; unsigned int port; char *host,*init_command,*user,*password,*unix_socket,*db; char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name; - my_bool use_ssl; /* if to use SSL or not */ char *ssl_key; /* PEM key file */ char *ssl_cert; /* PEM cert file */ char *ssl_ca; /* PEM CA file */ char *ssl_capath; /* PEM directory of CA-s? */ + my_bool use_ssl; /* if to use SSL or not */ + my_bool compress,named_pipe; + /* + on connect, find out the replication role of the server, and + establish connections to all the peers + */ + my_bool rpl_probe; + /* + each call to mysql_real_query() will parse it to tell if it is a read + or a write, and direct it to the slave or the master + */ + my_bool rpl_parse; + /* + if set, never read from a master,only from slave, when doing + a read that is replication-aware + */ + my_bool no_master_reads; }; enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, @@ -145,6 +158,15 @@ enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT}; +/* + There are three types of queries - the ones that have to go to + the master, the ones that go to a slave, and the adminstrative + type which must happen on the pivot connectioin +*/ +enum mysql_rpl_type { MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, + MYSQL_RPL_ADMIN }; + + typedef struct st_mysql { NET net; /* Communication parameters */ gptr connector_fd; /* ConnectorFd for SSL */ @@ -168,6 +190,19 @@ typedef struct st_mysql { char scramble_buff[9]; struct charset_info_st *charset; unsigned int server_language; + + /* pointers to the master, and the next slave + connections, points to itself if lone connection */ + struct st_mysql* master, *next_slave; + + struct st_mysql* last_used_slave; /* needed for round-robin slave pick */ + /* needed for send/read/store/use result to work correctly with replication */ + struct st_mysql* last_used_con; + /* + Set if this is the original connection, not a master or a slave we have + added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave() + */ + my_bool rpl_pivot; } MYSQL; @@ -185,6 +220,20 @@ typedef struct st_mysql_res { my_bool eof; /* Used my mysql_fetch_row */ } MYSQL_RES; + +/* Set up and bring down the server; to ensure that applications will + * work when linked against either the standard client library or the + * embedded server library, these functions should be called. */ +void mysql_server_init(int argc, char **argv, const char **groups); +void mysql_server_end(); + +/* Set up and bring down a thread; these function should be called + * for each thread in an application which opens at least one MySQL + * connection. All uses of the connection(s) should be between these + * function calls. */ +my_bool mysql_thread_init(); +void mysql_thread_end(); + /* Functions to get information from the MYSQL and MYSQL_RES structures */ /* Should definitely be used if one uses shared libraries */ @@ -207,18 +256,12 @@ unsigned long STDCALL mysql_thread_id(MYSQL *mysql); const char * STDCALL mysql_character_set_name(MYSQL *mysql); MYSQL * STDCALL mysql_init(MYSQL *mysql); -#ifdef HAVE_OPENSSL int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath); -char * STDCALL mysql_ssl_cipher(MYSQL *mysql); int STDCALL mysql_ssl_clear(MYSQL *mysql); -#endif /* HAVE_OPENSSL */ -MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host, - const char *user, const char *passwd); my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, const char *passwd, const char *db); -#if MYSQL_VERSION_ID >= 32200 MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd, @@ -226,14 +269,6 @@ MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, unsigned int port, const char *unix_socket, unsigned int clientflag); -#else -MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, - const char *user, - const char *passwd, - unsigned int port, - const char *unix_socket, - unsigned int clientflag); -#endif void STDCALL mysql_close(MYSQL *sock); int STDCALL mysql_select_db(MYSQL *mysql, const char *db); int STDCALL mysql_query(MYSQL *mysql, const char *q); @@ -242,8 +277,47 @@ int STDCALL mysql_send_query(MYSQL *mysql, const char *q, int STDCALL mysql_read_query_result(MYSQL *mysql); int STDCALL mysql_real_query(MYSQL *mysql, const char *q, unsigned int length); -int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); -int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); +/* perform query on master */ +int STDCALL mysql_master_query(MYSQL *mysql, const char *q, + unsigned int length); +int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q, + unsigned int length); +/* perform query on slave */ +int STDCALL mysql_slave_query(MYSQL *mysql, const char *q, + unsigned int length); +int STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q, + unsigned int length); + +/* + enable/disable parsing of all queries to decide if they go on master or + slave +*/ +void STDCALL mysql_enable_rpl_parse(MYSQL* mysql); +void STDCALL mysql_disable_rpl_parse(MYSQL* mysql); +/* get the value of the parse flag */ +int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql); + +/* enable/disable reads from master */ +void STDCALL mysql_enable_reads_from_master(MYSQL* mysql); +void STDCALL mysql_disable_reads_from_master(MYSQL* mysql); +/* get the value of the master read flag */ +int 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); + +/* set the master, close/free the old one, if it is not a pivot */ +int STDCALL mysql_set_master(MYSQL* mysql, const char* host, + unsigned int port, + const char* user, + const char* passwd); +int STDCALL mysql_add_slave(MYSQL* mysql, const char* host, + unsigned int port, + const char* user, + const char* passwd); + int STDCALL mysql_shutdown(MYSQL *mysql); int STDCALL mysql_dump_debug_info(MYSQL *mysql); int STDCALL mysql_refresh(MYSQL *mysql, @@ -292,10 +366,14 @@ char * STDCALL mysql_odbc_escape_string(MYSQL *mysql, void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name); unsigned int STDCALL mysql_thread_safe(void); - #define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) -/* new api functions */ +#ifdef USE_OLD_FUNCTIONS +MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host, + const char *user, const char *passwd); +int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); +int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); +#endif #define HAVE_MYSQL_REAL_CONNECT diff --git a/include/mysql_com.h b/include/mysql_com.h index 2e455c456fa..ce134fcab2c 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -42,7 +42,8 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY, 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_TABLE_DUMP, COM_CONNECT_OUT, + COM_REGISTER_SLAVE}; #define NOT_NULL_FLAG 1 /* Field can't be NULL */ #define PRI_KEY_FLAG 2 /* Field is part of a primary key */ @@ -100,15 +101,8 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY, #define NET_WRITE_TIMEOUT 60 /* Timeout on write */ #define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */ -#ifndef Vio_defined -#define Vio_defined -#ifdef HAVE_VIO -class Vio; /* Fill Vio class in C++ */ -#else struct st_vio; /* Only C */ typedef struct st_vio Vio; -#endif -#endif typedef struct st_net { Vio* vio; @@ -152,11 +146,15 @@ enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY, #define FIELD_TYPE_CHAR FIELD_TYPE_TINY /* For compability */ #define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM /* For compability */ +#define net_new_transaction(net) ((net)->pkt_nr=0) + +#ifdef __cplusplus +extern "C" { +#endif + extern unsigned long max_allowed_packet; extern unsigned long net_buffer_length; -#define net_new_transaction(net) ((net)->pkt_nr=0) - int my_net_init(NET *net, Vio* vio); void net_end(NET *net); void net_clear(NET *net); @@ -165,13 +163,17 @@ 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); int net_real_write(NET *net,const char *packet,unsigned long len); -unsigned int my_net_read(NET *net); +unsigned long my_net_read(NET *net); struct rand_struct { unsigned long seed1,seed2,max_value; double max_value_dbl; }; +#ifdef __cplusplus +} +#endif + /* The following is for user defined functions */ enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT}; diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 08e621f4a2a..b81e10308ff 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -211,6 +211,13 @@ #define ER_DROP_DB_WITH_READ_LOCK 1208 #define ER_CREATE_DB_WITH_READ_LOCK 1209 #define ER_WRONG_ARGUMENTS 1210 -#define ER_NO_PERMISSON_TO_CREATE_USER 1211 +#define ER_NO_PERMISSION_TO_CREATE_USER 1211 #define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212 -#define ER_ERROR_MESSAGES 213 +#define ER_CONNECT_TO_MASTER 1213 +#define ER_QUERY_ON_MASTER 1214 +#define ER_ERROR_WHEN_EXECUTING_COMMAND 1215 +#define ER_WRONG_USAGE 1216 +#define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1217 +#define ER_CANT_UPDATE_WITH_READLOCK 1218 +#define ER_MIXING_NOT_ALLOWED 1219 +#define ER_ERROR_MESSAGES 220 diff --git a/include/violite.h b/include/violite.h index 49df6994d53..49791c6b68a 100644 --- a/include/violite.h +++ b/include/violite.h @@ -25,9 +25,6 @@ #include "my_net.h" /* needed because of struct in_addr */ -#ifdef HAVE_VIO -#include <Vio.h> /* Full VIO interface */ -#else /* Simple vio interface in C; The functions are implemented in violite.c */ @@ -35,14 +32,12 @@ extern "C" { #endif /* __cplusplus */ -#ifndef Vio_defined -#define Vio_defined -struct st_vio; /* Only C */ -typedef struct st_vio Vio; -#endif - enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, - VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL}; + VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL}; + +#ifndef __WIN__ +#define HANDLE void * +#endif Vio* vio_new(my_socket sd, enum enum_vio_type type, @@ -52,6 +47,14 @@ Vio* vio_new_win32pipe(HANDLE hPipe); #endif void vio_delete(Vio* vio); +#ifdef EMBEDDED_LIBRARY +void vio_reset(Vio *vio); +#else +void vio_reset(Vio* vio, enum enum_vio_type type, + my_socket sd, HANDLE hPipe, + my_bool localhost); +#endif + /* * vio_read and vio_write should have the same semantics * as read(2) and write(2). @@ -83,7 +86,7 @@ my_bool vio_should_retry( Vio* vio); /* * When the workday is over... */ -int vio_close( Vio* vio); +int vio_close(Vio* vio); /* * Short text description of the socket for those, who are curious.. */ @@ -93,15 +96,15 @@ const char* vio_description( Vio* vio); 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); +my_socket vio_fd(Vio*vio); /* * Remote peer's address and name in text form. */ -my_bool vio_peer_addr(Vio * vio, char *buf); +my_bool vio_peer_addr(Vio* vio, char *buf); /* Remotes in_addr */ @@ -113,5 +116,140 @@ my_bool vio_poll_read(Vio *vio,uint timeout); #ifdef __cplusplus } #endif -#endif /* HAVE_VIO */ #endif /* vio_violite_h_ */ +#ifdef HAVE_VIO +#ifndef 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_blocking(vio, set_blocking_mode) (vio)->vioblocking(vio, set_blocking_mode) +#define vio_is_blocking(vio) (vio)->is_blocking(vio) +#define vio_fastsend(vio) (vio)->fastsend(vio) +#define vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive) +#define vio_should_retry(vio) (vio)->should_retry(vio) +#define vio_close(vio) ((vio)->vioclose)(vio) +#define vio_peer_addr(vio, buf) (vio)->peer_addr(vio, buf) +#define vio_in_addr(vio, in) (vio)->in_addr(vio, in) +#define vio_poll_read(vio,timeout) (vio)->poll_read(vio,timeout) +#endif /* !DONT_MAP_VIO */ +#endif /* HAVE_VIO */ + + +#ifdef HAVE_OPENSSL +#define HEADER_DES_LOCL_H dummy_something +#include <openssl/ssl.h> +#include <openssl/err.h> +#include "my_net.h" /* needed because of struct in_addr */ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +void vio_ssl_delete(Vio* vio); + +int vio_ssl_read(Vio* vio,gptr buf, int size); +int vio_ssl_write(Vio* vio,const gptr buf,int size); +int vio_ssl_blocking(Vio* vio,my_bool onoff); +my_bool vio_ssl_is_blocking(Vio* vio); + +/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */ + int vio_ssl_fastsend(Vio* vio); +/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */ +int vio_ssl_keepalive(Vio* vio, my_bool onoff); +/* Whenever we should retry the last read/write operation. */ +my_bool vio_ssl_should_retry(Vio* vio); +/* When the workday is over... */ +int vio_ssl_close(Vio* vio); +/* Return last error number */ +int vio_ssl_errno(Vio *vio); +my_bool vio_ssl_peer_addr(Vio* vio, char *buf); +void vio_ssl_in_addr(Vio *vio, struct in_addr *in); + +/* Return 1 if there is data to be read */ +my_bool vio_ssl_poll_read(Vio *vio,uint timeout); + +#ifdef HAVE_OPENSSL + +/* Single copy for server */ +struct st_VioSSLAcceptorFd +{ + SSL_CTX* ssl_context_; + SSL_METHOD* ssl_method_; + struct st_VioSSLAcceptorFd* session_id_context_; + enum { + state_connect = 1, + state_accept = 2 + }; +// BIO* bio_; +// char desc_[100]; +// Vio* sd_; + + /* function pointers which are only once for SSL server + Vio*(*sslaccept)(struct st_VioSSLAcceptorFd*,Vio*); */ +}; + +/* One copy for client */ +struct st_VioSSLConnectorFd +{ + SSL_CTX* ssl_context_; + SSL_METHOD* ssl_method_; + /* function pointers which are only once for SSL client */ +}; +void sslaccept(struct st_VioSSLAcceptorFd*, Vio*); +void sslconnect(struct st_VioSSLConnectorFd*, Vio*); + +#else /* HAVE_OPENSSL */ +/* This dummy is required to maintain proper size of st_mysql in mysql.h */ +struct st_VioSSLConnectorFd {}; +#endif /* HAVE_OPENSSL */ +struct st_VioSSLConnectorFd *new_VioSSLConnectorFd( + const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path); +struct st_VioSSLAcceptorFd *new_VioSSLAcceptorFd( + const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path); +Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state); + +#ifdef __cplusplus +} +#endif +#endif /* HAVE_OPENSSL */ + +#ifndef EMBEDDED_LIBRARY +/* This structure is for every connection on both sides */ +struct st_vio +{ + my_socket sd; /* my_socket - real or imaginary */ + HANDLE hPipe; + my_bool localhost; /* Are we from localhost? */ + int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */ + struct sockaddr_in local; /* Local internet address */ + struct sockaddr_in remote; /* Remote internet address */ + enum enum_vio_type type; /* Type of connection */ + char desc[30]; /* String description */ +#ifdef HAVE_VIO + /* function pointers. They are similar for socket/SSL/whatever */ + void (*viodelete)(Vio*); + int(*vioerrno)(Vio*); + int(*read)(Vio*, gptr, int); + int(*write)(Vio*, gptr, int); + int(*vioblocking)(Vio*, my_bool); + my_bool(*is_blocking)(Vio*); + int(*viokeepalive)(Vio*, my_bool); + int(*fastsend)(Vio*); + my_bool(*peer_addr)(Vio*, gptr); + void(*in_addr)(Vio*, struct in_addr*); + my_bool(*should_retry)(Vio*); + int(*vioclose)(Vio*); + my_bool(*poll_read)(Vio*,uint); + +#ifdef HAVE_OPENSSL + BIO* bio_; + SSL* ssl_; + my_bool open_; + char *ssl_cip_; +#endif /* HAVE_OPENSSL */ +#endif /* HAVE_VIO */ +}; +#endif /* EMBEDDED_LIBRARY */ + |