diff options
author | Michael Widenius <monty@askmonty.org> | 2011-05-02 20:58:45 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-05-02 20:58:45 +0300 |
commit | e415ba0fb2c57eaf370e84a3a9c8d831f820a560 (patch) | |
tree | f113a8024de4ee4f1bc19aae98c19a2835f5b4e7 /include | |
parent | 046418ad956c98c3788d79650fcb50479844df3b (diff) | |
parent | a1f7ceb281f9d87c9baea125ebab26f99a0370f8 (diff) | |
download | mariadb-git-e415ba0fb2c57eaf370e84a3a9c8d831f820a560.tar.gz |
Merge with MySQL 5.1.57/58
Moved some BSD string functions from Unireg
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 2 | ||||
-rw-r--r-- | include/config-win.h | 5 | ||||
-rw-r--r-- | include/ft_global.h | 2 | ||||
-rw-r--r-- | include/heap.h | 2 | ||||
-rw-r--r-- | include/maria.h | 1 | ||||
-rw-r--r-- | include/my_bit.h | 25 | ||||
-rw-r--r-- | include/my_bitmap.h | 10 | ||||
-rw-r--r-- | include/my_compare.h | 98 | ||||
-rw-r--r-- | include/my_handler.h | 86 | ||||
-rw-r--r-- | include/my_time.h | 13 | ||||
-rw-r--r-- | include/myisam.h | 1 |
11 files changed, 156 insertions, 89 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 0181695ab59..194a6bb58af 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -37,7 +37,7 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \ my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \ my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \ thr_lock.h t_ctype.h violite.h my_md5.h base64.h \ - my_handler.h my_time.h \ + my_compare.h my_handler.h my_time.h \ my_vle.h my_user.h my_atomic.h atomic/nolock.h \ atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \ atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \ diff --git a/include/config-win.h b/include/config-win.h index b4958243abc..6d12bb0e33f 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -201,6 +201,11 @@ typedef SSIZE_T ssize_t; #define SIZEOF_LONG 4 #define SIZEOF_LONG_LONG 8 #define SIZEOF_OFF_T 8 +/* + The size of time_t depends on the compiler. + But it's 8 for all the supported VC versions. +*/ +#define SIZEOF_TIME_T 8 #ifdef _WIN64 #define SIZEOF_CHARP 8 #else diff --git a/include/ft_global.h b/include/ft_global.h index 4a4cf84b119..e16b77422d1 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -25,6 +25,8 @@ extern "C" { #endif +#include <my_compare.h> + #define HA_FT_MAXBYTELEN 254 #define HA_FT_MAXCHARLEN (HA_FT_MAXBYTELEN/3) diff --git a/include/heap.h b/include/heap.h index 4a1c7d419ed..126ce4fa12d 100644 --- a/include/heap.h +++ b/include/heap.h @@ -30,7 +30,7 @@ extern "C" { #include <thr_lock.h> #endif -#include "my_handler.h" +#include "my_compare.h" #include "my_tree.h" /* defines used by heap-funktions */ diff --git a/include/maria.h b/include/maria.h index fb09116a24c..1f054bce58d 100644 --- a/include/maria.h +++ b/include/maria.h @@ -29,6 +29,7 @@ extern "C" { #endif #include "../storage/maria/ma_pagecache.h" #include "my_handler.h" +#include "my_compare.h" #include "ft_global.h" #include <myisamchk.h> #include <mysql/plugin.h> diff --git a/include/my_bit.h b/include/my_bit.h index 2e464e89049..266cfa8ff27 100644 --- a/include/my_bit.h +++ b/include/my_bit.h @@ -1,3 +1,19 @@ +/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. + Copyright (c) 2009-2011, Monty Program Ab + + 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; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + /* Some useful bit functions */ @@ -42,9 +58,12 @@ STATIC_INLINE uint my_count_bits(ulonglong v) #endif } -STATIC_INLINE uint my_count_bits_ushort(ushort v) +STATIC_INLINE uint my_count_bits_uint32(uint32 v) { - return _my_bits_nbits[v]; + return (uint) (uchar) (_my_bits_nbits[(uchar) v] + + _my_bits_nbits[(uchar) (v >> 8)] + + _my_bits_nbits[(uchar) (v >> 16)] + + _my_bits_nbits[(uchar) (v >> 24)]); } @@ -104,6 +123,6 @@ extern uint32 my_round_up_to_next_power(uint32 v); uint32 my_clear_highest_bit(uint32 v); uint32 my_reverse_bits(uint32 key); extern uint my_count_bits(ulonglong v); -extern uint my_count_bits_ushort(ushort v); +extern uint my_count_bits_uint32(uint32 v); #endif /* HAVE_INLINE */ C_MODE_END diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 39ee1d2f7fc..09a2ff3fe65 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2009-2011, Monty Program Ab 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 @@ -151,9 +152,10 @@ bitmap_is_set(const MY_BITMAP *map,uint bit) static inline my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2) { - *(map1)->last_word_ptr|= (map1)->last_word_mask; - *(map2)->last_word_ptr|= (map2)->last_word_mask; - return memcmp((map1)->bitmap, (map2)->bitmap, 4*no_words_in_map((map1)))==0; + if (memcmp(map1->bitmap, map2->bitmap, 4*(no_words_in_map(map1)-1)) != 0) + return FALSE; + return ((*map1->last_word_ptr | map1->last_word_mask) == + (*map2->last_word_ptr | map2->last_word_mask)); } #define bitmap_clear_all(MAP) \ diff --git a/include/my_compare.h b/include/my_compare.h new file mode 100644 index 00000000000..fc607a5b6c6 --- /dev/null +++ b/include/my_compare.h @@ -0,0 +1,98 @@ +/* Copyright (c) Monty Program Ab; 1991-2011 + Copyright (C) 2002-2006 MySQL AB + Copyright (c) 2011, Oracle and/or its affiliates. + + 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; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + 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 */ + +#ifndef _my_compare_h +#define _my_compare_h + +#include "myisampack.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct st_HA_KEYSEG /* Key-portion */ +{ + CHARSET_INFO *charset; + uint32 start; /* Start of key in record */ + uint32 null_pos; /* position to NULL indicator */ + uint16 bit_pos; /* Position to bit part */ + uint16 flag; + uint16 length; /* Keylength */ + uint8 type; /* Type of key (for sort) */ + uint8 language; + uint8 null_bit; /* bitmask to test for NULL */ + uint8 bit_start,bit_end; /* if bit field */ + uint8 bit_length; /* Length of bit part */ +} HA_KEYSEG; + +#define get_key_length(length,key) \ +{ if (*(const uchar*) (key) != 255) \ + length= (uint) *(const uchar*) ((key)++); \ + else \ + { length= mi_uint2korr((key)+1); (key)+=3; } \ +} + +#define get_key_length_rdonly(length,key) \ +{ if (*(const uchar*) (key) != 255) \ + length= ((uint) *(const uchar*) ((key))); \ + else \ + { length= mi_uint2korr((key)+1); } \ +} + +#define get_key_pack_length(length,length_pack,key) \ +{ if (*(const uchar*) (key) != 255) \ + { length= (uint) *(const uchar*) ((key)++); length_pack= 1; }\ + else \ + { length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \ +} + +#define store_key_length_inc(key,length) \ +{ if ((length) < 255) \ + { *(key)++= (length); } \ + else \ + { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \ +} + +#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3) + +#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \ + (((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \ + ((1 << (bit_len)) - 1)) + +#define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \ +{ \ + (bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \ + ((bits) << (bit_ofs)); \ + if ((bit_ofs) + (bit_len) > 8) \ + (bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \ + ((bits) >> (8 - (bit_ofs))); \ +} + +#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \ + set_rec_bits(0, bit_ptr, bit_ofs, bit_len) + +extern int ha_compare_text(CHARSET_INFO *, const uchar *, uint, + const uchar *, uint , my_bool, my_bool); +extern int ha_key_cmp(register HA_KEYSEG *keyseg, register const uchar *a, + register const uchar *b, uint key_length, + uint32 nextflag, uint *diff_pos); +extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, const uchar *a); + +#ifdef __cplusplus +} +#endif +#endif /* _my_compare_h */ diff --git a/include/my_handler.h b/include/my_handler.h index edb8e21b6a2..ca324c5b881 100644 --- a/include/my_handler.h +++ b/include/my_handler.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2006 MySQL AB +/* Copyright (c) Monty Program Ab; 1991-2011 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -18,12 +18,6 @@ #ifndef _my_handler_h #define _my_handler_h -#include "myisampack.h" - -#ifdef __cplusplus -extern "C" { -#endif - /* There is a hard limit for the maximum number of keys as there are only 8 bits in the index file header for the number of keys in a table. @@ -47,84 +41,16 @@ extern "C" { #define HA_MAX_KEY_BUFF (HA_MAX_KEY_LENGTH+HA_MAX_KEY_SEG*6+8+8) #define HA_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */ -typedef struct st_HA_KEYSEG /* Key-portion */ -{ - CHARSET_INFO *charset; - uint32 start; /* Start of key in record */ - uint32 null_pos; /* position to NULL indicator */ - uint16 bit_pos; /* Position to bit part */ - uint16 flag; - uint16 length; /* Keylength */ - uint8 type; /* Type of key (for sort) */ - uint8 language; - uint8 null_bit; /* bitmask to test for NULL */ - uint8 bit_start,bit_end; /* if bit field */ - uint8 bit_length; /* Length of bit part */ -} HA_KEYSEG; - -#define get_key_length(length,key) \ -{ if (*(const uchar*) (key) != 255) \ - length= (uint) *(const uchar*) ((key)++); \ - else \ - { length= mi_uint2korr((key)+1); (key)+=3; } \ -} - -#define get_key_length_rdonly(length,key) \ -{ if (*(const uchar*) (key) != 255) \ - length= ((uint) *(const uchar*) ((key))); \ - else \ - { length= mi_uint2korr((key)+1); } \ -} - -#define get_key_pack_length(length,length_pack,key) \ -{ if (*(const uchar*) (key) != 255) \ - { length= (uint) *(const uchar*) ((key)++); length_pack= 1; }\ - else \ - { length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \ -} - -#define store_key_length_inc(key,length) \ -{ if ((length) < 255) \ - { *(key)++= (length); } \ - else \ - { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \ -} - -#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3) - -#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \ - (((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \ - ((1 << (bit_len)) - 1)) - -#define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \ -{ \ - (bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \ - ((bits) << (bit_ofs)); \ - if ((bit_ofs) + (bit_len) > 8) \ - (bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \ - ((bits) >> (8 - (bit_ofs))); \ -} - -#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \ - set_rec_bits(0, bit_ptr, bit_ofs, bit_len) - -extern int ha_compare_text(CHARSET_INFO *, const uchar *, uint, - const uchar *, uint , my_bool, my_bool); -extern int ha_key_cmp(register HA_KEYSEG *keyseg, register const uchar *a, - register const uchar *b, uint key_length, - uint32 nextflag, uint *diff_pos); - -extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, const uchar *a); -extern void my_handler_error_register(void); -extern void my_handler_error_unregister(void); /* Inside an in-memory data record, memory pointers to pieces of the record (like BLOBs) are stored in their native byte order and in this amount of bytes. */ #define portable_sizeof_char_ptr 8 -#ifdef __cplusplus -} -#endif + +/* Register / unregister errors for my_error() */ + +extern void my_handler_error_register(void); +extern void my_handler_error_unregister(void); #endif /* _my_handler_h */ diff --git a/include/my_time.h b/include/my_time.h index 58995f1bf62..0bbb83b78b7 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -52,6 +52,19 @@ typedef long my_time_t; /* two-digit years < this are 20..; >= this are 19.. */ #define YY_PART_YEAR 70 +/* + check for valid times only if the range of time_t is greater than + the range of my_time_t +*/ +#if SIZEOF_TIME_T > 4 || defined(TIME_T_UNSIGNED) +# define IS_TIME_T_VALID_FOR_TIMESTAMP(x) \ + ((x) <= TIMESTAMP_MAX_VALUE && \ + (x) >= TIMESTAMP_MIN_VALUE) +#else +# define IS_TIME_T_VALID_FOR_TIMESTAMP(x) \ + ((x) >= TIMESTAMP_MIN_VALUE) +#endif + /* Flags to str_to_datetime */ #define TIME_FUZZY_DATE 1 #define TIME_DATETIME_ONLY 2 diff --git a/include/myisam.h b/include/myisam.h index bf31a96b792..9fc17fdf2d6 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -31,6 +31,7 @@ extern "C" { #include "keycache.h" #endif #include "my_handler.h" +#include "my_compare.h" #include <myisamchk.h> #include <mysql/plugin.h> |