19 #include "my_global.h"
24 #include <sys/asynch.h>
25 typedef struct my_aio_result {
32 # include <valgrind/memcheck.h>
33 # define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
34 # define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
35 # define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
36 # define MEM_CHECK_DEFINED(a,len) VALGRIND_CHECK_MEM_IS_DEFINED(a,len)
38 # define MEM_UNDEFINED(a,len) ((void) 0)
39 # define MEM_NOACCESS(a,len) ((void) 0)
40 # define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
41 # define MEM_CHECK_DEFINED(a,len) ((void) 0)
44 #include <my_pthread.h>
53 #define MY_INIT(name) { my_progname= name; my_init(); }
64 #define MYSYS_ERRMSG_SIZE (512)
65 #define MYSYS_STRERROR_SIZE (128)
67 #define MY_FILE_ERROR ((size_t) -1)
75 #define MY_WAIT_IF_FULL 32
76 #define MY_IGNORE_BADFD 32
77 #define MY_SYNC_DIR 8192
79 #define MY_FULL_IO 512
80 #define MY_DONT_CHECK_FILESIZE 128
81 #define MY_LINK_WARNING 32
82 #define MY_COPYTIME 64
83 #define MY_DELETE_OLD 256
84 #define MY_RESOLVE_LINK 128
85 #define MY_HOLD_ORIGINAL_MODES 128
86 #define MY_REDEL_MAKE_BACKUP 256
87 #define MY_SEEK_NOT_DONE 32
88 #define MY_DONT_WAIT 64
89 #define MY_ZEROFILL 32
90 #define MY_ALLOW_ZERO_PTR 64
91 #define MY_FREE_ON_ERROR 128
92 #define MY_HOLD_ON_ERROR 256
93 #define MY_DONT_OVERWRITE_FILE 1024
94 #define MY_THREADSAFE 2048
97 #define MY_CHECK_ERROR 1
98 #define MY_GIVE_INFO 2
99 #define MY_DONT_FREE_DBUG 4
101 #define ME_HIGHBYTE 8
105 #define ME_HOLDTANG 8
106 #define ME_WAITTOT 16
107 #define ME_WAITTANG 32
108 #define ME_NOREFRESH 64
109 #define ME_NOINPUT 128
110 #define ME_COLOUR1 ((1 << ME_HIGHBYTE))
111 #define ME_COLOUR2 ((2 << ME_HIGHBYTE))
112 #define ME_COLOUR3 ((3 << ME_HIGHBYTE))
113 #define ME_FATALERROR 1024
116 #define MY_REPLACE_DIR 1
117 #define MY_REPLACE_EXT 2
118 #define MY_UNPACK_FILENAME 4
119 #define MY_PACK_FILENAME 8
120 #define MY_RESOLVE_SYMLINKS 16
121 #define MY_RETURN_REAL_PATH 32
122 #define MY_SAFE_PATH 64
123 #define MY_RELATIVE_PATH 128
124 #define MY_APPEND_EXT 256
128 #define MY_SEEK_SET 0
129 #define MY_SEEK_CUR 1
130 #define MY_SEEK_END 2
133 #define MY_WAIT_FOR_USER_TO_FIX_PANIC 60
134 #define MY_WAIT_GIVE_USER_A_MESSAGE 10
135 #define MIN_COMPRESS_LENGTH 50
136 #define DFLT_INIT_HITS 3
139 #define MY_KEEP_PREALLOC 1
140 #define MY_MARK_BLOCKS_FREE 2
143 #define MY_ERRNO_EDOM 33
144 #define MY_ERRNO_ERANGE 34
147 #define GETDATE_DATE_TIME 1
148 #define GETDATE_SHORT_DATE 2
149 #define GETDATE_HHMMSSTIME 4
150 #define GETDATE_GMT 8
151 #define GETDATE_FIXEDLENGTH 16
154 extern void *my_malloc(
size_t Size,myf MyFlags);
155 extern void *my_multi_malloc(myf MyFlags, ...);
156 extern void *my_realloc(
void *oldpoint,
size_t Size, myf MyFlags);
157 extern void my_free(
void *ptr);
158 extern void *my_memdup(
const void *from,
size_t length,myf MyFlags);
159 extern char *my_strdup(
const char *from,myf MyFlags);
160 extern char *my_strndup(
const char *from,
size_t length,
168 #define my_safe_alloca(size, max_alloca_sz) my_alloca(size)
169 #define my_safe_afree(ptr, size, max_alloca_sz) my_afree(ptr)
171 #define my_safe_alloca(size, max_alloca_sz) ((size <= max_alloca_sz) ? \
173 my_malloc(size, MYF(0)))
174 #define my_safe_afree(ptr, size, max_alloca_sz) if (size > max_alloca_sz) \
178 #if !defined(DBUG_OFF) || defined(HAVE_VALGRIND)
185 #define TRASH(A,B) do { \
186 const size_t l= (B); \
187 MEM_CHECK_ADDRESSABLE(A, l); \
188 memset(A, 0x8F, l); \
189 MEM_UNDEFINED(A, l); \
192 #define TRASH(A,B) do {} while(0)
194 #if defined(ENABLED_DEBUG_SYNC)
195 extern void (*debug_sync_C_callback_ptr)(
const char *, size_t);
196 #define DEBUG_SYNC_C(_sync_point_name_) do { \
197 if (debug_sync_C_callback_ptr != NULL) \
198 (*debug_sync_C_callback_ptr)(STRING_WITH_LEN(_sync_point_name_)); } \
200 #define DEBUG_SYNC_C_IF_THD(thd, _sync_point_name_) do { \
201 if (debug_sync_C_callback_ptr != NULL && thd) \
202 (*debug_sync_C_callback_ptr)(STRING_WITH_LEN(_sync_point_name_)); } \
205 #define DEBUG_SYNC_C(_sync_point_name_)
206 #define DEBUG_SYNC_C_IF_THD(thd, _sync_point_name_)
209 #ifdef HAVE_LARGE_PAGES
210 extern uint my_get_large_page_size(
void);
211 extern uchar * my_large_malloc(
size_t size, myf my_flags);
212 extern void my_large_free(uchar *ptr);
214 #define my_get_large_page_size() (0)
215 #define my_large_malloc(A,B) my_malloc_lock((A),(B))
216 #define my_large_free(A) my_free_lock((A))
220 #if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
223 #if defined(__MWERKS__)
225 #define alloca _alloca
227 #if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
228 #define alloca __builtin_alloca
230 #define my_alloca(SZ) alloca((size_t) (SZ))
231 #define my_afree(PTR) {}
233 #define my_alloca(SZ) my_malloc(SZ,MYF(MY_FAE))
234 #define my_afree(PTR) my_free(PTR)
239 extern char *home_dir;
240 extern const char *my_progname;
241 extern char curr_dir[];
242 extern void (*error_handler_hook)(uint my_err,
const char *str,myf MyFlags);
243 extern void (*fatal_error_handler_hook)(uint my_err,
const char *str,
245 extern void(*sql_print_warning_hook)(
const char *format,...);
246 extern uint my_file_limit;
247 extern ulong my_thread_stack_size;
250 const char *,
const char *,
const unsigned int);
252 #ifdef HAVE_LARGE_PAGES
253 extern my_bool my_use_large_pages;
254 extern uint my_large_page_size;
258 #define MY_ALL_CHARSETS_SIZE 2048
259 extern MYSQL_PLUGIN_IMPORT
CHARSET_INFO *default_charset_info;
260 extern MYSQL_PLUGIN_IMPORT
CHARSET_INFO *all_charsets[MY_ALL_CHARSETS_SIZE];
264 extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
265 extern ulong my_file_total_opened;
266 extern my_bool my_init_done;
269 extern void (*my_sigtstp_cleanup)(void),
271 (*my_sigtstp_restart)(void),
272 (*my_abort_hook)(int);
274 extern MYSQL_PLUGIN_IMPORT
int my_umask;
275 extern int my_umask_dir,
277 my_safe_to_handle_signal,
279 extern my_bool my_use_symdir;
281 extern ulong my_default_record_cache_size;
282 extern my_bool my_disable_locking, my_disable_async_io,
283 my_disable_flush_key_blocks, my_disable_symlinks;
284 extern char wild_many,wild_one,wild_prefix;
285 extern const char *charsets_dir;
287 extern my_bool timed_mutexes;
291 TYPE_NOT_SET= 0, READ_CACHE, WRITE_CACHE,
293 READ_FIFO, READ_NET,WRITE_NET};
299 FLUSH_IGNORE_CHANGED,
310 int rc_seek,error,inited;
311 uint rc_length,read_length,reclength;
312 my_off_t rc_record_pos,end_of_file;
313 uchar *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
316 my_aio_result aio_result;
318 enum cache_type type;
323 UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN,
324 FILE_BY_MKSTEMP, FILE_BY_DUP
335 #if !defined(HAVE_PREAD) && !defined(_WIN32)
345 uint elements,max_element;
346 uint alloc_increment;
347 uint size_of_element;
361 size_t length,max_length,alloc_increment;
365 typedef int (*IO_CACHE_CALLBACK)(
struct st_io_cache*);
373 my_off_t pos_in_file;
381 #ifdef NOT_YET_IMPLEMENTED
390 my_off_t pos_in_file;
396 my_off_t end_of_file;
413 uchar *append_read_pos;
425 uchar **current_pos, **current_end;
449 int (*read_function)(
struct st_io_cache *,uchar *,size_t);
454 int (*write_function)(
struct st_io_cache *,
const uchar *,size_t);
460 enum cache_type type;
468 IO_CACHE_CALLBACK pre_read;
469 IO_CACHE_CALLBACK post_read;
470 IO_CACHE_CALLBACK pre_close;
488 int seek_not_done,error;
490 size_t buffer_length;
500 my_bool alloced_buffer;
507 my_off_t aio_read_pos;
508 my_aio_result aio_result;
512 typedef int (*qsort2_cmp)(
const void *,
const void *,
const void *);
514 typedef void (*my_error_reporter)(
enum loglevel
level,
const char *format, ...)
515 ATTRIBUTE_FORMAT_FPTR(printf, 2, 3);
517 extern my_error_reporter my_charset_error_reporter;
522 #define my_b_clear(info) (info)->buffer=0
523 #define my_b_inited(info) (info)->buffer
524 #define my_b_EOF INT_MIN
526 #define my_b_read(info,Buffer,Count) \
527 ((info)->read_pos + (Count) <= (info)->read_end ?\
528 (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \
529 ((info)->read_pos+=(Count)),0) :\
530 (*(info)->read_function)((info),Buffer,Count))
532 #define my_b_write(info,Buffer,Count) \
533 ((info)->write_pos + (Count) <=(info)->write_end ?\
534 (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\
535 ((info)->write_pos+=(Count)),0) : \
536 (*(info)->write_function)((info),(uchar *)(Buffer),(Count)))
538 #define my_b_get(info) \
539 ((info)->read_pos != (info)->read_end ?\
540 ((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\
544 #define my_b_write_byte(info,chr) \
545 (((info)->write_pos < (info)->write_end) ?\
546 ((*(info)->write_pos++)=(chr)) :\
547 (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr))))
549 #define my_b_fill_cache(info) \
550 (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0))
552 #define my_b_tell(info) ((info)->pos_in_file + \
553 (size_t) (*(info)->current_pos - (info)->request_pos))
555 #define my_b_get_buffer_start(info) (info)->request_pos
556 #define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \
557 (char*) my_b_get_buffer_start(info)
558 #define my_b_get_pos_in_file(info) (info)->pos_in_file
562 my_off_t my_b_append_tell(
IO_CACHE* info);
563 my_off_t my_b_safe_tell(
IO_CACHE* info);
565 #define my_b_bytes_in_cache(info) (size_t) (*(info)->current_end - \
566 *(info)->current_pos)
568 typedef uint32 ha_checksum;
570 #include <my_alloc.h>
575 extern int my_copy(
const char *from,
const char *
to,myf MyFlags);
576 extern int my_delete(
const char *
name,myf MyFlags);
577 extern int my_getwd(
char *
buf,
size_t size,myf MyFlags);
578 extern int my_setwd(
const char *dir,myf MyFlags);
579 extern int my_lock(File fd,
int op,my_off_t start, my_off_t length,myf MyFlags);
580 extern void *my_once_alloc(
size_t Size,myf MyFlags);
581 extern void my_once_free(
void);
582 extern char *my_once_strdup(
const char *src,myf myflags);
583 extern void *my_once_memdup(
const void *src,
size_t len, myf myflags);
584 extern File my_open(
const char *FileName,
int Flags,myf MyFlags);
585 extern File my_register_filename(File fd,
const char *FileName,
586 enum file_type type_of_file,
587 uint error_message_number, myf MyFlags);
588 extern File my_create(
const char *FileName,
int CreateFlags,
589 int AccessFlags, myf MyFlags);
590 extern int my_close(File Filedes,myf MyFlags);
591 extern int my_mkdir(
const char *dir,
int Flags, myf MyFlags);
592 extern int my_readlink(
char *
to,
const char *filename, myf MyFlags);
593 extern int my_is_symlink(
const char *filename);
594 extern int my_realpath(
char *
to,
const char *filename, myf MyFlags);
595 extern File my_create_with_symlink(
const char *linkname,
const char *filename,
596 int createflags,
int access_flags,
598 extern int my_delete_with_symlink(
const char *
name, myf MyFlags);
599 extern int my_rename_with_symlink(
const char *from,
const char *
to,myf MyFlags);
600 extern int my_symlink(
const char *content,
const char *linkname, myf MyFlags);
601 extern size_t my_read(File Filedes,uchar *
Buffer,
size_t Count,myf MyFlags);
602 extern size_t my_pread(File Filedes,uchar *
Buffer,
size_t Count,my_off_t
offset,
604 extern int my_rename(
const char *from,
const char *
to,myf MyFlags);
605 extern my_off_t my_seek(File fd,my_off_t pos,
int whence,myf MyFlags);
606 extern my_off_t my_tell(File fd,myf MyFlags);
607 extern size_t my_write(File Filedes,
const uchar *
Buffer,
size_t Count,
609 extern size_t my_pwrite(File Filedes,
const uchar *
Buffer,
size_t Count,
610 my_off_t
offset,myf MyFlags);
611 extern size_t my_fread(FILE *stream,uchar *
Buffer,
size_t Count,myf MyFlags);
612 extern size_t my_fwrite(FILE *stream,
const uchar *
Buffer,
size_t Count,
614 extern my_off_t my_fseek(FILE *stream,my_off_t pos,
int whence,myf MyFlags);
615 extern my_off_t my_ftell(FILE *stream,myf MyFlags);
618 extern void *my_memmem(
const void *haystack,
size_t haystacklen,
619 const void *needle,
size_t needlelen);
623 extern int my_access(
const char *path,
int amode);
625 #define my_access access
628 extern int check_if_legal_filename(
const char *path);
629 extern int check_if_legal_tablename(
const char *path);
632 extern my_bool is_filename_allowed(
const char *
name,
size_t length,
633 my_bool allow_current_dir);
635 # define is_filename_allowed(name, length, allow_cwd) (TRUE)
639 extern int nt_share_delete(
const char *
name,myf MyFlags);
640 #define my_delete_allow_opened(fname,flags) nt_share_delete((fname),(flags))
642 #define my_delete_allow_opened(fname,flags) my_delete((fname),(flags))
647 extern HANDLE my_get_osfhandle(File fd);
648 extern void my_osmaperr(
unsigned long last_error);
651 extern void init_glob_errs(
void);
652 extern const char** get_global_errmsgs();
653 extern void wait_for_free_space(
const char *filename,
int errors);
654 extern FILE *my_fopen(
const char *FileName,
int Flags,myf MyFlags);
655 extern FILE *my_fdopen(File Filedes,
const char *
name,
int Flags,myf MyFlags);
656 extern FILE *my_freopen(
const char *path,
const char *
mode, FILE *stream);
657 extern int my_fclose(FILE *fd,myf MyFlags);
658 extern File my_fileno(FILE *fd);
659 extern int my_chsize(File fd,my_off_t newlength,
int filler, myf MyFlags);
660 extern void thr_set_sync_wait_callback(
void (*before_sync)(
void),
661 void (*after_sync)(
void));
662 extern int my_sync(File fd, myf my_flags);
663 extern int my_sync_dir(
const char *dir_name, myf my_flags);
664 extern int my_sync_dir_by_file(
const char *file_name, myf my_flags);
665 extern char *my_strerror(
char *
buf,
size_t len,
int errnum);
666 extern const char *my_get_err_msg(
int nr);
667 extern void my_error(
int nr,myf MyFlags, ...);
668 extern void my_printf_error(uint my_err,
const char *format,
670 ATTRIBUTE_FORMAT(printf, 2, 4);
671 extern
void my_printv_error(uint error, const
char *format, myf MyFlags,
673 extern
int my_error_register(const
char** (*get_errmsgs) (),
674 int first,
int last);
675 extern
void my_printf_warning (const
char * format, ...);
676 extern const
char **my_error_unregister(
int first,
int last);
677 extern
void my_message(uint my_err, const
char *str,myf MyFlags);
678 extern
void my_message_stderr(uint my_err, const
char *str, myf MyFlags);
679 extern my_bool my_init(
void);
680 extern
void my_end(
int infoflag);
681 extern
int my_redel(const
char *from, const
char *
to,
int MyFlags);
682 extern
int my_copystat(const
char *from, const
char *to,
int MyFlags);
683 extern
char * my_filename(File fd);
686 void my_print_open_files(
void);
688 #define my_print_open_files()
691 extern my_bool init_tmpdir(
MY_TMPDIR *tmpdir,
const char *pathlist);
692 extern char *my_tmpdir(
MY_TMPDIR *tmpdir);
693 extern void free_tmpdir(
MY_TMPDIR *tmpdir);
695 extern void my_remember_signal(
int signal_number,sig_handler (*func)(
int));
696 extern size_t dirname_part(
char * to,
const char *
name,
size_t *to_res_length);
697 extern size_t dirname_length(
const char *
name);
698 #define base_name(A) (A+dirname_length(A))
699 extern int test_if_hard_path(
const char *dir_name);
700 extern my_bool has_path(
const char *
name);
701 extern char *convert_dirname(
char *to,
const char *from,
const char *from_end);
702 extern void to_unix_path(
char *
name);
703 extern char * fn_ext(
const char *
name);
704 extern char * fn_same(
char * toname,
const char *
name,
int flag);
705 extern char * fn_format(
char * to,
const char *
name,
const char *dir,
706 const char *
form, uint flag);
707 extern size_t strlength(
const char *str);
708 extern void pack_dirname(
char * to,
const char *from);
709 extern size_t normalize_dirname(
char * to,
const char *from);
710 extern size_t unpack_dirname(
char * to,
const char *from, my_bool *is_symdir);
711 extern size_t cleanup_dirname(
char * to,
const char *from);
712 extern size_t system_filename(
char * to,
const char *from);
713 extern size_t unpack_filename(
char * to,
const char *from);
714 extern char * intern_filename(
char * to,
const char *from);
715 extern char * directory_file_name(
char * dst,
const char *src);
716 extern int pack_filename(
char * to,
const char *
name,
size_t max_length);
717 extern char * my_path(
char * to,
const char *progname,
718 const char *own_pathname_part);
719 extern char * my_load_path(
char * to,
const char *path,
720 const char *own_path_prefix);
721 extern int wild_compare(
const char *str,
const char *wildstr,
722 pbool str_is_pattern);
723 extern my_bool array_append_string_unique(
const char *str,
724 const char **array,
size_t size);
725 extern void get_date(
char * to,
int timeflag,time_t use_time);
726 extern void soundex(
CHARSET_INFO *,
char * out_pntr,
char * in_pntr,
727 pbool remove_garbage);
729 size_t reclength,
enum cache_type
type,
731 extern int read_cache_record(
RECORD_CACHE *info,uchar *to);
733 extern int write_cache_record(
RECORD_CACHE *info,my_off_t filepos,
734 const uchar *
record,
size_t length);
736 extern void handle_recived_signals(
void);
738 extern sig_handler my_set_alarm_variable(
int signo);
739 extern my_bool radixsort_is_appliccable(uint n_items,
size_t size_of_element);
740 extern void my_string_ptr_sort(uchar *base,uint
items,
size_t size);
741 extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
742 size_t size_of_element,uchar *buffer[]);
743 extern qsort_t my_qsort(
void *base_ptr,
size_t total_elems,
size_t size,
745 extern qsort_t my_qsort2(
void *base_ptr,
size_t total_elems,
size_t size,
746 qsort2_cmp cmp,
const void *cmp_argument);
747 extern qsort2_cmp get_ptr_compare(
size_t);
748 void my_store_ptr(uchar *buff,
size_t pack_length, my_off_t pos);
749 my_off_t my_get_ptr(uchar *ptr,
size_t pack_length);
750 extern int init_io_cache(
IO_CACHE *info,File
file,
size_t cachesize,
751 enum cache_type
type,my_off_t seek_offset,
752 pbool use_async_io, myf cache_myflags);
753 extern my_bool reinit_io_cache(
IO_CACHE *info,
enum cache_type
type,
754 my_off_t seek_offset,pbool use_async_io,
756 extern void setup_io_cache(
IO_CACHE* info);
758 extern int _my_b_read_r(
IO_CACHE *info,uchar *
Buffer,
size_t Count);
760 IO_CACHE *write_cache, uint num_threads);
761 extern void remove_io_thread(
IO_CACHE *info);
762 extern int _my_b_seq_read(
IO_CACHE *info,uchar *
Buffer,
size_t Count);
763 extern int _my_b_net_read(
IO_CACHE *info,uchar *
Buffer,
size_t Count);
764 extern int _my_b_get(
IO_CACHE *info);
765 extern int _my_b_async_read(
IO_CACHE *info,uchar *
Buffer,
size_t Count);
766 extern int _my_b_write(
IO_CACHE *info,
const uchar *
Buffer,
size_t Count);
767 extern int my_b_append(
IO_CACHE *info,
const uchar *
Buffer,
size_t Count);
768 extern int my_b_safe_write(
IO_CACHE *info,
const uchar *
Buffer,
size_t Count);
771 size_t Count, my_off_t pos);
772 extern int my_b_flush_io_cache(
IO_CACHE *info,
int need_append_buffer_lock);
774 #define flush_io_cache(info) my_b_flush_io_cache((info),1)
776 extern int end_io_cache(
IO_CACHE *info);
777 extern size_t my_b_fill(
IO_CACHE *info);
778 extern void my_b_seek(
IO_CACHE *info,my_off_t pos);
779 extern size_t my_b_gets(
IO_CACHE *info,
char *to,
size_t max_length);
780 extern my_off_t my_b_filelength(
IO_CACHE *info);
781 extern size_t my_b_printf(
IO_CACHE *info,
const char*
fmt, ...)
782 ATTRIBUTE_FORMAT(printf, 2, 3);
783 extern
size_t my_b_vprintf(
IO_CACHE *info, const
char* fmt, va_list ap);
784 extern my_bool open_cached_file(
IO_CACHE *cache,const
char *dir,
785 const
char *prefix,
size_t cache_size,
787 extern my_bool real_open_cached_file(
IO_CACHE *cache);
788 extern
void close_cached_file(
IO_CACHE *cache);
789 File create_temp_file(
char *to, const
char *dir, const
char *pfx,
790 int mode, myf MyFlags);
791 #define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
792 #define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
793 #define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
794 #define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
795 extern my_bool init_dynamic_array2(
DYNAMIC_ARRAY *array, uint element_size,
796 void *init_buffer, uint init_alloc,
797 uint alloc_increment);
799 extern my_bool init_dynamic_array(
DYNAMIC_ARRAY *array, uint element_size,
800 uint init_alloc, uint alloc_increment);
801 extern my_bool insert_dynamic(
DYNAMIC_ARRAY *array,
const void *element);
804 extern my_bool set_dynamic(
DYNAMIC_ARRAY *array,
const void *element,
806 extern my_bool allocate_dynamic(
DYNAMIC_ARRAY *array, uint max_elements);
810 extern void delete_dynamic_element(
DYNAMIC_ARRAY *array, uint array_index);
812 #define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
813 #define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
814 #define push_dynamic(A,B) insert_dynamic((A),(B))
815 #define reset_dynamic(array) ((array)->elements= 0)
816 #define sort_dynamic(A,cmp) my_qsort((A)->buffer, (A)->elements, (A)->size_of_element, (cmp))
818 extern my_bool init_dynamic_string(
DYNAMIC_STRING *str,
const char *init_str,
819 size_t init_alloc,
size_t alloc_increment);
820 extern my_bool dynstr_append(
DYNAMIC_STRING *str,
const char *append);
821 my_bool dynstr_append_mem(
DYNAMIC_STRING *str,
const char *append,
823 extern my_bool dynstr_append_os_quoted(
DYNAMIC_STRING *str,
const char *append,
825 extern my_bool dynstr_set(
DYNAMIC_STRING *str,
const char *init_str);
826 extern my_bool dynstr_realloc(
DYNAMIC_STRING *str,
size_t additional_size);
830 extern void *my_malloc_lock(
size_t length,myf
flags);
831 extern void my_free_lock(
void *ptr);
833 #define my_malloc_lock(A,B) my_malloc((A),(B))
834 #define my_free_lock(A) my_free((A))
836 #define alloc_root_inited(A) ((A)->min_malloc != 0)
837 #define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
838 #define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
839 extern void init_alloc_root(
MEM_ROOT *mem_root,
size_t block_size,
840 size_t pre_alloc_size);
841 extern void *alloc_root(
MEM_ROOT *mem_root,
size_t Size);
842 extern void *multi_alloc_root(
MEM_ROOT *mem_root, ...);
843 extern void free_root(
MEM_ROOT *root, myf MyFLAGS);
844 extern void set_prealloc_root(
MEM_ROOT *root,
char *ptr);
845 extern void reset_root_defaults(
MEM_ROOT *mem_root,
size_t block_size,
846 size_t prealloc_size);
847 extern char *strdup_root(
MEM_ROOT *root,
const char *str);
848 static inline char *safe_strdup_root(
MEM_ROOT *root,
const char *str)
850 return str ? strdup_root(root, str) : 0;
852 extern char *strmake_root(
MEM_ROOT *root,
const char *str,
size_t len);
853 extern void *memdup_root(
MEM_ROOT *root,
const void *str,
size_t len);
854 extern my_bool my_compress(uchar *,
size_t *,
size_t *);
855 extern my_bool my_uncompress(uchar *,
size_t ,
size_t *);
856 extern uchar *my_compress_alloc(
const uchar *packet,
size_t *len,
858 extern int packfrm(uchar *,
size_t, uchar **,
size_t *);
859 extern int unpackfrm(uchar **,
size_t *,
const uchar *);
861 extern ha_checksum my_checksum(ha_checksum crc,
const uchar *mem,
863 extern void my_sleep(ulong m_seconds);
864 extern ulong crc32(ulong crc,
const uchar *
buf, uint len);
865 extern uint my_set_max_open_files(uint files);
866 void my_free_open_file_info(
void);
868 extern time_t my_time(myf
flags);
869 extern ulonglong my_getsystime(
void);
870 extern ulonglong my_micro_time();
871 extern ulonglong my_micro_time_and_time(time_t *time_arg);
872 time_t my_time_possible_from_micro(ulonglong microtime);
873 extern my_bool my_gethwaddr(uchar *to);
874 extern int my_getncpus();
876 #ifdef HAVE_SYS_MMAN_H
877 #include <sys/mman.h>
882 #ifndef MAP_NORESERVE
883 #define MAP_NORESERVE 0
887 #define my_mmap(a,b,c,d,e,f) mmap64(a,b,c,d,e,f)
889 #define my_mmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f)
891 #define my_munmap(a,b) munmap((a),(b))
897 #define MAP_NORESERVE 0
898 #define MAP_SHARED 0x0001
899 #define MAP_PRIVATE 0x0002
900 #define MAP_NOSYNC 0x0800
901 #define MAP_FAILED ((void *)-1)
902 #define MS_SYNC 0x0000
905 void *my_mmap(
void *,
size_t,
int,
int,
int, my_off_t);
906 int my_munmap(
void *,
size_t);
910 #ifdef HAVE_GETPAGESIZE
911 #define my_getpagesize() getpagesize()
913 int my_getpagesize(
void);
916 int my_msync(
int,
void *,
size_t,
int);
920 extern uint get_charset_number(
const char *cs_name, uint cs_flags);
921 extern uint get_collation_number(
const char *
name);
922 extern const char *get_charset_name(uint cs_number);
928 extern CHARSET_INFO *get_charset_by_csname(
const char *cs_name,
929 uint cs_flags, myf my_flags);
932 uint cs_flags, myf my_flags);
933 extern my_bool resolve_charset(
const char *cs_name,
936 extern my_bool resolve_collation(
const char *cl_name,
939 extern void free_charsets(
void);
940 extern char *get_charsets_dir(
char *
buf);
943 extern my_bool init_compiled_charsets(myf
flags);
945 extern size_t escape_string_for_mysql(
const CHARSET_INFO *charset_info,
946 char *to,
size_t to_length,
947 const char *from,
size_t length);
949 #define BACKSLASH_MBTAIL
953 extern size_t escape_quotes_for_mysql(
CHARSET_INFO *charset_info,
954 char *to,
size_t to_length,
955 const char *from,
size_t length);
957 extern void thd_increment_bytes_sent(ulong length);
958 extern void thd_increment_bytes_received(ulong length);
961 extern my_bool have_tcpip;
965 int my_security_attr_create(SECURITY_ATTRIBUTES **psa,
const char **perror,
966 DWORD owner_rights, DWORD everybody_rights);
968 void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
971 my_bool my_win_is_console(FILE *
file);
972 char *my_win_console_readline(
const CHARSET_INFO *cs,
char *mbbuf,
size_t mbbufsize);
973 void my_win_console_write(
const CHARSET_INFO *cs,
const char *data,
size_t datalen);
974 void my_win_console_fputs(
const CHARSET_INFO *cs,
const char *data);
975 void my_win_console_putc(
const CHARSET_INFO *cs,
int c);
976 void my_win_console_vfprintf(
const CHARSET_INFO *cs,
const char *fmt, va_list args);
977 int my_win_translate_command_line_args(
const CHARSET_INFO *cs,
int *ac,
char ***av);
982 #ifdef HAVE_PSI_INTERFACE
984 extern void set_psi_server(
PSI *psi);
985 void my_init_mysys_psi_keys(
void);
991 enum durability_properties
995 HA_REGULAR_DURABILITY= 0,
1000 HA_IGNORE_DURABILITY= 1