Commit 65a9dd2d authored by jan@hundin.mysql.fi's avatar jan@hundin.mysql.fi

SHOW TABLE STATUS now prints create_time, update_time and check_time

for InnoDB tables. Note that these times may always be correct ones,
because for example ALTER TABLE creates a table again.
parent de0488ee
......@@ -14,6 +14,7 @@ Created 10/21/1995 Heikki Tuuri
#ifndef __WIN__
#include <dirent.h>
#include <sys/stat.h>
#include <time.h>
#endif
extern ibool os_do_not_call_flush_at_each_write;
......@@ -142,12 +143,15 @@ bigger than 4000 bytes */
#define OS_FILE_MAX_PATH 4000
/* Struct used in fetching information of a file in a directory */
typedef struct os_file_stat_struct os_file_stat_t;
struct os_file_stat_struct{
char name[OS_FILE_MAX_PATH]; /* path to a file */
os_file_type_t type; /* file type */
ib_longlong size; /* file size */
char name[OS_FILE_MAX_PATH]; /* path to a file */
os_file_type_t type; /* file type */
ib_longlong size; /* file size */
time_t ctime; /* creation time */
time_t mtime; /* modification time */
time_t atime; /* access time */
};
typedef struct os_file_stat_struct os_file_stat_t;
#ifdef __WIN__
typedef HANDLE os_file_dir_t; /* directory stream */
......@@ -686,5 +690,14 @@ no pending io operations. */
ibool
os_aio_all_slots_free(void);
/*=======================*/
/* out: TRUE if all free */
/***********************************************************************
This function returns information about the specified file */
ibool
os_file_get_status(
/*===============*/
/* out: TRUE if stat information found */
const char* path, /* in: pathname of the file */
os_file_stat_t* stat_info); /* information of a file in a directory */
#endif
......@@ -2359,6 +2359,83 @@ os_file_status(
#endif
}
/***********************************************************************
This function returns information about the specified file */
ibool
os_file_get_status(
/*===========*/
/* out: TRUE if stat information found */
const char* path, /* in: pathname of the file */
os_file_stat_t* stat_info) /* information of a file in a directory */
{
#ifdef __WIN__
int ret;
struct _stat statinfo;
ret = _stat(path, &statinfo);
if (ret && (errno == ENOENT || errno == ENOTDIR)) {
/* file does not exist */
return(FALSE);
} else if (ret) {
/* file exists, but stat call failed */
os_file_handle_error_no_exit(0, path, "stat");
return(FALSE);
}
if (_S_IFDIR & statinfo.st_mode) {
stat_info->type = OS_FILE_TYPE_DIR;
} else if (_S_IFREG & statinfo.st_mode) {
stat_info->type = OS_FILE_TYPE_FILE;
} else {
stat_info_>type = OS_FILE_TYPE_UNKNOWN;
}
stat_info->ctime = statinfo.st_ctime;
stat_info->atime = statinfo.st_atime;
stat_info->mtime = statinfo.st_mtime;
stat_info->size = statinfo.st_size;
return(TRUE);
#else
int ret;
struct stat statinfo;
ret = stat(path, &statinfo);
if (ret && (errno == ENOENT || errno == ENOTDIR)) {
/* file does not exist */
return(FALSE);
} else if (ret) {
/* file exists, but stat call failed */
os_file_handle_error_no_exit(0, path, "stat");
return(FALSE);
}
if (S_ISDIR(statinfo.st_mode)) {
stat_info->type = OS_FILE_TYPE_DIR;
} else if (S_ISLNK(statinfo.st_mode)) {
stat_info->type = OS_FILE_TYPE_LINK;
} else if (S_ISREG(statinfo.st_mode)) {
stat_info->type = OS_FILE_TYPE_FILE;
} else {
stat_info->type = OS_FILE_TYPE_UNKNOWN;
}
stat_info->ctime = statinfo.st_ctime;
stat_info->atime = statinfo.st_atime;
stat_info->mtime = statinfo.st_mtime;
stat_info->size = statinfo.st_size;
return(TRUE);
#endif
}
/* path name separator character */
#ifdef __WIN__
# define OS_FILE_PATH_SEPARATOR '\\'
......
......@@ -4337,6 +4337,8 @@ ha_innobase::info(
ha_rows rec_per_key;
ulong j;
ulong i;
char path[FN_REFLEN];
os_file_stat_t stat_info;
DBUG_ENTER("info");
......@@ -4374,6 +4376,25 @@ ha_innobase::info(
prebuilt->trx->op_info = (char*)
"returning various info to MySQL";
if (ib_table->space != 0) {
my_snprintf(path, sizeof(path), "%s/%s%s",
mysql_data_home, ib_table->name,
".ibd");
unpack_filename(path,path);
} else {
my_snprintf(path, sizeof(path), "%s/%s%s",
mysql_data_home, ib_table->name,
reg_ext);
unpack_filename(path,path);
}
if (os_file_get_status(path,&stat_info)) {
create_time = stat_info.ctime;
check_time = stat_info.atime;
update_time = stat_info.mtime;
}
}
if (flag & HA_STATUS_VARIABLE) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment