Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
bf1c8f2b
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bf1c8f2b
编写于
6月 02, 2000
作者:
V
Vadim B. Mikheev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
heap' xlog records
上级
664dd614
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
150 addition
and
24 deletion
+150
-24
src/backend/access/heap/heapam.c
src/backend/access/heap/heapam.c
+36
-1
src/backend/access/transam/xlog.c
src/backend/access/transam/xlog.c
+33
-19
src/include/access/htup.h
src/include/access/htup.h
+68
-1
src/include/access/xlog.h
src/include/access/xlog.h
+8
-2
src/include/storage/bufpage.h
src/include/storage/bufpage.h
+5
-1
未找到文件。
src/backend/access/heap/heapam.c
浏览文件 @
bf1c8f2b
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.
69 2000/05/30 00:49:39 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.
70 2000/06/02 10:20:24 vadim
Exp $
*
*
* INTERFACE ROUTINES
...
...
@@ -1246,6 +1246,27 @@ heap_insert(Relation relation, HeapTuple tup)
RelationPutHeapTupleAtEnd
(
relation
,
tup
);
#ifdef XLOG
/* XLOG stuff */
{
xl_heap_insert
xlrec
;
xlrec
.
itid
.
dbId
=
relation
->
rd_lockInfo
.
lockRelId
.
dbId
;
xlrec
.
itid
.
relId
=
relation
->
rd_lockInfo
.
lockRelId
.
relId
;
XXX
xlrec
.
itid
.
tid
=
tp
.
t_self
;
xlrec
.
t_natts
=
tup
->
t_data
->
t_natts
;
xlrec
.
t_oid
=
tup
->
t_data
->
t_oid
;
xlrec
.
t_hoff
=
tup
->
t_data
->
t_hoff
;
xlrec
.
mask
=
tup
->
t_data
->
t_infomask
;
XLogRecPtr
recptr
=
XLogInsert
(
RM_HEAP_ID
,
XLOG_HEAP_INSERT
,
(
char
*
)
xlrec
,
sizeof
(
xlrec
),
(
char
*
)
tup
->
t_data
+
offsetof
(
HeapTupleHeaderData
,
tbits
),
tup
->
t_len
-
offsetof
(
HeapTupleHeaderData
,
tbits
));
dp
->
pd_lsn
=
recptr
;
}
#endif
if
(
IsSystemRelationName
(
RelationGetRelationName
(
relation
)))
RelationMark4RollbackHeapTuple
(
relation
,
tup
);
...
...
@@ -1333,6 +1354,20 @@ l1:
return
result
;
}
#ifdef XLOG
/* XLOG stuff */
{
xl_heap_delete
xlrec
;
xlrec
.
dtid
.
dbId
=
relation
->
rd_lockInfo
.
lockRelId
.
dbId
;
xlrec
.
dtid
.
relId
=
relation
->
rd_lockInfo
.
lockRelId
.
relId
;
xlrec
.
dtid
.
tid
=
tp
.
t_self
;
XLogRecPtr
recptr
=
XLogInsert
(
RM_HEAP_ID
,
XLOG_HEAP_DELETE
,
(
char
*
)
xlrec
,
sizeof
(
xlrec
),
NULL
,
0
);
dp
->
pd_lsn
=
recptr
;
}
#endif
/* store transaction information of xact deleting the tuple */
TransactionIdStore
(
GetCurrentTransactionId
(),
&
(
tp
.
t_data
->
t_xmax
));
tp
.
t_data
->
t_cmax
=
GetCurrentCommandId
();
...
...
src/backend/access/transam/xlog.c
浏览文件 @
bf1c8f2b
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.1
4 2000/06/02 03:58:34 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.1
5 2000/06/02 10:20:25 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -219,7 +219,7 @@ static char readBuf[BLCKSZ];
static
XLogRecord
*
nextRecord
=
NULL
;
XLogRecPtr
XLogInsert
(
RmgrId
rmid
,
char
*
hdr
,
uint32
hdrlen
,
char
*
buf
,
uint32
buflen
)
XLogInsert
(
RmgrId
rmid
,
uint8
info
,
char
*
hdr
,
uint32
hdrlen
,
char
*
buf
,
uint32
buflen
)
{
XLogCtlInsert
*
Insert
=
&
XLogCtl
->
Insert
;
XLogRecord
*
record
;
...
...
@@ -231,6 +231,7 @@ XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
uint16
curridx
;
bool
updrqst
=
false
;
Assert
(
!
(
info
&
XLR_INFO_MASK
));
if
(
len
==
0
||
len
>
MAXLOGRECSZ
)
elog
(
STOP
,
"XLogInsert: invalid record len %u"
,
len
);
...
...
@@ -306,7 +307,8 @@ XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
}
record
->
xl_xid
=
GetCurrentTransactionId
();
record
->
xl_len
=
(
len
>
freespace
)
?
freespace
:
len
;
record
->
xl_info
=
(
len
>
freespace
)
?
XLR_TO_BE_CONTINUED
:
0
;
record
->
xl_info
=
(
len
>
freespace
)
?
(
info
|
XLR_TO_BE_CONTINUED
)
:
info
;
record
->
xl_rmid
=
rmid
;
RecPtr
.
xlogid
=
XLogCtl
->
xlblocks
[
curridx
].
xlogid
;
RecPtr
.
xrecoff
=
...
...
@@ -318,8 +320,7 @@ XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, char *buf, uint32 buflen)
MyProc
->
logRec
=
RecPtr
;
SpinRelease
(
SInvalLock
);
}
MyLastRecPtr
=
RecPtr
;
RecPtr
.
xrecoff
+=
record
->
xl_len
;
MyLastRecPtr
=
RecPtr
;
/* begin of record */
Insert
->
currpos
+=
SizeOfXLogRecord
;
if
(
freespace
>
0
)
{
...
...
@@ -364,6 +365,7 @@ nbuf:
if
(
hdrlen
>
freespace
)
{
subrecord
->
xl_len
=
freespace
;
/* we don't store info in subrecord' xl_info */
subrecord
->
xl_info
=
XLR_TO_BE_CONTINUED
;
memcpy
(
Insert
->
currpos
,
hdr
,
freespace
);
hdrlen
-=
freespace
;
...
...
@@ -383,6 +385,7 @@ nbuf:
if
(
buflen
>
freespace
)
{
subrecord
->
xl_len
+=
freespace
;
/* we don't store info in subrecord' xl_info */
subrecord
->
xl_info
=
XLR_TO_BE_CONTINUED
;
memcpy
(
Insert
->
currpos
,
buf
,
freespace
);
buflen
-=
freespace
;
...
...
@@ -395,15 +398,22 @@ nbuf:
memcpy
(
Insert
->
currpos
,
buf
,
buflen
);
Insert
->
currpos
+=
buflen
;
}
/* we don't store info in subrecord' xl_info */
subrecord
->
xl_info
=
0
;
RecPtr
.
xlogid
=
XLogCtl
->
xlblocks
[
curridx
].
xlogid
;
RecPtr
.
xrecoff
=
XLogCtl
->
xlblocks
[
curridx
].
xrecoff
-
BLCKSZ
+
SizeOfXLogPHD
+
subrecord
->
xl_len
;
Insert
->
currpos
=
((
char
*
)
Insert
->
currpage
)
+
DOUBLEALIGN
(
Insert
->
currpos
-
((
char
*
)
Insert
->
currpage
));
}
freespace
=
((
char
*
)
Insert
->
currpage
)
+
BLCKSZ
-
Insert
->
currpos
;
/*
* Begin of the next record will be stored as LSN for
* changed data page...
*/
RecPtr
.
xlogid
=
XLogCtl
->
xlblocks
[
curridx
].
xlogid
;
RecPtr
.
xrecoff
=
XLogCtl
->
xlblocks
[
curridx
].
xrecoff
-
BLCKSZ
+
Insert
->
currpos
-
((
char
*
)
Insert
->
currpage
);
/*
* All done! Update global LgwrRqst if some block was filled up.
*/
...
...
@@ -884,7 +894,8 @@ got_record:;
XLogSubRecord
*
subrecord
;
uint32
len
=
record
->
xl_len
;
if
(
record
->
xl_len
+
RecPtr
->
xrecoff
%
BLCKSZ
+
SizeOfXLogRecord
!=
BLCKSZ
)
if
(
DOUBLEALIGN
(
record
->
xl_len
)
+
RecPtr
->
xrecoff
%
BLCKSZ
+
SizeOfXLogRecord
!=
BLCKSZ
)
{
elog
(
emode
,
"ReadRecord: invalid fragmented record len %u in (%u, %u)"
,
record
->
xl_len
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
);
...
...
@@ -945,7 +956,7 @@ got_record:;
buffer
+=
subrecord
->
xl_len
;
if
(
subrecord
->
xl_info
&
XLR_TO_BE_CONTINUED
)
{
if
(
subrecord
->
xl_len
+
if
(
DOUBLEALIGN
(
subrecord
->
xl_len
)
+
SizeOfXLogPHD
+
SizeOfXLogSubRecord
!=
BLCKSZ
)
{
elog
(
emode
,
"ReadRecord: invalid fragmented subrecord len %u in logfile %u seg %u off %u"
,
...
...
@@ -956,23 +967,26 @@ got_record:;
}
break
;
}
if
(
BLCKSZ
-
SizeOfXLogRecord
>=
subrecord
->
xl_len
+
SizeOfXLogPHD
+
SizeOfXLogSubRecord
)
if
(
BLCKSZ
-
SizeOfXLogRecord
>=
DOUBLEALIGN
(
subrecord
->
xl_len
)
+
SizeOfXLogPHD
+
SizeOfXLogSubRecord
)
{
nextRecord
=
(
XLogRecord
*
)
((
char
*
)
subrecord
+
subrecord
->
xl_len
+
SizeOfXLogSubRecord
);
nextRecord
=
(
XLogRecord
*
)
((
char
*
)
subrecord
+
DOUBLEALIGN
(
subrecord
->
xl_len
)
+
SizeOfXLogSubRecord
);
}
EndRecPtr
.
xlogid
=
readId
;
EndRecPtr
.
xrecoff
=
readSeg
*
XLogSegSize
+
readOff
*
BLCKSZ
+
SizeOfXLogPHD
+
SizeOfXLogSubRecord
+
subrecord
->
xl_len
;
SizeOfXLogPHD
+
SizeOfXLogSubRecord
+
DOUBLEALIGN
(
subrecord
->
xl_len
);
ReadRecPtr
=
*
RecPtr
;
return
(
record
);
}
if
(
BLCKSZ
-
SizeOfXLogRecord
>=
record
->
xl_len
+
RecPtr
->
xrecoff
%
BLCKSZ
+
SizeOfXLogRecord
)
nextRecord
=
(
XLogRecord
*
)
((
char
*
)
record
+
record
->
xl_len
+
SizeOfXLogRecord
);
if
(
BLCKSZ
-
SizeOfXLogRecord
>=
DOUBLEALIGN
(
record
->
xl_len
)
+
RecPtr
->
xrecoff
%
BLCKSZ
+
SizeOfXLogRecord
)
nextRecord
=
(
XLogRecord
*
)
((
char
*
)
record
+
DOUBLEALIGN
(
record
->
xl_len
)
+
SizeOfXLogRecord
);
EndRecPtr
.
xlogid
=
RecPtr
->
xlogid
;
EndRecPtr
.
xrecoff
=
RecPtr
->
xrecoff
+
record
->
xl_len
+
SizeOfXLogRecord
;
EndRecPtr
.
xrecoff
=
RecPtr
->
xrecoff
+
DOUBLEALIGN
(
record
->
xl_len
)
+
SizeOfXLogRecord
;
ReadRecPtr
=
*
RecPtr
;
return
(
record
);
...
...
src/include/access/htup.h
浏览文件 @
bf1c8f2b
...
...
@@ -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.
29 2000/04/12 17:16:26 momjian
Exp $
* $Id: htup.h,v 1.
30 2000/06/02 10:20:26 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -44,6 +44,8 @@ typedef struct HeapTupleHeaderData
uint8
t_hoff
;
/* sizeof tuple header */
/* ^ - 31 bytes - ^ */
bits8
t_bits
[
MinHeapTupleBitmapSize
/
8
];
/* bit map of domains */
...
...
@@ -52,6 +54,71 @@ typedef struct HeapTupleHeaderData
typedef
HeapTupleHeaderData
*
HeapTupleHeader
;
#ifdef XLOG
/* XLOG stuff */
/*
* XLOG allows to store some information in high 4 bits of log
* record xl_info field
*/
#define XLOG_HEAP_INSERT 0x00
#define XLOG_HEAP_DELETE 0x10
#define XLOG_HEAP_UPDATE 0x20
#define XLOG_HEAP_MOVE 0x30
/*
* All what we need to find changed tuple (14 bytes)
*/
typedef
struct
xl_heaptid
{
Oid
dbId
;
/* database */
Oid
relId
;
/* relation */
ItemPointerData
tid
;
/* changed tuple id */
}
xl_heaptid
;
/* This is what we need to know about delete - ALIGN(14) = 16 bytes */
typedef
struct
xl_heap_delete
{
xl_heaptid
dtid
;
/* deleted tuple id */
}
xl_heap_delete
;
/* This is what we need to know about insert - 22 + data */
typedef
struct
xl_heap_insert
{
xl_heaptid
itid
;
/* inserted tuple id */
/* something from tuple header */
int16
t_natts
;
Oid
t_oid
;
uint8
t_hoff
;
uint8
mask
;
/* low 8 bits of t_infomask */
/* TUPLE DATA FOLLOWS AT END OF 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
itid
;
/* new inserted tuple id */
/* something from header of new tuple version */
int16
t_natts
;
uint8
t_hoff
;
uint8
mask
;
/* low 8 bits of t_infomask */
/* NEW TUPLE DATA FOLLOWS AT END OF STRUCT */
}
xl_heap_update
;
/* This is what we need to know about tuple move - ALIGN(20) = 24 bytes */
typedef
struct
xl_heap_move
{
xl_heaptid
ftid
;
/* moved from */
ItemPointerData
ttid
;
/* moved to */
}
xl_heap_move
;
/* end of XLOG stuff */
#endif
/* XLOG */
#define MinTupleSize (MAXALIGN(sizeof (PageHeaderData)) + \
MAXALIGN(sizeof(HeapTupleHeaderData)) + \
MAXALIGN(sizeof(char)))
...
...
src/include/access/xlog.h
浏览文件 @
bf1c8f2b
...
...
@@ -47,7 +47,12 @@ typedef struct XLogSubRecord
#define SizeOfXLogSubRecord DOUBLEALIGN(sizeof(XLogSubRecord))
/*
* XLOG uses only low 4 bits of xl_info. High 4 bits may be used
* by rmgr...
*/
#define XLR_TO_BE_CONTINUED 0x01
#define XLR_INFO_MASK 0x0F
#define XLOG_PAGE_MAGIC 0x17345168
...
...
@@ -63,8 +68,9 @@ typedef XLogPageHeaderData *XLogPageHeader;
#define XLP_FIRST_IS_SUBRECORD 0x0001
extern
XLogRecPtr
XLogInsert
(
RmgrId
rmid
,
char
*
hdr
,
uint32
hdrlen
,
char
*
buf
,
uint32
buflen
);
extern
XLogRecPtr
XLogInsert
(
RmgrId
rmid
,
uint8
info
,
char
*
hdr
,
uint32
hdrlen
,
char
*
buf
,
uint32
buflen
);
extern
void
XLogFlush
(
XLogRecPtr
RecPtr
);
#endif
/* XLOG_H */
src/include/storage/bufpage.h
浏览文件 @
bf1c8f2b
...
...
@@ -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.2
8 2000/01/26 05:58:32 momjian
Exp $
* $Id: bufpage.h,v 1.2
9 2000/06/02 10:20:27 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -117,6 +117,10 @@ typedef OpaqueData *Opaque;
*/
typedef
struct
PageHeaderData
{
#ifdef XLOG
XLogRecPtr
pd_lsn
;
/* XLOG: next byte after last byte of xlog */
/* record for last change of this page */
#endif
LocationIndex
pd_lower
;
/* offset to start of free space */
LocationIndex
pd_upper
;
/* offset to end of free space */
LocationIndex
pd_special
;
/* offset to start of special space */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录