From 2cdcb18bf4f7a68fcb05e50a66e0689a513b49e2 Mon Sep 17 00:00:00 2001 From: Inaam Rana Date: Wed, 21 Dec 2011 21:33:13 -0500 Subject: [PATCH 01/11] Bug#11866367 FPE WHEN SETTING INNODB_SPIN_WAIT_DELAY rb://865 approved by: Jimmy Integer overflow causes division by zero. --- storage/innobase/include/ut0rnd.ic | 2 +- storage/innodb_plugin/include/ut0rnd.ic | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/include/ut0rnd.ic b/storage/innobase/include/ut0rnd.ic index dc4c0d62f56..b54f629de37 100644 --- a/storage/innobase/include/ut0rnd.ic +++ b/storage/innobase/include/ut0rnd.ic @@ -96,7 +96,7 @@ ut_rnd_interval( rnd = ut_rnd_gen_ulint(); - return(low + (rnd % (high - low + 1))); + return(low + (rnd % (high - low))); } /************************************************************* diff --git a/storage/innodb_plugin/include/ut0rnd.ic b/storage/innodb_plugin/include/ut0rnd.ic index a33813037ea..3ae12f69186 100644 --- a/storage/innodb_plugin/include/ut0rnd.ic +++ b/storage/innodb_plugin/include/ut0rnd.ic @@ -114,7 +114,7 @@ ut_rnd_interval( rnd = ut_rnd_gen_ulint(); - return(low + (rnd % (high - low + 1))); + return(low + (rnd % (high - low))); } /*********************************************************//** From 5107833244b0273896eb0b54cd4be84da4d66f10 Mon Sep 17 00:00:00 2001 From: Inaam Rana Date: Wed, 21 Dec 2011 21:36:52 -0500 Subject: [PATCH 02/11] Add ChangeLog message. --- storage/innodb_plugin/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 5fc0cce3ff2..1385da94bfb 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,8 @@ +2011-12-21 The InnoDB Team + + * include/ut0rnd.ic: + Fix Bug#11866367:FPE WHEN SETTING INNODB_SPIN_WAIT_DELAY + 2011-12-13 The InnoDB Team * handler/ha_innodb.cc, innodb.test, innodb.result: From 2a21a662a3ce5a7090f8959fffd7981e0248b59e Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Fri, 23 Dec 2011 17:22:48 +0400 Subject: [PATCH 03/11] Fix for bug#11758931 - 51196: SLAVE SQL: GOT AN ERROR WRITING COMMUNICATION PACKETS, ERROR_CODE: 1160 If idle FEDERATED table is evicted from the table cache when a connection to remote server is lost, query that initiated eviction may fail. If this query is executed by slave SQL thread it may fail as well. An error of close was stored in diagnostics area, which was later attributed to the statement that caused eviction. With this patch FEDERATED clears an error of close. --- storage/federated/ha_federated.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 21c0b7b178d..64d5af446d8 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -1651,6 +1651,15 @@ int ha_federated::close(void) mysql_close(mysql); mysql= NULL; + /* + mysql_close() might return an error if a remote server's gone + for some reason. If that happens while removing a table from + the table cache, the error will be propagated to a client even + if the original query was not issued against the FEDERATED table. + So, don't propagate errors from mysql_close(). + */ + table->in_use->clear_error(); + DBUG_RETURN(free_share(share)); } From 5e6ff79ac2751e1285edc7ad2508d3fe546d59d3 Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Fri, 23 Dec 2011 18:52:44 +0400 Subject: [PATCH 04/11] Fix for bug#11758931 - 51196: SLAVE SQL: GOT AN ERROR WRITING COMMUNICATION PACKETS, ERROR_CODE: 1160 Addendum: for some queries table->in_use might be NULL - check it. --- storage/federated/ha_federated.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 64d5af446d8..f53066a4b22 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -1658,7 +1658,8 @@ int ha_federated::close(void) if the original query was not issued against the FEDERATED table. So, don't propagate errors from mysql_close(). */ - table->in_use->clear_error(); + if (table->in_use) + table->in_use->clear_error(); DBUG_RETURN(free_share(share)); } From a290a8440367abbc6a29235d0f35cd52c139690f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 28 Dec 2011 12:19:30 +0200 Subject: [PATCH 05/11] Bug#13418934 REMOVE HAVE_PURIFY DEPENDENCES FROM INNODB InnoDB: Remove HAVE_purify, UNIV_INIT_MEM_TO_ZERO, UNIV_SET_MEM_TO_ZERO. The compile-time setting HAVE_purify can mask potential bugs. It is being set in PB2 Valgrind runs. We should simply get rid of it, and replace it with UNIV_MEM_INVALID() to declare uninitialized memory as such in Valgrind-instrumented binaries. os_mem_alloc_large(), ut_malloc_low(): Remove the parameter set_to_zero. ut_malloc(): Define as a macro that invokes ut_malloc_low(). buf_pool_init(): Never initialize the buffer pool frames. All pages must be initialized before flushing them to disk. mem_heap_alloc(): Never initialize the allocated memory block. os_mem_alloc_nocache(), ut_test_malloc(): Unused function, remove. rb:813 approved by Jimmy Yang --- storage/innobase/buf/buf0buf.c | 8 +-- storage/innobase/include/mem0mem.ic | 4 -- storage/innobase/include/os0proc.h | 11 ---- storage/innobase/include/univ.i | 17 ----- storage/innobase/include/ut0mem.h | 26 +------- storage/innobase/mem/mem0pool.c | 6 +- storage/innobase/os/os0proc.c | 33 +--------- storage/innobase/ut/ut0mem.c | 65 +------------------ storage/innodb_plugin/buf/buf0buf.c | 5 +- storage/innodb_plugin/include/mem0mem.ic | 4 -- storage/innodb_plugin/include/univ.i | 17 ----- storage/innodb_plugin/include/ut0mem.h | 31 ++------- storage/innodb_plugin/mem/mem0pool.c | 6 +- storage/innodb_plugin/os/os0proc.c | 3 - storage/innodb_plugin/ut/ut0mem.c | 82 +----------------------- 15 files changed, 16 insertions(+), 302 deletions(-) diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index 78b39812cff..5463098a654 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -634,7 +634,7 @@ buf_pool_init( /*----------------------------------------*/ } else { buf_pool->frame_mem = os_mem_alloc_large( - UNIV_PAGE_SIZE * (n_frames + 1), TRUE, FALSE); + UNIV_PAGE_SIZE * (n_frames + 1), FALSE); } if (buf_pool->frame_mem == NULL) { @@ -756,12 +756,8 @@ buf_pool_init( block = buf_pool_get_nth_block(buf_pool, i); if (block->frame) { - /* Wipe contents of frame to eliminate a Purify - warning */ + UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE); -#ifdef HAVE_purify - memset(block->frame, '\0', UNIV_PAGE_SIZE); -#endif if (srv_use_awe) { /* Add to the list of blocks mapped to frames */ diff --git a/storage/innobase/include/mem0mem.ic b/storage/innobase/include/mem0mem.ic index 782672dbc18..0191e9a3ffd 100644 --- a/storage/innobase/include/mem0mem.ic +++ b/storage/innobase/include/mem0mem.ic @@ -194,10 +194,6 @@ mem_heap_alloc( caller */ buf = (byte*)buf + MEM_FIELD_HEADER_SIZE; -#endif -#ifdef UNIV_SET_MEM_TO_ZERO - UNIV_MEM_ALLOC(buf, n); - memset(buf, '\0', n); #endif UNIV_MEM_ALLOC(buf, n); return(buf); diff --git a/storage/innobase/include/os0proc.h b/storage/innobase/include/os0proc.h index f54e08de7ee..8c169f92431 100644 --- a/storage/innobase/include/os0proc.h +++ b/storage/innobase/include/os0proc.h @@ -104,14 +104,6 @@ ulint os_proc_get_number(void); /*====================*/ /******************************************************************** -Allocates non-cacheable memory. */ - -void* -os_mem_alloc_nocache( -/*=================*/ - /* out: allocated memory */ - ulint n); /* in: number of bytes */ -/******************************************************************** Allocates large pages memory. */ void* @@ -119,9 +111,6 @@ os_mem_alloc_large( /*===============*/ /* out: allocated memory */ ulint n, /* in: number of bytes */ - ibool set_to_zero, /* in: TRUE if allocated memory - should be set to zero if - UNIV_SET_MEM_TO_ZERO is defined */ ibool assert_on_error);/* in: if TRUE, we crash mysqld if the memory cannot be allocated */ /******************************************************************** diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index a67b1b3895e..4ac0809bcd2 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -72,14 +72,6 @@ Microsoft Visual C++ */ /* DEBUG VERSION CONTROL ===================== */ -/* The following flag will make InnoDB to initialize -all memory it allocates to zero. It hides Purify -warnings about reading unallocated memory unless -memory is read outside the allocated blocks. */ -/* -#define UNIV_INIT_MEM_TO_ZERO -*/ - /* Make a non-inline debug version */ #if defined HAVE_VALGRIND @@ -112,15 +104,6 @@ operations (very slow); also UNIV_DEBUG must be defined */ #define UNIV_BTR_DEBUG /* check B-tree links */ #define UNIV_LIGHT_MEM_DEBUG /* light memory debugging */ -#ifdef HAVE_purify -/* The following sets all new allocated memory to zero before use: -this can be used to eliminate unnecessary Purify warnings, but note that -it also masks many bugs Purify could detect. For detailed Purify analysis it -is best to remove the define below and look through the warnings one -by one. */ -#define UNIV_SET_MEM_TO_ZERO -#endif - /* #define UNIV_SQL_DEBUG #define UNIV_LOG_DEBUG diff --git a/storage/innobase/include/ut0mem.h b/storage/innobase/include/ut0mem.h index cb369e85c39..0dff70abc3a 100644 --- a/storage/innobase/include/ut0mem.h +++ b/storage/innobase/include/ut0mem.h @@ -30,38 +30,18 @@ ut_memcmp(const void* str1, const void* str2, ulint n); /************************************************************************** -Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is -defined and set_to_zero is TRUE. */ +Allocates memory. */ void* ut_malloc_low( /*==========*/ /* out, own: allocated memory */ ulint n, /* in: number of bytes to allocate */ - ibool set_to_zero, /* in: TRUE if allocated memory - should be set to zero if - UNIV_SET_MEM_TO_ZERO is defined */ ibool assert_on_error); /* in: if TRUE, we crash mysqld if the memory cannot be allocated */ /************************************************************************** -Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is -defined. */ - -void* -ut_malloc( -/*======*/ - /* out, own: allocated memory */ - ulint n); /* in: number of bytes to allocate */ -/************************************************************************** -Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs -out. It cannot be used if we want to return an error message. Prints to -stderr a message if fails. */ - -ibool -ut_test_malloc( -/*===========*/ - /* out: TRUE if succeeded */ - ulint n); /* in: try to allocate this many bytes */ +Allocates memory. */ +#define ut_malloc(n) ut_malloc_low(n, TRUE) /************************************************************************** Frees a memory block allocated with ut_malloc. */ diff --git a/storage/innobase/mem/mem0pool.c b/storage/innobase/mem/mem0pool.c index 27da86a0309..6740ff04a4f 100644 --- a/storage/innobase/mem/mem0pool.c +++ b/storage/innobase/mem/mem0pool.c @@ -196,11 +196,7 @@ mem_pool_create( pool = ut_malloc(sizeof(mem_pool_t)); - /* We do not set the memory to zero (FALSE) in the pool, - but only when allocated at a higher level in mem0mem.c. - This is to avoid masking useful Purify warnings. */ - - pool->buf = ut_malloc_low(size, FALSE, TRUE); + pool->buf = ut_malloc_low(size, TRUE); pool->size = size; mutex_create(&pool->mutex, SYNC_MEM_POOL); diff --git a/storage/innobase/os/os0proc.c b/storage/innobase/os/os0proc.c index f00475fc528..6092392616f 100644 --- a/storage/innobase/os/os0proc.c +++ b/storage/innobase/os/os0proc.c @@ -531,28 +531,6 @@ os_proc_get_number(void) #endif } -/******************************************************************** -Allocates non-cacheable memory. */ - -void* -os_mem_alloc_nocache( -/*=================*/ - /* out: allocated memory */ - ulint n) /* in: number of bytes */ -{ -#ifdef __WIN__ - void* ptr; - - ptr = VirtualAlloc(NULL, n, MEM_COMMIT, - PAGE_READWRITE | PAGE_NOCACHE); - ut_a(ptr); - - return(ptr); -#else - return(ut_malloc(n)); -#endif -} - /******************************************************************** Allocates large pages memory. */ @@ -561,9 +539,6 @@ os_mem_alloc_large( /*===============*/ /* out: allocated memory */ ulint n, /* in: number of bytes */ - ibool set_to_zero, /* in: TRUE if allocated memory - should be set to zero if - UNIV_SET_MEM_TO_ZERO is defined */ ibool assert_on_error)/* in: if TRUE, we crash mysqld if the memory cannot be allocated */ { @@ -602,12 +577,6 @@ os_mem_alloc_large( #endif if (ptr) { - if (set_to_zero) { -#ifdef UNIV_SET_MEM_TO_ZERO - memset(ptr, '\0', size); -#endif - } - return(ptr); } @@ -616,7 +585,7 @@ os_mem_alloc_large( skip: #endif /* HAVE_LARGE_PAGES */ - return(ut_malloc_low(n, set_to_zero, assert_on_error)); + return(ut_malloc_low(n, assert_on_error)); } /******************************************************************** diff --git a/storage/innobase/ut/ut0mem.c b/storage/innobase/ut/ut0mem.c index 2e0dd27edf4..55f1c8593b8 100644 --- a/storage/innobase/ut/ut0mem.c +++ b/storage/innobase/ut/ut0mem.c @@ -54,17 +54,13 @@ ut_mem_block_list_init(void) } /************************************************************************** -Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is -defined and set_to_zero is TRUE. */ +Allocates memory. */ void* ut_malloc_low( /*==========*/ /* out, own: allocated memory */ ulint n, /* in: number of bytes to allocate */ - ibool set_to_zero, /* in: TRUE if allocated memory should be - set to zero if UNIV_SET_MEM_TO_ZERO is - defined */ ibool assert_on_error)/* in: if TRUE, we crash mysqld if the memory cannot be allocated */ { @@ -156,12 +152,6 @@ retry: #endif } - if (set_to_zero) { -#ifdef UNIV_SET_MEM_TO_ZERO - memset(ret, '\0', n + sizeof(ut_mem_block_t)); -#endif - } - UNIV_MEM_ALLOC(ret, n + sizeof(ut_mem_block_t)); ((ut_mem_block_t*)ret)->size = n + sizeof(ut_mem_block_t); @@ -176,59 +166,6 @@ retry: return((void*)((byte*)ret + sizeof(ut_mem_block_t))); } -/************************************************************************** -Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is -defined. */ - -void* -ut_malloc( -/*======*/ - /* out, own: allocated memory */ - ulint n) /* in: number of bytes to allocate */ -{ - return(ut_malloc_low(n, TRUE, TRUE)); -} - -/************************************************************************** -Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs -out. It cannot be used if we want to return an error message. Prints to -stderr a message if fails. */ - -ibool -ut_test_malloc( -/*===========*/ - /* out: TRUE if succeeded */ - ulint n) /* in: try to allocate this many bytes */ -{ - void* ret; - - ret = malloc(n); - - if (ret == NULL) { - ut_print_timestamp(stderr); - fprintf(stderr, - " InnoDB: Error: cannot allocate" - " %lu bytes of memory for\n" - "InnoDB: a BLOB with malloc! Total allocated memory\n" - "InnoDB: by InnoDB %lu bytes." - " Operating system errno: %d\n" - "InnoDB: Check if you should increase" - " the swap file or\n" - "InnoDB: ulimits of your operating system.\n" - "InnoDB: On FreeBSD check you have" - " compiled the OS with\n" - "InnoDB: a big enough maximum process size.\n", - (ulong) n, - (ulong) ut_total_allocated_memory, - (int) errno); - return(FALSE); - } - - free(ret); - - return(TRUE); -} - /************************************************************************** Frees a memory block allocated with ut_malloc. */ diff --git a/storage/innodb_plugin/buf/buf0buf.c b/storage/innodb_plugin/buf/buf0buf.c index d88860b807b..6daaacb0ac0 100644 --- a/storage/innodb_plugin/buf/buf0buf.c +++ b/storage/innodb_plugin/buf/buf0buf.c @@ -750,11 +750,8 @@ buf_chunk_init( for (i = chunk->size; i--; ) { buf_block_init(block, frame); + UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE); -#ifdef HAVE_purify - /* Wipe contents of frame to eliminate a Purify warning */ - memset(block->frame, '\0', UNIV_PAGE_SIZE); -#endif /* Add the block to the free list */ UT_LIST_ADD_LAST(list, buf_pool->free, (&block->page)); ut_d(block->page.in_free_list = TRUE); diff --git a/storage/innodb_plugin/include/mem0mem.ic b/storage/innodb_plugin/include/mem0mem.ic index cbce2edc661..bf7b1c20cb4 100644 --- a/storage/innodb_plugin/include/mem0mem.ic +++ b/storage/innodb_plugin/include/mem0mem.ic @@ -208,10 +208,6 @@ mem_heap_alloc( caller */ buf = (byte*)buf + MEM_FIELD_HEADER_SIZE; -#endif -#ifdef UNIV_SET_MEM_TO_ZERO - UNIV_MEM_ALLOC(buf, n); - memset(buf, '\0', n); #endif UNIV_MEM_ALLOC(buf, n); return(buf); diff --git a/storage/innodb_plugin/include/univ.i b/storage/innodb_plugin/include/univ.i index 5e36867f05a..c3aa3d25e36 100644 --- a/storage/innodb_plugin/include/univ.i +++ b/storage/innodb_plugin/include/univ.i @@ -146,14 +146,6 @@ Sun Studio */ /* DEBUG VERSION CONTROL ===================== */ -/* The following flag will make InnoDB to initialize -all memory it allocates to zero. It hides Purify -warnings about reading unallocated memory unless -memory is read outside the allocated blocks. */ -/* -#define UNIV_INIT_MEM_TO_ZERO -*/ - /* When this macro is defined then additional test functions will be compiled. These functions live at the end of each relevant source file and have "test_" prefix. These functions are not called from anywhere in @@ -218,15 +210,6 @@ operations (very slow); also UNIV_DEBUG must be defined */ #define UNIV_BTR_DEBUG /* check B-tree links */ #define UNIV_LIGHT_MEM_DEBUG /* light memory debugging */ -#ifdef HAVE_purify -/* The following sets all new allocated memory to zero before use: -this can be used to eliminate unnecessary Purify warnings, but note that -it also masks many bugs Purify could detect. For detailed Purify analysis it -is best to remove the define below and look through the warnings one -by one. */ -#define UNIV_SET_MEM_TO_ZERO -#endif - /* #define UNIV_SQL_DEBUG #define UNIV_LOG_DEBUG diff --git a/storage/innodb_plugin/include/ut0mem.h b/storage/innodb_plugin/include/ut0mem.h index 9c6ee9049ec..5002c9e3801 100644 --- a/storage/innodb_plugin/include/ut0mem.h +++ b/storage/innodb_plugin/include/ut0mem.h @@ -78,40 +78,19 @@ ut_mem_init(void); /*=============*/ /**********************************************************************//** -Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is -defined and set_to_zero is TRUE. +Allocates memory. @return own: allocated memory */ UNIV_INTERN void* ut_malloc_low( /*==========*/ ulint n, /*!< in: number of bytes to allocate */ - ibool set_to_zero, /*!< in: TRUE if allocated memory - should be set to zero if - UNIV_SET_MEM_TO_ZERO is defined */ - ibool assert_on_error); /*!< in: if TRUE, we crash mysqld if + ibool assert_on_error) /*!< in: if TRUE, we crash mysqld if the memory cannot be allocated */ + __attribute__((malloc)); /**********************************************************************//** -Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is -defined. -@return own: allocated memory */ -UNIV_INTERN -void* -ut_malloc( -/*======*/ - ulint n); /*!< in: number of bytes to allocate */ -#ifndef UNIV_HOTBACKUP -/**********************************************************************//** -Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs -out. It cannot be used if we want to return an error message. Prints to -stderr a message if fails. -@return TRUE if succeeded */ -UNIV_INTERN -ibool -ut_test_malloc( -/*===========*/ - ulint n); /*!< in: try to allocate this many bytes */ -#endif /* !UNIV_HOTBACKUP */ +Allocates memory. */ +#define ut_malloc(n) ut_malloc_low(n, TRUE) /**********************************************************************//** Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is a nop. */ diff --git a/storage/innodb_plugin/mem/mem0pool.c b/storage/innodb_plugin/mem/mem0pool.c index 3291453eeb5..8a01be66506 100644 --- a/storage/innodb_plugin/mem/mem0pool.c +++ b/storage/innodb_plugin/mem/mem0pool.c @@ -223,11 +223,7 @@ mem_pool_create( pool = ut_malloc(sizeof(mem_pool_t)); - /* We do not set the memory to zero (FALSE) in the pool, - but only when allocated at a higher level in mem0mem.c. - This is to avoid masking useful Purify warnings. */ - - pool->buf = ut_malloc_low(size, FALSE, TRUE); + pool->buf = ut_malloc_low(size, TRUE); pool->size = size; mutex_create(&pool->mutex, SYNC_MEM_POOL); diff --git a/storage/innodb_plugin/os/os0proc.c b/storage/innodb_plugin/os/os0proc.c index 48922886f23..a0679e31570 100644 --- a/storage/innodb_plugin/os/os0proc.c +++ b/storage/innodb_plugin/os/os0proc.c @@ -111,9 +111,6 @@ os_mem_alloc_large( os_fast_mutex_lock(&ut_list_mutex); ut_total_allocated_memory += size; os_fast_mutex_unlock(&ut_list_mutex); -# ifdef UNIV_SET_MEM_TO_ZERO - memset(ptr, '\0', size); -# endif UNIV_MEM_ALLOC(ptr, size); return(ptr); } diff --git a/storage/innodb_plugin/ut/ut0mem.c b/storage/innodb_plugin/ut/ut0mem.c index 95fb2187b79..9f9eb1c4d49 100644 --- a/storage/innodb_plugin/ut/ut0mem.c +++ b/storage/innodb_plugin/ut/ut0mem.c @@ -84,17 +84,13 @@ ut_mem_init(void) #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** -Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is -defined and set_to_zero is TRUE. +Allocates memory. @return own: allocated memory */ UNIV_INTERN void* ut_malloc_low( /*==========*/ ulint n, /*!< in: number of bytes to allocate */ - ibool set_to_zero, /*!< in: TRUE if allocated memory should be - set to zero if UNIV_SET_MEM_TO_ZERO is - defined */ ibool assert_on_error)/*!< in: if TRUE, we crash mysqld if the memory cannot be allocated */ { @@ -106,12 +102,6 @@ ut_malloc_low( ret = malloc(n); ut_a(ret || !assert_on_error); -#ifdef UNIV_SET_MEM_TO_ZERO - if (set_to_zero) { - memset(ret, '\0', n); - UNIV_MEM_ALLOC(ret, n); - } -#endif return(ret); } @@ -199,12 +189,6 @@ retry: #endif } - if (set_to_zero) { -#ifdef UNIV_SET_MEM_TO_ZERO - memset(ret, '\0', n + sizeof(ut_mem_block_t)); -#endif - } - UNIV_MEM_ALLOC(ret, n + sizeof(ut_mem_block_t)); ((ut_mem_block_t*)ret)->size = n + sizeof(ut_mem_block_t); @@ -221,74 +205,10 @@ retry: void* ret = malloc(n); ut_a(ret || !assert_on_error); -# ifdef UNIV_SET_MEM_TO_ZERO - if (set_to_zero) { - memset(ret, '\0', n); - } -# endif return(ret); #endif /* !UNIV_HOTBACKUP */ } -/**********************************************************************//** -Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is -defined. -@return own: allocated memory */ -UNIV_INTERN -void* -ut_malloc( -/*======*/ - ulint n) /*!< in: number of bytes to allocate */ -{ -#ifndef UNIV_HOTBACKUP - return(ut_malloc_low(n, TRUE, TRUE)); -#else /* !UNIV_HOTBACKUP */ - return(malloc(n)); -#endif /* !UNIV_HOTBACKUP */ -} - -#ifndef UNIV_HOTBACKUP -/**********************************************************************//** -Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs -out. It cannot be used if we want to return an error message. Prints to -stderr a message if fails. -@return TRUE if succeeded */ -UNIV_INTERN -ibool -ut_test_malloc( -/*===========*/ - ulint n) /*!< in: try to allocate this many bytes */ -{ - void* ret; - - ret = malloc(n); - - if (ret == NULL) { - ut_print_timestamp(stderr); - fprintf(stderr, - " InnoDB: Error: cannot allocate" - " %lu bytes of memory for\n" - "InnoDB: a BLOB with malloc! Total allocated memory\n" - "InnoDB: by InnoDB %lu bytes." - " Operating system errno: %d\n" - "InnoDB: Check if you should increase" - " the swap file or\n" - "InnoDB: ulimits of your operating system.\n" - "InnoDB: On FreeBSD check you have" - " compiled the OS with\n" - "InnoDB: a big enough maximum process size.\n", - (ulong) n, - (ulong) ut_total_allocated_memory, - (int) errno); - return(FALSE); - } - - free(ret); - - return(TRUE); -} -#endif /* !UNIV_HOTBACKUP */ - /**********************************************************************//** Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is a nop. */ From 1666da4b23a7b5ad1a442d39aedefd933fadd015 Mon Sep 17 00:00:00 2001 From: Tatjana Azundris Nuernberg Date: Mon, 2 Jan 2012 06:25:48 +0000 Subject: [PATCH 06/11] BUG#11755281/47032: ERROR 2006 / ERROR 2013 INSTEAD OF PROPER ERROR MESSAGE If init_command was incorrect, we couldn't let users execute queries, but we couldn't report the issue to the client either as it does not expect error messages before even sending a command. Thus, we simply disconnected them without throwing a clear error. We now go through the proper sequence once (without executing any user statements) so we can report back what the problem is. Only then do we disconnect the user. As always, root remains unaffected by this as init_command is (still) not executed for them. --- mysql-test/r/init_connect.result | 2 ++ mysql-test/t/init_connect.test | 8 ++++++++ sql/sql_connect.cc | 29 +++++++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/init_connect.result b/mysql-test/r/init_connect.result index f5ec0bdc932..0ff6c206422 100644 --- a/mysql-test/r/init_connect.result +++ b/mysql-test/r/init_connect.result @@ -20,6 +20,8 @@ hex(a) 616263 set GLOBAL init_connect="adsfsdfsdfs"; select @a; +ERROR 08S01: Aborted connection to db: 'test' user: 'user_1' host: 'localhost' (init_connect command failed) +select @a; Got one of the listed errors drop table t1; End of 4.1 tests diff --git a/mysql-test/t/init_connect.test b/mysql-test/t/init_connect.test index b6bac5f65fa..e96d02fe0d1 100644 --- a/mysql-test/t/init_connect.test +++ b/mysql-test/t/init_connect.test @@ -36,6 +36,14 @@ connection con0; set GLOBAL init_connect="adsfsdfsdfs"; connect (con5,localhost,user_1,,); connection con5; +# BUG#11755281/47032: ERROR 2006 / ERROR 2013 INSTEAD OF PROPER ERROR MESSAGE +# We now throw a proper error message here: +--replace_regex /connection .* to/connection to/ +--error ER_NEW_ABORTING_CONNECTION +select @a; +# We got disconnected after receiving the above error message; any further +# requests should fail with a notice that no one's listening to us. +# --error CR_SERVER_GONE_ERROR,CR_SERVER_LOST --error 2013,2006 select @a; connection con0; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 44b4af74ef1..03f9d1e2732 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1342,13 +1342,38 @@ static void prepare_new_connection_state(THD* thd) execute_init_command(thd, &sys_init_connect, &LOCK_sys_init_connect); if (thd->is_error()) { - thd->killed= THD::KILL_CONNECTION; + ulong packet_length; + NET *net= &thd->net; + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), - thd->thread_id,(thd->db ? thd->db : "unconnected"), + thd->thread_id, + thd->db ? thd->db : "unconnected", sctx->user ? sctx->user : "unauthenticated", sctx->host_or_ip, "init_connect command failed"); sql_print_warning("%s", thd->main_da.message()); + + thd->lex->current_select= 0; + my_net_set_read_timeout(net, thd->variables.net_wait_timeout); + thd->clear_error(); + net_new_transaction(net); + packet_length= my_net_read(net); + /* + If my_net_read() failed, my_error() has been already called, + and the main Diagnostics Area contains an error condition. + */ + if (packet_length != packet_error) + my_error(ER_NEW_ABORTING_CONNECTION, MYF(0), + thd->thread_id, + thd->db ? thd->db : "unconnected", + sctx->user ? sctx->user : "unauthenticated", + sctx->host_or_ip, "init_connect command failed"); + + thd->server_status&= ~SERVER_STATUS_CLEAR_SET; + net_end_statement(thd); + thd->killed = THD::KILL_CONNECTION; + return; } + thd->proc_info=0; thd->set_time(); thd->init_for_queries(); From 595f116df0a6cce5faaafbf7b70ef735bb8d7577 Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Fri, 6 Jan 2012 15:46:03 +0530 Subject: [PATCH 07/11] Bug#12872804 - 62155: BINLOG.BINLOG_STM_UNSAFE_WARNING FAILS WHEN RUN WITH --REPEAT=2 Fixed the testcase using timestamp logic while doing grep from the error file. --- .../binlog/r/binlog_stm_unsafe_warning.result | 6 ++--- .../binlog/t/binlog_stm_unsafe_warning.test | 23 +++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result index edbd878982b..08f193c9f5f 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result +++ b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result @@ -34,13 +34,13 @@ USE test; # SET @old_log_warnings = @@log_warnings; DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(10)); +CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(15)); SET GLOBAL LOG_WARNINGS = 0; -INSERT INTO t1 VALUES(UUID(), 'Bug#46265'); +INSERT INTO t1 VALUES(UUID(), 'timestamp'); Warnings: Note 1592 Statement may not be safe to log in statement format. SET GLOBAL LOG_WARNINGS = 1; -INSERT INTO t1 VALUES(UUID(), 'Bug#46265'); +INSERT INTO t1 VALUES(UUID(), 'timestamp'); Warnings: Note 1592 Statement may not be safe to log in statement format. DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test index 21c11d5a3df..e5424a911bb 100644 --- a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test +++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test @@ -80,22 +80,33 @@ eval USE $old_db; --echo # Bug#46265: Can not disable warning about unsafe statements for binary logging --echo # +# Here introducing a sleep of one Second, just to make sure +# that when this test executes with "--repeat" option, +# the timestamp value is different and hence the Occcurrence count is one. +--sleep 1 + SET @old_log_warnings = @@log_warnings; --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings -CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(10)); +let BINLOG_COUNTER1= `select CONVERT(NOW(),UNSIGNED) as timestmap from dual`; + +CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(15)); SET GLOBAL LOG_WARNINGS = 0; -INSERT INTO t1 VALUES(UUID(), 'Bug#46265'); +# Replacing the result file content here. +# Instead of writing $BINLOG_COUNTER1 value to result file, writing a fixed string timestamp to it. +--replace_result $BINLOG_COUNTER1 timestamp +eval INSERT INTO t1 VALUES(UUID(), '$BINLOG_COUNTER1'); SET GLOBAL LOG_WARNINGS = 1; -INSERT INTO t1 VALUES(UUID(), 'Bug#46265'); +--replace_result $BINLOG_COUNTER1 timestamp +eval INSERT INTO t1 VALUES(UUID(), '$BINLOG_COUNTER1'); DROP TABLE t1; SET GLOBAL log_warnings = @old_log_warnings; let $log_error_= `SELECT @@GLOBAL.log_error`; -if(!`select LENGTH('$log_error_')`) +if(!$log_error_) { # MySQL Server on windows is started with --console and thus # does not know the location of its .err log, use default location @@ -111,7 +122,9 @@ perl; use strict; my $log_error= $ENV{'LOG_ERROR'} or die "LOG_ERROR not set"; open(FILE, "$log_error") or die("Unable to open $log_error: $!\n"); - my $count = () = grep(/Bug#46265/g,); + my $binlog_counter= $ENV{'BINLOG_COUNTER1'} or die "BINLOG_COUNTER1 not set"; + my $count = () = grep(/$binlog_counter/g,); + # Grep the timestamp value from the error file. print "Occurrences: $count\n"; close(FILE); EOF From 5b576596a299ea84a6fb1abfdd65c95adb1e85aa Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Fri, 6 Jan 2012 16:28:24 +0530 Subject: [PATCH 08/11] Bug#12872803 - 62154: FEDERATED.FEDERATED_SERVER TEST FAILS WITH RUN --REPEAT=2 Fixed it to work with "--repeat" option. --- mysql-test/suite/federated/federated_server.result | 4 ++-- mysql-test/suite/federated/federated_server.test | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/federated/federated_server.result b/mysql-test/suite/federated/federated_server.result index 2c20d1c1d57..6b37277b5a9 100644 --- a/mysql-test/suite/federated/federated_server.result +++ b/mysql-test/suite/federated/federated_server.result @@ -54,7 +54,7 @@ PASSWORD '', PORT SLAVE_PORT, SOCKET '', OWNER 'root'); -select * from mysql.servers; +select * from mysql.servers order by Server_name; Server_name Host Db Username Password Port Socket Wrapper Owner server_one 127.0.0.1 first_db root SLAVE_PORT mysql root server_two 127.0.0.1 second_db root SLAVE_PORT mysql root @@ -154,7 +154,7 @@ id name drop table federated.t1; drop server 'server_one'; drop server 'server_two'; -select * from mysql.servers; +select * from mysql.servers order by Server_name; Server_name Host Db Username Password Port Socket Wrapper Owner drop table first_db.t1; drop table second_db.t1; diff --git a/mysql-test/suite/federated/federated_server.test b/mysql-test/suite/federated/federated_server.test index ec952d071f2..64ee74edb16 100644 --- a/mysql-test/suite/federated/federated_server.test +++ b/mysql-test/suite/federated/federated_server.test @@ -62,7 +62,9 @@ eval create server 'server_two' foreign data wrapper 'mysql' options OWNER 'root'); --replace_result $SLAVE_MYPORT SLAVE_PORT -eval select * from mysql.servers; +# Adding 'order by' clause here, in order to maintain consistent result out of the select query. +#eval select * from mysql.servers; +eval select * from mysql.servers order by Server_name; DROP TABLE IF EXISTS federated.old; --replace_result $SLAVE_MYPORT SLAVE_PORT @@ -147,7 +149,9 @@ drop table federated.t1; drop server 'server_one'; drop server 'server_two'; -select * from mysql.servers; +# Adding 'order by' clause here, in order to maintain consistent result out of the select query. +#select * from mysql.servers; +eval select * from mysql.servers order by Server_name; connection slave; drop table first_db.t1; From 40203bd584a4b4c6a74458baf8ac1b26ce0e5603 Mon Sep 17 00:00:00 2001 From: Yasufumi Kinoshita Date: Tue, 10 Jan 2012 14:18:58 +0900 Subject: [PATCH 09/11] Bug#12400341 INNODB CAN LEAVE ORPHAN IBD FILES AROUND If we meet DB_TOO_MANY_CONCURRENT_TRXS during the execution tab_create_graph from row_create_table_for_mysql(), .ibd file for the table should be created already but was not deleted for the error handling. rb:875 approved by Jimmy Yang --- .../suite/innodb/r/innodb_bug12400341.result | 25 +++++ .../innodb/t/innodb_bug12400341-master.opt | 1 + .../suite/innodb/t/innodb_bug12400341.test | 103 ++++++++++++++++++ .../innodb_plugin/r/innodb_bug12400341.result | 25 +++++ .../t/innodb_bug12400341-master.opt | 1 + .../innodb_plugin/t/innodb_bug12400341.test | 103 ++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 10 ++ storage/innobase/include/trx0rseg.ic | 9 +- storage/innobase/include/trx0sys.h | 5 + storage/innobase/row/row0mysql.c | 12 ++ storage/innobase/trx/trx0sys.c | 4 + storage/innodb_plugin/ChangeLog | 5 + storage/innodb_plugin/handler/ha_innodb.cc | 10 ++ storage/innodb_plugin/include/trx0rseg.ic | 9 +- storage/innodb_plugin/include/trx0sys.h | 6 + storage/innodb_plugin/row/row0mysql.c | 14 +++ storage/innodb_plugin/trx/trx0sys.c | 5 + 17 files changed, 345 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/innodb/r/innodb_bug12400341.result create mode 100644 mysql-test/suite/innodb/t/innodb_bug12400341-master.opt create mode 100644 mysql-test/suite/innodb/t/innodb_bug12400341.test create mode 100644 mysql-test/suite/innodb_plugin/r/innodb_bug12400341.result create mode 100644 mysql-test/suite/innodb_plugin/t/innodb_bug12400341-master.opt create mode 100644 mysql-test/suite/innodb_plugin/t/innodb_bug12400341.test diff --git a/mysql-test/suite/innodb/r/innodb_bug12400341.result b/mysql-test/suite/innodb/r/innodb_bug12400341.result new file mode 100644 index 00000000000..551e94f5e77 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug12400341.result @@ -0,0 +1,25 @@ +call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too"); +show variables like "max_connections"; +Variable_name Value +max_connections 64 +show variables like "innodb_thread_concurrency"; +Variable_name Value +innodb_thread_concurrency 0 +show variables like "innodb_file_per_table"; +Variable_name Value +innodb_file_per_table ON +drop database if exists mysqltest; +create database mysqltest; +CREATE TABLE mysqltest.transtable (id int unsigned NOT NULL PRIMARY KEY, val int DEFAULT 0) ENGINE=InnoDB; +select count(*) from information_schema.processlist; +count(*) +33 +CREATE TABLE mysqltest.testtable (id int unsigned not null primary key) ENGINE=InnoDB; +ERROR HY000: Can't create table 'mysqltest.testtable' (errno: 177) +select count(*) from information_schema.processlist; +count(*) +33 +select count(*) from information_schema.processlist; +count(*) +33 +drop database mysqltest; diff --git a/mysql-test/suite/innodb/t/innodb_bug12400341-master.opt b/mysql-test/suite/innodb/t/innodb_bug12400341-master.opt new file mode 100644 index 00000000000..2e85b082c68 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug12400341-master.opt @@ -0,0 +1 @@ +--max_connections=64 --innodb_thread_concurrency=0 --innodb_file_per_table diff --git a/mysql-test/suite/innodb/t/innodb_bug12400341.test b/mysql-test/suite/innodb/t/innodb_bug12400341.test new file mode 100644 index 00000000000..2ab1be81f6d --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug12400341.test @@ -0,0 +1,103 @@ +# Test for bug #12400341: INNODB CAN LEAVE ORPHAN IBD FILES AROUND + +-- source include/have_innodb.inc + +if (`select count(*)=0 from information_schema.global_variables where variable_name = 'INNODB_TRX_RSEG_N_SLOTS_DEBUG'`) +{ + --skip Test requires InnoDB built with UNIV_DEBUG definition. +} + +call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too"); + +--disable_query_log +set @old_innodb_trx_rseg_n_slots_debug = @@innodb_trx_rseg_n_slots_debug; +set global innodb_trx_rseg_n_slots_debug = 32; +--enable_query_log + +show variables like "max_connections"; +show variables like "innodb_thread_concurrency"; +show variables like "innodb_file_per_table"; + +--disable_warnings +drop database if exists mysqltest; +--enable_warnings + +create database mysqltest; +CREATE TABLE mysqltest.transtable (id int unsigned NOT NULL PRIMARY KEY, val int DEFAULT 0) ENGINE=InnoDB; + +--disable_query_log +# +# Insert in 1 transaction which needs over 1 page undo record to avoid the insert_undo cached, +# because the cached insert_undo can be reused at "CREATE TABLE" statement later. +# +START TRANSACTION; +let $c = 1024; +while ($c) +{ + eval INSERT INTO mysqltest.transtable (id) VALUES ($c); + dec $c; +} +COMMIT; + +let $c = 32; +while ($c) +{ + # if failed at here, it might be shortage of file descriptors limit. + connect (con$c,localhost,root,,); + dec $c; +} +--enable_query_log + +select count(*) from information_schema.processlist; + +# +# fill the all undo slots +# +--disable_query_log +let $c = 32; +while ($c) +{ + connection con$c; + START TRANSACTION; + eval UPDATE mysqltest.transtable SET val = 1 WHERE id = 33 - $c; + dec $c; +} +--enable_query_log + +connection default; + +--error ER_CANT_CREATE_TABLE +CREATE TABLE mysqltest.testtable (id int unsigned not null primary key) ENGINE=InnoDB; + +select count(*) from information_schema.processlist; + +--disable_query_log +let $c = 32; +while ($c) +{ + connection con$c; + ROLLBACK; + dec $c; +} +--enable_query_log + +connection default; +select count(*) from information_schema.processlist; + +--disable_query_log +let $c = 32; +while ($c) +{ + disconnect con$c; + dec $c; +} +--enable_query_log + +# +# If the isolated .ibd file remained, the drop database should fail. +# +drop database mysqltest; + +--disable_query_log +set global innodb_trx_rseg_n_slots_debug = @old_innodb_trx_rseg_n_slots_debug; +--enable_query_log diff --git a/mysql-test/suite/innodb_plugin/r/innodb_bug12400341.result b/mysql-test/suite/innodb_plugin/r/innodb_bug12400341.result new file mode 100644 index 00000000000..551e94f5e77 --- /dev/null +++ b/mysql-test/suite/innodb_plugin/r/innodb_bug12400341.result @@ -0,0 +1,25 @@ +call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too"); +show variables like "max_connections"; +Variable_name Value +max_connections 64 +show variables like "innodb_thread_concurrency"; +Variable_name Value +innodb_thread_concurrency 0 +show variables like "innodb_file_per_table"; +Variable_name Value +innodb_file_per_table ON +drop database if exists mysqltest; +create database mysqltest; +CREATE TABLE mysqltest.transtable (id int unsigned NOT NULL PRIMARY KEY, val int DEFAULT 0) ENGINE=InnoDB; +select count(*) from information_schema.processlist; +count(*) +33 +CREATE TABLE mysqltest.testtable (id int unsigned not null primary key) ENGINE=InnoDB; +ERROR HY000: Can't create table 'mysqltest.testtable' (errno: 177) +select count(*) from information_schema.processlist; +count(*) +33 +select count(*) from information_schema.processlist; +count(*) +33 +drop database mysqltest; diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug12400341-master.opt b/mysql-test/suite/innodb_plugin/t/innodb_bug12400341-master.opt new file mode 100644 index 00000000000..2e85b082c68 --- /dev/null +++ b/mysql-test/suite/innodb_plugin/t/innodb_bug12400341-master.opt @@ -0,0 +1 @@ +--max_connections=64 --innodb_thread_concurrency=0 --innodb_file_per_table diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug12400341.test b/mysql-test/suite/innodb_plugin/t/innodb_bug12400341.test new file mode 100644 index 00000000000..b9e40e0dff3 --- /dev/null +++ b/mysql-test/suite/innodb_plugin/t/innodb_bug12400341.test @@ -0,0 +1,103 @@ +# Test for bug #12400341: INNODB CAN LEAVE ORPHAN IBD FILES AROUND + +-- source include/have_innodb_plugin.inc + +if (`select count(*)=0 from information_schema.global_variables where variable_name = 'INNODB_TRX_RSEG_N_SLOTS_DEBUG'`) +{ + --skip Test requires InnoDB built with UNIV_DEBUG definition. +} + +call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too"); + +--disable_query_log +set @old_innodb_trx_rseg_n_slots_debug = @@innodb_trx_rseg_n_slots_debug; +set global innodb_trx_rseg_n_slots_debug = 32; +--enable_query_log + +show variables like "max_connections"; +show variables like "innodb_thread_concurrency"; +show variables like "innodb_file_per_table"; + +--disable_warnings +drop database if exists mysqltest; +--enable_warnings + +create database mysqltest; +CREATE TABLE mysqltest.transtable (id int unsigned NOT NULL PRIMARY KEY, val int DEFAULT 0) ENGINE=InnoDB; + +--disable_query_log +# +# Insert in 1 transaction which needs over 1 page undo record to avoid the insert_undo cached, +# because the cached insert_undo can be reused at "CREATE TABLE" statement later. +# +START TRANSACTION; +let $c = 1024; +while ($c) +{ + eval INSERT INTO mysqltest.transtable (id) VALUES ($c); + dec $c; +} +COMMIT; + +let $c = 32; +while ($c) +{ + # if failed at here, it might be shortage of file descriptors limit. + connect (con$c,localhost,root,,); + dec $c; +} +--enable_query_log + +select count(*) from information_schema.processlist; + +# +# fill the all undo slots +# +--disable_query_log +let $c = 32; +while ($c) +{ + connection con$c; + START TRANSACTION; + eval UPDATE mysqltest.transtable SET val = 1 WHERE id = 33 - $c; + dec $c; +} +--enable_query_log + +connection default; + +--error ER_CANT_CREATE_TABLE +CREATE TABLE mysqltest.testtable (id int unsigned not null primary key) ENGINE=InnoDB; + +select count(*) from information_schema.processlist; + +--disable_query_log +let $c = 32; +while ($c) +{ + connection con$c; + ROLLBACK; + dec $c; +} +--enable_query_log + +connection default; +select count(*) from information_schema.processlist; + +--disable_query_log +let $c = 32; +while ($c) +{ + disconnect con$c; + dec $c; +} +--enable_query_log + +# +# If the isolated .ibd file remained, the drop database should fail. +# +drop database mysqltest; + +--disable_query_log +set global innodb_trx_rseg_n_slots_debug = @old_innodb_trx_rseg_n_slots_debug; +--enable_query_log diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index a4d79a5934e..573e0a4455a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -9060,6 +9060,13 @@ static MYSQL_SYSVAR_UINT(change_buffering_debug, ibuf_debug, NULL, NULL, 0, 0, 1, 0); #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ +#ifdef UNIV_DEBUG +static MYSQL_SYSVAR_UINT(trx_rseg_n_slots_debug, trx_rseg_n_slots_debug, + PLUGIN_VAR_RQCMDARG, + "Debug flags for InnoDB to limit TRX_RSEG_N_SLOTS for trx_rsegf_undo_find_free()", + NULL, NULL, 0, 0, 1024, 0); +#endif /* UNIV_DEBUG */ + static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(additional_mem_pool_size), MYSQL_SYSVAR(autoextend_increment), @@ -9105,6 +9112,9 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG MYSQL_SYSVAR(change_buffering_debug), #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ +#ifdef UNIV_DEBUG + MYSQL_SYSVAR(trx_rseg_n_slots_debug), +#endif /* UNIV_DEBUG */ NULL }; diff --git a/storage/innobase/include/trx0rseg.ic b/storage/innobase/include/trx0rseg.ic index 577cd0dee7b..5b01b2f197d 100644 --- a/storage/innobase/include/trx0rseg.ic +++ b/storage/innobase/include/trx0rseg.ic @@ -8,6 +8,7 @@ Created 3/26/1996 Heikki Tuuri #include "srv0srv.h" #include "mtr0log.h" +#include "trx0sys.h" /********************************************************************** Gets a rollback segment header. */ @@ -113,7 +114,13 @@ trx_rsegf_undo_find_free( ulint i; ulint page_no; - for (i = 0; i < TRX_RSEG_N_SLOTS; i++) { + for (i = 0; +#ifndef UNIV_DEBUG + i < TRX_RSEG_N_SLOTS; +#else + i < (trx_rseg_n_slots_debug ? trx_rseg_n_slots_debug : TRX_RSEG_N_SLOTS); +#endif + i++) { page_no = trx_rsegf_get_nth_undo(rsegf, i, mtr); diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index 7ea981eb85c..aedeb51d3b3 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -47,6 +47,11 @@ extern ibool trx_doublewrite_buf_is_being_created; extern ibool trx_doublewrite_must_reset_space_ids; extern ibool trx_sys_multiple_tablespace_format; +#ifdef UNIV_DEBUG +/* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */ +extern uint trx_rseg_n_slots_debug; +#endif + /******************************************************************** Creates the doublewrite buffer to a new InnoDB installation. The header of the doublewrite buffer is placed on the trx system header page. */ diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index cee97871470..6148b01af9d 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -1948,6 +1948,18 @@ row_create_table_for_mysql( FALSE); } + } else if (err == DB_TOO_MANY_CONCURRENT_TRXS) { + /* We already have .ibd file here. it should be deleted. */ + if (table->space + && !fil_delete_tablespace(table->space)) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Error: not able to" + " delete tablespace %lu of table ", + (ulong) table->space); + ut_print_name(stderr, trx, TRUE, table->name); + fputs("!\n", stderr); + } } else if (err == DB_DUPLICATE_KEY) { ut_print_timestamp(stderr); diff --git a/storage/innobase/trx/trx0sys.c b/storage/innobase/trx/trx0sys.c index 137771b71ed..09b1b5d8198 100644 --- a/storage/innobase/trx/trx0sys.c +++ b/storage/innobase/trx/trx0sys.c @@ -54,6 +54,10 @@ InnoDB. */ char trx_sys_mysql_bin_log_name[TRX_SYS_MYSQL_LOG_NAME_LEN]; ib_longlong trx_sys_mysql_bin_log_pos = -1; +#ifdef UNIV_DEBUG +/* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */ +uint trx_rseg_n_slots_debug = 0; +#endif /******************************************************************** Determines if a page number is located inside the doublewrite buffer. */ diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 1385da94bfb..d33dfd33043 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,8 @@ +2012-01-04 The InnoDB Team + + * row/row0mysql.c: + Fix Bug#12400341: INNODB CAN LEAVE ORPHAN IBD FILES AROUND + 2011-12-21 The InnoDB Team * include/ut0rnd.ic: diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index 122bf1f7846..149e660e36e 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -11033,6 +11033,13 @@ static MYSQL_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold, "trigger a readahead.", NULL, NULL, 56, 0, 64, 0); +#ifdef UNIV_DEBUG +static MYSQL_SYSVAR_UINT(trx_rseg_n_slots_debug, trx_rseg_n_slots_debug, + PLUGIN_VAR_RQCMDARG, + "Debug flags for InnoDB to limit TRX_RSEG_N_SLOTS for trx_rsegf_undo_find_free()", + NULL, NULL, 0, 0, 1024, 0); +#endif /* UNIV_DEBUG */ + static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(additional_mem_pool_size), MYSQL_SYSVAR(autoextend_increment), @@ -11094,6 +11101,9 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(random_read_ahead), MYSQL_SYSVAR(read_ahead_threshold), MYSQL_SYSVAR(io_capacity), +#ifdef UNIV_DEBUG + MYSQL_SYSVAR(trx_rseg_n_slots_debug), +#endif /* UNIV_DEBUG */ NULL }; diff --git a/storage/innodb_plugin/include/trx0rseg.ic b/storage/innodb_plugin/include/trx0rseg.ic index daffa92fc7d..5e8d2b41120 100644 --- a/storage/innodb_plugin/include/trx0rseg.ic +++ b/storage/innodb_plugin/include/trx0rseg.ic @@ -25,6 +25,7 @@ Created 3/26/1996 Heikki Tuuri #include "srv0srv.h" #include "mtr0log.h" +#include "trx0sys.h" /******************************************************************//** Gets a rollback segment header. @@ -131,7 +132,13 @@ trx_rsegf_undo_find_free( ulint i; ulint page_no; - for (i = 0; i < TRX_RSEG_N_SLOTS; i++) { + for (i = 0; +#ifndef UNIV_DEBUG + i < TRX_RSEG_N_SLOTS; +#else + i < (trx_rseg_n_slots_debug ? trx_rseg_n_slots_debug : TRX_RSEG_N_SLOTS); +#endif + i++) { page_no = trx_rsegf_get_nth_undo(rsegf, i, mtr); diff --git a/storage/innodb_plugin/include/trx0sys.h b/storage/innodb_plugin/include/trx0sys.h index 78bb6fc349b..56fb801ee42 100644 --- a/storage/innodb_plugin/include/trx0sys.h +++ b/storage/innodb_plugin/include/trx0sys.h @@ -229,6 +229,12 @@ trx_id_t trx_sys_get_new_trx_no(void); /*========================*/ #endif /* !UNIV_HOTBACKUP */ + +#ifdef UNIV_DEBUG +/* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */ +extern uint trx_rseg_n_slots_debug; +#endif + /*****************************************************************//** Writes a trx id to an index page. In case that the id size changes in some future version, this function should be used instead of diff --git a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/row0mysql.c index 6f689f9909d..36aad4f8ca2 100644 --- a/storage/innodb_plugin/row/row0mysql.c +++ b/storage/innodb_plugin/row/row0mysql.c @@ -1900,6 +1900,20 @@ err_exit: } break; + case DB_TOO_MANY_CONCURRENT_TRXS: + /* We already have .ibd file here. it should be deleted. */ + + if (table->space && !fil_delete_tablespace(table->space)) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Error: not able to" + " delete tablespace %lu of table ", + (ulong) table->space); + ut_print_name(stderr, trx, TRUE, table->name); + fputs("!\n", stderr); + } + /* fall through */ + case DB_DUPLICATE_KEY: default: /* We may also get err == DB_ERROR if the .ibd file for the diff --git a/storage/innodb_plugin/trx/trx0sys.c b/storage/innodb_plugin/trx/trx0sys.c index 352fa6af219..e9328b27bba 100644 --- a/storage/innodb_plugin/trx/trx0sys.c +++ b/storage/innodb_plugin/trx/trx0sys.c @@ -127,6 +127,11 @@ static const char* file_format_name_map[] = { static const ulint FILE_FORMAT_NAME_N = sizeof(file_format_name_map) / sizeof(file_format_name_map[0]); +#ifdef UNIV_DEBUG +/* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */ +uint trx_rseg_n_slots_debug = 0; +#endif + #ifndef UNIV_HOTBACKUP /** This is used to track the maximum file format id known to InnoDB. It's updated via SET GLOBAL innodb_file_format_check = 'x' or when we open From 7faf69dd82550d921761c142aefeb93c93c4f44b Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 10 Jan 2012 13:33:45 +0530 Subject: [PATCH 10/11] BUG#11760384 - 52792: mysqldump in XML mode does not dump routines. mysqldump in xml mode did not dump routines, events or triggers. This patch fixes this issue by fixing the if conditions that disallowed the dump of above mentioned objects in xml mode, and added the required code to enable dump in xml format. --- client/mysqldump.c | 461 ++++++++++++++++++++++++---------- mysql-test/r/mysqldump.result | 439 ++++++++++++++++++++++++++++++++ mysql-test/t/mysqldump.test | 112 +++++++++ 3 files changed, 884 insertions(+), 128 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 31d4ba40109..27a593ff592 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -76,6 +76,9 @@ /* Size of buffer for dump's select query */ #define QUERY_LENGTH 1536 +/* Size of comment buffer. */ +#define COMMENT_LENGTH 2048 + /* ignore table flags */ #define IGNORE_NONE 0x00 /* no ignore */ #define IGNORE_DATA 0x01 /* don't dump data for this table */ @@ -102,7 +105,7 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_complete_insert= 0, opt_drop_database= 0, opt_replace_into= 0, opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1, - opt_events= 0, + opt_events= 0, opt_comments_used= 0, opt_alltspcs=0, opt_notspcs= 0; static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0; static ulong opt_max_allowed_packet, opt_net_buffer_length; @@ -509,6 +512,8 @@ static int dump_all_tablespaces(); static int dump_tablespaces_for_tables(char *db, char **table_names, int tables); static int dump_tablespaces_for_databases(char** databases); static int dump_tablespaces(char* ts_where); +static void print_comment(FILE *sql_file, my_bool is_error, const char *format, + ...); #include @@ -606,19 +611,19 @@ static void write_header(FILE *sql_file, char *db_name) } else if (!opt_compact) { - if (opt_comments) - { - fprintf(sql_file, - "-- MySQL dump %s Distrib %s, for %s (%s)\n--\n", - DUMP_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); - fprintf(sql_file, "-- Host: %s Database: %s\n", - current_host ? current_host : "localhost", db_name ? db_name : - ""); - fputs("-- ------------------------------------------------------\n", - sql_file); - fprintf(sql_file, "-- Server version\t%s\n", - mysql_get_server_info(&mysql_connection)); - } + print_comment(sql_file, 0, + "-- MySQL dump %s Distrib %s, for %s (%s)\n--\n", + DUMP_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE, + MACHINE_TYPE); + print_comment(sql_file, 0, "-- Host: %s Database: %s\n", + current_host ? current_host : "localhost", + db_name ? db_name : ""); + print_comment(sql_file, 0, + "-- ------------------------------------------------------\n" + ); + print_comment(sql_file, 0, "-- Server version\t%s\n", + mysql_get_server_info(&mysql_connection)); + if (opt_set_charset) fprintf(sql_file, "\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" @@ -676,18 +681,16 @@ static void write_footer(FILE *sql_file) fprintf(sql_file, "/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n"); fputs("\n", sql_file); - if (opt_comments) + + if (opt_dump_date) { - if (opt_dump_date) - { - char time_str[20]; - get_date(time_str, GETDATE_DATE_TIME, 0); - fprintf(sql_file, "-- Dump completed on %s\n", - time_str); - } - else - fprintf(sql_file, "-- Dump completed\n"); + char time_str[20]; + get_date(time_str, GETDATE_DATE_TIME, 0); + print_comment(sql_file, 0, "-- Dump completed on %s\n", time_str); } + else + print_comment(sql_file, 0, "-- Dump completed\n"); + check_io(sql_file); } } /* write_footer */ @@ -772,6 +775,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), extended_insert= opt_drop= opt_lock= opt_disable_keys= opt_autocommit= opt_create_db= 0; break; + case 'i': + opt_comments_used= 1; + break; case 'I': case '?': usage(); @@ -798,11 +804,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_disable_keys= lock_tables= opt_set_charset= 0; break; case (int) OPT_COMPACT: - if (opt_compact) - { - opt_comments= opt_drop= opt_disable_keys= opt_lock= 0; - opt_set_charset= 0; - } + if (opt_compact) + { + opt_comments= opt_drop= opt_disable_keys= opt_lock= 0; + opt_set_charset= 0; + } + break; case (int) OPT_TABLES: opt_databases=0; break; @@ -1660,20 +1667,20 @@ static char *quote_for_like(const char *name, char *buff) } -/* +/** Quote and print a string. - SYNOPSIS - print_quoted_xml() - xml_file - output file - str - string to print - len - its length + @param xml_file - Output file. + @param str - String to print. + @param len - Its length. + @param is_attribute_name - A check for attribute name or value. - DESCRIPTION + @description Quote '<' '>' '&' '\"' chars and print a string to the xml_file. */ -static void print_quoted_xml(FILE *xml_file, const char *str, ulong len) +static void print_quoted_xml(FILE *xml_file, const char *str, ulong len, + my_bool is_attribute_name) { const char *end; @@ -1692,6 +1699,14 @@ static void print_quoted_xml(FILE *xml_file, const char *str, ulong len) case '\"': fputs(""", xml_file); break; + case ' ': + /* Attribute names cannot contain spaces. */ + if (is_attribute_name) + { + fputs("_", xml_file); + break; + } + /* fall through */ default: fputc(*str, xml_file); break; @@ -1752,7 +1767,7 @@ static void print_xml_tag(FILE * xml_file, const char* sbeg, fputs(attribute_name, xml_file); fputc('\"', xml_file); - print_quoted_xml(xml_file, attribute_value, strlen(attribute_value)); + print_quoted_xml(xml_file, attribute_value, strlen(attribute_value), 0); fputc('\"', xml_file); attribute_name= va_arg(arg_list, char *); @@ -1792,13 +1807,52 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg, fputs("<", xml_file); fputs(stag_atr, xml_file); fputs("\"", xml_file); - print_quoted_xml(xml_file, sval, strlen(sval)); + print_quoted_xml(xml_file, sval, strlen(sval), 0); fputs("\" xsi:nil=\"true\" />", xml_file); fputs(line_end, xml_file); check_io(xml_file); } +/** + Print xml CDATA section. + + @param xml_file - output file + @param str - string to print + @param len - length of the string + + @note + This function also takes care of the presence of '[[>' + string in the str. If found, the CDATA section is broken + into two CDATA sections, and ]]. +*/ + +static void print_xml_cdata(FILE *xml_file, const char *str, ulong len) +{ + const char *end; + + fputs("')) + { + fputs("]]]]>", xml_file); + str += 2; + continue; + } + /* fall through */ + default: + fputc(*str, xml_file); + break; + } + } + fputs("\n]]>\n", xml_file); + check_io(xml_file); +} + + /* Print xml tag with many attributes. @@ -1808,6 +1862,7 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg, row_name - xml tag name tableRes - query result row - result row + str_create - create statement header string DESCRIPTION Print tag with many attribute to the xml_file. Format is: @@ -1817,9 +1872,13 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg, */ static void print_xml_row(FILE *xml_file, const char *row_name, - MYSQL_RES *tableRes, MYSQL_ROW *row) + MYSQL_RES *tableRes, MYSQL_ROW *row, + const char *str_create) { uint i; + my_bool body_found= 0; + char *create_stmt_ptr; + ulong create_stmt_len= 0; MYSQL_FIELD *field; ulong *lengths= mysql_fetch_lengths(tableRes); @@ -1830,19 +1889,109 @@ static void print_xml_row(FILE *xml_file, const char *row_name, { if ((*row)[i]) { - fputc(' ', xml_file); - print_quoted_xml(xml_file, field->name, field->name_length); - fputs("=\"", xml_file); - print_quoted_xml(xml_file, (*row)[i], lengths[i]); - fputc('"', xml_file); - check_io(xml_file); + /* For 'create' statements, dump using CDATA. */ + if ((str_create) && (strcmp(str_create, field->name) == 0)) + { + create_stmt_ptr= (*row)[i]; + create_stmt_len= lengths[i]; + body_found= 1; + } + else + { + fputc(' ', xml_file); + print_quoted_xml(xml_file, field->name, field->name_length, 1); + fputs("=\"", xml_file); + print_quoted_xml(xml_file, (*row)[i], lengths[i], 0); + fputc('"', xml_file); + check_io(xml_file); + } } } - fputs(" />\n", xml_file); + + if (create_stmt_len) + { + DBUG_ASSERT(body_found); + fputs(">\n", xml_file); + print_xml_cdata(xml_file, create_stmt_ptr, create_stmt_len); + fprintf(xml_file, "\t\t\n", row_name); + } + else + fputs(" />\n", xml_file); + check_io(xml_file); } +/** + Print xml comments. + + @param xml_file - output file + @param len - length of comment message + @param comment_string - comment message + + @description + Print the comment message in the format: + "\n" + + @note + Any occurrence of continuous hyphens will be + squeezed to a single hyphen. +*/ + +static void print_xml_comment(FILE *xml_file, ulong len, + const char *comment_string) +{ + const char* end; + + fputs("\n", xml_file); + check_io(xml_file); +} + + + +/* A common printing function for xml and non-xml modes. */ + +static void print_comment(FILE *sql_file, my_bool is_error, const char *format, + ...) +{ + static char comment_buff[COMMENT_LENGTH]; + va_list args; + + /* If its an error message, print it ignoring opt_comments. */ + if (!is_error && !opt_comments) + return; + + va_start(args, format); + my_vsnprintf(comment_buff, COMMENT_LENGTH, format, args); + va_end(args); + + if (!opt_xml) + { + fputs(comment_buff, sql_file); + check_io(sql_file); + return; + } + + print_xml_comment(sql_file, strlen(comment_buff), comment_buff); +} + + /* create_delimiter Generate a new (null-terminated) string that does not exist in query @@ -1909,8 +2058,8 @@ static uint dump_events_for_db(char *db) mysql_real_escape_string(mysql, db_name_buff, db, strlen(db)); /* nice comments */ - if (opt_comments) - fprintf(sql_file, "\n--\n-- Dumping events for database '%s'\n--\n", db); + print_comment(sql_file, 0, + "\n--\n-- Dumping events for database '%s'\n--\n", db); /* not using "mysql_query_with_error_report" because we may have not @@ -1925,12 +2074,17 @@ static uint dump_events_for_db(char *db) strcpy(delimiter, ";"); if (mysql_num_rows(event_list_res) > 0) { - fprintf(sql_file, "/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;\n"); + if (opt_xml) + fputs("\t\n", sql_file); + else + { + fprintf(sql_file, "/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;\n"); - /* Get database collation. */ + /* Get database collation. */ - if (fetch_db_collation(db_name_buff, db_cl_name, sizeof (db_cl_name))) - DBUG_RETURN(1); + if (fetch_db_collation(db_name_buff, db_cl_name, sizeof (db_cl_name))) + DBUG_RETURN(1); + } if (switch_character_set_results(mysql, "binary")) DBUG_RETURN(1); @@ -1947,6 +2101,13 @@ static uint dump_events_for_db(char *db) while ((row= mysql_fetch_row(event_res)) != NULL) { + if (opt_xml) + { + print_xml_row(sql_file, "event", event_res, &row, + "Create Event"); + continue; + } + /* if the user has EXECUTE privilege he can see event names, but not the event body! @@ -2025,8 +2186,16 @@ static uint dump_events_for_db(char *db) mysql_free_result(event_res); } /* end of list of events */ - fprintf(sql_file, "DELIMITER ;\n"); - fprintf(sql_file, "/*!50106 SET TIME_ZONE= @save_time_zone */ ;\n"); + if (opt_xml) + { + fputs("\t\n", sql_file); + check_io(sql_file); + } + else + { + fprintf(sql_file, "DELIMITER ;\n"); + fprintf(sql_file, "/*!50106 SET TIME_ZONE= @save_time_zone */ ;\n"); + } if (switch_character_set_results(mysql, default_charset)) DBUG_RETURN(1); @@ -2080,6 +2249,7 @@ static uint dump_routines_for_db(char *db) const char *routine_type[]= {"FUNCTION", "PROCEDURE"}; char db_name_buff[NAME_LEN*2+3], name_buff[NAME_LEN*2+3]; char *routine_name; + char *query_str; int i; FILE *sql_file= md_result_file; MYSQL_RES *routine_res, *routine_list_res; @@ -2094,8 +2264,8 @@ static uint dump_routines_for_db(char *db) mysql_real_escape_string(mysql, db_name_buff, db, strlen(db)); /* nice comments */ - if (opt_comments) - fprintf(sql_file, "\n--\n-- Dumping routines for database '%s'\n--\n", db); + print_comment(sql_file, 0, + "\n--\n-- Dumping routines for database '%s'\n--\n", db); /* not using "mysql_query_with_error_report" because we may have not @@ -2112,6 +2282,9 @@ static uint dump_routines_for_db(char *db) if (switch_character_set_results(mysql, "binary")) DBUG_RETURN(1); + if (opt_xml) + fputs("\t\n", sql_file); + /* 0, retrieve and dump functions, 1, procedures */ for (i= 0; i <= 1; i++) { @@ -2147,13 +2320,25 @@ static uint dump_routines_for_db(char *db) row[2] ? (int) strlen(row[2]) : 0)); if (row[2] == NULL) { - fprintf(sql_file, "\n-- insufficient privileges to %s\n", query_buff); - fprintf(sql_file, "-- does %s have permissions on mysql.proc?\n\n", current_user); + print_comment(sql_file, 1, "\n-- insufficient privileges to %s\n", + query_buff); + print_comment(sql_file, 1, + "-- does %s have permissions on mysql.proc?\n\n", + current_user); maybe_die(EX_MYSQLERR,"%s has insufficent privileges to %s!", current_user, query_buff); } else if (strlen(row[2])) { - char *query_str; + if (opt_xml) + { + if (i) // Procedures. + print_xml_row(sql_file, "routine", routine_res, &row, + "Create Procedure"); + else // Functions. + print_xml_row(sql_file, "routine", routine_res, &row, + "Create Function"); + continue; + } if (opt_drop) fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;\n", routine_type[i], routine_name); @@ -2224,6 +2409,12 @@ static uint dump_routines_for_db(char *db) mysql_free_result(routine_list_res); } /* end of for i (0 .. 1) */ + if (opt_xml) + { + fputs("\t\n", sql_file); + check_io(sql_file); + } + if (switch_character_set_results(mysql, default_charset)) DBUG_RETURN(1); @@ -2336,16 +2527,16 @@ static uint get_table_structure(char *table, char *db, char *table_type, write_header(sql_file, db); } - if (!opt_xml && opt_comments) - { + if (strcmp (table_type, "VIEW") == 0) /* view */ - fprintf(sql_file, "\n--\n-- Temporary table structure for view %s\n--\n\n", - result_table); + print_comment(sql_file, 0, + "\n--\n-- Temporary table structure for view %s\n--\n\n", + result_table); else - fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n", - result_table); - check_io(sql_file); - } + print_comment(sql_file, 0, + "\n--\n-- Table structure for table %s\n--\n\n", + result_table); + if (opt_drop) { /* @@ -2546,9 +2737,10 @@ static uint get_table_structure(char *table, char *db, char *table_type, DBUG_RETURN(0); write_header(sql_file, db); } - if (!opt_xml && opt_comments) - fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n", - result_table); + + print_comment(sql_file, 0, + "\n--\n-- Table structure for table %s\n--\n\n", + result_table); if (opt_drop) fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", result_table); if (!opt_xml) @@ -2599,7 +2791,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, { if (opt_xml) { - print_xml_row(sql_file, "field", result, &row); + print_xml_row(sql_file, "field", result, &row, NullS); continue; } @@ -2671,7 +2863,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, { if (opt_xml) { - print_xml_row(sql_file, "key", result, &row); + print_xml_row(sql_file, "key", result, &row, NullS); continue; } @@ -2730,7 +2922,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, else { if (opt_xml) - print_xml_row(sql_file, "options", result, &row); + print_xml_row(sql_file, "options", result, &row, NullS); else { fputs("/*!",sql_file); @@ -2774,9 +2966,19 @@ static void dump_trigger_old(FILE *sql_file, MYSQL_RES *show_triggers_rs, char *quoted_table_name= quote_name(table_name, quoted_table_name_buf, 1); char name_buff[NAME_LEN * 4 + 3]; + const char *xml_msg= "\nWarning! mysqldump being run against old server " + "that does not\nsupport 'SHOW CREATE TRIGGERS' " + "statement. Skipping..\n"; DBUG_ENTER("dump_trigger_old"); + if (opt_xml) + { + print_xml_comment(sql_file, strlen(xml_msg), xml_msg); + check_io(sql_file); + DBUG_VOID_RETURN; + } + fprintf(sql_file, "--\n" "-- WARNING: old server version. " @@ -2840,13 +3042,22 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs, const char *db_cl_name) { MYSQL_ROW row; + char *query_str; int db_cl_altered= FALSE; DBUG_ENTER("dump_trigger"); while ((row= mysql_fetch_row(show_create_trigger_rs))) { - char *query_str= cover_definer_clause_in_trigger(row[2], strlen(row[2])); + if (opt_xml) + { + print_xml_row(sql_file, "trigger", show_create_trigger_rs, &row, + "SQL Original Statement"); + check_io(sql_file); + continue; + } + + query_str= cover_definer_clause_in_trigger(row[2], strlen(row[2])); if (switch_db_collation(sql_file, db_name, ";", @@ -2936,6 +3147,13 @@ static int dump_triggers_for_table(char *table_name, char *db_name) /* Dump triggers. */ + if (! mysql_num_rows(show_triggers_rs)) + goto skip; + + if (opt_xml) + print_xml_tag(sql_file, "\t", "\n", "triggers", "name=", + table_name, NullS); + while ((row= mysql_fetch_row(show_triggers_rs))) { @@ -2968,6 +3186,13 @@ static int dump_triggers_for_table(char *table_name, char *db_name) } + if (opt_xml) + { + fputs("\t\n", sql_file); + check_io(sql_file); + } + +skip: mysql_free_result(show_triggers_rs); if (switch_character_set_results(mysql, default_charset)) @@ -3216,34 +3441,24 @@ static void dump_table(char *table, char *db) } else { - if (!opt_xml && opt_comments) - { - fprintf(md_result_file,"\n--\n-- Dumping data for table %s\n--\n", - result_table); - check_io(md_result_file); - } + print_comment(md_result_file, 0, + "\n--\n-- Dumping data for table %s\n--\n", + result_table); dynstr_append_checked(&query_string, "SELECT /*!40001 SQL_NO_CACHE */ * FROM "); dynstr_append_checked(&query_string, result_table); if (where) { - if (!opt_xml && opt_comments) - { - fprintf(md_result_file, "-- WHERE: %s\n", where); - check_io(md_result_file); - } - + print_comment(md_result_file, 0, "-- WHERE: %s\n", where); + dynstr_append_checked(&query_string, " WHERE "); dynstr_append_checked(&query_string, where); } if (order_by) { - if (!opt_xml && opt_comments) - { - fprintf(md_result_file, "-- ORDER BY: %s\n", order_by); - check_io(md_result_file); - } + print_comment(md_result_file, 0, "-- ORDER BY: %s\n", order_by); + dynstr_append_checked(&query_string, " ORDER BY "); dynstr_append_checked(&query_string, order_by); } @@ -3439,7 +3654,7 @@ static void dump_table(char *table, char *db) { print_xml_tag(md_result_file, "\t\t", "", "field", "name=", field->name, NullS); - print_quoted_xml(md_result_file, row[i], length); + print_quoted_xml(md_result_file, row[i], length, 0); } fputs("\n", md_result_file); } @@ -3743,11 +3958,9 @@ static int dump_tablespaces(char* ts_where) first= 1; if (first) { - if (!opt_xml && opt_comments) - { - fprintf(md_result_file,"\n--\n-- Logfile group: %s\n--\n", row[0]); - check_io(md_result_file); - } + print_comment(md_result_file, 0, "\n--\n-- Logfile group: %s\n--\n", + row[0]); + fprintf(md_result_file, "\nCREATE"); } else @@ -3815,11 +4028,7 @@ static int dump_tablespaces(char* ts_where) first= 1; if (first) { - if (!opt_xml && opt_comments) - { - fprintf(md_result_file,"\n--\n-- Tablespace: %s\n--\n", row[0]); - check_io(md_result_file); - } + print_comment(md_result_file, 0, "\n--\n-- Tablespace: %s\n--\n", row[0]); fprintf(md_result_file, "\nCREATE"); } else @@ -4009,11 +4218,9 @@ static int init_dumping(char *database, int init_func(char*)) */ char quoted_database_buf[NAME_LEN*2+3]; char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted); - if (opt_comments) - { - fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase); - check_io(md_result_file); - } + + print_comment(md_result_file, 0, + "\n--\n-- Current Database: %s\n--\n", qdatabase); /* Call the view or table specific function */ init_func(qdatabase); @@ -4087,8 +4294,7 @@ static int dump_all_tables_in_db(char *database) dump_table(table,database); my_free(order_by, MYF(MY_ALLOW_ZERO_PTR)); order_by= 0; - if (opt_dump_triggers && ! opt_xml && - mysql_get_server_version(mysql) >= 50009) + if (opt_dump_triggers && mysql_get_server_version(mysql) >= 50009) { if (dump_triggers_for_table(table, database)) { @@ -4099,14 +4305,12 @@ static int dump_all_tables_in_db(char *database) } } } - if (opt_events && !opt_xml && - mysql_get_server_version(mysql) >= 50106) + if (opt_events && mysql_get_server_version(mysql) >= 50106) { DBUG_PRINT("info", ("Dumping events for database %s", database)); dump_events_for_db(database); } - if (opt_routines && !opt_xml && - mysql_get_server_version(mysql) >= 50009) + if (opt_routines && mysql_get_server_version(mysql) >= 50009) { DBUG_PRINT("info", ("Dumping routines for database %s", database)); dump_routines_for_db(database); @@ -4341,15 +4545,13 @@ static int dump_selected_tables(char *db, char **table_names, int tables) for (pos= dump_tables; pos < end; pos++) get_view_structure(*pos, db); } - if (opt_events && !opt_xml && - mysql_get_server_version(mysql) >= 50106) + if (opt_events && mysql_get_server_version(mysql) >= 50106) { DBUG_PRINT("info", ("Dumping events for database %s", db)); dump_events_for_db(db); } /* obtain dump of routines (procs/functions) */ - if (opt_routines && !opt_xml && - mysql_get_server_version(mysql) >= 50009) + if (opt_routines && mysql_get_server_version(mysql) >= 50009) { DBUG_PRINT("info", ("Dumping routines for database %s", db)); dump_routines_for_db(db); @@ -4384,10 +4586,9 @@ static int do_show_master_status(MYSQL *mysql_con) if (row && row[0] && row[1]) { /* SHOW MASTER STATUS reports file and position */ - if (opt_comments) - fprintf(md_result_file, - "\n--\n-- Position to start replication or point-in-time " - "recovery from\n--\n\n"); + print_comment(md_result_file, 0, + "\n--\n-- Position to start replication or point-in-time " + "recovery from\n--\n\n"); fprintf(md_result_file, "%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n", comment_prefix, row[0], row[1]); @@ -4850,12 +5051,10 @@ static my_bool get_view_structure(char *table, char* db) write_header(sql_file, db); } - if (!opt_xml && opt_comments) - { - fprintf(sql_file, "\n--\n-- Final view structure for view %s\n--\n\n", - result_table); - check_io(sql_file); - } + print_comment(sql_file, 0, + "\n--\n-- Final view structure for view %s\n--\n\n", + result_table); + /* Table might not exist if this view was dumped with --tab. */ fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table); if (opt_drop) @@ -5052,6 +5251,12 @@ int main(int argc, char **argv) exit(exit_code); } + /* + Disable comments in xml mode if 'comments' option is not explicitly used. + */ + if (opt_xml && !opt_comments_used) + opt_comments= 0; + if (log_error_file) { if(!(stderror_file= freopen(log_error_file, "a+", stderr))) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index a337c0384f6..1d4a5783c3f 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -4628,5 +4628,444 @@ ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; DROP DATABASE `test-database`; USE `test`; # +# BUG#11760384 : 52792: mysqldump in XML mode does not dump routines. +# +CREATE DATABASE BUG52792; +USE BUG52792; +CREATE TABLE t1 (c1 INT, c2 VARCHAR(20)); +CREATE TABLE t2 (c1 INT); +INSERT INTO t1 VALUES (1, 'aaa'), (2, 'bbb'), (3, 'ccc'); +INSERT INTO t2 VALUES (1),(2),(3); +# Stored Procedures. +CREATE PROCEDURE simpleproc1 (OUT param1 INT) +BEGIN +SELECT COUNT(*) INTO param1 FROM t1; +END// +CREATE PROCEDURE simpleproc2 (OUT param1 INT) +BEGIN +SELECT COUNT(*) INTO param1 FROM t2; +END// +# Events. +CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE BUG52792; +CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE BUG52792; +# Functions. +CREATE FUNCTION `hello1` (s CHAR(20)) +RETURNS CHAR(50) DETERMINISTIC +RETURN CONCAT('Hello, ' ,s ,'!'); +CREATE FUNCTION `hello2` (s CHAR(20)) +RETURNS CHAR(50) DETERMINISTIC +RETURN CONCAT(']]>, ' , s ,'!'); +# Triggers. +CREATE TRIGGER trig1 BEFORE INSERT ON t2 +FOR EACH ROW BEGIN +INSERT INTO t2 VALUES(1); +END; +| +CREATE TRIGGER trig2 AFTER INSERT ON t2 +FOR EACH ROW BEGIN +INSERT INTO t2 VALUES(1, ']]>'); +INSERT INTO t2 VALUES(2, ''); +INSERT INTO t2 VALUES(3, ' & \ " _'); +END; +| +# Views +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; + +# Dumping BUG52792 database in xml format. + +# Running 'replace_regex on timestamp' + + + + + + + + + + + 1 + aaa + + + 2 + bbb + + + 3 + ccc + + + + + + + + + 1 + + + 2 + + + 3 + + + + + + + +'); +INSERT INTO t2 VALUES(2, ''); +INSERT INTO t2 VALUES(3, ' & \ " _'); +END +]]> + + + + + + + + + + + + + + + + + + + + + + + + +, ' , s ,'!') +]]> + + + + + + + + + + + +# Dumping BUG52792 database in xml format with comments. + +# Running 'replace_regex on timestamp' + + + + + + + + + + + + + 1 + aaa + + + 2 + bbb + + + 3 + ccc + + + + + + + + + + + 1 + + + 2 + + + 3 + + + + + + + +'); +INSERT INTO t2 VALUES(2, ''); +INSERT INTO t2 VALUES(3, ' & \ " _'); +END +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +, ' , s ,'!') +]]> + + + + + + + + + + + +# Test to check 'Insufficient privileges' error. + +GRANT ALL PRIVILEGES ON BUG52792.* TO user1; +# Running 'replace_regex on timestamp' + + + + + + + + + + + 1 + aaa + + + 2 + bbb + + + 3 + ccc + + + + + + + + + 1 + + + 2 + + + 3 + + + + + + + +'); +INSERT INTO t2 VALUES(2, ''); +INSERT INTO t2 VALUES(3, ' & \ " _'); +END +]]> + + + + + + + + + + + + + + + + + + + + + + +DROP USER user1; +DROP DATABASE BUG52792; +# UTF-8 +CREATE DATABASE BUG52792; +USE BUG52792; +SET NAMES utf8; +CREATE FUNCTION `straße` ( c1 CHAR(20)) +RETURNS CHAR(50) DETERMINISTIC +RETURN CONCAT(']]>, ', s, '!'); + + + + + +, ', s, '!') +]]> + + + + +DROP DATABASE BUG52792; +USE test; +# # End of 5.1 tests # diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 8ecf8187ff9..20c788e3b9a 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -2196,6 +2196,118 @@ DROP DATABASE `test-database`; # Switching back to test database. USE `test`; +--echo # +--echo # BUG#11760384 : 52792: mysqldump in XML mode does not dump routines. +--echo # +CREATE DATABASE BUG52792; +USE BUG52792; +CREATE TABLE t1 (c1 INT, c2 VARCHAR(20)); +CREATE TABLE t2 (c1 INT); +INSERT INTO t1 VALUES (1, 'aaa'), (2, 'bbb'), (3, 'ccc'); +INSERT INTO t2 VALUES (1),(2),(3); + +--echo # Stored Procedures. + +DELIMITER //; +CREATE PROCEDURE simpleproc1 (OUT param1 INT) +BEGIN + SELECT COUNT(*) INTO param1 FROM t1; +END// +DELIMITER ;// + +DELIMITER //; +CREATE PROCEDURE simpleproc2 (OUT param1 INT) +BEGIN + SELECT COUNT(*) INTO param1 FROM t2; +END// +DELIMITER ;// + +--echo # Events. + +CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE BUG52792; +CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE BUG52792; + +--echo # Functions. + +CREATE FUNCTION `hello1` (s CHAR(20)) + RETURNS CHAR(50) DETERMINISTIC +RETURN CONCAT('Hello, ' ,s ,'!'); + +CREATE FUNCTION `hello2` (s CHAR(20)) + RETURNS CHAR(50) DETERMINISTIC +RETURN CONCAT(']]>, ' , s ,'!'); + +--echo # Triggers. + +DELIMITER |; +CREATE TRIGGER trig1 BEFORE INSERT ON t2 + FOR EACH ROW BEGIN + INSERT INTO t2 VALUES(1); +END; +| +DELIMITER ;| + +DELIMITER |; +CREATE TRIGGER trig2 AFTER INSERT ON t2 + FOR EACH ROW BEGIN + INSERT INTO t2 VALUES(1, ']]>'); + INSERT INTO t2 VALUES(2, ''); + INSERT INTO t2 VALUES(3, ' & \ " _'); +END; +| +DELIMITER ;| + +--echo # Views + +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +--echo +--echo # Dumping BUG52792 database in xml format. +--echo +--echo # Running 'replace_regex on timestamp' +--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/--TIME--/ +--exec $MYSQL_DUMP --user=root --compact -R -E --triggers -X BUG52792 +--echo +--echo # Dumping BUG52792 database in xml format with comments. +--echo +--echo # Running 'replace_regex on timestamp' +--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/--TIME--/ +--exec $MYSQL_DUMP --comments --user=root -R -E --triggers -X BUG52792 + +--echo +--echo # Test to check 'Insufficient privileges' error. +--echo + +GRANT ALL PRIVILEGES ON BUG52792.* TO user1; + +connect (conn_1, localhost, user1, , BUG52792, $MASTER_MYPORT, $MASTER_MYSOCK); +connection conn_1; + +--echo # Running 'replace_regex on timestamp' +--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/--TIME--/ +--error 2 +--exec $MYSQL_DUMP --user=user1 -R -E --triggers -X BUG52792 + +connection default; +disconnect conn_1; + +DROP USER user1; +DROP DATABASE BUG52792; +--echo # UTF-8 +CREATE DATABASE BUG52792; +USE BUG52792; +SET NAMES utf8; +CREATE FUNCTION `straße` ( c1 CHAR(20)) + RETURNS CHAR(50) DETERMINISTIC +RETURN CONCAT(']]>, ', s, '!'); + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 -R -X BUG52792 + +DROP DATABASE BUG52792; + +USE test; + --echo # --echo # End of 5.1 tests --echo # From b2766703a85ec1c806074b0aee8a8ad85d6b4d77 Mon Sep 17 00:00:00 2001 From: Karen Langford Date: Wed, 11 Jan 2012 18:40:29 +0100 Subject: [PATCH 11/11] Fixes required to build on AIX --- cmd-line-utils/libedit/chartype.h | 6 +++--- cmd-line-utils/libedit/eln.c | 2 +- cmd-line-utils/libedit/readline.c | 2 +- unittest/mysys/bitmap-t.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd-line-utils/libedit/chartype.h b/cmd-line-utils/libedit/chartype.h index 678d13683be..40012afb47d 100644 --- a/cmd-line-utils/libedit/chartype.h +++ b/cmd-line-utils/libedit/chartype.h @@ -45,11 +45,11 @@ * seems to actually advertise this properly, despite Unicode 3.1 having * been around since 2001... */ -/* XXXMYSQL : Added FreeBSD to bypass this check. - TODO : Verify if FreeBSD stores ISO 10646 in wchar_t. */ +/* XXXMYSQL : Added FreeBSD & AIX to bypass this check. + TODO : Verify if FreeBSD & AIX stores ISO 10646 in wchar_t. */ #if !defined(__NetBSD__) && !defined(__sun) \ && !(defined(__APPLE__) && defined(__MACH__)) \ - && !defined(__FreeBSD__) + && !defined(__FreeBSD__) && !defined(_AIX) #ifndef __STDC_ISO_10646__ /* In many places it is assumed that the first 127 code points are ASCII * compatible, so ensure wchar_t indeed does ISO 10646 and not some other diff --git a/cmd-line-utils/libedit/eln.c b/cmd-line-utils/libedit/eln.c index 4b9f16c38f3..f996367115a 100644 --- a/cmd-line-utils/libedit/eln.c +++ b/cmd-line-utils/libedit/eln.c @@ -200,7 +200,7 @@ el_set(EditLine *el, int op, ...) ret = -1; goto out; } - // XXX: The two strdup's leak + /* XXX: The two strdups leak. */ ret = map_addfunc(el, Strdup(wargv[0]), Strdup(wargv[1]), func); ct_free_argv(wargv); diff --git a/cmd-line-utils/libedit/readline.c b/cmd-line-utils/libedit/readline.c index eaf26d4c497..a2a92edc1b4 100644 --- a/cmd-line-utils/libedit/readline.c +++ b/cmd-line-utils/libedit/readline.c @@ -1978,7 +1978,7 @@ rl_callback_read_char() } else wbuf = NULL; (*(void (*)(const char *))rl_linefunc)(wbuf); - //el_set(e, EL_UNBUFFERED, 1); + /*el_set(e, EL_UNBUFFERED, 1);*/ } } diff --git a/unittest/mysys/bitmap-t.c b/unittest/mysys/bitmap-t.c index 0127b7b86f4..9a5337c79b5 100644 --- a/unittest/mysys/bitmap-t.c +++ b/unittest/mysys/bitmap-t.c @@ -429,7 +429,7 @@ my_bool test_intersect(MY_BITMAP *map, uint bitsize) { uint bitsize2 = 1 + get_rand_bit(MAX_TESTED_BITMAP_SIZE - 1); MY_BITMAP map2; - uint32 map2buf[bitsize2]; + uint32 map2buf[MAX_TESTED_BITMAP_SIZE]; uint i, test_bit1, test_bit2, test_bit3; if (bitmap_init(&map2, map2buf, bitsize2, FALSE)) {