diff options
author | unknown <monty@hundin.mysql.fi> | 2001-09-22 17:40:57 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-09-22 17:40:57 +0300 |
commit | e7b9eabecaf2f7da05a934a5c757b438d4406bd6 (patch) | |
tree | 23349a84d09c518565222da27e0607b42d415f18 | |
parent | 2504336b415dfbc6f47c7666f986e2eae47921b4 (diff) | |
download | mariadb-git-e7b9eabecaf2f7da05a934a5c757b438d4406bd6.tar.gz |
Added support of INSERT to MERGE tables
Fixes for embedded libary and openssl
BUILD/compile-pentium-debug-max:
Added --with-openssl
acinclude.m4:
Cleanup
client/client_priv.h:
Include mysql_embed.h to remove not used functions in embedded server
client/mysql.cc:
Don't use openssl with embedded server
include/Makefile.am:
Move mysql_embed.h to 'include' directory
include/myisammrg.h:
Added support of INSERT to MERGE tables
include/mysql.h:
Fixes for embedded libary and openssl
include/mysql_com.h:
Fixes for embedded libary and openssl
include/mysql_embed.h:
Fixes for embedded libary and openssl
include/violite.h:
Cleanup
libmysql/libmysql.c:
Safety
libmysqld/examples/Makefile.am:
Fixes for embedded libary and openssl
libmysqld/lib_sql.cc:
Fixes for embedded libary and openssl
libmysqld/lib_vio.c:
Fixes for embedded libary and openssl
libmysqld/libmysqld.c:
Fixes for embedded libary and openssl
myisammrg/Makefile.am:
Added support of INSERT to MERGE tables
myisammrg/myrg_create.c:
Added support of INSERT to MERGE tables
myisammrg/myrg_open.c:
Added support of INSERT to MERGE tables
myisammrg/myrg_static.c:
Added support of INSERT to MERGE tables
mysql-test/t/union.test:
Portability fix
sql/Makefile.am:
Fixes for embedded libary and openssl
sql/gen_lex_hash.cc:
Added support of INSERT to MERGE tables
sql/ha_myisammrg.cc:
Added support of INSERT to MERGE tables
sql/handler.h:
Added support of INSERT to MERGE tables
sql/mini_client.cc:
Fixes for embedded libary and openssl
sql/net_serv.cc:
Fixes for embedded libary and openssl
sql/sql_show.cc:
Cleanup
Build-tools/Do-all-build-steps:
Don't build openssl (Need to add proper configure test when to build ssl)
sql/lex.h:
Added support of INSERT to MERGE tables
sql/sql_yacc.yy:
Fixes for embedded libary and openssl
31 files changed, 234 insertions, 192 deletions
diff --git a/BUILD/compile-pentium-debug-max b/BUILD/compile-pentium-debug-max index 4149267811d..ccd6faa0448 100755 --- a/BUILD/compile-pentium-debug-max +++ b/BUILD/compile-pentium-debug-max @@ -8,6 +8,6 @@ c_warnings="$c_warnings $debug_extra_warnings" cxx_warnings="$cxx_warnings $debug_extra_warnings" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-berkeley-db --with-innodb --with-embedded-server" +extra_configs="$extra_configs --with-berkeley-db --with-innodb --with-vio --with-openssl --with-embedded-server" . "$path/FINISH.sh" diff --git a/Build-tools/Do-all-build-steps b/Build-tools/Do-all-build-steps index e17e6acf305..ad3868733fa 100755 --- a/Build-tools/Do-all-build-steps +++ b/Build-tools/Do-all-build-steps @@ -65,7 +65,6 @@ aclocal; autoheader; aclocal; automake; autoconf --enable-thread-safe-client \ --with-berkeley-db \ --with-innodb \ - --with-openssl \ --with-vio \ --without-pstack \ --with-extra-tools \ diff --git a/acinclude.m4 b/acinclude.m4 index ca711a7c641..d7e492856bb 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -690,8 +690,7 @@ fi AC_DEFUN(MYSQL_CHECK_VIO, [ AC_ARG_WITH([vio], - [\ - --with-vio Include the Virtual IO support], + [ --with-vio Include the Virtual IO support], [vio="$withval"], [vio=no]) @@ -712,8 +711,7 @@ AC_DEFUN(MYSQL_CHECK_VIO, [ AC_DEFUN(MYSQL_CHECK_OPENSSL, [ AC_MSG_CHECKING(for OpenSSL) AC_ARG_WITH([openssl], - [\ - --with-openssl Include the OpenSSL support], + [ --with-openssl Include the OpenSSL support], [openssl="$withval"], [openssl=no]) @@ -722,7 +720,7 @@ AC_MSG_CHECKING(for OpenSSL) if test -n "$vio_dir" then AC_MSG_RESULT(yes) - openssl_libs="-lssl -lcrypto -L/usr/local/ssl/lib" + openssl_libs="-L/usr/local/ssl/lib -lssl -lcrypto" openssl_includes="-I/usr/local/ssl/include" else AC_MSG_ERROR([OpenSSL requires Virtual IO support (--with-vio)]) diff --git a/client/client_priv.h b/client/client_priv.h index 64ded3ed7f3..b015e378127 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -19,6 +19,7 @@ #include <my_global.h> #include <my_sys.h> #include <m_string.h> +#include <mysql_embed.h> #include <mysql.h> #include <errmsg.h> #include <getopt.h> diff --git a/client/mysql.cc b/client/mysql.cc index 6c947d90d76..6382fd66f35 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -303,6 +303,7 @@ int main(int argc,char *argv[]) exit(1); glob_buffer.realloc(512); completion_hash_init(&ht,50); + bzero((char*) &mysql, sizeof(mysql)); if (sql_connect(current_host,current_db,current_user,opt_password, opt_silent)) { @@ -326,11 +327,13 @@ int main(int argc,char *argv[]) put_info((char*) glob_buffer.ptr(),INFO_INFO); #ifdef HAVE_OPENSSL - if(mysql.net.vio->ssl_ && SSL_get_cipher(mysql.net.vio->ssl_)) { + if (mysql.net.vio->ssl_ && SSL_get_cipher(mysql.net.vio->ssl_)) + { sprintf((char*) glob_buffer.ptr(), - "SSL cipher in use is %s\n", SSL_get_cipher(mysql.net.vio->ssl_)); + "SSL cipher in use is %s\n", SSL_get_cipher(mysql.net.vio->ssl_)); put_info((char*) glob_buffer.ptr(),INFO_INFO); - } else + } + else put_info("SSL is not in use\n",INFO_INFO); #endif /* HAVE_OPENSSL */ @@ -373,13 +376,7 @@ int main(int argc,char *argv[]) sig_handler mysql_end(int sig) { - if (connected) - mysql_close(&mysql); -#ifdef HAVE_OPENSSL - else - mysql_ssl_clear(&mysql); /* SSL data structres should be freed - even if connection was not made */ -#endif + mysql_close(&mysql); #ifdef HAVE_READLINE if (!status.batch && !quick && !opt_html && !opt_xml) { @@ -2208,16 +2205,8 @@ static int sql_real_connect(char *host,char *database,char *user,char *password, uint silent) { - if (connected) - { /* if old is open, close it first */ - mysql_close(&mysql); - connected= 0; - } -#ifdef HAVE_OPENSSL - else - mysql_ssl_clear(&mysql); /* SSL data structres should be freed - even if connection was not made */ -#endif + mysql_close(&mysql); + connected= 0; mysql_init(&mysql); if (opt_connect_timeout) { @@ -2569,7 +2558,7 @@ static void mysql_end_timer(ulong start_time,char *buff) strmov(strend(buff),")"); } -#ifndef EMBEDDED_SERVER +#ifndef EMBEDDED_LIBRARY /* Keep sql_string library happy */ gptr sql_alloc(unsigned int Size) @@ -2581,4 +2570,4 @@ void sql_element_free(void *ptr) { my_free((gptr) ptr,MYF(0)); } -#endif /* EMBEDDED_SERVER */ +#endif /* EMBEDDED_LIBRARY */ diff --git a/include/Makefile.am b/include/Makefile.am index 0821afeb01d..aaf11db7a50 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -16,8 +16,8 @@ # MA 02111-1307, USA BUILT_SOURCES = mysql_version.h m_ctype.h my_config.h -pkginclude_HEADERS = dbug.h m_string.h my_sys.h mysql.h mysql_com.h \ - mysqld_error.h my_list.h \ +pkginclude_HEADERS = dbug.h m_string.h my_sys.h my_list.h \ + mysql.h mysql_com.h mysqld_error.h mysql_embed.h \ my_pthread.h my_no_pthread.h raid.h errmsg.h \ my_global.h my_net.h \ sslopt-case.h sslopt-longopts.h sslopt-usage.h \ diff --git a/include/myisammrg.h b/include/myisammrg.h index a797c954614..1ae825b4b94 100644 --- a/include/myisammrg.h +++ b/include/myisammrg.h @@ -34,6 +34,13 @@ extern "C" { #define MYRG_NAME_EXT ".MRG" +/* In which table to INSERT rows */ +#define MERGE_INSERT_DISABLED 0 +#define MERGE_INSERT_TO_FIRST 1 +#define MERGE_INSERT_TO_LAST 2 + +extern TYPELIB merge_insert_method; + /* Param to/from myrg_info */ typedef struct st_mymerge_info /* Struct from h_info */ @@ -44,7 +51,7 @@ typedef struct st_mymerge_info /* Struct from h_info */ ulonglong data_file_length; uint reclength; /* Recordlength */ int errkey; /* With key was dupplicated on err */ - uint options; /* HA_OPTIONS_... used */ + uint options; /* HA_OPTION_... used */ } MYMERGE_INFO; typedef struct st_myrg_table_info @@ -56,6 +63,7 @@ typedef struct st_myrg_table_info typedef struct st_myrg_info { MYRG_TABLE *open_tables,*current_table,*end_table,*last_used_table; + uint merge_insert_method; ulonglong records; /* records in tables */ ulonglong del; /* Removed records */ ulonglong data_file_length; @@ -81,10 +89,11 @@ extern int myrg_rkey(MYRG_INFO *file,byte *buf,int inx,const byte *key, extern int myrg_rrnd(MYRG_INFO *file,byte *buf,ulonglong pos); extern int myrg_rsame(MYRG_INFO *file,byte *record,int inx); extern int myrg_update(MYRG_INFO *file,const byte *old,byte *new_rec); +extern int myrg_write(MYRG_INFO *info,byte *rec); extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag); extern int myrg_lock_database(MYRG_INFO *file,int lock_type); -extern int myrg_create(const char *name,const char **table_names, - my_bool fix_names); +extern int myrg_create(const char *name, const char **table_names, + uint insert_method, my_bool fix_names); extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function); extern ha_rows myrg_records_in_range(MYRG_INFO *info,int inx, const byte *start_key,uint start_key_len, diff --git a/include/mysql.h b/include/mysql.h index 3e3a6f35e56..a1bd96540e8 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -48,32 +48,15 @@ typedef char my_bool; #endif typedef char * gptr; -#ifndef ST_USED_MEM_DEFINED -#define ST_USED_MEM_DEFINED -typedef struct st_used_mem { /* struct for once_alloc */ - struct st_used_mem *next; /* Next block in use */ - unsigned int left; /* memory left in block */ - unsigned int size; /* size of block */ -} USED_MEM; -typedef struct st_mem_root { - USED_MEM *free; - USED_MEM *used; - USED_MEM *pre_alloc; - unsigned int min_malloc; - unsigned int block_size; - - void (*error_handler)(void); -} MEM_ROOT; -#endif - #ifndef my_socket_defined #ifdef __WIN__ #define my_socket SOCKET #else typedef int my_socket; -#endif -#endif -#endif +#endif /* __WIN__ */ +#endif /* my_socket_defined */ +#endif /* _global_h */ + #include "mysql_com.h" #include "mysql_version.h" @@ -118,6 +101,24 @@ typedef struct st_mysql_rows { typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ +#ifndef ST_USED_MEM_DEFINED +#define ST_USED_MEM_DEFINED +typedef struct st_used_mem { /* struct for once_alloc */ + struct st_used_mem *next; /* Next block in use */ + unsigned int left; /* memory left in block */ + unsigned int size; /* size of block */ +} USED_MEM; +typedef struct st_mem_root { + USED_MEM *free; + USED_MEM *used; + USED_MEM *pre_alloc; + unsigned int min_malloc; + unsigned int block_size; + + void (*error_handler)(void); +} MEM_ROOT; +#endif + typedef struct st_mysql_data { my_ulonglong rows; unsigned int fields; diff --git a/include/mysql_com.h b/include/mysql_com.h index ce134fcab2c..63fbc05b0cb 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -113,10 +113,12 @@ typedef struct st_net { unsigned int last_errno,max_packet,timeout,pkt_nr; unsigned char error; my_bool return_errno,compress; - my_bool no_send_ok; /* needed if we are doing several - queries in one command ( as in LOAD TABLE ... FROM MASTER ), - and do not want to confuse the client with OK at the wrong time - */ + /* + The following variable is set if we are doing several queries in one + command ( as in LOAD TABLE ... FROM MASTER ), + and do not want to confuse the client with OK at the wrong time + */ + my_bool no_send_ok; unsigned long remain_in_buf,length, buf_length, where_b; unsigned int *return_status; unsigned char reading_or_writing; diff --git a/sql/mysql_embed.h b/include/mysql_embed.h index 4bfaca547a8..77f6f3fa32c 100644 --- a/sql/mysql_embed.h +++ b/include/mysql_embed.h @@ -22,5 +22,8 @@ #undef HAVE_PSTACK /* No stacktrace */ #undef HAVE_DLOPEN /* No udf functions */ +#undef HAVE_OPENSSL +#undef HAVE_VIO +#define DONT_USE_RAID #endif /* EMBEDDED_LIBRARY */ diff --git a/include/violite.h b/include/violite.h index 49791c6b68a..947b874c46a 100644 --- a/include/violite.h +++ b/include/violite.h @@ -33,67 +33,59 @@ extern "C" { #endif /* __cplusplus */ 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, - my_bool localhost); +Vio* vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost); #ifdef __WIN__ -Vio* vio_new_win32pipe(HANDLE hPipe); +Vio* vio_new_win32pipe(HANDLE hPipe); #endif -void vio_delete(Vio* vio); +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); + 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). */ -int vio_read( Vio* vio, - gptr buf, int size); -int vio_write( Vio* vio, - const gptr buf, - int size); +int vio_read(Vio *vio, gptr buf, int size); +int vio_write(Vio *vio, const gptr buf, int size); /* * Whenever the socket is set to blocking mode or not. */ -int vio_blocking( Vio* vio, - my_bool onoff); -my_bool vio_is_blocking( Vio* vio); +int vio_blocking(Vio *vio, my_bool onoff); +my_bool vio_is_blocking(Vio *vio); /* * setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */ - int vio_fastsend( Vio* vio); +int vio_fastsend(Vio *vio); /* * setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */ -int vio_keepalive( Vio* vio, - my_bool onoff); +int vio_keepalive(Vio *vio, my_bool onoff); /* * Whenever we should retry the last read/write operation. */ -my_bool vio_should_retry( Vio* vio); +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.. */ -const char* vio_description( Vio* vio); +const char* vio_description(Vio *vio); /* Return the type of the connection */ - enum enum_vio_type vio_type(Vio* vio); +enum enum_vio_type vio_type(Vio* vio); /* Return last error number */ int vio_errno(Vio*vio); @@ -117,8 +109,8 @@ my_bool vio_poll_read(Vio *vio,uint timeout); } #endif #endif /* vio_violite_h_ */ -#ifdef HAVE_VIO -#ifndef DONT_MAP_VIO + +#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) @@ -132,9 +124,7 @@ my_bool vio_poll_read(Vio *vio,uint timeout); #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 */ - +#endif /* defined(HAVE_VIO) && !defined(DONT_MAP_VIO) */ #ifdef HAVE_OPENSSL #define HEADER_DES_LOCL_H dummy_something @@ -142,17 +132,16 @@ my_bool vio_poll_read(Vio *vio,uint timeout); #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); +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); +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); @@ -170,8 +159,6 @@ 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 { @@ -200,16 +187,14 @@ struct st_VioSSLConnectorFd 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); +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 @@ -229,19 +214,19 @@ struct st_vio 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); + 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_; @@ -252,4 +237,3 @@ struct st_vio #endif /* HAVE_VIO */ }; #endif /* EMBEDDED_LIBRARY */ - diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index eb0e2f1820a..03162bc1dfa 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2014,6 +2014,7 @@ mysql_close(MYSQL *mysql) mysql_close(tmp); tmp = tmp1; } + mysql->rpl_pivot=0; } if (mysql != mysql->master) mysql_close(mysql->master); diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am index b687a528c6f..75487302e46 100644 --- a/libmysqld/examples/Makefile.am +++ b/libmysqld/examples/Makefile.am @@ -7,7 +7,7 @@ link_sources: @LN_CP_F@ $(srcdir)/../../client/$$f $(srcdir)/$$f; \ done; -DEFS = -DEMBEDDED_SERVER +DEFS = -DEMBEDDED_LIBRARY INCLUDES = -I$(top_srcdir)/include $(openssl_includes) \ -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/client LIBS = @LIBS@ diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index f07150c9845..e7da577ab0c 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -13,6 +13,7 @@ * */ #include "my_global.h" +#include "mysql_embed.h" #include "my_pthread.h" #include "sys/types.h" #include "../regex/regex.h" diff --git a/libmysqld/lib_vio.c b/libmysqld/lib_vio.c index e86e6c7e8da..37f77eaaad5 100644 --- a/libmysqld/lib_vio.c +++ b/libmysqld/lib_vio.c @@ -23,12 +23,13 @@ */ #include <my_global.h> +#include "mysql_embed.h" +#include "mysql.h" #ifndef HAVE_VIO /* is Vio suppored by the Vio lib ? */ #include <errno.h> #include <my_sys.h> -#include "mysql.h" #include <violite.h> #include <my_sys.h> #include <my_net.h> diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index cb8b2f02773..8931bc3cd48 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -15,19 +15,19 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#define DONT_USE_RAID #include <my_global.h> #if defined(__WIN__) || defined(_WIN32) || defined(_WIN64) #include <winsock.h> #include <odbcinst.h> #endif +#include "mysql_embed.h" +#include "mysql.h" +#include "mysql_version.h" +#include "mysqld_error.h" #include <my_sys.h> #include <mysys_err.h> #include <m_string.h> #include <m_ctype.h> -#include "mysql.h" -#include "mysql_version.h" -#include "mysqld_error.h" #include "errmsg.h" #include <violite.h> #include <sys/stat.h> @@ -88,7 +88,6 @@ static int read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, static void end_server(MYSQL *mysql); static void read_user_name(char *name); static void append_wild(char *to,char *end,const char *wild); -static my_bool mysql_reconnect(MYSQL *mysql); static int send_file_to_server(MYSQL *mysql,const char *filename); static sig_handler pipe_sig_handler(int sig); static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, @@ -1346,35 +1345,6 @@ error: } -static my_bool mysql_reconnect(MYSQL *mysql) -{ - MYSQL tmp_mysql; - DBUG_ENTER("mysql_reconnect"); - - if (!mysql->reconnect || - (mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info) - { - /* Allov reconnect next time */ - mysql->server_status&= ~SERVER_STATUS_IN_TRANS; - DBUG_RETURN(1); - } - mysql_init(&tmp_mysql); - tmp_mysql.options=mysql->options; - if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, - mysql->db, mysql->port, mysql->unix_socket, - mysql->client_flag)) - DBUG_RETURN(1); - tmp_mysql.free_me=mysql->free_me; - mysql->free_me=0; - bzero((char*) &mysql->options,sizeof(mysql->options)); - mysql_close(mysql); - *mysql=tmp_mysql; - net_clear(&mysql->net); - mysql->affected_rows= ~(my_ulonglong) 0; - DBUG_RETURN(0); -} - - /************************************************************************** ** Change user and database **************************************************************************/ diff --git a/myisammrg/Makefile.am b/myisammrg/Makefile.am index b09d7d70191..8b05bc5f386 100644 --- a/myisammrg/Makefile.am +++ b/myisammrg/Makefile.am @@ -21,7 +21,7 @@ libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \ myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \ myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \ myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \ - myrg_rprev.c myrg_queue.c + myrg_rprev.c myrg_queue.c myrg_write.c OMIT_DEPENDENCIES = pthread.h stdio.h __stdio.h stdlib.h __stdlib.h math.h\ __math.h time.h __time.h unistd.h __unistd.h types.h \ xtypes.h ac-types.h posix.h string.h __string.h \ diff --git a/myisammrg/myrg_create.c b/myisammrg/myrg_create.c index 113831b9d7f..5c6638b6ef2 100644 --- a/myisammrg/myrg_create.c +++ b/myisammrg/myrg_create.c @@ -23,7 +23,8 @@ a NULL-pointer last */ -int myrg_create(const char *name, const char **table_names, my_bool fix_names) +int myrg_create(const char *name, const char **table_names, + uint insert_method, my_bool fix_names) { int save_errno; uint errpos; @@ -50,6 +51,13 @@ int myrg_create(const char *name, const char **table_names, my_bool fix_names) goto err; } } + if (insert_method != MERGE_INSERT_DISABLED) + { + end=strxmov(buff,"#INSERT_METHOD=", + get_type(&merge_insert_method,insert_method),"\n",NullS); + if (my_write(file,buff,(uint) (end-buff),MYF(MY_WME | MY_NABP))) + goto err; + } if (my_close(file,MYF(0))) goto err; DBUG_RETURN(0); diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index 9fa89b315ff..60523c90ff4 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -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 */ -/* open a MYMERGE_-database */ +/* open a MyISAM MERGE table */ #include "mymrgdef.h" #include <stddef.h> @@ -23,17 +23,14 @@ #include "mrg_static.c" #endif -/* open a MYMERGE_-database. - +/* + open a MyISAM MERGE table if handle_locking is 0 then exit with error if some database is locked if handle_locking is 1 then wait if database is locked */ -MYRG_INFO *myrg_open( -const char *name, -int mode, -int handle_locking) +MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) { int save_errno,i,errpos; uint files,dir_length,length,options; @@ -63,25 +60,34 @@ int handle_locking) { if ((end=buff+length)[-1] == '\n') end[-1]='\0'; - if (buff[0] && buff[0] != '#') /* Skipp empty lines and comments */ + if (!buff[0]) + continue; /* Skip empty lines */ + if (buff[0] == '#') { - if (!test_if_hard_path(buff)) - { - VOID(strmake(name_buff+dir_length,buff, - sizeof(name_buff)-1-dir_length)); - VOID(cleanup_dirname(buff,name_buff)); + if( !strncmp(buff+1,"INSERT_METHOD=",14)) + { /* Lookup insert method */ + int tmp=find_type(buff+15,&merge_insert_method,2); + info.merge_insert_method = (uint) (tmp >= 0 ? tmp : 0); } - if (!(isam=mi_open(buff,mode,test(handle_locking)))) - goto err; - files++; - last_isam=isam; - if (info.reclength && info.reclength != isam->s->base.reclength) - { - my_errno=HA_ERR_WRONG_IN_RECORD; + continue; /* Skip comments */ + } + + if (!test_if_hard_path(buff)) + { + VOID(strmake(name_buff+dir_length,buff, + sizeof(name_buff)-1-dir_length)); + VOID(cleanup_dirname(buff,name_buff)); + } + if (!(isam=mi_open(buff,mode,test(handle_locking)))) goto err; - } - info.reclength=isam->s->base.reclength; + files++; + last_isam=isam; + if (info.reclength && info.reclength != isam->s->base.reclength) + { + my_errno=HA_ERR_WRONG_IN_RECORD; + goto err; } + info.reclength=isam->s->base.reclength; } if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO)+ files*sizeof(MYRG_TABLE), diff --git a/myisammrg/myrg_static.c b/myisammrg/myrg_static.c index 88eb095382b..ad57ea847d5 100644 --- a/myisammrg/myrg_static.c +++ b/myisammrg/myrg_static.c @@ -24,3 +24,7 @@ #endif LIST *myrg_open_list=0; +static const char *merge_insert_methods[] = +{ "FIRST", "LAST", NullS }; +TYPELIB merge_insert_method= { array_elements(merge_insert_methods),"", + merge_insert_methods}; diff --git a/myisammrg/myrg_write.c b/myisammrg/myrg_write.c new file mode 100644 index 00000000000..b1b0b33f73d --- /dev/null +++ b/myisammrg/myrg_write.c @@ -0,0 +1,30 @@ +/* Copyright (C) 2001 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 */ + +/* Write a row to a MyISAM MERGE table */ + +#include "mymrgdef.h" + +int myrg_write(register MYRG_INFO *info, byte *rec) +{ + /* [phi] MERGE_WRITE_DISABLED is handled by the else case */ + if (info->merge_insert_method == MERGE_INSERT_TO_FIRST) + return mi_write(info->open_tables[0].table,rec); + else if (info->merge_insert_method == MERGE_INSERT_TO_LAST) + return mi_write(info->end_table[-1].table,rec); + else /* unsupported insertion method */ + return (my_errno=HA_ERR_WRONG_COMMAND); +} diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 4c67ec10bb3..5c4a62d5c41 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -61,7 +61,7 @@ CREATE TABLE t1 ( INSERT INTO t1 (pseudo,pseudo1,same) VALUES ('joce', 'testtt', 1),('joce', 'tsestset', 1),('dekad', 'joce', 1); SELECT pseudo FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo FROM t1 WHERE pseudo='joce'; SELECT pseudo1 FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo1 FROM t1 WHERE pseudo='joce'; -SELECT * FROM t1 WHERE pseudo1='joce' UNION SELECT * FROM t1 WHERE pseudo='joce' order by pseudo desc; +SELECT * FROM t1 WHERE pseudo1='joce' UNION SELECT * FROM t1 WHERE pseudo='joce' order by pseudo desc,pseudo1 desc; SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT pseudo FROM t1 WHERE pseudo1='joce'; SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION ALL SELECT pseudo FROM t1 WHERE pseudo1='joce'; SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT 1; diff --git a/sql/Makefile.am b/sql/Makefile.am index f6d7888691d..ea29aa2e5a7 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -57,7 +57,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ sql_select.h structs.h table.h sql_udf.h hash_filo.h\ lex.h lex_symbol.h sql_acl.h sql_crypt.h md5.h \ log_event.h mini_client.h sql_repl.h slave.h \ - stacktrace.h sql_sort.h mysql_embed.h + stacktrace.h sql_sort.h mysqld_SOURCES = sql_lex.cc sql_handler.cc \ item.cc item_sum.cc item_buff.cc item_func.cc \ item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \ diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 722f5226980..cfd859acf06 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -216,7 +216,7 @@ you have to change 'main' to print out the new function\n"); return(1); } - if (opt_verbose) + if (opt_verbose > 1) fprintf (stderr,"Info: Possible add values: %d\n",found-type_count); for (prime=primes; (function_mod=*prime) ; prime++) @@ -376,7 +376,7 @@ static int get_options(int argc, char **argv) opt_search=1; break; case 'v': - opt_verbose=1; + opt_verbose++; break; case 'V': usage(1); exit(0); case 'I': @@ -473,7 +473,7 @@ int main(int argc,char **argv) MY_INIT(argv[0]); - start_value=2250933L; best_t1=2721579L; best_t2=4627039L; best_type=3; /* mode=4567 add=4 type: 0 */ + start_value=4198729L; best_t1=6245075L; best_t2=3686256L; best_type=4; /* mode=5839 add=1 type: 0 */ if (get_options(argc,(char **) argv)) exit(1); @@ -493,7 +493,7 @@ int main(int argc,char **argv) printf("start_value=%ldL; best_t1=%ldL; best_t2=%ldL; best_type=%d; /* mode=%d add=%d type: %d */\n", start_value, best_t1,best_t2,best_type,best_mod,best_add, best_functype); - + best_start_value=start_value; for (uint i=1 ; i <= opt_count ; i++) { if (i % 10 == 0) @@ -516,6 +516,10 @@ int main(int argc,char **argv) best_start_value,best_t1,best_t2,best_type,best_mod,best_add, best_functype); } + if (opt_verbose && (i % 20000) == 0) + printf("\nstart_value=%ldL; best_t1=%ldL; best_t2=%ldL; best_type=%d; /* mode=%d add=%d type: %d */\n", + best_start_value,best_t1,best_t2,best_type,best_mod,best_add, + best_functype); } } diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index abcf81806ad..92c1372a7a1 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -66,7 +66,13 @@ int ha_myisammrg::close(void) int ha_myisammrg::write_row(byte * buf) { - return (my_errno=HA_ERR_WRONG_COMMAND); + statistic_increment(ha_write_count,&LOCK_status); + if (table->time_stamp) + update_timestamp(buf+table->time_stamp-1); + if (table->next_number_field && buf == table->record[0]) + return (my_errno=HA_ERR_WRONG_COMMAND); + // update_auto_increment(); - [phi] have to check this before allowing it + return myrg_write(file,buf); } int ha_myisammrg::update_row(const byte * old_data, byte * new_data) @@ -217,6 +223,7 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd, void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info) { + // [phi] auto_increment stuff is missing (but currently not needed) DBUG_ENTER("ha_myisammrg::update_create_info"); if (!(create_info->used_fields & HA_CREATE_USED_UNION)) { @@ -241,6 +248,10 @@ void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info) } *create_info->merge_list.next=0; } + if (!(create_info->used_fields & HA_CREATE_USED_INSERT_METHOD)) + { + create_info->merge_insert_method = file->merge_insert_method; + } DBUG_VOID_RETURN; err: @@ -263,12 +274,20 @@ int ha_myisammrg::create(const char *name, register TABLE *form, *pos++= tables->real_name; *pos=0; DBUG_RETURN(myrg_create(fn_format(buff,name,"","",2+4+16), - (const char **) table_names, (my_bool) 0)); + (const char **) table_names, + create_info->merge_insert_method, + (my_bool) 0)); } void ha_myisammrg::append_create_info(String *packet) { char buff[FN_REFLEN]; + if (file->merge_insert_method != MERGE_INSERT_DISABLED) + { + packet->append(" INSERT_METHOD=",15); + const char *tmp = get_type(&merge_insert_method,file->merge_insert_method); + packet->append(tmp); + } packet->append(" UNION=(",8); MYRG_TABLE *table,*first; diff --git a/sql/handler.h b/sql/handler.h index 5cf39daeadf..dee71e8ebda 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -120,9 +120,10 @@ enum row_type { ROW_TYPE_DEFAULT, ROW_TYPE_FIXED, ROW_TYPE_DYNAMIC, /* struct to hold information about the table that should be created */ /* Bits in used_fields */ -#define HA_CREATE_USED_AUTO 1 -#define HA_CREATE_USED_RAID 2 -#define HA_CREATE_USED_UNION 4 +#define HA_CREATE_USED_AUTO 1 +#define HA_CREATE_USED_RAID 2 +#define HA_CREATE_USED_UNION 4 +#define HA_CREATE_USED_INSERT_METHOD 8 typedef struct st_thd_trans { void *bdb_tid; @@ -150,6 +151,7 @@ typedef struct st_ha_create_information bool if_not_exists; ulong used_fields; SQL_LIST merge_list; + uint merge_insert_method; } HA_CREATE_INFO; diff --git a/sql/lex.h b/sql/lex.h index ca797e5b894..5decf089e68 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -178,6 +178,7 @@ static SYMBOL symbols[] = { { "INNODB", SYM(INNOBASE_SYM),0,0}, { "INSERT", SYM(INSERT),0,0}, { "INSERT_ID", SYM(INSERT_ID),0,0}, + { "INSERT_METHOD", SYM(INSERT_METHOD),0,0}, { "INT", SYM(INT_SYM),0,0}, { "INTEGER", SYM(INT_SYM),0,0}, { "INTERVAL", SYM(INTERVAL_SYM),0,0}, diff --git a/sql/mini_client.cc b/sql/mini_client.cc index 1afe4c97b8e..d60a3bce880 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -22,7 +22,6 @@ in case we decide to make them external at some point */ -#define DONT_USE_RAID #if defined(__WIN__) #include <winsock.h> #include <odbcinst.h> @@ -41,6 +40,7 @@ inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __a #endif #include <my_global.h> +#include <mysql_embed.h> #include <mysql_com.h> #include <violite.h> #include <my_sys.h> diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 43650f365bb..59fee295b60 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -31,6 +31,7 @@ #include <winsock.h> #endif #include <my_global.h> +#include "mysql_embed.h" #include <mysql_com.h> #include <violite.h> #include <my_sys.h> diff --git a/sql/sql_show.cc b/sql/sql_show.cc index b51e9ab5a73..67713b85720 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -17,7 +17,6 @@ /* Function with list databases, tables or fields */ -#include "my_global.h" #include "mysql_priv.h" #include "sql_select.h" // For select_describe #include "sql_acl.h" diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6d80234082d..1995c1295f1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -27,6 +27,7 @@ #include "sql_acl.h" #include "lex_symbol.h" #include <myisam.h> +#include <myisammrg.h> extern void yyerror(const char*); int yylex(void *yylval); @@ -390,6 +391,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token IDENTIFIED_SYM %token IF %token INSERT_ID +%token INSERT_METHOD %token INTERVAL_SYM %token LAST_INSERT_ID %token LEFT @@ -490,7 +492,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); table_option opt_if_not_exists %type <ulong_num> - ULONG_NUM raid_types + ULONG_NUM raid_types merge_insert_types %type <ulonglong_number> ulonglong_num @@ -796,6 +798,7 @@ create_table_option: table_list->next=0; lex->create_info.used_fields|= HA_CREATE_USED_UNION; } + | INSERT_METHOD EQ merge_insert_types { Lex->create_info.merge_insert_method= $3; Lex->create_info.used_fields|= HA_CREATE_USED_INSERT_METHOD;} | DATA_SYM DIRECTORY_SYM EQ TEXT_STRING { Lex->create_info.data_file_name= $4.str; } | INDEX DIRECTORY_SYM EQ TEXT_STRING { Lex->create_info.index_file_name= $4.str; } @@ -819,6 +822,11 @@ raid_types: | RAID_0_SYM { $$= RAID_TYPE_0; } | ULONG_NUM { $$=$1;} +merge_insert_types: + NO_SYM { $$= MERGE_INSERT_DISABLED; } + | FIRST_SYM { $$= MERGE_INSERT_TO_FIRST; } + | LAST_SYM { $$= MERGE_INSERT_TO_LAST; } + opt_select_from: /* empty */ | select_from select_lock_type @@ -2862,6 +2870,7 @@ keyword: | ISAM_SYM {} | ISSUER_SYM {} | INNOBASE_SYM {} + | INSERT_METHOD {} | LAST_SYM {} | LEVEL_SYM {} | LOCAL_SYM {} |