mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Added support of INSERT to MERGE tables
Fixes for embedded libary and openssl
This commit is contained in:
@ -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"
|
||||
|
@ -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 \
|
||||
|
@ -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)])
|
||||
|
@ -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>
|
||||
|
@ -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_));
|
||||
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
|
||||
#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_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 */
|
||||
|
@ -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 \
|
||||
|
@ -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);
|
||||
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,
|
||||
|
@ -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;
|
||||
|
@ -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 ),
|
||||
/*
|
||||
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;
|
||||
|
@ -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 */
|
@ -39,9 +39,7 @@ enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
|
||||
#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);
|
||||
#endif
|
||||
@ -51,24 +49,19 @@ void vio_delete(Vio* vio);
|
||||
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);
|
||||
int vio_blocking(Vio *vio, my_bool onoff);
|
||||
my_bool vio_is_blocking(Vio *vio);
|
||||
/*
|
||||
* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible.
|
||||
@ -77,8 +70,7 @@ my_bool vio_is_blocking( 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.
|
||||
*/
|
||||
@ -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,7 +132,6 @@ 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 */
|
||||
@ -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,14 +187,12 @@ 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
|
||||
@ -252,4 +237,3 @@ struct st_vio
|
||||
#endif /* HAVE_VIO */
|
||||
};
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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@
|
||||
|
@ -13,6 +13,7 @@
|
||||
*
|
||||
*/
|
||||
#include "my_global.h"
|
||||
#include "mysql_embed.h"
|
||||
#include "my_pthread.h"
|
||||
#include "sys/types.h"
|
||||
#include "../regex/regex.h"
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
**************************************************************************/
|
||||
|
@ -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 \
|
||||
|
@ -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);
|
||||
|
@ -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,8 +60,18 @@ 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( !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);
|
||||
}
|
||||
continue; /* Skip comments */
|
||||
}
|
||||
|
||||
if (!test_if_hard_path(buff))
|
||||
{
|
||||
VOID(strmake(name_buff+dir_length,buff,
|
||||
@ -82,7 +89,6 @@ int handle_locking)
|
||||
}
|
||||
info.reclength=isam->s->base.reclength;
|
||||
}
|
||||
}
|
||||
if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO)+
|
||||
files*sizeof(MYRG_TABLE),
|
||||
MYF(MY_WME))))
|
||||
|
@ -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};
|
||||
|
30
myisammrg/myrg_write.c
Normal file
30
myisammrg/myrg_write.c
Normal file
@ -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);
|
||||
}
|
@ -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;
|
||||
|
@ -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 \
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,13 @@ int ha_myisammrg::close(void)
|
||||
|
||||
int ha_myisammrg::write_row(byte * buf)
|
||||
{
|
||||
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;
|
||||
|
||||
|
@ -123,6 +123,7 @@ enum row_type { ROW_TYPE_DEFAULT, ROW_TYPE_FIXED, ROW_TYPE_DYNAMIC,
|
||||
#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;
|
||||
|
||||
|
||||
|
@ -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},
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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"
|
||||
|
@ -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 {}
|
||||
|
Reference in New Issue
Block a user