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
8a7f31a7
Commit
8a7f31a7
authored
Nov 29, 1999
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to detect oversize tuple before corrupting relation, instead of
after...
parent
66dbcd47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
16 deletions
+29
-16
src/backend/access/heap/hio.c
src/backend/access/heap/hio.c
+29
-16
No files found.
src/backend/access/heap/hio.c
View file @
8a7f31a7
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Id: hio.c,v 1.2
6 1999/07/19 07:07:18 momjian
Exp $
* $Id: hio.c,v 1.2
7 1999/11/29 04:34:55 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -107,10 +107,20 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
ItemId
itemId
;
Item
item
;
len
=
(
unsigned
)
MAXALIGN
(
tuple
->
t_len
);
/* be conservative */
/*
* If we're gonna fail for oversize tuple, do it right away...
* this code should go away eventually.
*/
if
(
len
>
MaxTupleSize
)
elog
(
ERROR
,
"Tuple is too big: size %d, max size %d"
,
len
,
MaxTupleSize
);
/*
* Lock relation for exten
t
ion. We can use LockPage here as long as in
* Lock relation for exten
s
ion. We can use LockPage here as long as in
* all other places we use page-level locking for indices only.
* Alternat
e
vely, we could define pseudo-table as we do for
* Alternat
i
vely, we could define pseudo-table as we do for
* transactions with XactLockTable.
*/
if
(
!
relation
->
rd_myxactonly
)
...
...
@@ -122,17 +132,17 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
* relation. A good optimization would be to get this to actually
* work properly.
*/
lastblock
=
RelationGetNumberOfBlocks
(
relation
);
/*
* Get the last existing page --- may need to create the first one
* if this is a virgin relation.
*/
if
(
lastblock
==
0
)
{
/* what exactly is this all about??? */
buffer
=
ReadBuffer
(
relation
,
lastblock
);
pageHeader
=
(
Page
)
BufferGetPage
(
buffer
);
/*
* There was IF instead of ASSERT here ?!
*/
Assert
(
PageIsNew
((
PageHeader
)
pageHeader
));
buffer
=
ReleaseAndReadBuffer
(
buffer
,
relation
,
P_NEW
);
pageHeader
=
(
Page
)
BufferGetPage
(
buffer
);
...
...
@@ -143,13 +153,10 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
LockBuffer
(
buffer
,
BUFFER_LOCK_EXCLUSIVE
);
pageHeader
=
(
Page
)
BufferGetPage
(
buffer
);
len
=
(
unsigned
)
MAXALIGN
(
tuple
->
t_len
);
/* be conservative */
/*
* Note that this is true if the above returned a bogus page, which it
* will do for a completely empty relation.
* Is there room on the last existing page?
*/
if
(
len
>
PageGetFreeSpace
(
pageHeader
))
{
LockBuffer
(
buffer
,
BUFFER_LOCK_UNLOCK
);
...
...
@@ -159,12 +166,18 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
PageInit
(
pageHeader
,
BufferGetPageSize
(
buffer
),
0
);
if
(
len
>
PageGetFreeSpace
(
pageHeader
))
{
/*
* BUG: by elog'ing here, we leave the new buffer locked and not
* marked dirty, which may result in an invalid page header
* being left on disk. But we should not get here given the
* test at the top of the routine, and the whole deal should
* go away when we implement tuple splitting anyway...
*/
elog
(
ERROR
,
"Tuple is too big: size %d"
,
len
);
}
}
if
(
len
>
MaxTupleSize
)
elog
(
ERROR
,
"Tuple is too big: size %d, max size %d"
,
len
,
MaxTupleSize
);
if
(
!
relation
->
rd_myxactonly
)
UnlockPage
(
relation
,
0
,
ExclusiveLock
);
...
...
@@ -178,7 +191,7 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
ItemPointerSet
(
&
((
HeapTupleHeader
)
item
)
->
t_ctid
,
lastblock
,
offnum
);
/* return an accurate tuple */
/* return an accurate tuple
self-pointer
*/
ItemPointerSet
(
&
tuple
->
t_self
,
lastblock
,
offnum
);
LockBuffer
(
buffer
,
BUFFER_LOCK_UNLOCK
);
...
...
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