You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

421 lines
13 KiB

20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
branches/innodb+: Merge revisions 2774:2799 from branches/zip: ------------------------------------------------------------------------ r2781 | marko | 2008-10-13 13:40:57 +0300 (Mon, 13 Oct 2008) | 1 line branches/zip: page_cur_delete_rec(): Call page_zip_validate_low(). ------------------------------------------------------------------------ r2783 | vasil | 2008-10-13 18:34:34 +0300 (Mon, 13 Oct 2008) | 9 lines branches/zip: Remove mysql-test/patches/bug37312.diff because MySQL "fixed" Bug#37312 by removing the test. http://bugs.mysql.com/37312 http://lists.mysql.com/commits/54462 ------------------------------------------------------------------------ r2784 | marko | 2008-10-13 21:35:30 +0300 (Mon, 13 Oct 2008) | 1 line branches/zip: Add missing NULL check to the assertion added in r2781. ------------------------------------------------------------------------ r2785 | marko | 2008-10-13 22:29:12 +0300 (Mon, 13 Oct 2008) | 2 lines branches/zip: page_cur_delete_rec(): Remove the bogus page_zip_validate_low() assertion that was added in r2781 and explain why it was bogus. ------------------------------------------------------------------------ r2786 | calvin | 2008-10-14 19:14:47 +0300 (Tue, 14 Oct 2008) | 7 lines branches/zip: fix Mantis issue #96 Problem compiling ha_innodb.cc on 64-bit Windows Change the definition of srv_replication_delay from ulint to ulong. ulint is 64-bit on Win64. Approved by: Heikki (on IM) ------------------------------------------------------------------------ r2787 | calvin | 2008-10-14 19:19:41 +0300 (Tue, 14 Oct 2008) | 7 lines branches/zip: fix compiler warning Change the definition of add_on from ulint to ullint, to eliminate the warning in .\btr\btr0cur.c: conversion from 'ullint' to 'ulint', possible loss of data Approved by: Heikki (on IM) ------------------------------------------------------------------------ r2793 | marko | 2008-10-15 10:00:06 +0300 (Wed, 15 Oct 2008) | 2 lines branches/zip: row_create_table_for_mysql(), row_create_index_for_mysql(): Note that the dictionary object will be freed. ------------------------------------------------------------------------ r2794 | marko | 2008-10-15 10:32:40 +0300 (Wed, 15 Oct 2008) | 9 lines branches/zip: When invoking page_zip_copy_recs(), update the lock table and the adaptive hash index. This should fix Issue #95 and Issue #87. page_zip_copy_recs(): Copy PAGE_MAX_TRX_ID as well, to have similar behavior to page_copy_rec_list_start() and page_copy_rec_list_end(). btr_root_raise_and_insert(), btr_page_split_and_insert(), btr_lift_page_up(): Update the lock table and the adaptive hash index. ------------------------------------------------------------------------ r2797 | marko | 2008-10-15 13:21:54 +0300 (Wed, 15 Oct 2008) | 3 lines branches/zip: Introduce UNIV_ZIP_COPY for invoking page_zip_copy_recs() more often in B-tree operations. ------------------------------------------------------------------------ r2799 | marko | 2008-10-15 14:27:42 +0300 (Wed, 15 Oct 2008) | 25 lines branches/zip: When the server crashes while freeing an externally stored column of a compressed table, the BTR_EXTERN_LEN field in the BLOB pointer will be written as 0. Tolerate this in the functions that deal with externally stored columns. This fixes Issue #80 and was posted at rb://26. Note that the clustered index record is always deleted or purged last, after any secondary index records referring to it have been deleted. btr_free_externally_stored_field(): On an uncompressed table, zero out the BTR_EXTERN_LEN, so that half-deleted BLOBs can be detected after crash recovery. btr_copy_externally_stored_field_prefix(): Return 0 if the BLOB has been half-deleted. row_upd_ext_fetch(): Assert that the externally stored column exists. row_ext_cache_fill(): Allow btr_copy_externally_stored_field_prefix() to return 0. row_sel_sec_rec_is_for_blob(): Return FALSE if the BLOB has been half-deleted. This is correct, because the clustered index record would have been deleted or purged last, after any secondary index records referring to it had been deleted. ------------------------------------------------------------------------
17 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
  1. /***************************************************************************
  2. Version control for database, common definitions, and include files
  3. (c) 1994 - 2000 Innobase Oy
  4. Created 1/20/1994 Heikki Tuuri
  5. ****************************************************************************/
  6. #ifndef univ_i
  7. #define univ_i
  8. #define INNODB_VERSION_MAJOR 1
  9. #define INNODB_VERSION_MINOR 0
  10. #define INNODB_VERSION_BUGFIX 1
  11. /* The following is the InnoDB version as shown in
  12. SELECT plugin_version FROM information_schema.plugins;
  13. calculated in in make_version_string() in sql/sql_show.cc like this:
  14. "version >> 8" . "version & 0xff"
  15. because the version is shown with only one dot, we skip the last
  16. component, i.e. we show M.N.P as M.N */
  17. #define INNODB_VERSION_SHORT \
  18. (INNODB_VERSION_MAJOR << 8 | INNODB_VERSION_MINOR)
  19. /* auxiliary macros to help creating the version as string */
  20. #define __INNODB_VERSION(a, b, c) (#a "." #b "." #c)
  21. #define _INNODB_VERSION(a, b, c) __INNODB_VERSION(a, b, c)
  22. #define INNODB_VERSION_STR \
  23. _INNODB_VERSION(INNODB_VERSION_MAJOR, \
  24. INNODB_VERSION_MINOR, \
  25. INNODB_VERSION_BUGFIX)
  26. #ifdef MYSQL_DYNAMIC_PLUGIN
  27. /* In the dynamic plugin, redefine some externally visible symbols
  28. in order not to conflict with the symbols of a builtin InnoDB. */
  29. /* Rename all C++ classes that contain virtual functions, because we
  30. have not figured out how to apply the visibility=hidden attribute to
  31. the virtual method table (vtable) in GCC 3. */
  32. # define ha_innobase ha_innodb
  33. #endif /* MYSQL_DYNAMIC_PLUGIN */
  34. #if (defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)) && !defined(MYSQL_SERVER) && !defined(__WIN__)
  35. # undef __WIN__
  36. # define __WIN__
  37. # include <windows.h>
  38. # if !defined(WIN64) && !defined(_WIN64)
  39. # define UNIV_CAN_USE_X86_ASSEMBLER
  40. # endif
  41. # ifdef _NT_
  42. # define __NT__
  43. # endif
  44. #else
  45. /* The defines used with MySQL */
  46. /* Include two header files from MySQL to make the Unix flavor used
  47. in compiling more Posix-compatible. These headers also define __WIN__
  48. if we are compiling on Windows. */
  49. # include <my_global.h>
  50. # include <my_pthread.h>
  51. /* Include <sys/stat.h> to get S_I... macros defined for os0file.c */
  52. # include <sys/stat.h>
  53. # if !defined(__NETWARE__) && !defined(__WIN__)
  54. # include <sys/mman.h> /* mmap() for os0proc.c */
  55. # endif
  56. # undef PACKAGE
  57. # undef VERSION
  58. /* Include the header file generated by GNU autoconf */
  59. # ifndef __WIN__
  60. # include "config.h"
  61. # endif
  62. # ifdef HAVE_SCHED_H
  63. # include <sched.h>
  64. # endif
  65. /* When compiling for Itanium IA64, undefine the flag below to prevent use
  66. of the 32-bit x86 assembler in mutex operations. */
  67. # if defined(__WIN__) && !defined(WIN64) && !defined(_WIN64)
  68. # define UNIV_CAN_USE_X86_ASSEMBLER
  69. # endif
  70. /* We only try to do explicit inlining of functions with gcc and
  71. Microsoft Visual C++ */
  72. # if !defined(__GNUC__)
  73. # undef UNIV_MUST_NOT_INLINE /* Remove compiler warning */
  74. # define UNIV_MUST_NOT_INLINE
  75. # endif
  76. # ifdef HAVE_PREAD
  77. # define HAVE_PWRITE
  78. # endif
  79. #endif /* #if (defined(WIN32) || ... */
  80. /* DEBUG VERSION CONTROL
  81. ===================== */
  82. /* The following flag will make InnoDB to initialize
  83. all memory it allocates to zero. It hides Purify
  84. warnings about reading unallocated memory unless
  85. memory is read outside the allocated blocks. */
  86. /*
  87. #define UNIV_INIT_MEM_TO_ZERO
  88. */
  89. /* When this macro is defined then additional test functions will be
  90. compiled. These functions live at the end of each relevant source file
  91. and have "test_" prefix. These functions are not called from anywhere in
  92. the code, they can be called from gdb after
  93. innobase_start_or_create_for_mysql() has executed using the call
  94. command. Not tested on Windows. */
  95. /*
  96. #define UNIV_COMPILE_TEST_FUNCS
  97. */
  98. #if 0
  99. #define UNIV_DEBUG_VALGRIND /* Enable extra
  100. Valgrind instrumentation */
  101. #define UNIV_DEBUG_PRINT /* Enable the compilation of
  102. some debug print functions */
  103. #define UNIV_BUF_DEBUG /* Enable buffer pool
  104. debugging without UNIV_DEBUG */
  105. #define UNIV_DEBUG /* Enable ut_ad() assertions
  106. and disable UNIV_INLINE */
  107. #define UNIV_DEBUG_FILE_ACCESSES /* Debug .ibd file access
  108. (field file_page_was_freed
  109. in buf_page_t) */
  110. #define UNIV_LRU_DEBUG /* debug the buffer pool LRU */
  111. #define UNIV_HASH_DEBUG /* debug HASH_ macros */
  112. #define UNIV_LIST_DEBUG /* debug UT_LIST_ macros */
  113. #define UNIV_MEM_DEBUG /* detect memory leaks etc */
  114. #define UNIV_IBUF_DEBUG /* debug the insert buffer */
  115. #define UNIV_IBUF_COUNT_DEBUG /* debug the insert buffer;
  116. this limits the database to IBUF_COUNT_N_SPACES and IBUF_COUNT_N_PAGES,
  117. and the insert buffer must be empty when the database is started */
  118. #define UNIV_SYNC_DEBUG /* debug mutex and latch
  119. operations (very slow); also UNIV_DEBUG must be defined */
  120. #define UNIV_SEARCH_DEBUG /* debug B-tree comparisons */
  121. #define UNIV_SYNC_PERF_STAT /* operation counts for
  122. rw-locks and mutexes */
  123. #define UNIV_SEARCH_PERF_STAT /* statistics for the
  124. adaptive hash index */
  125. #define UNIV_SRV_PRINT_LATCH_WAITS /* enable diagnostic output
  126. in sync0sync.c */
  127. #define UNIV_BTR_PRINT /* enable functions for
  128. printing B-trees */
  129. #define UNIV_ZIP_DEBUG /* extensive consistency checks
  130. for compressed pages */
  131. #define UNIV_ZIP_COPY /* call page_zip_copy_recs()
  132. more often */
  133. #endif
  134. #define UNIV_BTR_DEBUG /* check B-tree links */
  135. #define UNIV_LIGHT_MEM_DEBUG /* light memory debugging */
  136. #ifdef HAVE_purify
  137. /* The following sets all new allocated memory to zero before use:
  138. this can be used to eliminate unnecessary Purify warnings, but note that
  139. it also masks many bugs Purify could detect. For detailed Purify analysis it
  140. is best to remove the define below and look through the warnings one
  141. by one. */
  142. #define UNIV_SET_MEM_TO_ZERO
  143. #endif
  144. /*
  145. #define UNIV_SQL_DEBUG
  146. #define UNIV_LOG_DEBUG
  147. */
  148. /* the above option prevents forcing of log to disk
  149. at a buffer page write: it should be tested with this
  150. option off; also some ibuf tests are suppressed */
  151. /*
  152. #define UNIV_BASIC_LOG_DEBUG
  153. */
  154. /* the above option enables basic recovery debugging:
  155. new allocated file pages are reset */
  156. /* Linkage specifier for non-static InnoDB symbols (variables and functions)
  157. that are only referenced from within InnoDB, not from MySQL */
  158. #ifdef __WIN__
  159. # define UNIV_INTERN
  160. #else
  161. # define UNIV_INTERN __attribute__((visibility ("hidden")))
  162. #endif
  163. #if (!defined(UNIV_DEBUG) && !defined(UNIV_MUST_NOT_INLINE))
  164. /* Definition for inline version */
  165. #ifdef __WIN__
  166. #define UNIV_INLINE __inline
  167. #else
  168. #define UNIV_INLINE static __inline__
  169. #endif
  170. #else
  171. /* If we want to compile a noninlined version we use the following macro
  172. definitions: */
  173. #define UNIV_NONINL
  174. #define UNIV_INLINE UNIV_INTERN
  175. #endif /* UNIV_DEBUG */
  176. #ifdef _WIN32
  177. #define UNIV_WORD_SIZE 4
  178. #elif defined(_WIN64)
  179. #define UNIV_WORD_SIZE 8
  180. #else
  181. /* MySQL config.h generated by GNU autoconf will define SIZEOF_LONG in Posix */
  182. #define UNIV_WORD_SIZE SIZEOF_LONG
  183. #endif
  184. /* The following alignment is used in memory allocations in memory heap
  185. management to ensure correct alignment for doubles etc. */
  186. #define UNIV_MEM_ALIGNMENT 8
  187. /* The following alignment is used in aligning lints etc. */
  188. #define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
  189. /*
  190. DATABASE VERSION CONTROL
  191. ========================
  192. */
  193. /* The 2-logarithm of UNIV_PAGE_SIZE: */
  194. #define UNIV_PAGE_SIZE_SHIFT 14
  195. /* The universal page size of the database */
  196. #define UNIV_PAGE_SIZE (1 << UNIV_PAGE_SIZE_SHIFT)
  197. /* Maximum number of parallel threads in a parallelized operation */
  198. #define UNIV_MAX_PARALLELISM 32
  199. /*
  200. UNIVERSAL TYPE DEFINITIONS
  201. ==========================
  202. */
  203. /* Note that inside MySQL 'byte' is defined as char on Linux! */
  204. #define byte unsigned char
  205. /* Define an unsigned integer type that is exactly 32 bits. */
  206. #if SIZEOF_INT == 4
  207. typedef unsigned int ib_uint32_t;
  208. #elif SIZEOF_LONG == 4
  209. typedef unsigned long ib_uint32_t;
  210. #else
  211. #error "Neither int or long is 4 bytes"
  212. #endif
  213. /* Another basic type we use is unsigned long integer which should be equal to
  214. the word size of the machine, that is on a 32-bit platform 32 bits, and on a
  215. 64-bit platform 64 bits. We also give the printf format for the type as a
  216. macro ULINTPF. */
  217. #ifdef _WIN64
  218. typedef unsigned __int64 ulint;
  219. #define ULINTPF "%I64u"
  220. typedef __int64 lint;
  221. #else
  222. typedef unsigned long int ulint;
  223. #define ULINTPF "%lu"
  224. typedef long int lint;
  225. #endif
  226. #ifdef __WIN__
  227. typedef __int64 ib_int64_t;
  228. typedef unsigned __int64 ib_uint64_t;
  229. #else
  230. /* Note: longlong and ulonglong come from MySQL headers. */
  231. typedef longlong ib_int64_t;
  232. typedef ulonglong ib_uint64_t;
  233. #endif
  234. typedef unsigned long long int ullint;
  235. #ifndef __WIN__
  236. #if SIZEOF_LONG != SIZEOF_VOIDP
  237. #error "Error: InnoDB's ulint must be of the same size as void*"
  238. #endif
  239. #endif
  240. /* The 'undefined' value for a ulint */
  241. #define ULINT_UNDEFINED ((ulint)(-1))
  242. /* The undefined 32-bit unsigned integer */
  243. #define ULINT32_UNDEFINED 0xFFFFFFFF
  244. /* Maximum value for a ulint */
  245. #define ULINT_MAX ((ulint)(-2))
  246. /* Maximum value for ib_uint64_t */
  247. #define IB_ULONGLONG_MAX ((ib_uint64_t) (~0ULL))
  248. /* This 'ibool' type is used within Innobase. Remember that different included
  249. headers may define 'bool' differently. Do not assume that 'bool' is a ulint! */
  250. #define ibool ulint
  251. #ifndef TRUE
  252. #define TRUE 1
  253. #define FALSE 0
  254. #endif
  255. /* The following number as the length of a logical field means that the field
  256. has the SQL NULL as its value. NOTE that because we assume that the length
  257. of a field is a 32-bit integer when we store it, for example, to an undo log
  258. on disk, we must have also this number fit in 32 bits, also in 64-bit
  259. computers! */
  260. #define UNIV_SQL_NULL ULINT32_UNDEFINED
  261. /* Lengths which are not UNIV_SQL_NULL, but bigger than the following
  262. number indicate that a field contains a reference to an externally
  263. stored part of the field in the tablespace. The length field then
  264. contains the sum of the following flag and the locally stored len. */
  265. #define UNIV_EXTERN_STORAGE_FIELD (UNIV_SQL_NULL - UNIV_PAGE_SIZE)
  266. /* Some macros to improve branch prediction and reduce cache misses */
  267. #if defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER)
  268. /* Tell the compiler that 'expr' probably evaluates to 'constant'. */
  269. # define UNIV_EXPECT(expr,constant) __builtin_expect(expr, constant)
  270. /* Tell the compiler that a pointer is likely to be NULL */
  271. # define UNIV_LIKELY_NULL(ptr) __builtin_expect((ulint) ptr, 0)
  272. /* Minimize cache-miss latency by moving data at addr into a cache before
  273. it is read. */
  274. # define UNIV_PREFETCH_R(addr) __builtin_prefetch(addr, 0, 3)
  275. /* Minimize cache-miss latency by moving data at addr into a cache before
  276. it is read or written. */
  277. # define UNIV_PREFETCH_RW(addr) __builtin_prefetch(addr, 1, 3)
  278. #else
  279. /* Dummy versions of the macros */
  280. # define UNIV_EXPECT(expr,value) (expr)
  281. # define UNIV_LIKELY_NULL(expr) (expr)
  282. # define UNIV_PREFETCH_R(addr) ((void) 0)
  283. # define UNIV_PREFETCH_RW(addr) ((void) 0)
  284. #endif
  285. /* Tell the compiler that cond is likely to hold */
  286. #define UNIV_LIKELY(cond) UNIV_EXPECT(cond, TRUE)
  287. /* Tell the compiler that cond is unlikely to hold */
  288. #define UNIV_UNLIKELY(cond) UNIV_EXPECT(cond, FALSE)
  289. /* Compile-time constant of the given array's size. */
  290. #define UT_ARR_SIZE(a) (sizeof(a) / sizeof((a)[0]))
  291. /* The return type from a thread's start function differs between Unix and
  292. Windows, so define a typedef for it and a macro to use at the end of such
  293. functions. */
  294. #ifdef __WIN__
  295. typedef ulint os_thread_ret_t;
  296. #define OS_THREAD_DUMMY_RETURN return(0)
  297. #else
  298. typedef void* os_thread_ret_t;
  299. #define OS_THREAD_DUMMY_RETURN return(NULL)
  300. #endif
  301. #include <stdio.h>
  302. #include "ut0dbg.h"
  303. #include "ut0ut.h"
  304. #include "db0err.h"
  305. #ifdef UNIV_DEBUG_VALGRIND
  306. # include <valgrind/memcheck.h>
  307. # define UNIV_MEM_VALID(addr, size) VALGRIND_MAKE_MEM_DEFINED(addr, size)
  308. # define UNIV_MEM_INVALID(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size)
  309. # define UNIV_MEM_FREE(addr, size) VALGRIND_MAKE_MEM_NOACCESS(addr, size)
  310. # define UNIV_MEM_ALLOC(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size)
  311. # define UNIV_MEM_DESC(addr, size, b) VALGRIND_CREATE_BLOCK(addr, size, b)
  312. # define UNIV_MEM_UNDESC(b) VALGRIND_DISCARD(b)
  313. # define UNIV_MEM_ASSERT_RW(addr, size) do { \
  314. const void* _p = (const void*) (ulint) \
  315. VALGRIND_CHECK_MEM_IS_DEFINED(addr, size); \
  316. if (UNIV_LIKELY_NULL(_p)) \
  317. fprintf(stderr, "%s:%d: %p[%u] undefined at %ld\n", \
  318. __FILE__, __LINE__, \
  319. (const void*) (addr), (unsigned) (size), (long) \
  320. (((const char*) _p) - ((const char*) (addr)))); \
  321. } while (0)
  322. # define UNIV_MEM_ASSERT_W(addr, size) do { \
  323. const void* _p = (const void*) (ulint) \
  324. VALGRIND_CHECK_MEM_IS_ADDRESSABLE(addr, size); \
  325. if (UNIV_LIKELY_NULL(_p)) \
  326. fprintf(stderr, "%s:%d: %p[%u] unwritable at %ld\n", \
  327. __FILE__, __LINE__, \
  328. (const void*) (addr), (unsigned) (size), (long) \
  329. (((const char*) _p) - ((const char*) (addr)))); \
  330. } while (0)
  331. #else
  332. # define UNIV_MEM_VALID(addr, size) do {} while(0)
  333. # define UNIV_MEM_INVALID(addr, size) do {} while(0)
  334. # define UNIV_MEM_FREE(addr, size) do {} while(0)
  335. # define UNIV_MEM_ALLOC(addr, size) do {} while(0)
  336. # define UNIV_MEM_DESC(addr, size, b) do {} while(0)
  337. # define UNIV_MEM_UNDESC(b) do {} while(0)
  338. # define UNIV_MEM_ASSERT_RW(addr, size) do {} while(0)
  339. # define UNIV_MEM_ASSERT_W(addr, size) do {} while(0)
  340. #endif
  341. #define UNIV_MEM_ASSERT_AND_FREE(addr, size) do { \
  342. UNIV_MEM_ASSERT_W(addr, size); \
  343. UNIV_MEM_FREE(addr, size); \
  344. } while (0)
  345. #define UNIV_MEM_ASSERT_AND_ALLOC(addr, size) do { \
  346. UNIV_MEM_ASSERT_W(addr, size); \
  347. UNIV_MEM_ALLOC(addr, size); \
  348. } while (0)
  349. #endif