Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
f3e5d862
Commit
f3e5d862
authored
Jul 10, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent creating a boatload of empty segments when md.c is asked to
access a ridiculously large block number within a relation.
parent
b54faa1b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
7 deletions
+25
-7
src/backend/storage/smgr/md.c
src/backend/storage/smgr/md.c
+25
-7
No files found.
src/backend/storage/smgr/md.c
View file @
f3e5d862
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.7
2 2000/06/28 03:32:14
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.7
3 2000/07/10 04:32:00
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -714,9 +714,16 @@ mdnblocks(Relation reln)
...
@@ -714,9 +714,16 @@ mdnblocks(Relation reln)
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
{
{
/*
* Because we pass O_CREAT, we will create the next segment
* (with zero length) immediately, if the last segment is of
* length REL_SEGSIZE. This is unnecessary but harmless, and
* testing for the case would take more cycles than it seems
* worth.
*/
v
->
mdfd_chain
=
_mdfd_openseg
(
reln
,
segno
,
O_CREAT
);
v
->
mdfd_chain
=
_mdfd_openseg
(
reln
,
segno
,
O_CREAT
);
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
elog
(
ERROR
,
"cannot count blocks for %s -- open failed"
,
elog
(
ERROR
,
"cannot count blocks for %s -- open failed
: %m
"
,
RelationGetRelationName
(
reln
));
RelationGetRelationName
(
reln
));
}
}
...
@@ -1038,11 +1045,20 @@ _mdfd_getseg(Relation reln, int blkno)
...
@@ -1038,11 +1045,20 @@ _mdfd_getseg(Relation reln, int blkno)
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
{
{
v
->
mdfd_chain
=
_mdfd_openseg
(
reln
,
i
,
O_CREAT
);
/*
* We will create the next segment only if the target block
* is within it. This prevents Sorcerer's Apprentice syndrome
* if a bug at higher levels causes us to be handed a ridiculously
* large blkno --- otherwise we could create many thousands of
* empty segment files before reaching the "target" block. We
* should never need to create more than one new segment per call,
* so this restriction seems reasonable.
*/
v
->
mdfd_chain
=
_mdfd_openseg
(
reln
,
i
,
(
segno
==
1
)
?
O_CREAT
:
0
);
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
elog
(
ERROR
,
"cannot open segment %d of relation %s"
,
elog
(
ERROR
,
"cannot open segment %d of relation %s
(target block %d): %m
"
,
i
,
RelationGetRelationName
(
reln
));
i
,
RelationGetRelationName
(
reln
)
,
blkno
);
}
}
v
=
v
->
mdfd_chain
;
v
=
v
->
mdfd_chain
;
}
}
...
@@ -1060,8 +1076,10 @@ _mdfd_getseg(Relation reln, int blkno)
...
@@ -1060,8 +1076,10 @@ _mdfd_getseg(Relation reln, int blkno)
* "blind" with no Relation struct. We assume that we are not likely to
* "blind" with no Relation struct. We assume that we are not likely to
* touch the same relation again soon, so we do not create an FD entry for
* touch the same relation again soon, so we do not create an FD entry for
* the relation --- we just open a kernel file descriptor which will be
* the relation --- we just open a kernel file descriptor which will be
* used and promptly closed. The return value is the kernel descriptor,
* used and promptly closed. We also assume that the target block already
* or -1 on failure.
* exists, ie, we need not extend the relation.
*
* The return value is the kernel descriptor, or -1 on failure.
*/
*/
static
int
static
int
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment