diff options
author | unknown <monty@mashka.mysql.fi> | 2002-06-11 11:20:31 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2002-06-11 11:20:31 +0300 |
commit | 70aa7424c41c45a8fb171bbdd9e24d74b70a7765 (patch) | |
tree | 8fcaabe013fff43cf466235067f2c47f0cd66531 /include | |
parent | 30d5eb22877d0546fb4bd93ead7e8602285d449b (diff) | |
download | mariadb-git-70aa7424c41c45a8fb171bbdd9e24d74b70a7765.tar.gz |
Big code cleanup/review before 4.0.2 release.
(All commit emails since 4.0.1 checked)
This had to be done now, before the 4.1 tree changes to much, to make it easy to propagate bug fixes to the 4.1 tree.
BUILD/SETUP.sh:
Added -DPEDANTIC_SAFEMALLOC as standard debug option
Docs/manual.texi:
Changes for new version.
client/mysql.cc:
Fixed default value for rehash
cleanup
client/mysqladmin.c:
Cleanup
client/mysqlbinlog.cc:
cleanup
client/mysqldump.c:
Cleanup
client/mysqlmanager-pwgen.c:
Cleanup
client/mysqlmanagerc.c:
Cleanup
client/mysqltest.c:
Cleanup
dbug/dbug.c:
Cleanup
extra/resolve_stack_dump.c:
Cleanup & Simple optimizations
include/ft_global.h:
Cleanup
include/my_alloc.h:
Cleanup
include/my_global.h:
Cleanup
include/my_sys.h:
Cleanup
include/myisam.h:
Cleanup
libmysql/libmysql.c:
Cleanup
libmysql/manager.c:
Cleanup
myisam/ft_boolean_search.c:
Cleanup
myisam/ft_dump.c:
Change strcpy -> strmov
myisam/ft_eval.c:
Cleanup
myisam/ft_nlq_search.c:
Cleanup
myisam/ft_test1.c:
strncpy -> strnmov
myisam/ft_update.c:
Cleanup
myisam/mi_static.c:
Cleanup
myisam/mi_test2.c:
Cleanup
myisam/mi_write.c:
Cleanup
mysys/mf_fn_ext.c:
Cleanup
mysys/mf_iocache.c:
Cleanup
mysys/mf_iocache2.c:
Cleanup
mysys/my_getopt.c:
Cleanup
mysys/my_read.c:
Cleanup
mysys/my_thr_init.c:
Cleanup
mysys/queues.c:
Cleanup
mysys/safemalloc.c:
Cleanup
sql/field.cc:
Indentation cleanups
sql/ha_berkeley.cc:
Indentation cleanups
sql/ha_myisam.cc:
Cleanup
sql/item.h:
Indentation cleanups
sql/item_cmpfunc.cc:
Indentation cleanups
sql/item_create.cc:
cleanup
sql/item_func.cc:
Cleanup
sql/item_func.h:
Indentation cleanups
sql/item_strfunc.cc:
Indentation cleanups
sql/item_sum.cc:
Indentation cleanups
sql/item_timefunc.cc:
Indentation cleanups
sql/lock.cc:
Indentation cleanups
sql/log.cc:
Cleanup
strnmov -> strmake
sql/log_event.cc:
Cleanup + optimizations
Fixed memory leak
Added missing pthread_mutex_unlock() (On error condition)
sql/log_event.h:
Indentation and comment cleanup
Merged #ifdef's into common blocks for better readability
sql/mini_client.cc:
Indentation cleanup
sql/mysql_priv.h:
Cleanup
Changed int function to bool
sql/mysqld.cc:
Indentation and comment cleanup
sql/net_pkg.cc:
Indentation cleanup
sql/net_serv.cc:
Changed int function -> bool
sql/nt_servc.cc:
Cleanup
sql/opt_range.cc:
Indentation cleanup
sql/repl_failsafe.cc:
Cleanup + simple optimization
strnmov -> strmake
sql/slave.cc:
strnmov -> strmake
Cleanups
sql/slave.h:
Cleanup
sql/sql_acl.cc:
Indentation and DBUG_PRINT cleanup
Changed WITH MAX... to not use =
sql/sql_base.cc:
Indentation cleanup
sql/sql_cache.cc:
Indentation cleanup
sql/sql_class.cc:
Indentation cleanup
sql/sql_class.h:
Renamed some struct slots
sql/sql_delete.cc:
Indentation cleanup
sql/sql_handler.cc:
Indentation cleanup
sql/sql_insert.cc:
Use new slot names.
sql/sql_lex.cc:
Indentation cleanup
sql/sql_lex.h:
Indentation cleanup
sql/sql_load.cc:
Indentation cleanup
sql/sql_parse.cc:
Indentation cleanup
Removed not used check from LOCK TABLES
sql/sql_repl.cc:
strnmov -> strmake
sql/sql_repl.h:
Removed test if file is included (We want to know if it's included twice to avoid this)
sql/sql_select.cc:
Indentation cleanup
sql/sql_show.cc:
Indentation cleanup
sql/sql_string.cc:
Indentation cleanup
sql/sql_table.cc:
Indentation cleanup
sql/sql_union.cc:
Use renamed struct slot
sql/sql_update.cc:
Indentation cleanup
sql/sql_yacc.yy:
Removed = after GRANT ... MAX_ to make the syntax uniform
sql/table.cc:
Indentation cleanup
sql/table.h:
Indentation cleanup
sql/time.cc:
Indentation cleanup
sql/udf_example.cc:
Indentation cleanup
sql/unireg.cc:
strnmov -> strmake
tests/grant.pl:
Added test for LOCK TABLES
tools/mysqlmanager.c:
Cleanup
fopen() -> my_fopen()
vio/viosocket.c:
DBUG_PRINT cleanups
vio/viosslfactories.c:
Indentation cleanup
Checking of results from malloc()
Fixed possible memory leak
BitKeeper/etc/ignore:
Added scripts/mysql_secure_installation to the ignore list
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'include')
-rw-r--r-- | include/ft_global.h | 6 | ||||
-rw-r--r-- | include/my_alloc.h | 15 | ||||
-rw-r--r-- | include/my_global.h | 92 | ||||
-rw-r--r-- | include/my_sys.h | 36 | ||||
-rw-r--r-- | include/myisam.h | 41 |
5 files changed, 108 insertions, 82 deletions
diff --git a/include/ft_global.h b/include/ft_global.h index 4218eb75aa7..449cc57729f 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -30,7 +30,8 @@ extern "C" { #define HA_FT_MAXLEN 254 typedef struct st_ft_info FT_INFO; -struct _ft_vft { +struct _ft_vft +{ int (*read_next)(FT_INFO *, char *); float (*find_relevance)(FT_INFO *, byte *, uint); void (*close_search)(FT_INFO *); @@ -39,7 +40,8 @@ struct _ft_vft { }; #ifndef FT_CORE -struct st_ft_info { +struct st_ft_info +{ struct _ft_vft *please; /* INTERCAL style :-) */ }; #endif diff --git a/include/my_alloc.h b/include/my_alloc.h index 0857c8886c5..60d0d4f4b6d 100644 --- a/include/my_alloc.h +++ b/include/my_alloc.h @@ -18,18 +18,23 @@ Data structures for mysys/my_alloc.c (root memory allocator) */ -#ifndef ST_USED_MEM_DEFINED -#define ST_USED_MEM_DEFINED -typedef struct st_used_mem { /* struct for once_alloc (block) */ +#ifndef _my_alloc_h +#define _my_alloc_h + +typedef struct st_used_mem +{ /* struct for once_alloc (block) */ struct st_used_mem *next; /* Next block in use */ unsigned int left; /* memory left in block */ unsigned int size; /* size of block */ } USED_MEM; -typedef struct st_mem_root { + + +typedef struct st_mem_root +{ USED_MEM *free; /* blocks with free memory in it */ USED_MEM *used; /* blocks almost without free memory */ USED_MEM *pre_alloc; /* preallocated block */ - /* if block have less memory it will be put in 'used' list*/ + /* if block have less memory it will be put in 'used' list */ unsigned int min_malloc; unsigned int block_size; /* initial block size */ unsigned int block_num; /* allocated blocks counter */ diff --git a/include/my_global.h b/include/my_global.h index 01910eb1342..6ffe6fe949d 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -14,8 +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 */ -/* This is the main include file that should included 'first' in every - C file. */ +/* This is the include file that should be included 'first' in every C file. */ #ifndef _global_h #define _global_h @@ -51,16 +50,6 @@ #endif #endif /* _WIN32... */ -/* sometimes we want to make sure that the variable is not put into - a register in debugging mode so we can see its value in the core -*/ - -#ifndef DBUG_OFF -#define dbug_volatile volatile -#else -#define dbug_volatile -#endif - /* The macros below are borrowed from include/linux/compiler.h in the Linux kernel. Use them to indicate the likelyhood of the truthfulness @@ -106,7 +95,7 @@ #ifndef _POSIX_PTHREAD_SEMANTICS #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ #endif -/* was #if defined(HAVE_LINUXTHREADS) || defined(HAVE_DEC_THREADS) || defined(HPUX) */ + #if !defined(SCO) #define _REENTRANT 1 /* Some thread libraries require this */ #endif @@ -275,10 +264,6 @@ #define DONT_USE_MYSQL_PWD 1 #endif -/* #define USE_some_charset 1 was deprecated by changes to configure */ -/* my_ctype my_to_upper, my_to_lower, my_sort_order gain theit right value */ -/* automagically during configuration */ - /* Does the system remember a signal handler after a signal ? */ #ifndef HAVE_BSD_SIGNALS #define DONT_REMEMBER_SIGNAL @@ -348,9 +333,11 @@ typedef unsigned short ushort; /* From old s-system.h */ -/* Support macros for non ansi & other old compilers. Since such - things are no longer supported we do nothing. We keep then since - some of our code may still be needed to upgrade old customers. */ +/* + Support macros for non ansi & other old compilers. Since such + things are no longer supported we do nothing. We keep then since + some of our code may still be needed to upgrade old customers. +*/ #define _VARARGS(X) X #define _STATIC_VARARGS(X) X #define _PC(X) X @@ -468,12 +455,16 @@ typedef SOCKET_SIZE_TYPE size_socket; /* #define FN_NO_CASE_SENCE */ /* #define FN_UPPER_CASE TRUE */ -/* Io buffer size; Must be a power of 2 and a multiple of 512. May be - smaller what the disk page size. This influences the speed of the - isam btree library. eg to big to slow. */ +/* + Io buffer size; Must be a power of 2 and a multiple of 512. May be + smaller what the disk page size. This influences the speed of the + isam btree library. eg to big to slow. +*/ #define IO_SIZE 4096 -/* How much overhead does malloc have. The code often allocates - something like 1024-MALLOC_OVERHEAD bytes */ +/* + How much overhead does malloc have. The code often allocates + something like 1024-MALLOC_OVERHEAD bytes +*/ #ifdef SAFEMALLOC #define MALLOC_OVERHEAD (8+24+4) #else @@ -488,7 +479,6 @@ typedef SOCKET_SIZE_TYPE size_socket; /* Some things that this system doesn't have */ -#define ONLY_OWN_DATABASES /* We are using only databases by monty */ #define NO_HASH /* Not needed anymore */ #ifdef __WIN__ #define NO_DIR_LIBRARY /* Not standar dir-library */ @@ -534,11 +524,6 @@ extern double my_atof(const char*); #define strtok_r(A,B,C) strtok((A),(B)) #endif -#ifdef HAVE_LINUXTHREADS -/* #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) */ -/* #define sigset(A,B) signal((A),(B)) */ -#endif - /* Remove some things that mit_thread break or doesn't support */ #if defined(HAVE_mit_thread) && defined(THREAD) #undef HAVE_PREAD @@ -589,8 +574,10 @@ extern double my_atof(const char*); #define FLT_MAX ((float)3.40282346638528860e+38) #endif -/* Max size that must be added to a so that we know Size to make - adressable obj. */ +/* + Max size that must be added to a so that we know Size to make + adressable obj. +*/ typedef long my_ptrdiff_t; #define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1)) #define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double)) @@ -648,21 +635,23 @@ error "Neither int or long is of 4 bytes width" #endif #if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC) -typedef unsigned long ulong; /* Short for unsigned long */ +typedef unsigned long ulong; /* Short for unsigned long */ #endif #ifndef longlong_defined #if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8 typedef unsigned long long int ulonglong; /* ulong or unsigned long long */ typedef long long int longlong; #else -typedef unsigned long ulonglong; /* ulong or unsigned long long */ +typedef unsigned long ulonglong; /* ulong or unsigned long long */ typedef long longlong; #endif #endif #ifdef USE_RAID -/* The following is done with a if to not get problems with pre-processors - with late define evaluation */ +/* + The following is done with a if to not get problems with pre-processors + with late define evaluation +*/ #if SIZEOF_OFF_T == 4 #define SYSTEM_SIZEOF_OFF_T 4 #else @@ -727,8 +716,10 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #define INT32(v) (int32) (v) #define MYF(v) (myf) (v) -/* Defines to make it possible to prioritize register assignments. No - longer needed with moder compilers */ +/* + Defines to make it possible to prioritize register assignments. No + longer that important with modern compilers. +*/ #ifndef USING_X #define reg1 register #define reg2 register @@ -748,6 +739,17 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #define reg16 register #endif +/* + Sometimes we want to make sure that the variable is not put into + a register in debugging mode so we can see its value in the core +*/ + +#ifndef DBUG_OFF +#define dbug_volatile volatile +#else +#define dbug_volatile +#endif + /* Defines for time function */ #define SCALE_SEC 100 #define SCALE_USEC 10000 @@ -769,8 +771,8 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #endif /* -** Define-funktions for reading and storing in machine independent format -** (low byte first) + Define-funktions for reading and storing in machine independent format + (low byte first) */ /* Optimized store functions for Intel x86 */ @@ -943,9 +945,11 @@ typedef union { #endif /* sint2korr */ -/* Define-funktions for reading and storing in machine format from/to - short/long to/from some place in memory V should be a (not - register) variable, M is a pointer to byte */ +/* + Define-funktions for reading and storing in machine format from/to + short/long to/from some place in memory V should be a (not + register) variable, M is a pointer to byte +*/ #ifdef WORDS_BIGENDIAN diff --git a/include/my_sys.h b/include/my_sys.h index 7ad638bcca8..894a9c653a7 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -245,16 +245,20 @@ typedef struct wild_file_pack /* Struct to hold info when selecting files */ typedef struct st_typelib { /* Different types saved here */ uint count; /* How many types */ - const char *name; /* Name of typelib */ + const char *name; /* Name of typelib */ const char **type_names; } TYPELIB; -enum cache_type {READ_CACHE,WRITE_CACHE, - SEQ_READ_APPEND /* sequential read or append */, - READ_FIFO, - READ_NET,WRITE_NET}; -enum flush_type { FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, - FLUSH_FORCE_WRITE}; +enum cache_type +{ + READ_CACHE,WRITE_CACHE, + SEQ_READ_APPEND /* sequential read or append */, + READ_FIFO, READ_NET,WRITE_NET}; + +enum flush_type +{ + FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE +}; typedef struct st_record_cache /* Used when cacheing records */ { @@ -270,9 +274,11 @@ typedef struct st_record_cache /* Used when cacheing records */ enum cache_type type; } RECORD_CACHE; -enum file_type { UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, - STREAM_BY_FOPEN, STREAM_BY_FDOPEN, FILE_BY_MKSTEMP, - FILE_BY_DUP }; +enum file_type +{ + UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN, + FILE_BY_MKSTEMP, FILE_BY_DUP +}; extern struct my_file_info { @@ -284,14 +290,16 @@ extern struct my_file_info } my_file_info[MY_NFILE]; -typedef struct st_dynamic_array { +typedef struct st_dynamic_array +{ char *buffer; uint elements,max_element; uint alloc_increment; uint size_of_element; } DYNAMIC_ARRAY; -typedef struct st_dynamic_string { +typedef struct st_dynamic_string +{ char *str; uint length,max_length,alloc_increment; } DYNAMIC_STRING; @@ -453,8 +461,8 @@ my_off_t my_b_append_tell(IO_CACHE* info); #define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \ *(info)->current_pos) - -typedef struct st_changeable_var { +typedef struct st_changeable_var +{ const char *name; /* Name of variable */ long *varptr; /* Pointer to variable */ long def_value, /* Default value */ diff --git a/include/myisam.h b/include/myisam.h index b7010dab814..0a7e23e7988 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -170,9 +170,11 @@ typedef struct st_mi_decode_tree /* Decode huff-table */ struct st_mi_bit_buff; -/* Note that null markers should always be first in a row ! - When creating a column, one should only specify: - type, length, null_bit and null_pos */ +/* + Note that null markers should always be first in a row ! + When creating a column, one should only specify: + type, length, null_bit and null_pos +*/ typedef struct st_columndef /* column information */ { @@ -253,14 +255,15 @@ extern uint mi_get_pointer_length(ulonglong file_length, uint def); #define MYISAMCHK_VERIFY 2 /* run equivalent of myisamchk -c, * if corruption is detected, do myisamchk -r*/ -/* definitions needed for myisamchk.c -- by Sasha Pachev */ +/* + Definitions needed for myisamchk.c -/* entries marked as "QQ to be removed" are NOT used to - * pass check/repair options to mi_check.c. They are used - * internally by myisamchk.c or/and ha_myisam.cc and should NOT - * be stored together with other flags. They should be removed - * from the following list to make adding of new flags possible. - * -- Sergei */ + Entries marked as "QQ to be removed" are NOT used to + pass check/repair options to mi_check.c. They are used + internally by myisamchk.c or/and ha_myisam.cc and should NOT + be stored together with other flags. They should be removed + from the following list to make adding of new flags possible. +*/ #define T_VERBOSE 1 #define T_SILENT 2 @@ -295,9 +298,10 @@ extern uint mi_get_pointer_length(ulonglong file_length, uint def); #define T_QUICK (1L << 30) #define T_RETRY_WITHOUT_QUICK (1L << 31) -/* flags used by myisamchk.c or/and ha_myisam.cc that are NOT passed - * to mi_check.c follows: - * */ +/* + Flags used by myisamchk.c or/and ha_myisam.cc that are NOT passed + to mi_check.c follows: +*/ #define TT_USEFRM 1 @@ -307,7 +311,8 @@ extern uint mi_get_pointer_length(ulonglong file_length, uint def); /* these struct is used by my_check to tell it what to do */ -typedef struct st_sort_key_blocks { /* Used when sorting */ +typedef struct st_sort_key_blocks /* Used when sorting */ +{ uchar *buff,*end_pos; uchar lastkey[MI_MAX_POSSIBLE_KEY_BUFF]; uint last_length; @@ -316,7 +321,8 @@ typedef struct st_sort_key_blocks { /* Used when sorting */ struct st_mi_check_param; -typedef struct st_sort_info { +typedef struct st_sort_info +{ MI_INFO *info; struct st_mi_check_param *param; enum data_file_type new_data_file_type; @@ -364,7 +370,8 @@ typedef struct st_mi_check_param } MI_CHECK; -typedef struct st_mi_sortinfo { +typedef struct st_mi_sortinfo +{ ha_rows max_records; SORT_INFO *sort_info; char *tmpdir; @@ -403,7 +410,7 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start, int movepoint(MI_INFO *info,byte *record,my_off_t oldpos, my_off_t newpos, uint prot_key); int sort_write_record(SORT_INFO *sort_info); - int write_data_suffix(MI_CHECK *param, MI_INFO *info); +int write_data_suffix(MI_CHECK *param, MI_INFO *info); int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong); int test_if_almost_full(MI_INFO *info); |