2 Copyright (c) 2000, 2001, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc.
3 Use is subject to license terms.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 /* Create a MYMERGE_-file */
23 /* create file named 'name' and save filenames in it
24 table_names should be NULL or a vector of string-pointers with
28 int myrg_create(const char *name
, const char **table_names
,
29 uint insert_method
, my_bool fix_names
)
34 char buff
[FN_REFLEN
],*end
;
35 DBUG_ENTER("myrg_create");
38 if ((file
= my_create(fn_format(buff
,name
,"",MYRG_NAME_EXT
,
39 MY_UNPACK_FILENAME
|MY_APPEND_EXT
),0,
40 O_RDWR
| O_EXCL
| O_NOFOLLOW
,MYF(MY_WME
))) < 0)
45 for ( ; *table_names
; table_names
++)
47 strmov(buff
,*table_names
);
50 *(end
=strend(buff
))='\n';
52 if (my_write(file
,(uchar
*) buff
,(uint
) (end
-buff
+1),
53 MYF(MY_WME
| MY_NABP
)))
57 if (insert_method
!= MERGE_INSERT_DISABLED
)
59 end
=strxmov(buff
,"#INSERT_METHOD=",
60 get_type(&merge_insert_method
,insert_method
-1),"\n",NullS
);
61 if (my_write(file
, (uchar
*) buff
,(uint
) (end
-buff
),MYF(MY_WME
| MY_NABP
)))
64 if (my_close(file
,MYF(0)))
69 save_errno
=my_errno
? my_errno
: -1;
72 VOID(my_close(file
,MYF(0)));
74 DBUG_RETURN(my_errno
=save_errno
);