my_sys.h 33.1 KB
Newer Older
1
/* Copyright (C) 2000-2003 MySQL AB
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
2 3 4 5 6 7 8

   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,
bk@work.mysql.com's avatar
bk@work.mysql.com committed
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
10 11 12 13 14 15
   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 */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
16 17 18

#ifndef _my_sys_h
#define _my_sys_h
19
C_MODE_START
bk@work.mysql.com's avatar
bk@work.mysql.com committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

#ifdef HAVE_AIOWAIT
#include <sys/asynch.h>			/* Used by record-cache */
typedef struct my_aio_result {
  aio_result_t result;
  int	       pending;
} my_aio_result;
#endif

#ifndef THREAD
extern int NEAR my_errno;		/* Last error in mysys */
#else
#include <my_pthread.h>
#endif

#ifndef _m_ctype_h
#include <m_ctype.h>                    /* for CHARSET_INFO */
#endif

39
#include <stdarg.h>
40
#include <typelib.h>
bk@work.mysql.com's avatar
bk@work.mysql.com committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

#define MYSYS_PROGRAM_USES_CURSES()  { error_handler_hook = my_message_curses;	mysys_uses_curses=1; }
#define MYSYS_PROGRAM_DONT_USE_CURSES()  { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
#define MY_INIT(name);		{ my_progname= name; my_init(); }

#define ERRMSGSIZE	(SC_MAXWIDTH)	/* Max length of a error message */
#define NRERRBUFFS	(2)	/* Buffers for parameters */
#define MY_FILE_ERROR	((uint) ~0)

	/* General bitmaps for my_func's */
#define MY_FFNF		1	/* Fatal if file not found */
#define MY_FNABP	2	/* Fatal if not all bytes read/writen */
#define MY_NABP		4	/* Error if not all bytes read/writen */
#define MY_FAE		8	/* Fatal if any error */
#define MY_WME		16	/* Write message on error */
#define MY_WAIT_IF_FULL 32	/* Wait and try again if disk full error */
#define MY_RAID         64      /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
58
#define MY_FULL_IO     512      /* For my_read - loop intil I/O
59 60
				   is complete
				*/
61
#define MY_DONT_CHECK_FILESIZE 128	/* Option to init_io_cache() */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
62 63
#define MY_LINK_WARNING 32	/* my_redel() gives warning if links */
#define MY_COPYTIME	64	/* my_redel() copys time */
64 65
#define MY_DELETE_OLD	256	/* my_create_with_symlink() */
#define MY_RESOLVE_LINK 128	/* my_realpath(); Only resolve links */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
66
#define MY_HOLD_ORIGINAL_MODES 128  /* my_copy() holds to file modes */
67
#define MY_REDEL_MAKE_BACKUP 256
bk@work.mysql.com's avatar
bk@work.mysql.com committed
68 69 70 71 72 73 74
#define MY_SEEK_NOT_DONE 32	/* my_lock may have to do a seek */
#define MY_DONT_WAIT	64	/* my_lock() don't wait if can't lock */
#define MY_ZEROFILL	32	/* my_malloc(), fill array with zero */
#define MY_ALLOW_ZERO_PTR 64	/* my_realloc() ; zero ptr -> malloc */
#define MY_FREE_ON_ERROR 128	/* my_realloc() ; Free old ptr on error */
#define MY_HOLD_ON_ERROR 256	/* my_realloc() ; Return old ptr on error */
#define MY_THREADSAFE	128	/* pread/pwrite:  Don't allow interrupts */
75
#define MY_DONT_OVERWRITE_FILE 1024	/* my_copy; Don't overwrite file */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92

#define MY_CHECK_ERROR	1	/* Params to my_end; Check open-close */
#define MY_GIVE_INFO	2	/* Give time info about process*/

#define ME_HIGHBYTE	8	/* Shift for colours */
#define ME_NOCUR	1	/* Don't use curses message */
#define ME_OLDWIN	2	/* Use old window */
#define ME_BELL		4	/* Ring bell then printing message */
#define ME_HOLDTANG	8	/* Don't delete last keys */
#define ME_WAITTOT	16	/* Wait for errtime secs of for a action */
#define ME_WAITTANG	32	/* Wait for a user action  */
#define ME_NOREFRESH	64	/* Dont refresh screen */
#define ME_NOINPUT	128	/* Dont use the input libary */
#define ME_COLOUR1	((1 << ME_HIGHBYTE))	/* Possibly error-colours */
#define ME_COLOUR2	((2 << ME_HIGHBYTE))
#define ME_COLOUR3	((3 << ME_HIGHBYTE))

93 94 95 96 97 98 99 100 101 102
	/* Bits in last argument to fn_format */
#define MY_REPLACE_DIR		1	/* replace dir in name with 'dir' */
#define MY_REPLACE_EXT		2	/* replace extension with 'ext' */
#define MY_UNPACK_FILENAME	4	/* Unpack name (~ -> home) */
#define MY_PACK_FILENAME	8	/* Pack name (home -> ~) */
#define MY_RESOLVE_SYMLINKS	16	/* Resolve all symbolic links */
#define MY_RETURN_REAL_PATH	32	/* return full path for file */
#define MY_SAFE_PATH		64	/* Return NULL if too long path */
#define MY_RELATIVE_PATH	128	/* name is relative to 'dir' */

bk@work.mysql.com's avatar
bk@work.mysql.com committed
103 104 105 106 107 108 109 110 111
	/* My seek flags */
#define MY_SEEK_SET	0
#define MY_SEEK_CUR	1
#define MY_SEEK_END	2

	/* Some constants */
#define MY_WAIT_FOR_USER_TO_FIX_PANIC	60	/* in seconds */
#define MY_WAIT_GIVE_USER_A_MESSAGE	10	/* Every 10 times of prev */
#define MIN_COMPRESS_LENGTH		50	/* Don't compress small bl. */
112
#define DFLT_INIT_HITS  3
bk@work.mysql.com's avatar
bk@work.mysql.com committed
113

114 115
	/* root_alloc flags */
#define MY_KEEP_PREALLOC	1
116
#define MY_MARK_BLOCKS_FREE     2  /* move used to free list and reuse them */
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
117

118 119 120
	/* Internal error numbers (for assembler functions) */
#define MY_ERRNO_EDOM		33
#define MY_ERRNO_ERANGE		34
bk@work.mysql.com's avatar
bk@work.mysql.com committed
121

122 123 124 125 126 127 128
	/* Bits for get_date timeflag */
#define GETDATE_DATE_TIME	1
#define GETDATE_SHORT_DATE	2
#define GETDATE_HHMMSSTIME	4
#define GETDATE_GMT		8
#define GETDATE_FIXEDLENGTH	16

129
	/* defines when allocating data */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
130
#ifdef SAFEMALLOC
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
131 132 133
#define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG )
#define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG )
#define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG )
bk@work.mysql.com's avatar
bk@work.mysql.com committed
134
#define my_checkmalloc() _sanity( __FILE__, __LINE__ )
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
135 136 137 138
#define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG)
#define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C)
#define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C)
#define my_strdup_with_length(A,B,C) _my_strdup_with_length((A),(B),__FILE__,__LINE__,C)
139
#define TRASH(A,B) bfill(A, B, 0x8F)
bk@work.mysql.com's avatar
bk@work.mysql.com committed
140 141 142
#define QUICK_SAFEMALLOC sf_malloc_quick=1
#define NORMAL_SAFEMALLOC sf_malloc_quick=0
extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
143
extern ulonglong sf_malloc_mem_limit;
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
144

145 146 147
#define CALLER_INFO_PROTO   , const char *sFile, uint uLine
#define CALLER_INFO         , __FILE__, __LINE__
#define ORIG_CALLER_INFO    , sFile, uLine
bk@work.mysql.com's avatar
bk@work.mysql.com committed
148
#else
149
#define my_checkmalloc()
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
150
#undef TERMINATE
bk@work.mysql.com's avatar
bk@work.mysql.com committed
151 152 153 154
#define TERMINATE(A) {}
#define QUICK_SAFEMALLOC
#define NORMAL_SAFEMALLOC
extern gptr my_malloc(uint Size,myf MyFlags);
155
#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
bk@work.mysql.com's avatar
bk@work.mysql.com committed
156 157 158
extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags);
extern void my_no_flags_free(gptr ptr);
extern gptr my_memdup(const byte *from,uint length,myf MyFlags);
159 160 161
extern char *my_strdup(const char *from,myf MyFlags);
extern char *my_strdup_with_length(const byte *from, uint length,
				   myf MyFlags);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
162
#define my_free(PTR,FG) my_no_flags_free(PTR)
163 164 165
#define CALLER_INFO_PROTO   /* nothing */
#define CALLER_INFO         /* nothing */
#define ORIG_CALLER_INFO    /* nothing */
166
#define TRASH(A,B) /* nothing */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
167
#endif
168

169 170 171 172 173 174 175 176 177 178
#ifdef HAVE_LARGE_PAGES
extern uint my_get_large_page_size(void);
extern gptr my_large_malloc(uint size, myf my_flags);
extern void my_large_free(gptr ptr, myf my_flags);
#else
#define my_get_large_page_size() (0)
#define my_large_malloc(A,B) my_malloc_lock((A),(B))
#define my_large_free(A,B) my_free_lock((A),(B))
#endif /* HAVE_LARGE_PAGES */

bk@work.mysql.com's avatar
bk@work.mysql.com committed
179
#ifdef HAVE_ALLOCA
180
#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
181
#pragma alloca
182
#endif /* _AIX */
183
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
184 185
#define alloca __builtin_alloca
#endif /* GNUC */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
186 187 188 189 190 191
#define my_alloca(SZ) alloca((size_t) (SZ))
#define my_afree(PTR) {}
#else
#define my_alloca(SZ) my_malloc(SZ,MYF(0))
#define my_afree(PTR) my_free(PTR,MYF(MY_WME))
#endif /* HAVE_ALLOCA */
192

bk@work.mysql.com's avatar
bk@work.mysql.com committed
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
#ifdef MSDOS
#ifdef __ZTC__
void * __CDECL halloc(long count,size_t length);
void   __CDECL hfree(void *ptr);
#endif
#if defined(USE_HALLOC)
#if defined(_VCM_) || defined(M_IC80386)
#undef USE_HALLOC
#endif
#endif
#ifdef USE_HALLOC
#define malloc(a) halloc((long) (a),1)
#define free(a) hfree(a)
#endif
#endif /* MSDOS */

#ifdef HAVE_ERRNO_AS_DEFINE
#include <errno.h>			/* errno is a define */
#else
extern int errno;			/* declare errno */
#endif
extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
extern char *home_dir;			/* Home directory for user */
extern char *my_progname;		/* program-name (printed in errors) */
extern char NEAR curr_dir[];		/* Current directory for user */
extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
				       myf MyFlags);
221
extern uint my_file_limit;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
222

223 224 225 226 227
#ifdef HAVE_LARGE_PAGES
extern my_bool my_use_large_pages;
extern uint    my_large_page_size;
#endif

bk@work.mysql.com's avatar
bk@work.mysql.com committed
228
/* charsets */
229 230 231 232
extern CHARSET_INFO *default_charset_info;
extern CHARSET_INFO *all_charsets[256];
extern CHARSET_INFO compiled_charsets[];

233
/* statistics */
234 235 236
extern ulong	my_cache_w_requests, my_cache_write, my_cache_r_requests,
		my_cache_read;
extern ulong	my_blocks_used, my_blocks_changed;
237
extern ulong	my_file_opened,my_stream_opened, my_tmp_file_created;
238
extern uint	mysys_usage_id;
239
extern my_bool	my_init_done;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
240 241 242 243 244 245 246 247 248 249 250 251 252

					/* Point to current my_message() */
extern void (*my_sigtstp_cleanup)(void),
					/* Executed before jump to shell */
	    (*my_sigtstp_restart)(void),
	    (*my_abort_hook)(int);
					/* Executed when comming from shell */
extern int NEAR my_umask,		/* Default creation mask  */
	   NEAR my_umask_dir,
	   NEAR my_recived_signals,	/* Signals we have got */
	   NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
	   NEAR my_dont_interrupt;	/* call remember_intr when set */
extern my_bool NEAR mysys_uses_curses, my_use_symdir;
253
extern ulong sf_malloc_cur_memory, sf_malloc_max_memory;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
254 255 256

extern ulong	my_default_record_cache_size;
extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
257
               NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
258 259
extern char	wild_many,wild_one,wild_prefix;
extern const char *charsets_dir;
monty@tramp.mysql.fi's avatar
monty@tramp.mysql.fi committed
260
extern char *defaults_extra_file;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
261

262 263
extern my_bool timed_mutexes;

bk@work.mysql.com's avatar
bk@work.mysql.com committed
264 265 266 267 268 269 270
typedef struct wild_file_pack	/* Struct to hold info when selecting files */
{
  uint		wilds;		/* How many wildcards */
  uint		not_pos;	/* Start of not-theese-files */
  my_string	*wild;		/* Pointer to wildcards */
} WF_PACK;

271 272 273 274 275 276
enum loglevel {
   ERROR_LEVEL,
   WARNING_LEVEL,
   INFORMATION_LEVEL
};

277 278 279 280 281 282 283 284
enum cache_type
{
  READ_CACHE,WRITE_CACHE,
  SEQ_READ_APPEND		/* sequential read or append */,
  READ_FIFO, READ_NET,WRITE_NET};

enum flush_type
{
igor@rurik.mysql.com's avatar
igor@rurik.mysql.com committed
285
  FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE
286
};
bk@work.mysql.com's avatar
bk@work.mysql.com committed
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301

typedef struct st_record_cache	/* Used when cacheing records */
{
  File file;
  int	rc_seek,error,inited;
  uint	rc_length,read_length,reclength;
  my_off_t rc_record_pos,end_of_file;
  byte	*rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
#ifdef HAVE_AIOWAIT
  int	use_async_io;
  my_aio_result aio_result;
#endif
  enum cache_type type;
} RECORD_CACHE;

302 303 304 305 306
enum file_type
{
  UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN,
  FILE_BY_MKSTEMP, FILE_BY_DUP
};
bk@work.mysql.com's avatar
bk@work.mysql.com committed
307

308
struct st_my_file_info
bk@work.mysql.com's avatar
bk@work.mysql.com committed
309 310 311
{
  my_string		name;
  enum file_type	type;
312
#if defined(THREAD) && !defined(HAVE_PREAD)
313 314
  pthread_mutex_t	mutex;
#endif
315 316 317
};

extern struct st_my_file_info *my_file_info;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
318

319 320 321 322 323 324 325 326
typedef struct st_my_tmpdir
{
  char **list;
  uint cur, max;
#ifdef THREAD
  pthread_mutex_t mutex;
#endif
} MY_TMPDIR;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
327

328 329
typedef struct st_dynamic_array
{
bk@work.mysql.com's avatar
bk@work.mysql.com committed
330 331 332 333 334 335
  char *buffer;
  uint elements,max_element;
  uint alloc_increment;
  uint size_of_element;
} DYNAMIC_ARRAY;

336 337
typedef struct st_dynamic_string
{
bk@work.mysql.com's avatar
bk@work.mysql.com committed
338 339 340 341
  char *str;
  uint length,max_length,alloc_increment;
} DYNAMIC_STRING;

342 343
struct st_io_cache;
typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
344

345 346 347 348 349 350
#ifdef THREAD
typedef struct st_io_cache_share
{
  /* to sync on reads into buffer */
  pthread_mutex_t mutex;
  pthread_cond_t  cond;
351
  int             count, total;
352 353
  /* actual IO_CACHE that filled the buffer */
  struct st_io_cache *active;
354
#ifdef NOT_YET_IMPLEMENTED
355 356 357 358 359
  /* whether the structure should be free'd */
  my_bool alloced;
#endif
} IO_CACHE_SHARE;
#endif
360

bk@work.mysql.com's avatar
bk@work.mysql.com committed
361 362
typedef struct st_io_cache		/* Used when cacheing files */
{
363 364 365 366 367 368
  /* Offset in file corresponding to the first byte of byte* buffer. */
  my_off_t pos_in_file;
  /*
    The offset of end of file for READ_CACHE and WRITE_CACHE.
    For SEQ_READ_APPEND it the maximum of the actual end of file and
    the position represented by read_end.
369
  */
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
  my_off_t end_of_file;
  /* Points to current read position in the buffer */
  byte	*read_pos;
  /* the non-inclusive boundary in the buffer for the currently valid read */
  byte  *read_end;
  byte  *buffer;				/* The read buffer */
  /* Used in ASYNC_IO */
  byte  *request_pos;

  /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */
  byte  *write_buffer;
  /*
    Only used in SEQ_READ_APPEND, and points to the current read position
    in the write buffer. Note that reads in SEQ_READ_APPEND caches can
    happen from both read buffer (byte* buffer) and write buffer
    (byte* write_buffer).
386
  */
387 388 389 390 391 392 393 394 395 396 397
  byte *append_read_pos;
  /* Points to current write position in the write buffer */
  byte *write_pos;
  /* The non-inclusive boundary of the valid write area */
  byte *write_end;

  /*
    Current_pos and current_end are convenience variables used by
    my_b_tell() and other routines that need to know the current offset
    current_pos points to &write_pos, and current_end to &write_end in a
    WRITE_CACHE, and &read_pos and &read_end respectively otherwise
398
  */
monty@bitch.mysql.fi's avatar
monty@bitch.mysql.fi committed
399
  byte  **current_pos, **current_end;
sasha@mysql.sashanet.com's avatar
sasha@mysql.sashanet.com committed
400
#ifdef THREAD
401 402 403 404
  /*
    The lock is for append buffer used in SEQ_READ_APPEND cache
    need mutex copying from append buffer to read buffer.
  */
sasha@mysql.sashanet.com's avatar
sasha@mysql.sashanet.com committed
405
  pthread_mutex_t append_buffer_lock;
406 407 408 409 410 411 412
  /*
    The following is used when several threads are reading the
    same file in parallel. They are synchronized on disk
    accesses reading the cached part of the file asynchronously.
    It should be set to NULL to disable the feature.  Only
    READ_CACHE mode is supported.
  */
413
  IO_CACHE_SHARE *share;
414
#endif
415 416 417 418 419 420 421
  /*
    A caller will use my_b_read() macro to read from the cache
    if the data is already in cache, it will be simply copied with
    memcpy() and internal variables will be accordinging updated with
    no functions invoked. However, if the data is not fully in the cache,
    my_b_read() will call read_function to fetch the data. read_function
    must never be invoked directly.
422
  */
423
  int (*read_function)(struct st_io_cache *,byte *,uint);
424 425 426
  /*
    Same idea as in the case of read_function, except my_b_write() needs to
    be replaced with my_b_append() for a SEQ_READ_APPEND cache
427
  */
428
  int (*write_function)(struct st_io_cache *,const byte *,uint);
429 430 431 432
  /*
    Specifies the type of the cache. Depending on the type of the cache
    certain operations might not be available and yield unpredicatable
    results. Details to be documented later
433
  */
monty@bitch.mysql.fi's avatar
monty@bitch.mysql.fi committed
434
  enum cache_type type;
435 436 437 438 439 440
  /*
    Callbacks when the actual read I/O happens. These were added and
    are currently used for binary logging of LOAD DATA INFILE - when a
    block is read from the file, we create a block create/append event, and
    when IO_CACHE is closed, we create an end event. These functions could,
    of course be used for other things
441
  */
442 443
  IO_CACHE_CALLBACK pre_read;
  IO_CACHE_CALLBACK post_read;
444
  IO_CACHE_CALLBACK pre_close;
445 446 447 448 449
  /*
    Counts the number of times, when we were forced to use disk. We use it to
    increase the binlog_cache_disk_use status variable.
  */
  ulong disk_writes;
450
  void* arg;				/* for use by pre/post_read */
451 452
  char *file_name;			/* if used with 'open_cached_file' */
  char *dir,*prefix;
453
  File file; /* file descriptor */
454 455 456 457 458 459
  /*
    seek_not_done is set by my_b_seek() to inform the upcoming read/write
    operation that a seek needs to be preformed prior to the actual I/O
    error is 0 if the cache operation was successful, -1 if there was a
    "hard" error, and the actual number of I/O-ed bytes if the read/write was
    partial.
460
  */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
461
  int	seek_not_done,error;
462 463 464 465
  /* buffer_length is memory size allocated for buffer or write_buffer */
  uint	buffer_length;
  /* read_length is the same as buffer_length except when we use async io */
  uint  read_length;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
466
  myf	myflags;			/* Flags used to my_read/my_write */
467
  /*
468 469 470 471 472
    alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
    0 if it was supplied by the user.
    Currently READ_NET is the only one that will use a buffer allocated
    somewhere else
  */
monty@bitch.mysql.fi's avatar
monty@bitch.mysql.fi committed
473
  my_bool alloced_buffer;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
474
#ifdef HAVE_AIOWAIT
475 476 477
  /*
    As inidicated by ifdef, this is for async I/O, which is not currently
    used (because it's not reliable on all systems)
478
  */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
  uint inited;
  my_off_t aio_read_pos;
  my_aio_result aio_result;
#endif
} IO_CACHE;

typedef int (*qsort2_cmp)(const void *, const void *, const void *);

	/* defines for mf_iocache */

	/* Test if buffer is inited */
#define my_b_clear(info) (info)->buffer=0
#define my_b_inited(info) (info)->buffer
#define my_b_EOF INT_MIN

#define my_b_read(info,Buffer,Count) \
monty@bitch.mysql.fi's avatar
monty@bitch.mysql.fi committed
495 496 497
  ((info)->read_pos + (Count) <= (info)->read_end ?\
   (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \
    ((info)->read_pos+=(Count)),0) :\
bk@work.mysql.com's avatar
bk@work.mysql.com committed
498 499
   (*(info)->read_function)((info),Buffer,Count))

500 501 502 503 504
#define my_b_write(info,Buffer,Count) \
 ((info)->write_pos + (Count) <=(info)->write_end ?\
  (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\
   ((info)->write_pos+=(Count)),0) : \
   (*(info)->write_function)((info),(Buffer),(Count)))
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
505

bk@work.mysql.com's avatar
bk@work.mysql.com committed
506
#define my_b_get(info) \
monty@bitch.mysql.fi's avatar
monty@bitch.mysql.fi committed
507 508
  ((info)->read_pos != (info)->read_end ?\
   ((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\
bk@work.mysql.com's avatar
bk@work.mysql.com committed
509 510 511 512
   _my_b_get(info))

	/* my_b_write_byte dosn't have any err-check */
#define my_b_write_byte(info,chr) \
513 514 515
  (((info)->write_pos < (info)->write_end) ?\
   ((*(info)->write_pos++)=(chr)) :\
   (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr))))
bk@work.mysql.com's avatar
bk@work.mysql.com committed
516 517

#define my_b_fill_cache(info) \
monty@bitch.mysql.fi's avatar
monty@bitch.mysql.fi committed
518
  (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0))
519

bk@work.mysql.com's avatar
bk@work.mysql.com committed
520
#define my_b_tell(info) ((info)->pos_in_file + \
monty@bitch.mysql.fi's avatar
monty@bitch.mysql.fi committed
521
			 (uint) (*(info)->current_pos - (info)->request_pos))
522 523 524

/* tell write offset in the SEQ_APPEND cache */
my_off_t my_b_append_tell(IO_CACHE* info);
525
my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
monty@bitch.mysql.fi's avatar
monty@bitch.mysql.fi committed
526 527 528

#define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \
					  *(info)->current_pos)
bk@work.mysql.com's avatar
bk@work.mysql.com committed
529

serg@serg.mylan's avatar
serg@serg.mylan committed
530 531
typedef uint32 ha_checksum;

532 533 534 535
/* Define the type of function to be passed to process_default_option_files */
typedef int (*Process_option_func)(void *ctx, const char *group_name,
                                    const char *option);

536
#include <my_alloc.h>
bk@work.mysql.com's avatar
bk@work.mysql.com committed
537 538 539 540 541 542 543 544 545 546 547

	/* Prototypes for mysys and my_func functions */

extern int my_copy(const char *from,const char *to,myf MyFlags);
extern int my_append(const char *from,const char *to,myf MyFlags);
extern int my_delete(const char *name,myf MyFlags);
extern int my_getwd(my_string buf,uint size,myf MyFlags);
extern int my_setwd(const char *dir,myf MyFlags);
extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
extern gptr my_once_alloc(uint Size,myf MyFlags);
extern void my_once_free(void);
548 549
extern char *my_once_strdup(const char *src,myf myflags);
extern char *my_once_memdup(const char *src, uint len, myf myflags);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
550 551
extern my_string my_tempnam(const char *dir,const char *pfx,myf MyFlags);
extern File my_open(const char *FileName,int Flags,myf MyFlags);
552 553 554
extern File my_register_filename(File fd, const char *FileName,
				 enum file_type type_of_file,
				 uint error_message_number, myf MyFlags);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
555 556 557
extern File my_create(const char *FileName,int CreateFlags,
		      int AccsesFlags, myf MyFlags);
extern int my_close(File Filedes,myf MyFlags);
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
558
extern File my_dup(File file, myf MyFlags);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
559
extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
560 561 562 563 564
extern int my_readlink(char *to, const char *filename, myf MyFlags);
extern int my_realpath(char *to, const char *filename, myf MyFlags);
extern File my_create_with_symlink(const char *linkname, const char *filename,
				   int createflags, int access_flags,
				   myf MyFlags);
565 566
extern int my_delete_with_symlink(const char *name, myf MyFlags);
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
567
extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags);
extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset,
		     myf MyFlags);
extern int my_rename(const char *from,const char *to,myf MyFlags);
extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
extern my_off_t my_tell(File fd,myf MyFlags);
extern uint my_write(File Filedes,const byte *Buffer,uint Count,
		     myf MyFlags);
extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count,
		      my_off_t offset,myf MyFlags);
extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags);
extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count,
		      myf MyFlags);
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
extern gptr _mymalloc(uint uSize,const char *sFile,
		      uint uLine, myf MyFlag);
extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile,
		       uint uLine, myf MyFlag);
extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
extern int _sanity(const char *sFile,unsigned int uLine);
extern gptr _my_memdup(const byte *from,uint length,
		       const char *sFile, uint uLine,myf MyFlag);
extern my_string _my_strdup(const char *from, const char *sFile, uint uLine,
			    myf MyFlag);
594 595 596
extern char *_my_strdup_with_length(const byte *from, uint length,
				    const char *sFile, uint uLine,
				    myf MyFlag);
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
597

598

bk@work.mysql.com's avatar
bk@work.mysql.com committed
599 600 601 602 603
#ifndef TERMINATE
extern void TERMINATE(FILE *file);
#endif
extern void init_glob_errs(void);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
604
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
605
extern int my_fclose(FILE *fd,myf MyFlags);
606
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
607
extern int my_sync(File fd, myf my_flags);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
608 609 610 611
extern int my_error _VARARGS((int nr,myf MyFlags, ...));
extern int my_printf_error _VARARGS((uint my_err, const char *format,
				     myf MyFlags, ...)
				    __attribute__ ((format (printf, 2, 4))));
612 613
extern int my_error_register(const char **errmsgs, int first, int last);
extern const char **my_error_unregister(int first, int last);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
614 615 616
extern int my_message(uint my_err, const char *str,myf MyFlags);
extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
617
extern my_bool my_init(void);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
618 619 620 621 622
extern void my_end(int infoflag);
extern int my_redel(const char *from, const char *to, int MyFlags);
extern int my_copystat(const char *from, const char *to, int MyFlags);
extern my_string my_filename(File fd);

623
#ifndef THREAD
bk@work.mysql.com's avatar
bk@work.mysql.com committed
624 625
extern void dont_break(void);
extern void allow_break(void);
626 627 628 629 630
#else
#define dont_break()
#define allow_break()
#endif

631 632 633 634
extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist);
extern char *my_tmpdir(MY_TMPDIR *tmpdir);
extern void free_tmpdir(MY_TMPDIR *tmpdir);

bk@work.mysql.com's avatar
bk@work.mysql.com committed
635 636 637 638 639
extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
extern uint dirname_part(my_string to,const char *name);
extern uint dirname_length(const char *name);
#define base_name(A) (A+dirname_length(A))
extern int test_if_hard_path(const char *dir_name);
640
extern char *convert_dirname(char *to, const char *from, const char *from_end);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
641 642 643
extern void to_unix_path(my_string name);
extern my_string fn_ext(const char *name);
extern my_string fn_same(my_string toname,const char *name,int flag);
644 645
extern my_string fn_format(my_string to,const char *name,const char *dir,
			   const char *form, uint flag);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
646 647 648 649 650
extern size_s strlength(const char *str);
extern void pack_dirname(my_string to,const char *from);
extern uint unpack_dirname(my_string to,const char *from);
extern uint cleanup_dirname(my_string to,const char *from);
extern uint system_filename(my_string to,const char *from);
651
extern uint unpack_filename(my_string to,const char *from);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
652 653 654 655 656 657 658
extern my_string intern_filename(my_string to,const char *from);
extern my_string directory_file_name(my_string dst, const char *src);
extern int pack_filename(my_string to, const char *name, size_s max_length);
extern my_string my_path(my_string to,const char *progname,
			 const char *own_pathname_part);
extern my_string my_load_path(my_string to, const char *path,
			      const char *own_path_prefix);
659
extern int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
660 661 662
extern WF_PACK *wf_comp(my_string str);
extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
extern void wf_end(struct wild_file_pack *buffer);
663
extern size_s strip_sp(my_string str);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
664
extern void get_date(my_string to,int timeflag,time_t use_time);
665
extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr,pbool remove_garbage);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
666 667 668 669 670 671 672 673 674 675 676
extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
			     uint reclength,enum cache_type type,
			     pbool use_async_io);
extern int read_cache_record(RECORD_CACHE *info,byte *to);
extern int end_record_cache(RECORD_CACHE *info);
extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
			      const byte *record,uint length);
extern int flush_write_cache(RECORD_CACHE *info);
extern long my_clock(void);
extern sig_handler sigtstp_handler(int signal_number);
extern void handle_recived_signals(void);
677

bk@work.mysql.com's avatar
bk@work.mysql.com committed
678 679 680 681 682 683 684
extern sig_handler my_set_alarm_variable(int signo);
extern void my_string_ptr_sort(void *base,uint items,size_s size);
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
				  size_s size_of_element,uchar *buffer[]);
extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
		      qsort2_cmp cmp, void *cmp_argument);
extern qsort2_cmp get_ptr_compare(uint);
685 686
void my_store_ptr(byte *buff, uint pack_length, my_off_t pos);
my_off_t my_get_ptr(byte *ptr, uint pack_length);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
687 688 689 690 691 692
extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
			 enum cache_type type,my_off_t seek_offset,
			 pbool use_async_io, myf cache_myflags);
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
			       my_off_t seek_offset,pbool use_async_io,
			       pbool clear_cache);
693
extern void setup_io_cache(IO_CACHE* info);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
694
extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count);
695 696
#ifdef THREAD
extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count);
697 698 699
extern void init_io_cache_share(IO_CACHE *info,
				IO_CACHE_SHARE *s, uint num_threads);
extern void remove_io_thread(IO_CACHE *info);
700
#endif
sasha@mysql.sashanet.com's avatar
sasha@mysql.sashanet.com committed
701
extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
702 703 704 705
extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_get(IO_CACHE *info);
extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count);
monty@bitch.mysql.fi's avatar
monty@bitch.mysql.fi committed
706
extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count);
707 708
extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count);

bk@work.mysql.com's avatar
bk@work.mysql.com committed
709 710
extern int my_block_write(IO_CACHE *info, const byte *Buffer,
			  uint Count, my_off_t pos);
711
extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
712

713
#define flush_io_cache(info) my_b_flush_io_cache((info),1)
714

bk@work.mysql.com's avatar
bk@work.mysql.com committed
715
extern int end_io_cache(IO_CACHE *info);
716 717 718
extern uint my_b_fill(IO_CACHE *info);
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
719
extern my_off_t my_b_filelength(IO_CACHE *info);
720
extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
721
extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
722 723 724 725 726
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
				 const char *prefix, uint cache_size,
				 myf cache_myflags);
extern my_bool real_open_cached_file(IO_CACHE *cache);
extern void close_cached_file(IO_CACHE *cache);
727 728
File create_temp_file(char *to, const char *dir, const char *pfx,
		      int mode, myf MyFlags);
729 730 731
#define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO)
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO)
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
732 733
                                  uint init_alloc,uint alloc_increment
                                  CALLER_INFO_PROTO);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
734 735 736 737 738 739 740 741 742 743 744
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element);
extern byte *alloc_dynamic(DYNAMIC_ARRAY *array);
extern byte *pop_dynamic(DYNAMIC_ARRAY*);
extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
extern void delete_dynamic(DYNAMIC_ARRAY *array);
extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
extern void freeze_size(DYNAMIC_ARRAY *array);
#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
#define push_dynamic(A,B) insert_dynamic(A,B)
745
#define reset_dynamic(array) ((array)->elements= 0)
bk@work.mysql.com's avatar
bk@work.mysql.com committed
746 747 748 749

extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
				   uint init_alloc,uint alloc_increment);
extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
750 751
my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
			  uint length);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
752 753 754 755 756 757 758 759 760 761
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
extern void dynstr_free(DYNAMIC_STRING *str);
#ifdef HAVE_MLOCK
extern byte *my_malloc_lock(uint length,myf flags);
extern void my_free_lock(byte *ptr,myf flags);
#else
#define my_malloc_lock(A,B) my_malloc((A),(B))
#define my_free_lock(A,B) my_free((A),(B))
#endif
monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
762
#define alloc_root_inited(A) ((A)->min_malloc != 0)
763
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
764
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
765 766 767 768 769
extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
			    uint pre_alloc_size);
extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
extern void free_root(MEM_ROOT *root, myf MyFLAGS);
extern void set_prealloc_root(MEM_ROOT *root, char *ptr);
770 771
extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
                                uint prealloc_size);
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
772 773 774
extern char *strdup_root(MEM_ROOT *root,const char *str);
extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
775 776
extern void get_defaults_files(int argc, char **argv,
                               char **defaults, char **extra_defaults);
777 778
extern int load_defaults(const char *conf_file, const char **groups,
			 int *argc, char ***argv);
779 780 781
extern int process_default_option_files(const char *conf_file,
                                        Process_option_func func,
                                        void *func_ctx);
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
782 783 784 785 786
extern void free_defaults(char **argv);
extern void print_defaults(const char *conf_file, const char **groups);
extern my_bool my_compress(byte *, ulong *, ulong *);
extern my_bool my_uncompress(byte *, ulong *, ulong *);
extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
serg@serg.mylan's avatar
serg@serg.mylan committed
787
extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count);
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
788
extern uint my_bit_log2(ulong value);
789
extern uint my_count_bits(ulonglong v);
790
extern uint my_count_bits_ushort(ushort v);
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
791
extern void my_sleep(ulong m_seconds);
792
extern ulong crc32(ulong crc, const uchar *buf, uint len);
793 794 795
extern uint my_set_max_open_files(uint files);
void my_free_open_file_info(void);

serg@serg.mylan's avatar
serg@serg.mylan committed
796
ulonglong my_getsystime(void);
797 798
my_bool my_gethwaddr(uchar *to);

799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
#ifdef HAVE_MMAP
#include <sys/mman.h>

#ifndef MAP_NOSYNC
#define MAP_NOSYNC      0
#endif

#define my_mmap(a,b,c,d,e,f)    mmap(a,b,c,d,e,f)
#define my_getpagesize()        getpagesize()
#define my_munmap(a,b)          munmap(a,b)

#else
/* not a complete set of mmap() flags, but only those that nesessary */
#define PROT_READ        1
#define PROT_WRITE       2
#define MAP_NOSYNC       0x800
#define MAP_FAILED       ((void *)-1)
#define MS_SYNC          0x0000

int my_getpagesize(void);
void *my_mmap(void *, size_t, int, int, int, my_off_t);
int my_munmap(void *, size_t);
#endif

int my_msync(int, void *, size_t, int);

825 826 827 828 829 830 831 832 833 834 835 836 837 838
/* character sets */
extern uint get_charset_number(const char *cs_name, uint cs_flags);
extern uint get_collation_number(const char *name);
extern const char *get_charset_name(uint cs_number);

extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
					   uint cs_flags, myf my_flags);
extern void free_charsets(void);
extern char *get_charsets_dir(char *buf);
extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
extern my_bool init_compiled_charsets(myf flags);
extern void add_compiled_collation(CHARSET_INFO *cs);
839 840
extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
                                     const char *from, ulong length);
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
841

842 843 844 845
extern void thd_increment_bytes_sent(ulong length);
extern void thd_increment_bytes_received(ulong length);
extern void thd_increment_net_big_packet_count(ulong length);

bk@work.mysql.com's avatar
bk@work.mysql.com committed
846 847 848
#ifdef __WIN__
extern my_bool have_tcpip;		/* Is set if tcpip is used */
#endif
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
849 850 851 852
#ifdef __NETWARE__
void netware_reg_user(const char *ip, const char *user,
		      const char *application);
#endif
bk@work.mysql.com's avatar
bk@work.mysql.com committed
853

854
C_MODE_END
bk@work.mysql.com's avatar
bk@work.mysql.com committed
855 856
#include "raid.h"
#endif /* _my_sys_h */