Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
42b991fd
Commit
42b991fd
authored
25 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
BufFileSeek's behavior at segment boundaries wasn't what
logfile.c wanted ... seems easier to fix BufFileSeek.
parent
d357c967
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/storage/file/buffile.c
+26
-13
26 additions, 13 deletions
src/backend/storage/file/buffile.c
with
26 additions
and
13 deletions
src/backend/storage/file/buffile.c
+
26
−
13
View file @
42b991fd
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.
2
1999/10/1
6 19:49:26
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.
3
1999/10/1
9 02:34:45
tgl Exp $
*
*
* NOTES:
* NOTES:
*
*
...
@@ -434,8 +434,7 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
...
@@ -434,8 +434,7 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
switch
(
whence
)
switch
(
whence
)
{
{
case
SEEK_SET
:
case
SEEK_SET
:
if
(
fileno
<
0
||
fileno
>=
file
->
numFiles
||
if
(
fileno
<
0
)
offset
<
0
)
return
EOF
;
return
EOF
;
newFile
=
fileno
;
newFile
=
fileno
;
newOffset
=
offset
;
newOffset
=
offset
;
...
@@ -443,7 +442,7 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
...
@@ -443,7 +442,7 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
case
SEEK_CUR
:
case
SEEK_CUR
:
/*
/*
* Relative seek considers only the signed offset, ignoring fileno.
* Relative seek considers only the signed offset, ignoring fileno.
* Note that large offsets (> 1 gig) risk overflow.
* Note that large offsets (> 1 gig) risk overflow
in this add..
.
*/
*/
newFile
=
file
->
curFile
;
newFile
=
file
->
curFile
;
newOffset
=
(
file
->
curOffset
+
file
->
pos
)
+
offset
;
newOffset
=
(
file
->
curOffset
+
file
->
pos
)
+
offset
;
...
@@ -463,15 +462,6 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
...
@@ -463,15 +462,6 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
return
EOF
;
return
EOF
;
newOffset
+=
MAX_PHYSICAL_FILESIZE
;
newOffset
+=
MAX_PHYSICAL_FILESIZE
;
}
}
if
(
file
->
isTemp
)
{
while
(
newOffset
>
MAX_PHYSICAL_FILESIZE
)
{
if
(
++
newFile
>=
file
->
numFiles
)
return
EOF
;
newOffset
-=
MAX_PHYSICAL_FILESIZE
;
}
}
if
(
newFile
==
file
->
curFile
&&
if
(
newFile
==
file
->
curFile
&&
newOffset
>=
file
->
curOffset
&&
newOffset
>=
file
->
curOffset
&&
newOffset
<=
file
->
curOffset
+
file
->
nbytes
)
newOffset
<=
file
->
curOffset
+
file
->
nbytes
)
...
@@ -488,6 +478,29 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
...
@@ -488,6 +478,29 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
/* Otherwise, must reposition buffer, so flush any dirty data */
/* Otherwise, must reposition buffer, so flush any dirty data */
if
(
BufFileFlush
(
file
)
!=
0
)
if
(
BufFileFlush
(
file
)
!=
0
)
return
EOF
;
return
EOF
;
/*
* At this point and no sooner, check for seek past last segment.
* The above flush could have created a new segment, so
* checking sooner would not work (at least not with this code).
*/
if
(
file
->
isTemp
)
{
/* convert seek to "start of next seg" to "end of last seg" */
if
(
newFile
==
file
->
numFiles
&&
newOffset
==
0
)
{
newFile
--
;
newOffset
=
MAX_PHYSICAL_FILESIZE
;
}
while
(
newOffset
>
MAX_PHYSICAL_FILESIZE
)
{
if
(
++
newFile
>=
file
->
numFiles
)
return
EOF
;
newOffset
-=
MAX_PHYSICAL_FILESIZE
;
}
}
if
(
newFile
>=
file
->
numFiles
)
return
EOF
;
/* Seek is OK! */
file
->
curFile
=
newFile
;
file
->
curFile
=
newFile
;
file
->
curOffset
=
newOffset
;
file
->
curOffset
=
newOffset
;
file
->
pos
=
0
;
file
->
pos
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment