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
b33428d2
Commit
b33428d2
authored
Oct 13, 2000
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various utils for WAL
parent
deee7830
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
0 deletions
+120
-0
src/backend/access/transam/xlogutils.c
src/backend/access/transam/xlogutils.c
+120
-0
No files found.
src/backend/access/transam/xlogutils.c
0 → 100644
View file @
b33428d2
/*-------------------------------------------------------------------------
*
* xlog.c
*
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/xlog.h"
#include "access/xact.h"
#ifdef XLOG
/*
* Check if specified heap tuple was inserted by given
* xaction/command and return
*
* - -1 if not
* - 0 if there is no tuple at all
* - 1 if yes
*/
int
XLogIsOwnerOfTuple
(
RelFileNode
hnode
,
ItemPointer
iptr
,
TransactionId
xid
,
CommandId
cid
)
{
Relation
reln
;
Buffer
buffer
;
Page
page
;
ItemId
lp
;
HeapTupleHeader
htup
;
reln
=
XLogOpenRelation
(
false
,
RM_HEAP_ID
,
hnode
);
if
(
!
RelationIsValid
(
reln
))
return
(
0
);
buffer
=
ReadBuffer
(
reln
,
ItemPointerGetBlockNumber
(
iptr
));
if
(
!
BufferIsValid
(
buffer
))
return
(
0
);
LockBuffer
(
buffer
,
BUFFER_LOCK_SHARE
);
page
=
(
Page
)
BufferGetPage
(
buffer
);
if
(
PageIsNew
((
PageHeader
)
page
)
||
ItemPointerGetOffsetNumber
(
iptr
)
>
PageGetMaxOffsetNumber
(
page
))
{
UnlockAndReleaseBuffer
(
buffer
);
return
(
0
);
}
lp
=
PageGetItemId
(
page
,
ItemPointerGetOffsetNumber
(
iptr
));
if
(
!
ItemIdIsUsed
(
lp
)
||
ItemIdDeleted
(
lp
))
{
UnlockAndReleaseBuffer
(
buffer
);
return
(
0
);
}
htup
=
(
HeapTupleHeader
)
PageGetItem
(
page
,
lp
);
if
(
PageGetSUI
(
page
)
!=
ThisStartUpID
||
htup
->
t_xmin
!=
xid
||
htup
->
t_cmin
!=
cid
)
{
UnlockAndReleaseBuffer
(
buffer
);
return
(
-
1
);
}
UnlockAndReleaseBuffer
(
buffer
);
return
(
1
);
}
/*
* Check if exists valid (inserted by not aborted xaction) heap tuple
* for given item pointer
*/
bool
XLogIsValidTuple
(
RelFileNode
hnode
,
ItemPointer
iptr
)
{
Relation
reln
;
Buffer
buffer
;
Page
page
;
ItemId
lp
;
HeapTupleHeader
htup
;
reln
=
XLogOpenRelation
(
false
,
RM_HEAP_ID
,
hnode
);
if
(
!
RelationIsValid
(
reln
))
return
(
false
);
buffer
=
ReadBuffer
(
reln
,
ItemPointerGetBlockNumber
(
iptr
));
if
(
!
BufferIsValid
(
buffer
))
return
(
false
);
LockBuffer
(
buffer
,
BUFFER_LOCK_SHARE
);
page
=
(
Page
)
BufferGetPage
(
buffer
);
if
(
PageIsNew
((
PageHeader
)
page
)
||
ItemPointerGetOffsetNumber
(
iptr
)
>
PageGetMaxOffsetNumber
(
page
))
{
UnlockAndReleaseBuffer
(
buffer
);
return
(
false
);
}
lp
=
PageGetItemId
(
page
,
ItemPointerGetOffsetNumber
(
iptr
));
if
(
!
ItemIdIsUsed
(
lp
)
||
ItemIdDeleted
(
lp
))
{
UnlockAndReleaseBuffer
(
buffer
);
return
(
false
);
}
htup
=
(
HeapTupleHeader
)
PageGetItem
(
page
,
lp
);
if
(
XLogIsAborted
(
PageGetSUI
(
page
),
htup
->
t_xmin
))
{
UnlockAndReleaseBuffer
(
buffer
);
return
(
false
);
}
UnlockAndReleaseBuffer
(
buffer
);
return
(
true
);
}
#endif
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