Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc3cc6a0

Browse files
committed
replcate truncate with ftruncate
1 parentcf99f6d commitc3cc6a0

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

‎src/data.c‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,15 +1792,16 @@ get_checksum_map(const char *fullpath, uint32 checksum_version,
17921792
charread_buffer[BLCKSZ];
17931793
charin_buf[STDIO_BUFSIZE];
17941794

1795-
/* truncate up to blocks */
1796-
if (truncate(fullpath,n_blocks*BLCKSZ)!=0)
1797-
elog(ERROR,"Cannot truncate file to blknum %u \"%s\": %s",
1798-
n_blocks,fullpath,strerror(errno));
1799-
18001795
/* open file */
18011796
in=fopen(fullpath,PG_BINARY_R);
18021797
if (!in)
18031798
elog(ERROR,"Cannot open source file \"%s\": %s",fullpath,strerror(errno));
1799+
1800+
/* truncate up to blocks */
1801+
if (ftruncate(fileno(in),n_blocks*BLCKSZ)!=0)
1802+
elog(ERROR,"Cannot truncate file to blknum %u \"%s\": %s",
1803+
n_blocks,fullpath,strerror(errno));
1804+
18041805
setvbuf(in,in_buf,_IOFBF,STDIO_BUFSIZE);
18051806

18061807
/* initialize array of checksums */
@@ -1860,17 +1861,18 @@ get_lsn_map(const char *fullpath, uint32 checksum_version,
18601861
charin_buf[STDIO_BUFSIZE];
18611862
datapagemap_t*lsn_map=NULL;
18621863

1863-
/* truncate up to blocks */
1864-
if (truncate(fullpath,n_blocks*BLCKSZ)!=0)
1865-
elog(ERROR,"Cannot truncate file to blknum %u \"%s\": %s",
1866-
n_blocks,fullpath,strerror(errno));
1867-
18681864
Assert(shift_lsn>0);
18691865

18701866
/* open file */
18711867
in=fopen(fullpath,PG_BINARY_R);
18721868
if (!in)
18731869
elog(ERROR,"Cannot open source file \"%s\": %s",fullpath,strerror(errno));
1870+
1871+
/* truncate up to blocks */
1872+
if (ftruncate(fileno(in),n_blocks*BLCKSZ)!=0)
1873+
elog(ERROR,"Cannot truncate file to blknum %u \"%s\": %s",
1874+
n_blocks,fullpath,strerror(errno));
1875+
18741876
setvbuf(in,in_buf,_IOFBF,STDIO_BUFSIZE);
18751877

18761878
lsn_map=pgut_malloc(sizeof(datapagemap_t));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp