1
/* Copyright (C) 2000-2001, 2005 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
/* Create a MYMERGE_-file */
20
/* create file named 'name' and save filenames in it
21
table_names should be NULL or a vector of string-pointers with
25
int myrg_create(const char *name, const char **table_names,
26
uint insert_method, my_bool fix_names)
31
char buff[FN_REFLEN],*end;
32
DBUG_ENTER("myrg_create");
35
if ((file = my_create(fn_format(buff,name,"",MYRG_NAME_EXT,
36
MY_UNPACK_FILENAME|MY_APPEND_EXT),0,
37
O_RDWR | O_EXCL | O_NOFOLLOW,MYF(MY_WME))) < 0)
42
for ( ; *table_names ; table_names++)
44
strmov(buff,*table_names);
47
*(end=strend(buff))='\n';
49
if (my_write(file,(uchar*) buff,(uint) (end-buff+1),
50
MYF(MY_WME | MY_NABP)))
54
if (insert_method != MERGE_INSERT_DISABLED)
56
end=strxmov(buff,"#INSERT_METHOD=",
57
get_type(&merge_insert_method,insert_method-1),"\n",NullS);
58
if (my_write(file, (uchar*) buff,(uint) (end-buff),MYF(MY_WME | MY_NABP)))
61
if (my_close(file,MYF(0)))
66
save_errno=my_errno ? my_errno : -1;
69
VOID(my_close(file,MYF(0)));
71
DBUG_RETURN(my_errno=save_errno);