View | Details | Raw Unified | Return to bug 257958
Collapse All | Expand All

(-)mysql-test/suite/innodb/t/check_ibd_filesize.test (+6 lines)
Lines 46-51 perl; Link Here
46
print "# bytes: ", (-s "$ENV{MYSQLD_DATADIR}/test/t1.ibd"), "\n";
46
print "# bytes: ", (-s "$ENV{MYSQLD_DATADIR}/test/t1.ibd"), "\n";
47
EOF
47
EOF
48
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
48
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
49
# Ensure that the file will be extended with the last 1024-byte page
50
# after the file was pre-extended in 4096-byte increments.
51
--disable_query_log
52
FLUSH TABLE t1 FOR EXPORT;
53
UNLOCK TABLES;
54
--enable_query_log
49
perl;
55
perl;
50
print "# bytes: ", (-s "$ENV{MYSQLD_DATADIR}/test/t1.ibd"), "\n";
56
print "# bytes: ", (-s "$ENV{MYSQLD_DATADIR}/test/t1.ibd"), "\n";
51
EOF
57
EOF
52
mysql-test/suite/innodb/t/check_ibd_filesize.test |  6 ++++++
58
mysql-test/suite/innodb/t/check_ibd_filesize.test |  6 ++++++
53
storage/innobase/fil/fil0fil.cc                   | 13 +++++++++----
59
storage/innobase/fil/fil0fil.cc                   | 13 +++++++++----
54
storage/innobase/os/os0file.cc                    |  7 ++++---
60
storage/innobase/os/os0file.cc                    |  7 ++++---
55
3 files changed, 19 insertions(+), 7 deletions(-)
61
3 files changed, 19 insertions(+), 7 deletions(-)
(-)storage/innobase/fil/fil0fil.cc (-4 / +10 lines)
Lines 942-952 fil_space_extend_must_retry( Link Here
942
	const page_size_t	pageSize(space->flags);
942
	const page_size_t	pageSize(space->flags);
943
	const ulint		page_size = pageSize.physical();
943
	const ulint		page_size = pageSize.physical();
944
944
945
	/* fil_read_first_page() expects srv_page_size bytes.
945
		/* fil_read_first_page() expects innodb_page_size bytes.
946
	fil_node_open_file() expects at least 4 * srv_page_size bytes.*/
946
		fil_node_open_file() expects at least 4 * innodb_page_size bytes.
947
	os_offset_t new_size = std::max(
947
		os_file_set_size() expects multiples of 4096 bytes.
948
		os_offset_t(size - file_start_page_no) * page_size,
948
		For ROW_FORMAT=COMPRESSED tables using 1024-byte or 2048-byte
949
		pages, we will preallocate up to an integer multiple of 4096 bytes,
950
		and let normal writes append 1024, 2048, or 3072 bytes to the file. */
951
		os_offset_t new_size = std::max(
952
		(os_offset_t(size - file_start_page_no) * page_size)
953
		& ~os_offset_t(4095),
949
		os_offset_t(FIL_IBD_FILE_INITIAL_SIZE << srv_page_size_shift));
954
		os_offset_t(FIL_IBD_FILE_INITIAL_SIZE << srv_page_size_shift));
955
		
950
956
951
	*success = os_file_set_size(node->name, node->handle, new_size,
957
	*success = os_file_set_size(node->name, node->handle, new_size,
952
		FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags));
958
		FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags));
(-)storage/innobase/os/os0file.cc (-3 / +4 lines)
Lines 5351-5356 os_file_set_size( Link Here
5351
	os_offset_t	size,
5351
	os_offset_t	size,
5352
	bool	is_sparse)
5352
	bool	is_sparse)
5353
{
5353
{
5354
	ut_ad(!(size & 4095));
5355
5354
#ifdef _WIN32
5356
#ifdef _WIN32
5355
	/* On Windows, changing file size works well and as expected for both
5357
	/* On Windows, changing file size works well and as expected for both
5356
	sparse and normal files.
5358
	sparse and normal files.
Lines 5392-5398 fallback: Link Here
5392
			if (current_size >= size) {
5394
			if (current_size >= size) {
5393
				return true;
5395
				return true;
5394
			}
5396
			}
5395
			current_size &= ~os_offset_t(statbuf.st_blksize - 1);
5397
			current_size &= ~4095ULL;
5396
			err = posix_fallocate(file, current_size,
5398
			err = posix_fallocate(file, current_size,
5397
					      size - current_size);
5399
					      size - current_size);
5398
		}
5400
		}
Lines 5432-5439 fallback: Link Here
5432
	if (fstat(file, &statbuf)) {
5434
	if (fstat(file, &statbuf)) {
5433
		return false;
5435
		return false;
5434
	}
5436
	}
5435
	os_offset_t current_size = statbuf.st_size
5437
	os_offset_t current_size = statbuf.st_size & ~4095ULL;
5436
		& ~os_offset_t(statbuf.st_blksize - 1);
5437
#endif
5438
#endif
5438
	if (current_size >= size) {
5439
	if (current_size >= size) {
5439
		return true;
5440
		return true;

Return to bug 257958