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

Commit79f29a1

Browse files
macdicepull[bot]
authored andcommitted
Remove dead pread and pwrite replacement code.
pread() and pwrite() are in SUSv2, and all targeted Unix systems havethem.Previously, we defined pg_pread and pg_pwrite to emulate these functionwith lseek() on old Unixen. The names with a pg_ prefix were a reminderof a portability hazard: they might change the current file position.That hazard is gone, so we can drop the prefixes.Since the remaining replacement code is Windows-only, move it intosrc/port/win32p{read,write}.c, and move the declarations intosrc/include/port/win32_port.h.No need for vestigial HAVE_PREAD, HAVE_PWRITE macros as they were onlyused for declarations in port.h which have now moved into win32_port.h.Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: Greg Stark <stark@mit.edu>Reviewed-by: Robert Haas <robertmhaas@gmail.com>Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
1 parent768d22a commit79f29a1

File tree

23 files changed

+76
-137
lines changed

23 files changed

+76
-137
lines changed

‎configure

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16728,32 +16728,6 @@ esac
1672816728

1672916729
fi
1673016730

16731-
ac_fn_c_check_func "$LINENO" "pread" "ac_cv_func_pread"
16732-
if test "x$ac_cv_func_pread" = xyes; then :
16733-
$as_echo "#define HAVE_PREAD 1" >>confdefs.h
16734-
16735-
else
16736-
case " $LIBOBJS " in
16737-
*" pread.$ac_objext "* ) ;;
16738-
*) LIBOBJS="$LIBOBJS pread.$ac_objext"
16739-
;;
16740-
esac
16741-
16742-
fi
16743-
16744-
ac_fn_c_check_func "$LINENO" "pwrite" "ac_cv_func_pwrite"
16745-
if test "x$ac_cv_func_pwrite" = xyes; then :
16746-
$as_echo "#define HAVE_PWRITE 1" >>confdefs.h
16747-
16748-
else
16749-
case " $LIBOBJS " in
16750-
*" pwrite.$ac_objext "* ) ;;
16751-
*) LIBOBJS="$LIBOBJS pwrite.$ac_objext"
16752-
;;
16753-
esac
16754-
16755-
fi
16756-
1675716731
ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
1675816732
if test "x$ac_cv_func_strlcat" = xyes; then :
1675916733
$as_echo "#define HAVE_STRLCAT 1" >>confdefs.h
@@ -17015,6 +16989,18 @@ esac
1701516989
;;
1701616990
esac
1701716991

16992+
case " $LIBOBJS " in
16993+
*" win32pread.$ac_objext "* ) ;;
16994+
*) LIBOBJS="$LIBOBJS win32pread.$ac_objext"
16995+
;;
16996+
esac
16997+
16998+
case " $LIBOBJS " in
16999+
*" win32pwrite.$ac_objext "* ) ;;
17000+
*) LIBOBJS="$LIBOBJS win32pwrite.$ac_objext"
17001+
;;
17002+
esac
17003+
1701817004
case " $LIBOBJS " in
1701917005
*" win32security.$ac_objext "* ) ;;
1702017006
*) LIBOBJS="$LIBOBJS win32security.$ac_objext"

‎configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,8 +1876,6 @@ AC_REPLACE_FUNCS(m4_normalize([
18761876
getpeereid
18771877
inet_aton
18781878
mkdtemp
1879-
pread
1880-
pwrite
18811879
strlcat
18821880
strlcpy
18831881
strnlen
@@ -1943,6 +1941,8 @@ if test "$PORTNAME" = "win32"; then
19431941
AC_LIBOBJ(win32error)
19441942
AC_LIBOBJ(win32link)
19451943
AC_LIBOBJ(win32ntdll)
1944+
AC_LIBOBJ(win32pread)
1945+
AC_LIBOBJ(win32pwrite)
19461946
AC_LIBOBJ(win32security)
19471947
AC_LIBOBJ(win32setlocale)
19481948
AC_LIBOBJ(win32stat)

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,9 +2103,9 @@ qtext_store(const char *query, int query_len,
21032103
if (fd<0)
21042104
gotoerror;
21052105

2106-
if (pg_pwrite(fd,query,query_len,off)!=query_len)
2106+
if (pwrite(fd,query,query_len,off)!=query_len)
21072107
gotoerror;
2108-
if (pg_pwrite(fd,"\0",1,off+query_len)!=1)
2108+
if (pwrite(fd,"\0",1,off+query_len)!=1)
21092109
gotoerror;
21102110

21112111
CloseTransientFile(fd);

‎src/backend/access/heap/rewriteheap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ heap_xlog_logical_rewrite(XLogReaderState *r)
11491149
/* write out tail end of mapping file (again) */
11501150
errno=0;
11511151
pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE);
1152-
if (pg_pwrite(fd,data,len,xlrec->offset)!=len)
1152+
if (pwrite(fd,data,len,xlrec->offset)!=len)
11531153
{
11541154
/* if write didn't set errno, assume problem is no disk space */
11551155
if (errno==0)

‎src/backend/access/transam/slru.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
718718

719719
errno=0;
720720
pgstat_report_wait_start(WAIT_EVENT_SLRU_READ);
721-
if (pg_pread(fd,shared->page_buffer[slotno],BLCKSZ,offset)!=BLCKSZ)
721+
if (pread(fd,shared->page_buffer[slotno],BLCKSZ,offset)!=BLCKSZ)
722722
{
723723
pgstat_report_wait_end();
724724
slru_errcause=SLRU_READ_FAILED;
@@ -873,7 +873,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
873873

874874
errno=0;
875875
pgstat_report_wait_start(WAIT_EVENT_SLRU_WRITE);
876-
if (pg_pwrite(fd,shared->page_buffer[slotno],BLCKSZ,offset)!=BLCKSZ)
876+
if (pwrite(fd,shared->page_buffer[slotno],BLCKSZ,offset)!=BLCKSZ)
877877
{
878878
pgstat_report_wait_end();
879879
/* if write didn't set errno, assume problem is no disk space */

‎src/backend/access/transam/xlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,7 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible)
21892189
INSTR_TIME_SET_CURRENT(start);
21902190

21912191
pgstat_report_wait_start(WAIT_EVENT_WAL_WRITE);
2192-
written=pg_pwrite(openLogFile,from,nleft,startoffset);
2192+
written=pwrite(openLogFile,from,nleft,startoffset);
21932193
pgstat_report_wait_end();
21942194

21952195
/*
@@ -3011,7 +3011,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli,
30113011
* enough.
30123012
*/
30133013
errno=0;
3014-
if (pg_pwrite(fd,zbuffer.data,1,wal_segment_size-1)!=1)
3014+
if (pwrite(fd,zbuffer.data,1,wal_segment_size-1)!=1)
30153015
{
30163016
/* if write didn't set errno, assume no disk space */
30173017
save_errno=errno ?errno :ENOSPC;

‎src/backend/access/transam/xlogreader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ WALRead(XLogReaderState *state,
15141514

15151515
/* Reset errno first; eases reporting non-errno-affecting errors */
15161516
errno=0;
1517-
readbytes=pg_pread(state->seg.ws_file,p,segbytes, (off_t)startoff);
1517+
readbytes=pread(state->seg.ws_file,p,segbytes, (off_t)startoff);
15181518

15191519
#ifndefFRONTEND
15201520
pgstat_report_wait_end();

‎src/backend/access/transam/xlogrecovery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3260,7 +3260,7 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
32603260
readOff=targetPageOff;
32613261

32623262
pgstat_report_wait_start(WAIT_EVENT_WAL_READ);
3263-
r=pg_pread(readFile,readBuf,XLOG_BLCKSZ, (off_t)readOff);
3263+
r=pread(readFile,readBuf,XLOG_BLCKSZ, (off_t)readOff);
32643264
if (r!=XLOG_BLCKSZ)
32653265
{
32663266
charfname[MAXFNAMELEN];

‎src/backend/replication/basebackup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offset,
18221822
intrc;
18231823

18241824
pgstat_report_wait_start(WAIT_EVENT_BASEBACKUP_READ);
1825-
rc=pg_pread(fd,buf,nbytes,offset);
1825+
rc=pread(fd,buf,nbytes,offset);
18261826
pgstat_report_wait_end();
18271827

18281828
if (rc<0)

‎src/backend/replication/walreceiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr, TimeLineID tli)
915915
/* OK to write the logs */
916916
errno=0;
917917

918-
byteswritten=pg_pwrite(recvFile,buf,segbytes, (off_t)startoff);
918+
byteswritten=pwrite(recvFile,buf,segbytes, (off_t)startoff);
919919
if (byteswritten <=0)
920920
{
921921
charxlogfname[MAXFNAMELEN];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp