mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 20:07:13 +02:00
Added support of INSERT to MERGE tables
Fixes for embedded libary and openssl
This commit is contained in:
parent
b0953cfa86
commit
e390a99573
31 changed files with 234 additions and 192 deletions
|
|
@ -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,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;
|
||||
goto err;
|
||||
}
|
||||
info.reclength=isam->s->base.reclength;
|
||||
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;
|
||||
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),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue