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
f2bfe8a2
Commit
f2bfe8a2
authored
Sep 07, 2000
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Heap redo/undo (except for tuple moving used by vacuum).
parent
c18c3213
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
497 additions
and
89 deletions
+497
-89
src/backend/access/heap/heapam.c
src/backend/access/heap/heapam.c
+441
-44
src/backend/access/heap/hio.c
src/backend/access/heap/hio.c
+15
-28
src/include/access/hio.h
src/include/access/hio.h
+2
-2
src/include/access/htup.h
src/include/access/htup.h
+13
-10
src/include/storage/bufpage.h
src/include/storage/bufpage.h
+14
-1
src/include/storage/itemid.h
src/include/storage/itemid.h
+9
-3
src/include/utils/rel.h
src/include/utils/rel.h
+3
-1
No files found.
src/backend/access/heap/heapam.c
View file @
f2bfe8a2
This diff is collapsed.
Click to expand it.
src/backend/access/heap/hio.c
View file @
f2bfe8a2
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Id: hio.c,v 1.3
2 2000/07/03 02:54:1
5 vadim Exp $
* $Id: hio.c,v 1.3
3 2000/09/07 09:58:3
5 vadim Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -67,16 +67,19 @@ RelationPutHeapTuple(Relation relation,
/*
* RelationGetBufferForTuple
*
* Returns (locked) buffer to add tuple with given len.
* If Ubuf is valid then no attempt to lock it should be made -
* this is for heap_update...
* Returns (locked) buffer with free space >= given len.
*
* Note that we use LockPage to lock relation for extension. We can
* do this as long as in all other places we use page-level locking
* for indices only. Alternatively, we could define pseudo-table as
* we do for transactions with XactLockTable.
*
* ELOG(ERROR) is allowed here, so this routine *must* be called
* before any (unlogged) changes are made in buffer pool.
*
*/
Buffer
RelationGetBufferForTuple
(
Relation
relation
,
Size
len
,
Buffer
Ubuf
)
RelationGetBufferForTuple
(
Relation
relation
,
Size
len
)
{
Buffer
buffer
;
Page
pageHeader
;
...
...
@@ -91,12 +94,6 @@ RelationGetBufferForTuple(Relation relation, Size len, Buffer Ubuf)
elog
(
ERROR
,
"Tuple is too big: size %u, max size %ld"
,
len
,
MaxTupleSize
);
/*
* Lock relation for extension. We can use LockPage here as long as in
* all other places we use page-level locking for indices only.
* Alternatively, we could define pseudo-table as we do for
* transactions with XactLockTable.
*/
if
(
!
relation
->
rd_myxactonly
)
LockPage
(
relation
,
0
,
ExclusiveLock
);
...
...
@@ -114,31 +111,29 @@ RelationGetBufferForTuple(Relation relation, Size len, Buffer Ubuf)
*/
if
(
lastblock
==
0
)
{
/* what exactly is this all about??? */
buffer
=
ReadBuffer
(
relation
,
lastblock
);
buffer
=
ReadBuffer
(
relation
,
P_NEW
);
LockBuffer
(
buffer
,
BUFFER_LOCK_EXCLUSIVE
);
pageHeader
=
(
Page
)
BufferGetPage
(
buffer
);
Assert
(
PageIsNew
((
PageHeader
)
pageHeader
));
buffer
=
ReleaseAndReadBuffer
(
buffer
,
relation
,
P_NEW
);
pageHeader
=
(
Page
)
BufferGetPage
(
buffer
);
PageInit
(
pageHeader
,
BufferGetPageSize
(
buffer
),
0
);
}
else
{
buffer
=
ReadBuffer
(
relation
,
lastblock
-
1
);
if
(
buffer
!=
Ubuf
)
LockBuffer
(
buffer
,
BUFFER_LOCK_EXCLUSIVE
);
pageHeader
=
(
Page
)
BufferGetPage
(
buffer
);
}
/*
* Is there room on the last existing page?
*/
if
(
len
>
PageGetFreeSpace
(
pageHeader
))
{
if
(
buffer
!=
Ubuf
)
LockBuffer
(
buffer
,
BUFFER_LOCK_UNLOCK
);
buffer
=
ReleaseAndReadBuffer
(
buffer
,
relation
,
P_NEW
);
LockBuffer
(
buffer
,
BUFFER_LOCK_EXCLUSIVE
);
pageHeader
=
(
Page
)
BufferGetPage
(
buffer
);
Assert
(
PageIsNew
((
PageHeader
)
pageHeader
));
PageInit
(
pageHeader
,
BufferGetPageSize
(
buffer
),
0
);
if
(
len
>
PageGetFreeSpace
(
pageHeader
))
...
...
@@ -147,14 +142,6 @@ RelationGetBufferForTuple(Relation relation, Size len, Buffer Ubuf)
elog
(
STOP
,
"Tuple is too big: size %u"
,
len
);
}
}
/*
* Caller should check space in Ubuf but...
*/
else
if
(
buffer
==
Ubuf
)
{
ReleaseBuffer
(
buffer
);
buffer
=
Ubuf
;
}
if
(
!
relation
->
rd_myxactonly
)
UnlockPage
(
relation
,
0
,
ExclusiveLock
);
...
...
src/include/access/hio.h
View file @
f2bfe8a2
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: hio.h,v 1.1
5 2000/07/03 02:54:17
vadim Exp $
* $Id: hio.h,v 1.1
6 2000/09/07 09:58:35
vadim Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -18,6 +18,6 @@
extern
void
RelationPutHeapTuple
(
Relation
relation
,
Buffer
buffer
,
HeapTuple
tuple
);
extern
Buffer
RelationGetBufferForTuple
(
Relation
relation
,
Size
len
,
Buffer
Ubuf
);
extern
Buffer
RelationGetBufferForTuple
(
Relation
relation
,
Size
len
);
#endif
/* HIO_H */
src/include/access/htup.h
View file @
f2bfe8a2
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: htup.h,v 1.3
4 2000/08/07 20:15:40 tgl
Exp $
* $Id: htup.h,v 1.3
5 2000/09/07 09:58:35 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -15,6 +15,7 @@
#define HTUP_H
#include "storage/bufpage.h"
#include "storage/relfilenode.h"
#define MinHeapTupleBitmapSize 32
/* 8 * 4 */
...
...
@@ -81,8 +82,7 @@ typedef HeapTupleHeaderData *HeapTupleHeader;
*/
typedef
struct
xl_heaptid
{
Oid
dbId
;
/* database */
Oid
relId
;
/* relation */
RelFileNode
node
;
CommandId
cid
;
/* this is for "better" tuple' */
/* identification - it allows to avoid */
/* "compensation" records for undo */
...
...
@@ -92,7 +92,7 @@ typedef struct xl_heaptid
/* This is what we need to know about delete - ALIGN(18) = 24 bytes */
typedef
struct
xl_heap_delete
{
xl_heaptid
dtid
;
/* deleted tuple id */
xl_heaptid
target
;
/* deleted tuple id */
}
xl_heap_delete
;
#define SizeOfHeapDelete (offsetof(xl_heaptid, tid) + SizeOfIptrData))
...
...
@@ -100,7 +100,7 @@ typedef struct xl_heap_delete
/* This is what we need to know about insert - 26 + data */
typedef
struct
xl_heap_insert
{
xl_heaptid
itid
;
/* inserted tuple id */
xl_heaptid
target
;
/* inserted tuple id */
/* something from tuple header */
int16
t_natts
;
Oid
t_oid
;
...
...
@@ -114,8 +114,8 @@ typedef struct xl_heap_insert
/* This is what we need to know about update - 28 + data */
typedef
struct
xl_heap_update
{
xl_heaptid
dtid
;
/* deleted tuple id */
ItemPointerData
i
tid
;
/* new inserted tuple id */
xl_heaptid
target
;
/* deleted tuple id */
ItemPointerData
new
tid
;
/* new inserted tuple id */
/* something from header of new tuple version */
int16
t_natts
;
uint8
t_hoff
;
...
...
@@ -128,8 +128,8 @@ typedef struct xl_heap_update
/* This is what we need to know about tuple move - 24 bytes */
typedef
struct
xl_heap_move
{
xl_heaptid
ftid
;
/* moved from */
ItemPointerData
t
tid
;
/* moved to */
xl_heaptid
target
;
/* moved from */
ItemPointerData
new
tid
;
/* moved to */
}
xl_heap_move
;
#define SizeOfHeapMove (offsetof(xl_heap_move, ttid) + SizeOfIptrData))
...
...
@@ -238,6 +238,9 @@ typedef HeapTupleData *HeapTuple;
#define HEAP_HASCOMPRESSED 0x0008
/* has compressed stored */
/* attribute(s) */
#define HEAP_HASEXTENDED 0x000C
/* the two above combined */
#define HEAP_XMAX_UNLOGGED 0x0080
/* to lock tuple for update */
/* without logging */
#define HEAP_XMIN_COMMITTED 0x0100
/* t_xmin committed */
#define HEAP_XMIN_INVALID 0x0200
/* t_xmin invalid/aborted */
#define HEAP_XMAX_COMMITTED 0x0400
/* t_xmax committed */
...
...
@@ -249,7 +252,7 @@ typedef HeapTupleData *HeapTuple;
#define HEAP_MOVED_IN 0x8000
/* moved from another place by
* vacuum */
#define HEAP_XACT_MASK 0xFF
0
0
/* */
#define HEAP_XACT_MASK 0xFF
F
0
/* */
#define HeapTupleNoNulls(tuple) \
(!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASNULL))
...
...
src/include/storage/bufpage.h
View file @
f2bfe8a2
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: bufpage.h,v 1.3
1 2000/07/21 06:42:39 tgl
Exp $
* $Id: bufpage.h,v 1.3
2 2000/09/07 09:58:36 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -296,6 +296,19 @@ typedef enum
(sizeof(PageHeaderData) - sizeof(ItemIdData)))) \
/ ((int) sizeof(ItemIdData)))
#ifdef XLOG
#define PageGetLSN(page) \
(((PageHeader) (page))->pd_lsn)
#define PageSetLSN(page, lsn) \
(((PageHeader) (page))->pd_lsn = (XLogRecPtr) (lsn))
#define PageGetSUI(page) \
(((PageHeader) (page))->pd_sui)
#define PageSetSUI(page, sui) \
(((PageHeader) (page))->pd_sui = (StartUpID) (sui))
#endif
/* ----------------------------------------------------------------
* extern declarations
...
...
src/include/storage/itemid.h
View file @
f2bfe8a2
...
...
@@ -7,14 +7,13 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: itemid.h,v 1.1
1 2000/08/07 20:15:50 tgl
Exp $
* $Id: itemid.h,v 1.1
2 2000/09/07 09:58:36 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef ITEMID_H
#define ITEMID_H
/*
* An item pointer (also called line pointer) on a buffer page
*/
...
...
@@ -31,8 +30,15 @@ typedef ItemIdData *ItemId;
* lp_flags contains these flags:
*/
#define LP_USED 0x01
/* this line pointer is being used */
/* currently, there is one unused flag bit ... */
#ifdef XLOG
#define LP_DELETE 0x02
/* item is to be deleted */
#define ItemIdDeleted(itemId) \
(((itemId)->lp_flags & LP_DELETE) != 0)
#endif
/*
* Item offsets, lengths, and flags are represented by these types when
...
...
src/include/utils/rel.h
View file @
f2bfe8a2
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: rel.h,v 1.4
0 2000/07/14 22:18:02 tgl
Exp $
* $Id: rel.h,v 1.4
1 2000/09/07 09:58:38 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -19,6 +19,7 @@
#include "catalog/pg_am.h"
#include "catalog/pg_class.h"
#include "rewrite/prs2lock.h"
#include "storage/relfilenode.h"
#include "storage/fd.h"
/* added to prevent circular dependency. bjm 1999/11/15 */
...
...
@@ -86,6 +87,7 @@ typedef struct TriggerDesc
typedef
struct
RelationData
{
File
rd_fd
;
/* open file descriptor, or -1 if none */
RelFileNode
rd_node
;
/* relation file node */
int
rd_nblocks
;
/* number of blocks in rel */
uint16
rd_refcnt
;
/* reference count */
bool
rd_myxactonly
;
/* rel uses the local buffer mgr */
...
...
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