diff options
author | unknown <heikki@hundin.mysql.fi> | 2003-01-12 23:58:56 +0200 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2003-01-12 23:58:56 +0200 |
commit | b82f3bbefd732526d086267ae76e23d4cfa27cbb (patch) | |
tree | 96c32f93a61f082a13e5381509f2c5a29cf81199 /innobase/ut | |
parent | 667a81eb27b2f8115576991d96689f73bbfdf46f (diff) | |
download | mariadb-git-b82f3bbefd732526d086267ae76e23d4cfa27cbb.tar.gz |
ut0mem.c, row0sel.c, row0mysql.c, ut0mem.h, row0sel.h, row0mysql.h:
Test allocation of memory beforehand if we are trying to return a > 2 MB BLOB; normally InnoDB asserts if memory allocation fails
ha_innodb.cc:
Do not fetch all columns if change_active_index() is called during a query; a sum(a), max(a) query seemed to do that, doing unnecessary copying (the change actually made in the previous bk ci)
Free BLOB heap of handle when MySQL calls some ::extra()'s
sql/ha_innodb.cc:
Do not fetch all columns if change_active_index() is called during a query; a sum(a), max(a) query seemed to do that, doing unnecessary copying (the change actually made in the previous bk ci)
innobase/include/row0mysql.h:
Test allocation of memory beforehand if we are trying to return a > 2 MB BLOB; normally InnoDB asserts if memory allocation fails
innobase/include/row0sel.h:
Test allocation of memory beforehand if we are trying to return a > 2 MB BLOB; normally InnoDB asserts if memory allocation fails
innobase/include/ut0mem.h:
Test allocation of memory beforehand if we are trying to return a > 2 MB BLOB; normally InnoDB asserts if memory allocation fails
innobase/row/row0mysql.c:
Test allocation of memory beforehand if we are trying to return a > 2 MB BLOB; normally InnoDB asserts if memory allocation fails
innobase/row/row0sel.c:
Test allocation of memory beforehand if we are trying to return a > 2 MB BLOB; normally InnoDB asserts if memory allocation fails
innobase/ut/ut0mem.c:
Test allocation of memory beforehand if we are trying to return a > 2 MB BLOB; normally InnoDB asserts if memory allocation fails
Diffstat (limited to 'innobase/ut')
-rw-r--r-- | innobase/ut/ut0mem.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c index 03f15031fdf..a5991d5683d 100644 --- a/innobase/ut/ut0mem.c +++ b/innobase/ut/ut0mem.c @@ -77,8 +77,9 @@ ut_malloc_low( ret = malloc(n + sizeof(ut_mem_block_t)); if (ret == NULL) { + ut_print_timestamp(stderr); fprintf(stderr, - "InnoDB: Fatal error: cannot allocate %lu bytes of\n" + " InnoDB: Fatal error: cannot allocate %lu bytes of\n" "InnoDB: memory with malloc! Total allocated memory\n" "InnoDB: by InnoDB %lu bytes. Operating system errno: %d\n" "InnoDB: Cannot continue operation!\n" @@ -135,6 +136,40 @@ ut_malloc( } /************************************************************************** +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", + n, ut_total_allocated_memory, errno); + return(FALSE); + } + + free(ret); + + return(TRUE); +} + +/************************************************************************** Frees a memory block allocated with ut_malloc. */ void |