mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
InnoDB portability fix: new function os_file_set_eof()
This commit is contained in:
@ -227,6 +227,14 @@ os_file_set_size(
|
|||||||
size */
|
size */
|
||||||
ulint size_high);/* in: most significant 32 bits of size */
|
ulint size_high);/* in: most significant 32 bits of size */
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
Truncates a file at its current position. */
|
||||||
|
|
||||||
|
ibool
|
||||||
|
os_file_set_eof(
|
||||||
|
/*============*/
|
||||||
|
/* out: TRUE if success */
|
||||||
|
FILE* file); /* in: file to be truncated */
|
||||||
|
/***************************************************************************
|
||||||
Flushes the write buffers of a given file to the disk. */
|
Flushes the write buffers of a given file to the disk. */
|
||||||
|
|
||||||
ibool
|
ibool
|
||||||
|
@ -1031,6 +1031,23 @@ error_handling:
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
Truncates a file at its current position. */
|
||||||
|
|
||||||
|
ibool
|
||||||
|
os_file_set_eof(
|
||||||
|
/*============*/
|
||||||
|
/* out: TRUE if success */
|
||||||
|
FILE* file) /* in: file to be truncated */
|
||||||
|
{
|
||||||
|
#ifdef __WIN__
|
||||||
|
HANDLE h = (HANDLE) _get_osfhandle(fileno(file));
|
||||||
|
return(SetEndOfFile(h));
|
||||||
|
#else /* __WIN__ */
|
||||||
|
return(!ftruncate(fileno(file), ftell(file)));
|
||||||
|
#endif /* __WIN__ */
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Flushes the write buffers of a given file to the disk. */
|
Flushes the write buffers of a given file to the disk. */
|
||||||
|
|
||||||
|
@ -1609,11 +1609,7 @@ loop:
|
|||||||
mutex_enter(&srv_monitor_file_mutex);
|
mutex_enter(&srv_monitor_file_mutex);
|
||||||
rewind(srv_monitor_file);
|
rewind(srv_monitor_file);
|
||||||
srv_printf_innodb_monitor(srv_monitor_file);
|
srv_printf_innodb_monitor(srv_monitor_file);
|
||||||
#ifdef __WIN__
|
os_file_set_eof(srv_monitor_file);
|
||||||
chsize(fileno(srv_monitor_file), ftell(srv_monitor_file));
|
|
||||||
#else /* __WIN__ */
|
|
||||||
ftruncate(fileno(srv_monitor_file), ftell(srv_monitor_file));
|
|
||||||
#endif /* __WIN__ */
|
|
||||||
mutex_exit(&srv_monitor_file_mutex);
|
mutex_exit(&srv_monitor_file_mutex);
|
||||||
|
|
||||||
if (srv_print_innodb_tablespace_monitor
|
if (srv_print_innodb_tablespace_monitor
|
||||||
|
@ -4648,7 +4648,7 @@ innodb_show_status(
|
|||||||
rewind(srv_monitor_file);
|
rewind(srv_monitor_file);
|
||||||
srv_printf_innodb_monitor(srv_monitor_file);
|
srv_printf_innodb_monitor(srv_monitor_file);
|
||||||
flen = ftell(srv_monitor_file);
|
flen = ftell(srv_monitor_file);
|
||||||
my_chsize(fileno(srv_monitor_file), flen, 0, MYF(0));
|
os_file_set_eof(srv_monitor_file);
|
||||||
if(flen > 64000 - 1) {
|
if(flen > 64000 - 1) {
|
||||||
flen = 64000 - 1;
|
flen = 64000 - 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user