summaryrefslogtreecommitdiff
path: root/myisammrg
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-09-22 17:40:57 +0300
committerunknown <monty@hundin.mysql.fi>2001-09-22 17:40:57 +0300
commite7b9eabecaf2f7da05a934a5c757b438d4406bd6 (patch)
tree23349a84d09c518565222da27e0607b42d415f18 /myisammrg
parent2504336b415dfbc6f47c7666f986e2eae47921b4 (diff)
downloadmariadb-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
Diffstat (limited to 'myisammrg')
-rw-r--r--myisammrg/Makefile.am2
-rw-r--r--myisammrg/myrg_create.c10
-rw-r--r--myisammrg/myrg_open.c50
-rw-r--r--myisammrg/myrg_static.c4
-rw-r--r--myisammrg/myrg_write.c30
5 files changed, 72 insertions, 24 deletions
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);
+}