From 4b325712b3d4408315d16e03b3ab0855b4a03af6 Mon Sep 17 00:00:00 2001 From: vasil <> Date: Tue, 26 Jun 2007 13:08:11 +0000 Subject: [PATCH] Fix Bug#29097 "fsp_get_available_space_in_free_extents() is capped at 4TB" by typecasting the variables before multiplying them, so that the result of the multiplication is of type "unsigned long long". I verified this fix by creating a sparse file of 6TB and forcing InnoDB to use it without overwriting it with zeroes (by commenting the code that overwrites :newraw files). New type ullint is introduced with the sole purpose of shortening "unsigned long long", please do not define it to something else than "unsigned long long". Approved by: Heikki --- fsp/fsp0fsp.c | 5 +++-- handler/ha_innodb.cc | 6 +++--- include/fsp0fsp.h | 2 +- include/univ.i | 2 ++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fsp/fsp0fsp.c b/fsp/fsp0fsp.c index 78fb55e4ef3..e1074933fe8 100644 --- a/fsp/fsp0fsp.c +++ b/fsp/fsp0fsp.c @@ -2829,7 +2829,7 @@ will be able to insert new data to the database without running out the tablespace. Only free extents are taken into account and we also subtract the safety margin required by the above function fsp_reserve_free_extents. */ -ulint +ullint fsp_get_available_space_in_free_extents( /*====================================*/ /* out: available space in kB */ @@ -2895,7 +2895,8 @@ fsp_get_available_space_in_free_extents( return(0); } - return(((n_free - reserve) * FSP_EXTENT_SIZE) + return((ullint)(n_free - reserve) + * FSP_EXTENT_SIZE * (UNIV_PAGE_SIZE / 1024)); } diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc index 694287cd70c..d67cf0192e1 100644 --- a/handler/ha_innodb.cc +++ b/handler/ha_innodb.cc @@ -5847,9 +5847,9 @@ ha_innobase::update_table_comment( mutex_enter_noninline(&srv_dict_tmpfile_mutex); rewind(srv_dict_tmpfile); - fprintf(srv_dict_tmpfile, "InnoDB free: %lu kB", - (ulong) fsp_get_available_space_in_free_extents( - prebuilt->table->space)); + fprintf(srv_dict_tmpfile, "InnoDB free: %llu kB", + fsp_get_available_space_in_free_extents( + prebuilt->table->space)); dict_print_info_on_foreign_keys(FALSE, srv_dict_tmpfile, prebuilt->trx, prebuilt->table); diff --git a/include/fsp0fsp.h b/include/fsp0fsp.h index d04269fc157..82e95a2e920 100644 --- a/include/fsp0fsp.h +++ b/include/fsp0fsp.h @@ -245,7 +245,7 @@ will be able to insert new data to the database without running out the tablespace. Only free extents are taken into account and we also subtract the safety margin required by the above function fsp_reserve_free_extents. */ -ulint +ullint fsp_get_available_space_in_free_extents( /*====================================*/ /* out: available space in kB */ diff --git a/include/univ.i b/include/univ.i index 39865c10e5e..ba8e6e56219 100644 --- a/include/univ.i +++ b/include/univ.i @@ -216,6 +216,8 @@ typedef __int64 ib_longlong; typedef longlong ib_longlong; #endif +typedef unsigned long long int ullint; + #ifndef __WIN__ #if SIZEOF_LONG != SIZEOF_VOIDP #error "Error: InnoDB's ulint must be of the same size as void*"