Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
2ec69545
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,发现更多精彩内容 >>
提交
2ec69545
编写于
9月 25, 2017
作者:
A
Ashwin Agrawal
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pgindent appendonly directory.
上级
4832071b
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
2211 addition
and
2151 deletion
+2211
-2151
src/backend/access/appendonly/aosegfiles.c
src/backend/access/appendonly/aosegfiles.c
+494
-491
src/backend/access/appendonly/appendonly_compaction.c
src/backend/access/appendonly/appendonly_compaction.c
+233
-222
src/backend/access/appendonly/appendonly_visimap.c
src/backend/access/appendonly/appendonly_visimap.c
+209
-202
src/backend/access/appendonly/appendonly_visimap_entry.c
src/backend/access/appendonly/appendonly_visimap_entry.c
+159
-151
src/backend/access/appendonly/appendonly_visimap_store.c
src/backend/access/appendonly/appendonly_visimap_store.c
+143
-144
src/backend/access/appendonly/appendonly_visimap_udf.c
src/backend/access/appendonly/appendonly_visimap_udf.c
+88
-92
src/backend/access/appendonly/appendonlyam.c
src/backend/access/appendonly/appendonlyam.c
+3
-3
src/backend/access/appendonly/appendonlyblockdirectory.c
src/backend/access/appendonly/appendonlyblockdirectory.c
+363
-354
src/backend/access/appendonly/appendonlytid.c
src/backend/access/appendonly/appendonlytid.c
+25
-24
src/backend/access/appendonly/appendonlywriter.c
src/backend/access/appendonly/appendonlywriter.c
+456
-431
src/backend/access/appendonly/test/aomd_test.c
src/backend/access/appendonly/test/aomd_test.c
+30
-30
src/backend/access/appendonly/test/appendonly_visimap_test.c
src/backend/access/appendonly/test/appendonly_visimap_test.c
+8
-7
未找到文件。
src/backend/access/appendonly/aosegfiles.c
浏览文件 @
2ec69545
此差异已折叠。
点击以展开。
src/backend/access/appendonly/appendonly_compaction.c
浏览文件 @
2ec69545
此差异已折叠。
点击以展开。
src/backend/access/appendonly/appendonly_visimap.c
浏览文件 @
2ec69545
此差异已折叠。
点击以展开。
src/backend/access/appendonly/appendonly_visimap_entry.c
浏览文件 @
2ec69545
...
@@ -21,13 +21,13 @@
...
@@ -21,13 +21,13 @@
/*
/*
* Frees the data allocated by the visimap entry.
* Frees the data allocated by the visimap entry.
*
*
* No other function should be called on the visibility map entry
* No other function should be called on the visibility map entry
* after this function has been called.
* after this function has been called.
*/
*/
void
void
AppendOnlyVisimapEntry_Finish
(
AppendOnlyVisimapEntry_Finish
(
AppendOnlyVisimapEntry
*
visiMapEntry
)
AppendOnlyVisimapEntry
*
visiMapEntry
)
{
{
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
...
@@ -45,14 +45,14 @@ AppendOnlyVisimapEntry_Finish(
...
@@ -45,14 +45,14 @@ AppendOnlyVisimapEntry_Finish(
;
;
* Assumes a zero-allocated visimap entry data structure.
* Assumes a zero-allocated visimap entry data structure.
*
*
* Until appendonly_visimap_copyout or appendonly_visimap_clear is called,
* Until appendonly_visimap_copyout or appendonly_visimap_clear is called,
* the data structure
* the data structure
* is not usable for visibility checks or updates.
* is not usable for visibility checks or updates.
*/
*/
void
void
AppendOnlyVisimapEntry_Init
(
AppendOnlyVisimapEntry_Init
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
MemoryContext
memoryContext
)
MemoryContext
memoryContext
)
{
{
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
...
@@ -68,12 +68,12 @@ AppendOnlyVisimapEntry_Init(
...
@@ -68,12 +68,12 @@ AppendOnlyVisimapEntry_Init(
/*
/*
* Resets the visibility map data structure.
* Resets the visibility map data structure.
*
*
* It puts the entry into the identical state as after a
* It puts the entry into the identical state as after a
* call to AppendOnlyVisimapEntry_Init.
* call to AppendOnlyVisimapEntry_Init.
*/
*/
void
void
AppendOnlyVisimapEntry_Reset
(
AppendOnlyVisimapEntry_Reset
(
AppendOnlyVisimapEntry
*
visiMapEntry
)
AppendOnlyVisimapEntry
*
visiMapEntry
)
{
{
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
...
@@ -89,12 +89,12 @@ AppendOnlyVisimapEntry_Reset(
...
@@ -89,12 +89,12 @@ AppendOnlyVisimapEntry_Reset(
* Initializes a previously unused entry that covers the given tuple id.
* Initializes a previously unused entry that covers the given tuple id.
* The tuple is not marked as updated as no state has been changed yet.
* The tuple is not marked as updated as no state has been changed yet.
*
*
* Note that the firstRowNum is not the rowNum of the tuple id.
* Note that the firstRowNum is not the rowNum of the tuple id.
*/
*/
void
void
AppendOnlyVisimapEntry_New
(
AppendOnlyVisimapEntry_New
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
AOTupleId
*
tupleId
)
AOTupleId
*
tupleId
)
{
{
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
tupleId
);
Assert
(
tupleId
);
...
@@ -105,22 +105,22 @@ AppendOnlyVisimapEntry_New(
...
@@ -105,22 +105,22 @@ AppendOnlyVisimapEntry_New(
visiMapEntry
->
segmentFileNum
=
AOTupleIdGet_segmentFileNum
(
tupleId
);
visiMapEntry
->
segmentFileNum
=
AOTupleIdGet_segmentFileNum
(
tupleId
);
visiMapEntry
->
firstRowNum
=
AppendOnlyVisimapEntry_GetFirstRowNum
(
visiMapEntry
,
visiMapEntry
->
firstRowNum
=
AppendOnlyVisimapEntry_GetFirstRowNum
(
visiMapEntry
,
tupleId
);
tupleId
);
ItemPointerSetInvalid
(
&
visiMapEntry
->
tupleTid
);
ItemPointerSetInvalid
(
&
visiMapEntry
->
tupleTid
);
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map entry: New entry "
"Append-only visi map entry: New entry "
"(segNum, firstRowNum) = (%u, "
INT64_FORMAT
")"
,
"(segNum, firstRowNum) = (%u, "
INT64_FORMAT
")"
,
visiMapEntry
->
segmentFileNum
,
visiMapEntry
->
segmentFileNum
,
visiMapEntry
->
firstRowNum
);
visiMapEntry
->
firstRowNum
);
}
}
static
Datum
static
Datum
AppendOnlyVisimap_GetAttrNotNull
(
HeapTuple
t
,
TupleDesc
td
,
int
attr
)
AppendOnlyVisimap_GetAttrNotNull
(
HeapTuple
t
,
TupleDesc
td
,
int
attr
)
{
{
Datum
d
;
Datum
d
;
bool
isNull
;
bool
isNull
;
d
=
fastgetattr
(
t
,
attr
,
td
,
&
isNull
);
d
=
fastgetattr
(
t
,
attr
,
td
,
&
isNull
);
if
(
isNull
)
if
(
isNull
)
...
@@ -132,17 +132,18 @@ AppendOnlyVisimap_GetAttrNotNull(HeapTuple t, TupleDesc td, int attr)
...
@@ -132,17 +132,18 @@ AppendOnlyVisimap_GetAttrNotNull(HeapTuple t, TupleDesc td, int attr)
void
void
AppendOnlyVisiMapEnty_ReadData
(
AppendOnlyVisiMapEnty_ReadData
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
size_t
dataSize
)
AppendOnlyVisimapEntry
*
visiMapEntry
,
size_t
dataSize
)
{
{
int
newWordCount
;
int
newWordCount
;
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
CurrentMemoryContext
==
visiMapEntry
->
memoryContext
);
Assert
(
CurrentMemoryContext
==
visiMapEntry
->
memoryContext
);
BitmapDecompressState
decompressState
;
BitmapDecompressState
decompressState
;
BitmapDecompress_Init
(
&
decompressState
,
BitmapDecompress_Init
(
&
decompressState
,
visiMapEntry
->
data
->
data
,
visiMapEntry
->
data
->
data
,
dataSize
);
dataSize
);
if
(
BitmapDecompress_HasError
(
&
decompressState
))
if
(
BitmapDecompress_HasError
(
&
decompressState
))
{
{
...
@@ -151,17 +152,17 @@ AppendOnlyVisiMapEnty_ReadData(
...
@@ -151,17 +152,17 @@ AppendOnlyVisiMapEnty_ReadData(
bms_free
(
visiMapEntry
->
bitmap
);
bms_free
(
visiMapEntry
->
bitmap
);
newWordCount
=
newWordCount
=
BitmapDecompress_GetBlockCount
(
&
decompressState
);
BitmapDecompress_GetBlockCount
(
&
decompressState
);
if
(
newWordCount
>
0
)
if
(
newWordCount
>
0
)
{
{
visiMapEntry
->
bitmap
=
palloc0
(
visiMapEntry
->
bitmap
=
palloc0
(
offsetof
(
Bitmapset
,
words
)
+
(
newWordCount
*
sizeof
(
bitmapword
)));
offsetof
(
Bitmapset
,
words
)
+
(
newWordCount
*
sizeof
(
bitmapword
)));
visiMapEntry
->
bitmap
->
nwords
=
newWordCount
;
visiMapEntry
->
bitmap
->
nwords
=
newWordCount
;
BitmapDecompress_Decompress
(
BitmapDecompress_Decompress
(
&
decompressState
,
&
decompressState
,
visiMapEntry
->
bitmap
->
words
,
visiMapEntry
->
bitmap
->
words
,
newWordCount
);
newWordCount
);
}
}
else
if
(
newWordCount
==
0
)
else
if
(
newWordCount
==
0
)
{
{
...
@@ -169,8 +170,8 @@ AppendOnlyVisiMapEnty_ReadData(
...
@@ -169,8 +170,8 @@ AppendOnlyVisiMapEnty_ReadData(
}
}
else
else
{
{
elog
(
ERROR
,
elog
(
ERROR
,
"illegal visimap block count: visimap block count %d"
,
newWordCount
);
"illegal visimap block count: visimap block count %d"
,
newWordCount
);
}
}
}
}
...
@@ -181,37 +182,37 @@ AppendOnlyVisiMapEnty_ReadData(
...
@@ -181,37 +182,37 @@ AppendOnlyVisiMapEnty_ReadData(
* Should only be called with values and nulls provides
* Should only be called with values and nulls provides
* by a successful read from the aovisimap table using
* by a successful read from the aovisimap table using
* an AppendOnlyVisimapIndex data structure.
* an AppendOnlyVisimapIndex data structure.
*/
*/
void
void
AppendOnlyVisimapEntry_Copyout
(
AppendOnlyVisimapEntry_Copyout
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
HeapTuple
tuple
,
HeapTuple
tuple
,
TupleDesc
tupleDesc
)
TupleDesc
tupleDesc
)
{
{
struct
varlena
*
value
;
struct
varlena
*
value
;
struct
varlena
*
detoast_value
;
struct
varlena
*
detoast_value
;
MemoryContext
oldContext
;
MemoryContext
oldContext
;
size_t
dataSize
;
size_t
dataSize
;
Datum
d
;
Datum
d
;
bool
isNull
;
bool
isNull
;
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
!
visiMapEntry
->
dirty
);
Assert
(
!
visiMapEntry
->
dirty
);
Assert
(
tuple
);
Assert
(
tuple
);
Assert
(
tupleDesc
);
Assert
(
tupleDesc
);
Assert
(
!
visiMapEntry
->
dirty
);
/* entry should not contain dirty data */
Assert
(
!
visiMapEntry
->
dirty
);
/* entry should not contain dirty data */
d
=
AppendOnlyVisimap_GetAttrNotNull
(
tuple
,
tupleDesc
,
Anum_pg_aovisimap_segno
);
d
=
AppendOnlyVisimap_GetAttrNotNull
(
tuple
,
tupleDesc
,
Anum_pg_aovisimap_segno
);
visiMapEntry
->
segmentFileNum
=
DatumGetInt64
(
d
);
visiMapEntry
->
segmentFileNum
=
DatumGetInt64
(
d
);
d
=
AppendOnlyVisimap_GetAttrNotNull
(
tuple
,
tupleDesc
,
Anum_pg_aovisimap_firstrownum
);
d
=
AppendOnlyVisimap_GetAttrNotNull
(
tuple
,
tupleDesc
,
Anum_pg_aovisimap_firstrownum
);
visiMapEntry
->
firstRowNum
=
DatumGetInt64
(
d
);
visiMapEntry
->
firstRowNum
=
DatumGetInt64
(
d
);
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map entry: copy out: "
"Append-only visi map entry: copy out: "
"segNo %u firstRowNum "
INT64_FORMAT
,
"segNo %u firstRowNum "
INT64_FORMAT
,
visiMapEntry
->
segmentFileNum
,
visiMapEntry
->
segmentFileNum
,
visiMapEntry
->
firstRowNum
);
visiMapEntry
->
firstRowNum
);
d
=
fastgetattr
(
tuple
,
Anum_pg_aovisimap_visimap
,
tupleDesc
,
&
isNull
);
d
=
fastgetattr
(
tuple
,
Anum_pg_aovisimap_visimap
,
tupleDesc
,
&
isNull
);
if
(
isNull
)
if
(
isNull
)
...
@@ -224,7 +225,7 @@ AppendOnlyVisimapEntry_Copyout(
...
@@ -224,7 +225,7 @@ AppendOnlyVisimapEntry_Copyout(
}
}
else
else
{
{
value
=
(
struct
varlena
*
)
DatumGetPointer
(
d
);
value
=
(
struct
varlena
*
)
DatumGetPointer
(
d
);
detoast_value
=
pg_detoast_datum
(
value
);
detoast_value
=
pg_detoast_datum
(
value
);
oldContext
=
MemoryContextSwitchTo
(
visiMapEntry
->
memoryContext
);
oldContext
=
MemoryContextSwitchTo
(
visiMapEntry
->
memoryContext
);
...
@@ -233,14 +234,15 @@ AppendOnlyVisimapEntry_Copyout(
...
@@ -233,14 +234,15 @@ AppendOnlyVisimapEntry_Copyout(
Assert
(
visiMapEntry
->
data
);
Assert
(
visiMapEntry
->
data
);
Assert
(
APPENDONLY_VISIMAP_DATA_BUFFER_SIZE
>=
VARSIZE
(
detoast_value
));
Assert
(
APPENDONLY_VISIMAP_DATA_BUFFER_SIZE
>=
VARSIZE
(
detoast_value
));
memcpy
(
visiMapEntry
->
data
,
detoast_value
,
VARSIZE
(
detoast_value
));
memcpy
(
visiMapEntry
->
data
,
detoast_value
,
VARSIZE
(
detoast_value
));
dataSize
=
VARSIZE
(
detoast_value
)
-
dataSize
=
VARSIZE
(
detoast_value
)
-
offsetof
(
AppendOnlyVisimapData
,
data
);
offsetof
(
AppendOnlyVisimapData
,
data
);
AppendOnlyVisiMapEnty_ReadData
(
visiMapEntry
,
dataSize
);
AppendOnlyVisiMapEnty_ReadData
(
visiMapEntry
,
dataSize
);
MemoryContextSwitchTo
(
oldContext
);
MemoryContextSwitchTo
(
oldContext
);
if
(
detoast_value
!=
value
)
{
if
(
detoast_value
!=
value
)
{
pfree
(
detoast_value
);
pfree
(
detoast_value
);
detoast_value
=
NULL
;
detoast_value
=
NULL
;
}
}
...
@@ -250,10 +252,10 @@ AppendOnlyVisimapEntry_Copyout(
...
@@ -250,10 +252,10 @@ AppendOnlyVisimapEntry_Copyout(
/*
/*
* Returns the hidden tuple count value from a visimap entry heap tuple.
* Returns the hidden tuple count value from a visimap entry heap tuple.
*
*
*/
*/
int64
int64
AppendOnlyVisimapEntry_GetHiddenTupleCount
(
AppendOnlyVisimapEntry_GetHiddenTupleCount
(
AppendOnlyVisimapEntry
*
visiMapEntry
)
AppendOnlyVisimapEntry
*
visiMapEntry
)
{
{
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
...
@@ -262,15 +264,16 @@ AppendOnlyVisimapEntry_GetHiddenTupleCount(
...
@@ -262,15 +264,16 @@ AppendOnlyVisimapEntry_GetHiddenTupleCount(
void
void
AppendOnlyVisimapEntry_WriteData
(
AppendOnlyVisimapEntry_WriteData
(
AppendOnlyVisimapEntry
*
visiMapEntry
)
AppendOnlyVisimapEntry
*
visiMapEntry
)
{
{
int
bitmapSize
,
compressedBitmapSize
;
int
bitmapSize
,
compressedBitmapSize
;
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
CurrentMemoryContext
==
visiMapEntry
->
memoryContext
);
Assert
(
CurrentMemoryContext
==
visiMapEntry
->
memoryContext
);
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
bitmapSize
=
(
visiMapEntry
->
bitmap
?
(
visiMapEntry
->
bitmap
->
nwords
*
sizeof
(
uint32
))
:
0
);
bitmapSize
=
(
visiMapEntry
->
bitmap
?
(
visiMapEntry
->
bitmap
->
nwords
*
sizeof
(
uint32
))
:
0
);
bitmapSize
+=
BITMAP_COMPRESSION_HEADER_SIZE
;
bitmapSize
+=
BITMAP_COMPRESSION_HEADER_SIZE
;
Assert
(
visiMapEntry
->
data
);
Assert
(
visiMapEntry
->
data
);
...
@@ -278,16 +281,17 @@ AppendOnlyVisimapEntry_WriteData(
...
@@ -278,16 +281,17 @@ AppendOnlyVisimapEntry_WriteData(
visiMapEntry
->
data
->
version
=
1
;
visiMapEntry
->
data
->
version
=
1
;
compressedBitmapSize
=
Bitmap_Compress
(
compressedBitmapSize
=
Bitmap_Compress
(
BITMAP_COMPRESSION_TYPE_DEFAULT
,
BITMAP_COMPRESSION_TYPE_DEFAULT
,
(
visiMapEntry
->
bitmap
?
visiMapEntry
->
bitmap
->
words
:
NULL
),
(
visiMapEntry
->
bitmap
?
visiMapEntry
->
bitmap
->
words
:
NULL
),
(
visiMapEntry
->
bitmap
?
visiMapEntry
->
bitmap
->
nwords
:
0
),
(
visiMapEntry
->
bitmap
?
visiMapEntry
->
bitmap
->
nwords
:
0
),
visiMapEntry
->
data
->
data
,
visiMapEntry
->
data
->
data
,
bitmapSize
);
bitmapSize
);
Assert
(
compressedBitmapSize
>=
BITMAP_COMPRESSION_HEADER_SIZE
);
Assert
(
compressedBitmapSize
>=
BITMAP_COMPRESSION_HEADER_SIZE
);
SET_VARSIZE
(
visiMapEntry
->
data
,
SET_VARSIZE
(
visiMapEntry
->
data
,
offsetof
(
AppendOnlyVisimapData
,
data
)
+
compressedBitmapSize
);
offsetof
(
AppendOnlyVisimapData
,
data
)
+
compressedBitmapSize
);
}
}
/**
/**
* Persist the entry information to heap tuple value/nulls.
* Persist the entry information to heap tuple value/nulls.
* Should only be called after a call to AppendOnlyVisimapEntry_copyout
* Should only be called after a call to AppendOnlyVisimapEntry_copyout
...
@@ -295,12 +299,12 @@ AppendOnlyVisimapEntry_WriteData(
...
@@ -295,12 +299,12 @@ AppendOnlyVisimapEntry_WriteData(
*
*
* May be called when visimap entry is not updated. However, that is usually
* May be called when visimap entry is not updated. However, that is usually
* wasteful.
* wasteful.
*/
*/
void
void
AppendOnlyVisimapEntry_Write
(
AppendOnlyVisimapEntry_Write
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
Datum
*
values
,
Datum
*
values
,
bool
*
nulls
)
bool
*
nulls
)
{
{
MemoryContext
oldContext
;
MemoryContext
oldContext
;
...
@@ -309,10 +313,10 @@ AppendOnlyVisimapEntry_Write(
...
@@ -309,10 +313,10 @@ AppendOnlyVisimapEntry_Write(
Assert
(
nulls
);
Assert
(
nulls
);
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map entry: write (segno, firstRowNum) = "
"Append-only visi map entry: write (segno, firstRowNum) = "
"(%d, "
INT64_FORMAT
")"
,
"(%d, "
INT64_FORMAT
")"
,
visiMapEntry
->
segmentFileNum
,
visiMapEntry
->
firstRowNum
);
visiMapEntry
->
segmentFileNum
,
visiMapEntry
->
firstRowNum
);
values
[
Anum_pg_aovisimap_segno
-
1
]
=
Int32GetDatum
(
visiMapEntry
->
segmentFileNum
);
values
[
Anum_pg_aovisimap_segno
-
1
]
=
Int32GetDatum
(
visiMapEntry
->
segmentFileNum
);
nulls
[
Anum_pg_aovisimap_segno
-
1
]
=
false
;
nulls
[
Anum_pg_aovisimap_segno
-
1
]
=
false
;
...
@@ -339,10 +343,10 @@ AppendOnlyVisimapEntry_Write(
...
@@ -339,10 +343,10 @@ AppendOnlyVisimapEntry_Write(
/*
/*
* Returns true iff all entries in the visimap entry are visible.
* Returns true iff all entries in the visimap entry are visible.
*/
*/
static
bool
static
bool
AppendOnlyVisimapEntry_AreAllVisible
(
AppendOnlyVisimapEntry_AreAllVisible
(
AppendOnlyVisimapEntry
*
visiMapEntry
)
AppendOnlyVisimapEntry
*
visiMapEntry
)
{
{
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
...
@@ -355,12 +359,12 @@ AppendOnlyVisimapEntry_AreAllVisible(
...
@@ -355,12 +359,12 @@ AppendOnlyVisimapEntry_AreAllVisible(
* visibility map entry).
* visibility map entry).
*
*
* Assumes that the current visibility map entry covers the row number.
* Assumes that the current visibility map entry covers the row number.
*/
*/
static
void
static
void
AppendOnlyVisimapEntry_GetRownumOffset
(
AppendOnlyVisimapEntry_GetRownumOffset
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
int64
rowNum
,
int64
rowNum
,
int64
*
rowNumOffset
)
int64
*
rowNumOffset
)
{
{
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
rowNum
>=
0
);
Assert
(
rowNum
>=
0
);
...
@@ -383,10 +387,10 @@ AppendOnlyVisimapEntry_GetRownumOffset(
...
@@ -383,10 +387,10 @@ AppendOnlyVisimapEntry_GetRownumOffset(
*/
*/
bool
bool
AppendOnlyVisimapEntry_CoversTuple
(
AppendOnlyVisimapEntry_CoversTuple
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
AOTupleId
*
tupleId
)
AOTupleId
*
tupleId
)
{
{
int
rowNum
;
int
rowNum
;
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
tupleId
);
Assert
(
tupleId
);
...
@@ -395,27 +399,27 @@ AppendOnlyVisimapEntry_CoversTuple(
...
@@ -395,27 +399,27 @@ AppendOnlyVisimapEntry_CoversTuple(
{
{
return
false
;
return
false
;
}
}
if
(
visiMapEntry
->
segmentFileNum
!=
if
(
visiMapEntry
->
segmentFileNum
!=
AOTupleIdGet_segmentFileNum
(
tupleId
))
AOTupleIdGet_segmentFileNum
(
tupleId
))
{
{
return
false
;
return
false
;
}
}
rowNum
=
AOTupleIdGet_rowNum
(
tupleId
);
rowNum
=
AOTupleIdGet_rowNum
(
tupleId
);
return
(
visiMapEntry
->
firstRowNum
<=
rowNum
)
return
(
visiMapEntry
->
firstRowNum
<=
rowNum
)
&&
((
visiMapEntry
->
firstRowNum
+
APPENDONLY_VISIMAP_MAX_RANGE
)
>
rowNum
);
&&
((
visiMapEntry
->
firstRowNum
+
APPENDONLY_VISIMAP_MAX_RANGE
)
>
rowNum
);
}
}
/*
/*
* Returns the matching first row number of a given
* Returns the matching first row number of a given
* AO tuple id.
* AO tuple id.
*/
*/
int64
int64
AppendOnlyVisimapEntry_GetFirstRowNum
(
AppendOnlyVisimapEntry_GetFirstRowNum
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
AOTupleId
*
tupleId
)
AOTupleId
*
tupleId
)
{
{
(
void
)
visiMapEntry
;
(
void
)
visiMapEntry
;
int
rowNum
;
int
rowNum
;
rowNum
=
AOTupleIdGet_rowNum
(
tupleId
);
rowNum
=
AOTupleIdGet_rowNum
(
tupleId
);
return
(
rowNum
/
APPENDONLY_VISIMAP_MAX_RANGE
)
*
APPENDONLY_VISIMAP_MAX_RANGE
;
return
(
rowNum
/
APPENDONLY_VISIMAP_MAX_RANGE
)
*
APPENDONLY_VISIMAP_MAX_RANGE
;
...
@@ -431,14 +435,15 @@ AppendOnlyVisimapEntry_GetFirstRowNum(
...
@@ -431,14 +435,15 @@ AppendOnlyVisimapEntry_GetFirstRowNum(
* The final visibility also depends on other information, e.g. if the
* The final visibility also depends on other information, e.g. if the
* original transaction has been aborted. Such information is
* original transaction has been aborted. Such information is
* not stored in the visimap.
* not stored in the visimap.
*/
*/
bool
bool
AppendOnlyVisimapEntry_IsVisible
(
AppendOnlyVisimapEntry_IsVisible
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
AOTupleId
*
tupleId
)
AOTupleId
*
tupleId
)
{
{
int64
rowNum
,
rowNumOffset
;
int64
rowNum
,
bool
visibilityBit
;
rowNumOffset
;
bool
visibilityBit
;
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
...
@@ -446,44 +451,44 @@ AppendOnlyVisimapEntry_IsVisible(
...
@@ -446,44 +451,44 @@ AppendOnlyVisimapEntry_IsVisible(
rowNum
=
AOTupleIdGet_rowNum
(
tupleId
);
rowNum
=
AOTupleIdGet_rowNum
(
tupleId
);
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map entry: Check row visibility: "
"Append-only visi map entry: Check row visibility: "
"firstRowNum "
INT64_FORMAT
", rowNum "
INT64_FORMAT
,
"firstRowNum "
INT64_FORMAT
", rowNum "
INT64_FORMAT
,
visiMapEntry
->
firstRowNum
,
rowNum
);
visiMapEntry
->
firstRowNum
,
rowNum
);
if
(
AppendOnlyVisimapEntry_AreAllVisible
(
visiMapEntry
))
if
(
AppendOnlyVisimapEntry_AreAllVisible
(
visiMapEntry
))
{
{
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map entry: All entries are visibile: "
"Append-only visi map entry: All entries are visibile: "
"(firstRowNum, rowNum) = ("
INT64_FORMAT
", "
INT64_FORMAT
")"
,
"(firstRowNum, rowNum) = ("
INT64_FORMAT
", "
INT64_FORMAT
")"
,
visiMapEntry
->
firstRowNum
,
rowNum
);
visiMapEntry
->
firstRowNum
,
rowNum
);
return
true
;
return
true
;
}
}
Assert
(
rowNum
>=
visiMapEntry
->
firstRowNum
);
Assert
(
rowNum
>=
visiMapEntry
->
firstRowNum
);
rowNumOffset
=
0
;
rowNumOffset
=
0
;
AppendOnlyVisimapEntry_GetRownumOffset
(
visiMapEntry
,
AppendOnlyVisimapEntry_GetRownumOffset
(
visiMapEntry
,
rowNum
,
&
rowNumOffset
);
rowNum
,
&
rowNumOffset
);
visibilityBit
=
!
bms_is_member
(
rowNumOffset
,
visibilityBit
=
!
bms_is_member
(
rowNumOffset
,
visiMapEntry
->
bitmap
);
visiMapEntry
->
bitmap
);
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map entry: (firstRowNum, rowNum, visible) = "
"Append-only visi map entry: (firstRowNum, rowNum, visible) = "
"("
INT64_FORMAT
", "
INT64_FORMAT
", %d)"
,
"("
INT64_FORMAT
", "
INT64_FORMAT
", %d)"
,
visiMapEntry
->
firstRowNum
,
rowNum
,
(
int
)
visibilityBit
);
visiMapEntry
->
firstRowNum
,
rowNum
,
(
int
)
visibilityBit
);
return
visibilityBit
;
return
visibilityBit
;
}
}
/*
/*
* The minimal size (in uint32's elements) the entry array needs to have to
* The minimal size (in uint32's elements) the entry array needs to have to
* cover the given offset
* cover the given offset
*/
*/
static
uint32
static
uint32
AppendOnlyVisimapEntry_GetMinimalSizeToCover
(
int64
offset
)
AppendOnlyVisimapEntry_GetMinimalSizeToCover
(
int64
offset
)
{
{
uint32
minSize
;
uint32
minSize
;
Assert
(
offset
>=
0
);
Assert
(
offset
>=
0
);
...
@@ -507,13 +512,14 @@ AppendOnlyVisimapEntry_GetMinimalSizeToCover(int64 offset)
...
@@ -507,13 +512,14 @@ AppendOnlyVisimapEntry_GetMinimalSizeToCover(int64 offset)
*
*
* This function is only modifying the bitmap. The caller needs to take
* This function is only modifying the bitmap. The caller needs to take
* care that change is persisted.
* care that change is persisted.
*/
*/
HTSU_Result
HTSU_Result
AppendOnlyVisimapEntry_HideTuple
(
AppendOnlyVisimapEntry_HideTuple
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
AOTupleId
*
tupleId
)
AOTupleId
*
tupleId
)
{
{
int64
rowNum
,
rowNumOffset
;
int64
rowNum
,
rowNumOffset
;
MemoryContext
oldContext
;
MemoryContext
oldContext
;
HTSU_Result
result
;
HTSU_Result
result
;
...
@@ -521,33 +527,35 @@ AppendOnlyVisimapEntry_HideTuple(
...
@@ -521,33 +527,35 @@ AppendOnlyVisimapEntry_HideTuple(
Assert
(
tupleId
);
Assert
(
tupleId
);
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
Assert
(
AppendOnlyVisimapEntry_CoversTuple
(
visiMapEntry
,
tupleId
));
Assert
(
AppendOnlyVisimapEntry_CoversTuple
(
visiMapEntry
,
tupleId
));
rowNum
=
AOTupleIdGet_rowNum
(
tupleId
);
rowNum
=
AOTupleIdGet_rowNum
(
tupleId
);
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map entry: Hide tuple: "
"Append-only visi map entry: Hide tuple: "
"firstRowNum "
INT64_FORMAT
", rowNum "
INT64_FORMAT
,
"firstRowNum "
INT64_FORMAT
", rowNum "
INT64_FORMAT
,
visiMapEntry
->
firstRowNum
,
rowNum
);
visiMapEntry
->
firstRowNum
,
rowNum
);
rowNumOffset
=
0
;
rowNumOffset
=
0
;
AppendOnlyVisimapEntry_GetRownumOffset
(
visiMapEntry
,
AppendOnlyVisimapEntry_GetRownumOffset
(
visiMapEntry
,
rowNum
,
rowNum
,
&
rowNumOffset
);
&
rowNumOffset
);
oldContext
=
MemoryContextSwitchTo
(
visiMapEntry
->
memoryContext
);
oldContext
=
MemoryContextSwitchTo
(
visiMapEntry
->
memoryContext
);
/* enlarge the bitmap by a power of two.
/*
* this avoids the O(n*n) resizing policy of the original bitmap set */
* enlarge the bitmap by a power of two. this avoids the O(n*n) resizing
* policy of the original bitmap set
*/
if
(
!
bms_covers_member
(
visiMapEntry
->
bitmap
,
rowNumOffset
))
if
(
!
bms_covers_member
(
visiMapEntry
->
bitmap
,
rowNumOffset
))
visiMapEntry
->
bitmap
=
visiMapEntry
->
bitmap
=
bms_resize
(
visiMapEntry
->
bitmap
,
bms_resize
(
visiMapEntry
->
bitmap
,
AppendOnlyVisimapEntry_GetMinimalSizeToCover
(
rowNumOffset
));
AppendOnlyVisimapEntry_GetMinimalSizeToCover
(
rowNumOffset
));
if
(
!
bms_is_member
(
rowNumOffset
,
visiMapEntry
->
bitmap
))
if
(
!
bms_is_member
(
rowNumOffset
,
visiMapEntry
->
bitmap
))
{
{
visiMapEntry
->
bitmap
=
bms_add_member
(
visiMapEntry
->
bitmap
,
rowNumOffset
);
visiMapEntry
->
bitmap
=
bms_add_member
(
visiMapEntry
->
bitmap
,
rowNumOffset
);
result
=
HeapTupleMayBeUpdated
;
result
=
HeapTupleMayBeUpdated
;
}
}
else
if
(
visiMapEntry
->
dirty
)
else
if
(
visiMapEntry
->
dirty
)
{
{
/* The bit was already set and it was this command */
/* The bit was already set and it was this command */
...
@@ -567,10 +575,10 @@ AppendOnlyVisimapEntry_HideTuple(
...
@@ -567,10 +575,10 @@ AppendOnlyVisimapEntry_HideTuple(
/**
/**
* Returns true iff the visi map entry needs to be persisted.
* Returns true iff the visi map entry needs to be persisted.
*/
*/
bool
bool
AppendOnlyVisimapEntry_HasChanged
(
AppendOnlyVisimapEntry_HasChanged
(
AppendOnlyVisimapEntry
*
visiMapEntry
)
AppendOnlyVisimapEntry
*
visiMapEntry
)
{
{
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
return
visiMapEntry
->
dirty
;
return
visiMapEntry
->
dirty
;
...
@@ -580,9 +588,9 @@ AppendOnlyVisimapEntry_HasChanged(
...
@@ -580,9 +588,9 @@ AppendOnlyVisimapEntry_HasChanged(
* Returns true iff the entry contains valid data.
* Returns true iff the entry contains valid data.
* That is either CopyOut or New has been called.
* That is either CopyOut or New has been called.
*/
*/
bool
bool
AppendOnlyVisimapEntry_IsValid
(
AppendOnlyVisimapEntry_IsValid
(
AppendOnlyVisimapEntry
*
visiMapEntry
)
AppendOnlyVisimapEntry
*
visiMapEntry
)
{
{
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
return
(
visiMapEntry
->
segmentFileNum
>=
0
&&
return
(
visiMapEntry
->
segmentFileNum
>=
0
&&
...
@@ -591,42 +599,43 @@ AppendOnlyVisimapEntry_IsValid(
...
@@ -591,42 +599,43 @@ AppendOnlyVisimapEntry_IsValid(
/*
/*
* Return the next invisible tuple id in the given visibility map.
* Return the next invisible tuple id in the given visibility map.
*/
*/
bool
bool
AppendOnlyVisimapEntry_GetNextInvisible
(
AppendOnlyVisimapEntry_GetNextInvisible
(
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
AOTupleId
*
tupleId
)
AOTupleId
*
tupleId
)
{
{
int64
currentBitmapOffset
,
rowNum
;
int64
currentBitmapOffset
,
int
offset
;
rowNum
;
int
offset
;
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
Assert
(
AppendOnlyVisimapEntry_IsValid
(
visiMapEntry
));
Assert
(
tupleId
);
Assert
(
tupleId
);
currentBitmapOffset
=
-
1
;
/* before the first */
currentBitmapOffset
=
-
1
;
/* before the first */
if
(
AppendOnlyVisimapEntry_CoversTuple
(
if
(
AppendOnlyVisimapEntry_CoversTuple
(
visiMapEntry
,
tupleId
))
visiMapEntry
,
tupleId
))
{
{
AppendOnlyVisimapEntry_GetRownumOffset
(
AppendOnlyVisimapEntry_GetRownumOffset
(
visiMapEntry
,
visiMapEntry
,
AOTupleIdGet_rowNum
(
tupleId
),
AOTupleIdGet_rowNum
(
tupleId
),
&
currentBitmapOffset
);
&
currentBitmapOffset
);
}
}
currentBitmapOffset
++
;
currentBitmapOffset
++
;
offset
=
bms_first_from
(
visiMapEntry
->
bitmap
,
offset
=
bms_first_from
(
visiMapEntry
->
bitmap
,
currentBitmapOffset
);
currentBitmapOffset
);
if
(
offset
>=
0
)
if
(
offset
>=
0
)
{
{
rowNum
=
visiMapEntry
->
firstRowNum
+
offset
;
rowNum
=
visiMapEntry
->
firstRowNum
+
offset
;
AOTupleIdInit_Init
(
tupleId
);
AOTupleIdInit_Init
(
tupleId
);
AOTupleIdInit_segmentFileNum
(
AOTupleIdInit_segmentFileNum
(
tupleId
,
tupleId
,
visiMapEntry
->
segmentFileNum
);
visiMapEntry
->
segmentFileNum
);
AOTupleIdInit_rowNum
(
AOTupleIdInit_rowNum
(
tupleId
,
tupleId
,
rowNum
);
rowNum
);
return
true
;
return
true
;
}
}
else
else
...
@@ -634,4 +643,3 @@ AppendOnlyVisimapEntry_GetNextInvisible(
...
@@ -634,4 +643,3 @@ AppendOnlyVisimapEntry_GetNextInvisible(
return
false
;
return
false
;
}
}
}
}
src/backend/access/appendonly/appendonly_visimap_store.c
浏览文件 @
2ec69545
...
@@ -26,14 +26,14 @@
...
@@ -26,14 +26,14 @@
/*
/*
* Frees the data allocated by the visimap store
* Frees the data allocated by the visimap store
*
*
* No function using the visibility map store should be called
* No function using the visibility map store should be called
* after this function call.
* after this function call.
*/
*/
void
void
AppendOnlyVisimapStore_Finish
(
AppendOnlyVisimapStore_Finish
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
LOCKMODE
lockmode
)
LOCKMODE
lockmode
)
{
{
if
(
visiMapStore
->
scanKeys
)
if
(
visiMapStore
->
scanKeys
)
{
{
...
@@ -46,23 +46,23 @@ AppendOnlyVisimapStore_Finish(
...
@@ -46,23 +46,23 @@ AppendOnlyVisimapStore_Finish(
}
}
/*
/*
* Inits the visimap store.
* Inits the visimap store.
* The store is ready for usage after this function call.
* The store is ready for usage after this function call.
*
*
* Assumes a zero-allocated visimap store data structure.
* Assumes a zero-allocated visimap store data structure.
* Assumes that the visimap memory context is active.
* Assumes that the visimap memory context is active.
*/
*/
void
void
AppendOnlyVisimapStore_Init
(
AppendOnlyVisimapStore_Init
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
Oid
visimapRelid
,
Oid
visimapRelid
,
Oid
visimapIdxid
,
Oid
visimapIdxid
,
LOCKMODE
lockmode
,
LOCKMODE
lockmode
,
Snapshot
snapshot
,
Snapshot
snapshot
,
MemoryContext
memoryContext
)
MemoryContext
memoryContext
)
{
{
TupleDesc
heapTupleDesc
;
TupleDesc
heapTupleDesc
;
ScanKey
scanKey
;
ScanKey
scanKey
;
Assert
(
visiMapStore
);
Assert
(
visiMapStore
);
Assert
(
CurrentMemoryContext
==
memoryContext
);
Assert
(
CurrentMemoryContext
==
memoryContext
);
...
@@ -73,9 +73,9 @@ AppendOnlyVisimapStore_Init(
...
@@ -73,9 +73,9 @@ AppendOnlyVisimapStore_Init(
visiMapStore
->
memoryContext
=
memoryContext
;
visiMapStore
->
memoryContext
=
memoryContext
;
visiMapStore
->
visimapRelation
=
heap_open
(
visiMapStore
->
visimapRelation
=
heap_open
(
visimapRelid
,
lockmode
);
visimapRelid
,
lockmode
);
visiMapStore
->
visimapIndex
=
index_open
(
visiMapStore
->
visimapIndex
=
index_open
(
visimapIdxid
,
lockmode
);
visimapIdxid
,
lockmode
);
heapTupleDesc
=
heapTupleDesc
=
RelationGetDescr
(
visiMapStore
->
visimapRelation
);
RelationGetDescr
(
visiMapStore
->
visimapRelation
);
...
@@ -83,21 +83,21 @@ AppendOnlyVisimapStore_Init(
...
@@ -83,21 +83,21 @@ AppendOnlyVisimapStore_Init(
visiMapStore
->
scanKeys
=
palloc0
(
sizeof
(
ScanKeyData
)
*
APPENDONLY_VISIMAP_INDEX_SCAN_KEY_NUM
);
visiMapStore
->
scanKeys
=
palloc0
(
sizeof
(
ScanKeyData
)
*
APPENDONLY_VISIMAP_INDEX_SCAN_KEY_NUM
);
/
/ scan key: segno
/
* scan key: segno */
scanKey
=
visiMapStore
->
scanKeys
;
scanKey
=
visiMapStore
->
scanKeys
;
ScanKeyInit
(
scanKey
,
ScanKeyInit
(
scanKey
,
Anum_pg_aovisimap_segno
,
/* segno */
Anum_pg_aovisimap_segno
,
/* segno */
BTEqualStrategyNumber
,
BTEqualStrategyNumber
,
F_INT4EQ
,
F_INT4EQ
,
0
);
0
);
/
/ scan key: firstRowNum
/
* scan key: firstRowNum */
scanKey
++
;
scanKey
++
;
ScanKeyInit
(
scanKey
,
ScanKeyInit
(
scanKey
,
Anum_pg_aovisimap_firstrownum
,
/* attribute number to scan */
Anum_pg_aovisimap_firstrownum
,
/* attribute number to scan */
BTEqualStrategyNumber
,
/* strategy */
BTEqualStrategyNumber
,
/* strategy */
F_INT8EQ
,
/* reg proc to use */
F_INT8EQ
,
/* reg proc to use */
0
);
0
);
}
}
/*
/*
...
@@ -110,42 +110,42 @@ AppendOnlyVisimapStore_Init(
...
@@ -110,42 +110,42 @@ AppendOnlyVisimapStore_Init(
* returned by AppendOnlyVisimapStore_find.
* returned by AppendOnlyVisimapStore_find.
*
*
* Should not be called twice in the same command.
* Should not be called twice in the same command.
*/
*/
void
void
AppendOnlyVisimapStore_Store
(
AppendOnlyVisimapStore_Store
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapEntry
*
visiMapEntry
)
AppendOnlyVisimapEntry
*
visiMapEntry
)
{
{
MemoryContext
oldContext
;
MemoryContext
oldContext
;
Relation
visimapRelation
;
Relation
visimapRelation
;
TupleDesc
heapTupleDesc
;
TupleDesc
heapTupleDesc
;
HeapTuple
tuple
;
HeapTuple
tuple
;
Datum
values
[
Natts_pg_aovisimap
];
Datum
values
[
Natts_pg_aovisimap
];
bool
nulls
[
Natts_pg_aovisimap
];
bool
nulls
[
Natts_pg_aovisimap
];
Assert
(
visiMapStore
);
Assert
(
visiMapStore
);
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map store: Store visimap entry: "
"Append-only visi map store: Store visimap entry: "
"(segFileNum, firstRowNum) = (%u, "
INT64_FORMAT
")"
,
"(segFileNum, firstRowNum) = (%u, "
INT64_FORMAT
")"
,
visiMapEntry
->
segmentFileNum
,
visiMapEntry
->
firstRowNum
);
visiMapEntry
->
segmentFileNum
,
visiMapEntry
->
firstRowNum
);
oldContext
=
MemoryContextSwitchTo
(
visiMapStore
->
memoryContext
);
oldContext
=
MemoryContextSwitchTo
(
visiMapStore
->
memoryContext
);
AppendOnlyVisimapEntry_Write
(
visiMapEntry
,
values
,
AppendOnlyVisimapEntry_Write
(
visiMapEntry
,
values
,
nulls
);
nulls
);
visimapRelation
=
visiMapStore
->
visimapRelation
;
visimapRelation
=
visiMapStore
->
visimapRelation
;
heapTupleDesc
=
RelationGetDescr
(
visimapRelation
);
heapTupleDesc
=
RelationGetDescr
(
visimapRelation
);
tuple
=
heap_form_tuple
(
heapTupleDesc
,
tuple
=
heap_form_tuple
(
heapTupleDesc
,
values
,
values
,
nulls
);
nulls
);
/*
/*
* Write out the visimap entry to the relation.
* Write out the visimap entry to the relation.
If this visimap entry
*
If this visimap entry already in the relation, we update
*
already in the relation, we update the row. Otherwise, a new row is
*
the row. Otherwise, a new row is
inserted.
* inserted.
*/
*/
if
(
ItemPointerIsValid
(
&
visiMapEntry
->
tupleTid
))
if
(
ItemPointerIsValid
(
&
visiMapEntry
->
tupleTid
))
{
{
...
@@ -157,13 +157,13 @@ AppendOnlyVisimapStore_Store(
...
@@ -157,13 +157,13 @@ AppendOnlyVisimapStore_Store(
}
}
CatalogUpdateIndexes
(
visimapRelation
,
tuple
);
CatalogUpdateIndexes
(
visimapRelation
,
tuple
);
heap_freetuple
(
tuple
);
heap_freetuple
(
tuple
);
MemoryContextSwitchTo
(
oldContext
);
MemoryContextSwitchTo
(
oldContext
);
/
/ Invalidate the data after storing it.
/
* Invalidate the data after storing it. */
ItemPointerSetInvalid
(
&
visiMapEntry
->
tupleTid
);
ItemPointerSetInvalid
(
&
visiMapEntry
->
tupleTid
);
}
}
/**
/**
...
@@ -171,7 +171,7 @@ AppendOnlyVisimapStore_Store(
...
@@ -171,7 +171,7 @@ AppendOnlyVisimapStore_Store(
* segmentFileNum and firstRowNum.
* segmentFileNum and firstRowNum.
*
*
* Note: The firstRowNum needs to be a valid firstRowNum. It is
* Note: The firstRowNum needs to be a valid firstRowNum. It is
* especially not the tuple id of the append-only tuple checked, updated,
* especially not the tuple id of the append-only tuple checked, updated,
* or deleted.
* or deleted.
*
*
* Returns true if there is such a tuple and
* Returns true if there is such a tuple and
...
@@ -182,46 +182,46 @@ AppendOnlyVisimapStore_Store(
...
@@ -182,46 +182,46 @@ AppendOnlyVisimapStore_Store(
*/
*/
bool
bool
AppendOnlyVisimapStore_Find
(
AppendOnlyVisimapStore_Find
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
int32
segmentFileNum
,
int32
segmentFileNum
,
int64
firstRowNum
,
int64
firstRowNum
,
AppendOnlyVisimapEntry
*
visiMapEntry
)
AppendOnlyVisimapEntry
*
visiMapEntry
)
{
{
ScanKey
scanKeys
;
ScanKey
scanKeys
;
IndexScanDesc
indexScan
;
IndexScanDesc
indexScan
;
Assert
(
visiMapStore
);
Assert
(
visiMapStore
);
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapIndex
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapIndex
));
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map store: Load entry: "
"Append-only visi map store: Load entry: "
"(segFileNum, firstRowNum) = (%u, "
INT64_FORMAT
")"
,
"(segFileNum, firstRowNum) = (%u, "
INT64_FORMAT
")"
,
segmentFileNum
,
firstRowNum
);
segmentFileNum
,
firstRowNum
);
scanKeys
=
visiMapStore
->
scanKeys
;
scanKeys
=
visiMapStore
->
scanKeys
;
scanKeys
[
0
].
sk_argument
=
Int32GetDatum
(
segmentFileNum
);
scanKeys
[
0
].
sk_argument
=
Int32GetDatum
(
segmentFileNum
);
scanKeys
[
1
].
sk_argument
=
Int64GetDatum
(
firstRowNum
);
scanKeys
[
1
].
sk_argument
=
Int64GetDatum
(
firstRowNum
);
indexScan
=
AppendOnlyVisimapStore_BeginScan
(
indexScan
=
AppendOnlyVisimapStore_BeginScan
(
visiMapStore
,
visiMapStore
,
APPENDONLY_VISIMAP_INDEX_SCAN_KEY_NUM
,
APPENDONLY_VISIMAP_INDEX_SCAN_KEY_NUM
,
scanKeys
);
scanKeys
);
if
(
!
AppendOnlyVisimapStore_GetNext
(
if
(
!
AppendOnlyVisimapStore_GetNext
(
visiMapStore
,
visiMapStore
,
indexScan
,
indexScan
,
BackwardScanDirection
,
BackwardScanDirection
,
visiMapEntry
,
visiMapEntry
,
&
visiMapEntry
->
tupleTid
))
&
visiMapEntry
->
tupleTid
))
{
{
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map store: Visimap entry does not exist: "
"Append-only visi map store: Visimap entry does not exist: "
"(segFileNum, firstRowNum) = (%u, "
INT64_FORMAT
")"
,
"(segFileNum, firstRowNum) = (%u, "
INT64_FORMAT
")"
,
segmentFileNum
,
firstRowNum
);
segmentFileNum
,
firstRowNum
);
/
/ failed to lookup row
/
* failed to lookup row */
AppendOnlyVisimapStore_EndScan
(
visiMapStore
,
indexScan
);
AppendOnlyVisimapStore_EndScan
(
visiMapStore
,
indexScan
);
return
false
;
return
false
;
}
}
...
@@ -238,9 +238,9 @@ AppendOnlyVisimapStore_Find(
...
@@ -238,9 +238,9 @@ AppendOnlyVisimapStore_Find(
*/
*/
static
HeapTuple
static
HeapTuple
AppendOnlyVisimapStore_GetNextTuple
(
AppendOnlyVisimapStore_GetNextTuple
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
IndexScanDesc
indexScan
,
IndexScanDesc
indexScan
,
ScanDirection
scanDirection
)
ScanDirection
scanDirection
)
{
{
Assert
(
visiMapStore
);
Assert
(
visiMapStore
);
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
...
@@ -263,14 +263,14 @@ AppendOnlyVisimapStore_GetNextTuple(
...
@@ -263,14 +263,14 @@ AppendOnlyVisimapStore_GetNextTuple(
*/
*/
bool
bool
AppendOnlyVisimapStore_GetNext
(
AppendOnlyVisimapStore_GetNext
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
IndexScanDesc
indexScan
,
IndexScanDesc
indexScan
,
ScanDirection
scanDirection
,
ScanDirection
scanDirection
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
ItemPointerData
*
tupleTid
)
ItemPointerData
*
tupleTid
)
{
{
HeapTuple
tuple
;
HeapTuple
tuple
;
TupleDesc
heapTupleDesc
;
TupleDesc
heapTupleDesc
;
Assert
(
visiMapStore
);
Assert
(
visiMapStore
);
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
...
@@ -286,7 +286,7 @@ AppendOnlyVisimapStore_GetNext(
...
@@ -286,7 +286,7 @@ AppendOnlyVisimapStore_GetNext(
if
(
visiMapEntry
)
if
(
visiMapEntry
)
{
{
AppendOnlyVisimapEntry_Copyout
(
visiMapEntry
,
tuple
,
AppendOnlyVisimapEntry_Copyout
(
visiMapEntry
,
tuple
,
heapTupleDesc
);
heapTupleDesc
);
}
}
if
(
tupleTid
)
if
(
tupleTid
)
{
{
...
@@ -298,11 +298,11 @@ AppendOnlyVisimapStore_GetNext(
...
@@ -298,11 +298,11 @@ AppendOnlyVisimapStore_GetNext(
/*
/*
* Deletes all visibility map information from a given
* Deletes all visibility map information from a given
* segment file.
* segment file.
*/
*/
void
void
AppendOnlyVisimapStore_DeleteSegmentFile
(
AppendOnlyVisimapStore_DeleteSegmentFile
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
int
segmentFileNum
)
int
segmentFileNum
)
{
{
ScanKeyData
scanKey
;
ScanKeyData
scanKey
;
IndexScanDesc
indexScan
;
IndexScanDesc
indexScan
;
...
@@ -311,66 +311,66 @@ AppendOnlyVisimapStore_DeleteSegmentFile(
...
@@ -311,66 +311,66 @@ AppendOnlyVisimapStore_DeleteSegmentFile(
Assert
(
visiMapStore
);
Assert
(
visiMapStore
);
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapIndex
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapIndex
));
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
elogif
(
Debug_appendonly_print_visimap
,
LOG
,
"Append-only visi map store: Delete segment file: "
"Append-only visi map store: Delete segment file: "
"(segFileNum) = (%u)"
,
segmentFileNum
);
"(segFileNum) = (%u)"
,
segmentFileNum
);
ScanKeyInit
(
&
scanKey
,
ScanKeyInit
(
&
scanKey
,
Anum_pg_aovisimap_segno
,
/* segno */
Anum_pg_aovisimap_segno
,
/* segno */
BTEqualStrategyNumber
,
BTEqualStrategyNumber
,
F_INT4EQ
,
F_INT4EQ
,
Int32GetDatum
(
segmentFileNum
));
Int32GetDatum
(
segmentFileNum
));
indexScan
=
AppendOnlyVisimapStore_BeginScan
(
indexScan
=
AppendOnlyVisimapStore_BeginScan
(
visiMapStore
,
visiMapStore
,
1
,
1
,
&
scanKey
);
&
scanKey
);
while
(
AppendOnlyVisimapStore_GetNext
(
visiMapStore
,
while
(
AppendOnlyVisimapStore_GetNext
(
visiMapStore
,
indexScan
,
indexScan
,
ForwardScanDirection
,
ForwardScanDirection
,
NULL
,
NULL
,
&
tid
))
&
tid
))
{
{
simple_heap_delete
(
visiMapStore
->
visimapRelation
,
simple_heap_delete
(
visiMapStore
->
visimapRelation
,
&
tid
);
&
tid
);
}
}
AppendOnlyVisimapStore_EndScan
(
visiMapStore
,
indexScan
);
AppendOnlyVisimapStore_EndScan
(
visiMapStore
,
indexScan
);
}
}
/*
/*
* Returns the number of hidden tuples in a given segment file
* Returns the number of hidden tuples in a given segment file
*/
*/
int64
int64
AppendOnlyVisimapStore_GetSegmentFileHiddenTupleCount
(
AppendOnlyVisimapStore_GetSegmentFileHiddenTupleCount
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
AppendOnlyVisimapEntry
*
visiMapEntry
,
int
segmentFileNum
)
int
segmentFileNum
)
{
{
ScanKeyData
scanKey
;
ScanKeyData
scanKey
;
IndexScanDesc
indexScan
;
IndexScanDesc
indexScan
;
int64
hiddenTupcount
=
0
;
int64
hiddenTupcount
=
0
;
Assert
(
visiMapStore
);
Assert
(
visiMapStore
);
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapIndex
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapIndex
));
ScanKeyInit
(
&
scanKey
,
ScanKeyInit
(
&
scanKey
,
Anum_pg_aovisimap_segno
,
/* segno */
Anum_pg_aovisimap_segno
,
/* segno */
BTEqualStrategyNumber
,
BTEqualStrategyNumber
,
F_INT4EQ
,
F_INT4EQ
,
Int32GetDatum
(
segmentFileNum
));
Int32GetDatum
(
segmentFileNum
));
indexScan
=
AppendOnlyVisimapStore_BeginScan
(
indexScan
=
AppendOnlyVisimapStore_BeginScan
(
visiMapStore
,
visiMapStore
,
1
,
1
,
&
scanKey
);
&
scanKey
);
while
(
AppendOnlyVisimapStore_GetNext
(
visiMapStore
,
while
(
AppendOnlyVisimapStore_GetNext
(
visiMapStore
,
indexScan
,
ForwardScanDirection
,
indexScan
,
ForwardScanDirection
,
visiMapEntry
,
NULL
))
visiMapEntry
,
NULL
))
{
{
hiddenTupcount
+=
AppendOnlyVisimapEntry_GetHiddenTupleCount
(
visiMapEntry
);
hiddenTupcount
+=
AppendOnlyVisimapEntry_GetHiddenTupleCount
(
visiMapEntry
);
}
}
...
@@ -380,28 +380,28 @@ AppendOnlyVisimapStore_GetSegmentFileHiddenTupleCount(
...
@@ -380,28 +380,28 @@ AppendOnlyVisimapStore_GetSegmentFileHiddenTupleCount(
/*
/*
* Returns the number of hidden tuples in a given releation
* Returns the number of hidden tuples in a given releation
*/
*/
int64
int64
AppendOnlyVisimapStore_GetRelationHiddenTupleCount
(
AppendOnlyVisimapStore_GetRelationHiddenTupleCount
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapEntry
*
visiMapEntry
)
AppendOnlyVisimapEntry
*
visiMapEntry
)
{
{
IndexScanDesc
indexScan
;
IndexScanDesc
indexScan
;
int64
hiddenTupcount
=
0
;
int64
hiddenTupcount
=
0
;
Assert
(
visiMapStore
);
Assert
(
visiMapStore
);
Assert
(
visiMapEntry
);
Assert
(
visiMapEntry
);
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapIndex
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapIndex
));
indexScan
=
AppendOnlyVisimapStore_BeginScan
(
indexScan
=
AppendOnlyVisimapStore_BeginScan
(
visiMapStore
,
visiMapStore
,
0
,
0
,
NULL
);
NULL
);
while
(
AppendOnlyVisimapStore_GetNext
(
visiMapStore
,
while
(
AppendOnlyVisimapStore_GetNext
(
visiMapStore
,
indexScan
,
ForwardScanDirection
,
indexScan
,
ForwardScanDirection
,
visiMapEntry
,
NULL
))
visiMapEntry
,
NULL
))
{
{
hiddenTupcount
+=
AppendOnlyVisimapEntry_GetHiddenTupleCount
(
visiMapEntry
);
hiddenTupcount
+=
AppendOnlyVisimapEntry_GetHiddenTupleCount
(
visiMapEntry
);
}
}
...
@@ -413,35 +413,34 @@ AppendOnlyVisimapStore_GetRelationHiddenTupleCount(
...
@@ -413,35 +413,34 @@ AppendOnlyVisimapStore_GetRelationHiddenTupleCount(
* Starts a scan over the visimap store.
* Starts a scan over the visimap store.
*
*
* Parameter keys may be NULL iff nkeys is zero.
* Parameter keys may be NULL iff nkeys is zero.
*/
*/
IndexScanDesc
IndexScanDesc
AppendOnlyVisimapStore_BeginScan
(
AppendOnlyVisimapStore_BeginScan
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
int
nkeys
,
int
nkeys
,
ScanKey
keys
)
ScanKey
keys
)
{
{
Assert
(
visiMapStore
);
Assert
(
visiMapStore
);
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
Assert
(
RelationIsValid
(
visiMapStore
->
visimapRelation
));
return
index_beginscan
(
return
index_beginscan
(
visiMapStore
->
visimapRelation
,
visiMapStore
->
visimapRelation
,
visiMapStore
->
visimapIndex
,
visiMapStore
->
visimapIndex
,
visiMapStore
->
snapshot
,
visiMapStore
->
snapshot
,
nkeys
,
nkeys
,
keys
);
keys
);
}
}
/*
/*
* Ends a index scan over the visimap store.
* Ends a index scan over the visimap store.
*/
*/
void
void
AppendOnlyVisimapStore_EndScan
(
AppendOnlyVisimapStore_EndScan
(
AppendOnlyVisimapStore
*
visiMapStore
,
AppendOnlyVisimapStore
*
visiMapStore
,
IndexScanDesc
indexScan
)
IndexScanDesc
indexScan
)
{
{
Assert
(
visiMapStore
);
Assert
(
visiMapStore
);
Assert
(
indexScan
);
Assert
(
indexScan
);
index_endscan
(
indexScan
);
index_endscan
(
indexScan
);
}
}
src/backend/access/appendonly/appendonly_visimap_udf.c
浏览文件 @
2ec69545
...
@@ -24,41 +24,38 @@
...
@@ -24,41 +24,38 @@
#include "utils/builtins.h"
#include "utils/builtins.h"
extern
Datum
extern
Datum
gp_aovisimap
(
PG_FUNCTION_ARGS
);
gp_aovisimap
(
PG_FUNCTION_ARGS
);
extern
Datum
gp_aovisimap_name
(
PG_FUNCTION_ARGS
);
extern
Datum
gp_aovisimap_name
(
PG_FUNCTION_ARGS
);
static
Datum
static
Datum
gp_aovisimap_internal
(
PG_FUNCTION_ARGS
,
Oid
aoRelOid
)
gp_aovisimap_internal
(
PG_FUNCTION_ARGS
,
Oid
aoRelOid
)
{
{
Datum
values
[
3
];
Datum
values
[
3
];
bool
nulls
[
3
];
bool
nulls
[
3
];
HeapTuple
tuple
;
HeapTuple
tuple
;
Datum
result
;
Datum
result
;
typedef
struct
Context
typedef
struct
Context
{
{
Relation
aorel
;
Relation
aorel
;
AppendOnlyVisimapScan
visiMapScan
;
AppendOnlyVisimapScan
visiMapScan
;
AOTupleId
aoTupleId
;
AOTupleId
aoTupleId
;
}
Context
;
}
Context
;
FuncCallContext
*
funcctx
;
FuncCallContext
*
funcctx
;
Context
*
context
;
Context
*
context
;
if
(
SRF_IS_FIRSTCALL
())
if
(
SRF_IS_FIRSTCALL
())
{
{
TupleDesc
tupdesc
;
TupleDesc
tupdesc
;
MemoryContext
oldcontext
;
MemoryContext
oldcontext
;
/* create a function context for cross-call persistence */
/* create a function context for cross-call persistence */
funcctx
=
SRF_FIRSTCALL_INIT
();
funcctx
=
SRF_FIRSTCALL_INIT
();
/*
/*
* switch to memory context appropriate for multiple function
* switch to memory context appropriate for multiple function calls
* calls
*/
*/
oldcontext
=
MemoryContextSwitchTo
(
funcctx
->
multi_call_memory_ctx
);
oldcontext
=
MemoryContextSwitchTo
(
funcctx
->
multi_call_memory_ctx
);
...
@@ -88,10 +85,10 @@ gp_aovisimap_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -88,10 +85,10 @@ gp_aovisimap_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
}
}
AppendOnlyVisimapScan_Init
(
&
context
->
visiMapScan
,
AppendOnlyVisimapScan_Init
(
&
context
->
visiMapScan
,
context
->
aorel
->
rd_appendonly
->
visimaprelid
,
context
->
aorel
->
rd_appendonly
->
visimaprelid
,
context
->
aorel
->
rd_appendonly
->
visimapidxid
,
context
->
aorel
->
rd_appendonly
->
visimapidxid
,
AccessShareLock
,
AccessShareLock
,
SnapshotNow
);
SnapshotNow
);
AOTupleIdInit_Init
(
&
context
->
aoTupleId
);
AOTupleIdInit_Init
(
&
context
->
aoTupleId
);
funcctx
->
user_fctx
=
(
void
*
)
context
;
funcctx
->
user_fctx
=
(
void
*
)
context
;
...
@@ -105,14 +102,14 @@ gp_aovisimap_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -105,14 +102,14 @@ gp_aovisimap_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
while
(
true
)
while
(
true
)
{
{
if
(
!
AppendOnlyVisimapScan_GetNextInvisible
(
if
(
!
AppendOnlyVisimapScan_GetNextInvisible
(
&
context
->
visiMapScan
,
&
context
->
visiMapScan
,
&
context
->
aoTupleId
))
&
context
->
aoTupleId
))
{
{
break
;
break
;
}
}
MemSet
(
values
,
0
,
sizeof
(
values
));
MemSet
(
values
,
0
,
sizeof
(
values
));
MemSet
(
nulls
,
false
,
sizeof
(
nulls
));
MemSet
(
nulls
,
false
,
sizeof
(
nulls
));
values
[
0
]
=
ItemPointerGetDatum
((
ItemPointer
)
&
context
->
aoTupleId
);
values
[
0
]
=
ItemPointerGetDatum
((
ItemPointer
)
&
context
->
aoTupleId
);
values
[
1
]
=
Int32GetDatum
(
AOTupleIdGet_segmentFileNum
(
&
context
->
aoTupleId
));
values
[
1
]
=
Int32GetDatum
(
AOTupleIdGet_segmentFileNum
(
&
context
->
aoTupleId
));
values
[
2
]
=
Int64GetDatum
(
AOTupleIdGet_rowNum
(
&
context
->
aoTupleId
));
values
[
2
]
=
Int64GetDatum
(
AOTupleIdGet_rowNum
(
&
context
->
aoTupleId
));
...
@@ -121,7 +118,7 @@ gp_aovisimap_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -121,7 +118,7 @@ gp_aovisimap_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
SRF_RETURN_NEXT
(
funcctx
,
result
);
SRF_RETURN_NEXT
(
funcctx
,
result
);
}
}
AppendOnlyVisimapScan_Finish
(
&
context
->
visiMapScan
,
AccessShareLock
);
AppendOnlyVisimapScan_Finish
(
&
context
->
visiMapScan
,
AccessShareLock
);
heap_close
(
context
->
aorel
,
AccessShareLock
);
heap_close
(
context
->
aorel
,
AccessShareLock
);
pfree
(
context
);
pfree
(
context
);
...
@@ -132,8 +129,8 @@ gp_aovisimap_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -132,8 +129,8 @@ gp_aovisimap_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
Datum
Datum
gp_aovisimap
(
PG_FUNCTION_ARGS
)
gp_aovisimap
(
PG_FUNCTION_ARGS
)
{
{
Oid
relid
;
Oid
relid
;
relid
=
PG_GETARG_OID
(
0
);
relid
=
PG_GETARG_OID
(
0
);
return
gp_aovisimap_internal
(
fcinfo
,
relid
);
return
gp_aovisimap_internal
(
fcinfo
,
relid
);
}
}
...
@@ -141,9 +138,9 @@ gp_aovisimap(PG_FUNCTION_ARGS)
...
@@ -141,9 +138,9 @@ gp_aovisimap(PG_FUNCTION_ARGS)
Datum
Datum
gp_aovisimap_name
(
PG_FUNCTION_ARGS
)
gp_aovisimap_name
(
PG_FUNCTION_ARGS
)
{
{
RangeVar
*
parentrv
;
RangeVar
*
parentrv
;
text
*
relname
=
PG_GETARG_TEXT_P
(
0
);
text
*
relname
=
PG_GETARG_TEXT_P
(
0
);
Oid
relid
;
Oid
relid
;
parentrv
=
makeRangeVarFromNameList
(
textToQualifiedNameList
(
relname
));
parentrv
=
makeRangeVarFromNameList
(
textToQualifiedNameList
(
relname
));
relid
=
RangeVarGetRelid
(
parentrv
,
false
);
relid
=
RangeVarGetRelid
(
parentrv
,
false
);
...
@@ -151,35 +148,33 @@ gp_aovisimap_name(PG_FUNCTION_ARGS)
...
@@ -151,35 +148,33 @@ gp_aovisimap_name(PG_FUNCTION_ARGS)
return
gp_aovisimap_internal
(
fcinfo
,
relid
);
return
gp_aovisimap_internal
(
fcinfo
,
relid
);
}
}
extern
Datum
extern
Datum
gp_aovisimap_hidden_info
(
PG_FUNCTION_ARGS
);
gp_aovisimap_hidden_info
(
PG_FUNCTION_ARGS
);
extern
Datum
gp_aovisimap_hidden_info_name
(
PG_FUNCTION_ARGS
);
extern
Datum
gp_aovisimap_hidden_info_name
(
PG_FUNCTION_ARGS
);
static
Datum
static
Datum
gp_aovisimap_hidden_info_internal
(
PG_FUNCTION_ARGS
,
Oid
aoRelOid
)
gp_aovisimap_hidden_info_internal
(
PG_FUNCTION_ARGS
,
Oid
aoRelOid
)
{
{
Datum
values
[
3
];
Datum
values
[
3
];
bool
nulls
[
3
];
bool
nulls
[
3
];
HeapTuple
tuple
;
HeapTuple
tuple
;
Datum
result
;
Datum
result
;
typedef
struct
Context
typedef
struct
Context
{
{
AppendOnlyVisimap
visiMap
;
AppendOnlyVisimap
visiMap
;
Relation
parentRelation
;
Relation
parentRelation
;
FileSegInfo
**
appendonlySegfileInfo
;
FileSegInfo
**
appendonlySegfileInfo
;
AOCSFileSegInfo
**
aocsSegfileInfo
;
AOCSFileSegInfo
**
aocsSegfileInfo
;
int
segfile_info_total
;
int
segfile_info_total
;
int
i
;
int
i
;
}
Context
;
}
Context
;
FuncCallContext
*
funcctx
;
FuncCallContext
*
funcctx
;
Context
*
context
;
Context
*
context
;
if
(
SRF_IS_FIRSTCALL
())
if
(
SRF_IS_FIRSTCALL
())
{
{
...
@@ -190,8 +185,7 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -190,8 +185,7 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
funcctx
=
SRF_FIRSTCALL_INIT
();
funcctx
=
SRF_FIRSTCALL_INIT
();
/*
/*
* switch to memory context appropriate for multiple function
* switch to memory context appropriate for multiple function calls
* calls
*/
*/
oldcontext
=
MemoryContextSwitchTo
(
funcctx
->
multi_call_memory_ctx
);
oldcontext
=
MemoryContextSwitchTo
(
funcctx
->
multi_call_memory_ctx
);
...
@@ -223,23 +217,23 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -223,23 +217,23 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
if
(
RelationIsAoRows
(
context
->
parentRelation
))
if
(
RelationIsAoRows
(
context
->
parentRelation
))
{
{
context
->
appendonlySegfileInfo
=
GetAllFileSegInfo
(
context
->
appendonlySegfileInfo
=
GetAllFileSegInfo
(
context
->
parentRelation
,
context
->
parentRelation
,
SnapshotNow
,
SnapshotNow
,
&
context
->
segfile_info_total
);
&
context
->
segfile_info_total
);
}
}
else
else
{
{
Assert
(
RelationIsAoCols
(
context
->
parentRelation
));
Assert
(
RelationIsAoCols
(
context
->
parentRelation
));
context
->
aocsSegfileInfo
=
GetAllAOCSFileSegInfo
(
context
->
parentRelation
,
context
->
aocsSegfileInfo
=
GetAllAOCSFileSegInfo
(
context
->
parentRelation
,
SnapshotNow
,
&
context
->
segfile_info_total
);
SnapshotNow
,
&
context
->
segfile_info_total
);
}
}
context
->
i
=
0
;
context
->
i
=
0
;
AppendOnlyVisimap_Init
(
&
context
->
visiMap
,
AppendOnlyVisimap_Init
(
&
context
->
visiMap
,
context
->
parentRelation
->
rd_appendonly
->
visimaprelid
,
context
->
parentRelation
->
rd_appendonly
->
visimaprelid
,
context
->
parentRelation
->
rd_appendonly
->
visimapidxid
,
context
->
parentRelation
->
rd_appendonly
->
visimapidxid
,
AccessShareLock
,
AccessShareLock
,
SnapshotNow
);
SnapshotNow
);
funcctx
->
user_fctx
=
(
void
*
)
context
;
funcctx
->
user_fctx
=
(
void
*
)
context
;
...
@@ -251,17 +245,20 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -251,17 +245,20 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
while
(
context
->
i
<
context
->
segfile_info_total
)
while
(
context
->
i
<
context
->
segfile_info_total
)
{
{
int64
tupcount
;
int64
tupcount
;
int
segno
;
int
segno
;
if
(
context
->
appendonlySegfileInfo
)
if
(
context
->
appendonlySegfileInfo
)
{
{
FileSegInfo
*
fsinfo
=
context
->
appendonlySegfileInfo
[
context
->
i
];
FileSegInfo
*
fsinfo
=
context
->
appendonlySegfileInfo
[
context
->
i
];
tupcount
=
fsinfo
->
total_tupcount
;
tupcount
=
fsinfo
->
total_tupcount
;
segno
=
fsinfo
->
segno
;
segno
=
fsinfo
->
segno
;
}
}
else
if
(
context
->
aocsSegfileInfo
)
else
if
(
context
->
aocsSegfileInfo
)
{
{
AOCSFileSegInfo
*
fsinfo
=
context
->
aocsSegfileInfo
[
context
->
i
];
AOCSFileSegInfo
*
fsinfo
=
context
->
aocsSegfileInfo
[
context
->
i
];
tupcount
=
fsinfo
->
total_tupcount
;
tupcount
=
fsinfo
->
total_tupcount
;
segno
=
fsinfo
->
segno
;
segno
=
fsinfo
->
segno
;
}
}
...
@@ -274,7 +271,7 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -274,7 +271,7 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
MemSet
(
nulls
,
false
,
sizeof
(
nulls
));
MemSet
(
nulls
,
false
,
sizeof
(
nulls
));
values
[
0
]
=
Int32GetDatum
(
segno
);
values
[
0
]
=
Int32GetDatum
(
segno
);
values
[
1
]
=
Int64GetDatum
(
AppendOnlyVisimap_GetSegmentFileHiddenTupleCount
(
values
[
1
]
=
Int64GetDatum
(
AppendOnlyVisimap_GetSegmentFileHiddenTupleCount
(
&
context
->
visiMap
,
segno
));
&
context
->
visiMap
,
segno
));
values
[
2
]
=
Int64GetDatum
(
tupcount
);
values
[
2
]
=
Int64GetDatum
(
tupcount
);
tuple
=
heap_form_tuple
(
funcctx
->
tuple_desc
,
values
,
nulls
);
tuple
=
heap_form_tuple
(
funcctx
->
tuple_desc
,
values
,
nulls
);
...
@@ -283,7 +280,7 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -283,7 +280,7 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
context
->
i
++
;
context
->
i
++
;
SRF_RETURN_NEXT
(
funcctx
,
result
);
SRF_RETURN_NEXT
(
funcctx
,
result
);
}
}
AppendOnlyVisimap_Finish
(
&
context
->
visiMap
,
AccessShareLock
);
AppendOnlyVisimap_Finish
(
&
context
->
visiMap
,
AccessShareLock
);
if
(
context
->
appendonlySegfileInfo
)
if
(
context
->
appendonlySegfileInfo
)
{
{
...
@@ -308,16 +305,17 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -308,16 +305,17 @@ gp_aovisimap_hidden_info_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
Datum
Datum
gp_aovisimap_hidden_info
(
PG_FUNCTION_ARGS
)
gp_aovisimap_hidden_info
(
PG_FUNCTION_ARGS
)
{
{
Oid
aoRelOid
=
PG_GETARG_OID
(
0
);
Oid
aoRelOid
=
PG_GETARG_OID
(
0
);
return
gp_aovisimap_hidden_info_internal
(
fcinfo
,
aoRelOid
);
return
gp_aovisimap_hidden_info_internal
(
fcinfo
,
aoRelOid
);
}
}
Datum
Datum
gp_aovisimap_hidden_info_name
(
PG_FUNCTION_ARGS
)
gp_aovisimap_hidden_info_name
(
PG_FUNCTION_ARGS
)
{
{
RangeVar
*
parentrv
;
RangeVar
*
parentrv
;
text
*
relname
=
PG_GETARG_TEXT_P
(
0
);
text
*
relname
=
PG_GETARG_TEXT_P
(
0
);
Oid
relid
;
Oid
relid
;
parentrv
=
makeRangeVarFromNameList
(
textToQualifiedNameList
(
relname
));
parentrv
=
makeRangeVarFromNameList
(
textToQualifiedNameList
(
relname
));
relid
=
RangeVarGetRelid
(
parentrv
,
false
);
relid
=
RangeVarGetRelid
(
parentrv
,
false
);
...
@@ -325,16 +323,14 @@ gp_aovisimap_hidden_info_name(PG_FUNCTION_ARGS)
...
@@ -325,16 +323,14 @@ gp_aovisimap_hidden_info_name(PG_FUNCTION_ARGS)
return
gp_aovisimap_hidden_info_internal
(
fcinfo
,
relid
);
return
gp_aovisimap_hidden_info_internal
(
fcinfo
,
relid
);
}
}
extern
Datum
extern
Datum
gp_aovisimap_entry
(
PG_FUNCTION_ARGS
);
gp_aovisimap_entry
(
PG_FUNCTION_ARGS
);
extern
Datum
gp_aovisimap_entry_name
(
PG_FUNCTION_ARGS
);
extern
Datum
gp_aovisimap_entry_name
(
PG_FUNCTION_ARGS
);
static
void
static
void
gp_aovisimap_encode_bitmap
(
char
*
bitmapBuffer
,
Bitmapset
*
bms
)
gp_aovisimap_encode_bitmap
(
char
*
bitmapBuffer
,
Bitmapset
*
bms
)
{
{
int
i
;
int
i
;
int
last
=
-
1
;
int
last
=
-
1
;
Assert
(
bitmapBuffer
);
Assert
(
bitmapBuffer
);
...
@@ -357,34 +353,33 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -357,34 +353,33 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
{
{
Datum
values
[
4
];
Datum
values
[
4
];
bool
nulls
[
4
];
bool
nulls
[
4
];
HeapTuple
tuple
;
HeapTuple
tuple
;
Datum
result
;
Datum
result
;
typedef
struct
Context
typedef
struct
Context
{
{
AppendOnlyVisimap
visiMap
;
AppendOnlyVisimap
visiMap
;
Relation
parentRelation
;
Relation
parentRelation
;
IndexScanDesc
indexScan
;
IndexScanDesc
indexScan
;
text
*
bitmapBuffer
;
text
*
bitmapBuffer
;
}
Context
;
}
Context
;
FuncCallContext
*
funcctx
;
FuncCallContext
*
funcctx
;
Context
*
context
;
Context
*
context
;
if
(
SRF_IS_FIRSTCALL
())
if
(
SRF_IS_FIRSTCALL
())
{
{
TupleDesc
tupdesc
;
TupleDesc
tupdesc
;
MemoryContext
oldcontext
;
MemoryContext
oldcontext
;
/* create a function context for cross-call persistence */
/* create a function context for cross-call persistence */
funcctx
=
SRF_FIRSTCALL_INIT
();
funcctx
=
SRF_FIRSTCALL_INIT
();
/*
/*
* switch to memory context appropriate for multiple function
* switch to memory context appropriate for multiple function calls
* calls
*/
*/
oldcontext
=
MemoryContextSwitchTo
(
funcctx
->
multi_call_memory_ctx
);
oldcontext
=
MemoryContextSwitchTo
(
funcctx
->
multi_call_memory_ctx
);
...
@@ -416,13 +411,13 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -416,13 +411,13 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
}
}
AppendOnlyVisimap_Init
(
&
context
->
visiMap
,
AppendOnlyVisimap_Init
(
&
context
->
visiMap
,
context
->
parentRelation
->
rd_appendonly
->
visimaprelid
,
context
->
parentRelation
->
rd_appendonly
->
visimaprelid
,
context
->
parentRelation
->
rd_appendonly
->
visimapidxid
,
context
->
parentRelation
->
rd_appendonly
->
visimapidxid
,
AccessShareLock
,
AccessShareLock
,
SnapshotNow
);
SnapshotNow
);
context
->
indexScan
=
AppendOnlyVisimapStore_BeginScan
(
&
context
->
indexScan
=
AppendOnlyVisimapStore_BeginScan
(
&
context
->
visiMap
.
visimapStore
,
0
,
NULL
);
context
->
visiMap
.
visimapStore
,
0
,
NULL
);
context
->
bitmapBuffer
=
palloc0
(
VARHDRSZ
+
APPENDONLY_VISIMAP_MAX_RANGE
+
1
);
context
->
bitmapBuffer
=
palloc0
(
VARHDRSZ
+
APPENDONLY_VISIMAP_MAX_RANGE
+
1
);
...
@@ -435,10 +430,10 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -435,10 +430,10 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
context
=
(
Context
*
)
funcctx
->
user_fctx
;
context
=
(
Context
*
)
funcctx
->
user_fctx
;
if
(
AppendOnlyVisimapStore_GetNext
(
&
context
->
visiMap
.
visimapStore
,
if
(
AppendOnlyVisimapStore_GetNext
(
&
context
->
visiMap
.
visimapStore
,
context
->
indexScan
,
context
->
indexScan
,
ForwardScanDirection
,
ForwardScanDirection
,
&
context
->
visiMap
.
visimapEntry
,
&
context
->
visiMap
.
visimapEntry
,
NULL
))
NULL
))
{
{
AppendOnlyVisimapEntry
*
visimapEntry
=
&
context
->
visiMap
.
visimapEntry
;
AppendOnlyVisimapEntry
*
visimapEntry
=
&
context
->
visiMap
.
visimapEntry
;
...
@@ -447,10 +442,10 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -447,10 +442,10 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
values
[
0
]
=
Int32GetDatum
(
visimapEntry
->
segmentFileNum
);
values
[
0
]
=
Int32GetDatum
(
visimapEntry
->
segmentFileNum
);
values
[
1
]
=
Int64GetDatum
(
visimapEntry
->
firstRowNum
);
values
[
1
]
=
Int64GetDatum
(
visimapEntry
->
firstRowNum
);
values
[
2
]
=
Int32GetDatum
(
values
[
2
]
=
Int32GetDatum
(
(
int32
)
AppendOnlyVisimapEntry_GetHiddenTupleCount
(
visimapEntry
));
(
int32
)
AppendOnlyVisimapEntry_GetHiddenTupleCount
(
visimapEntry
));
gp_aovisimap_encode_bitmap
(
VARDATA
(
context
->
bitmapBuffer
),
gp_aovisimap_encode_bitmap
(
VARDATA
(
context
->
bitmapBuffer
),
visimapEntry
->
bitmap
);
visimapEntry
->
bitmap
);
SET_VARSIZE
(
context
->
bitmapBuffer
,
APPENDONLY_VISIMAP_MAX_RANGE
);
SET_VARSIZE
(
context
->
bitmapBuffer
,
APPENDONLY_VISIMAP_MAX_RANGE
);
values
[
3
]
=
PointerGetDatum
(
context
->
bitmapBuffer
);
values
[
3
]
=
PointerGetDatum
(
context
->
bitmapBuffer
);
...
@@ -459,9 +454,9 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -459,9 +454,9 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
SRF_RETURN_NEXT
(
funcctx
,
result
);
SRF_RETURN_NEXT
(
funcctx
,
result
);
}
}
AppendOnlyVisimapStore_EndScan
(
&
context
->
visiMap
.
visimapStore
,
AppendOnlyVisimapStore_EndScan
(
&
context
->
visiMap
.
visimapStore
,
context
->
indexScan
);
context
->
indexScan
);
AppendOnlyVisimap_Finish
(
&
context
->
visiMap
,
AccessShareLock
);
AppendOnlyVisimap_Finish
(
&
context
->
visiMap
,
AccessShareLock
);
heap_close
(
context
->
parentRelation
,
AccessShareLock
);
heap_close
(
context
->
parentRelation
,
AccessShareLock
);
...
@@ -475,16 +470,17 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
...
@@ -475,16 +470,17 @@ gp_aovisimap_entry_internal(PG_FUNCTION_ARGS, Oid aoRelOid)
Datum
Datum
gp_aovisimap_entry
(
PG_FUNCTION_ARGS
)
gp_aovisimap_entry
(
PG_FUNCTION_ARGS
)
{
{
Oid
aoRelOid
=
PG_GETARG_OID
(
0
);
Oid
aoRelOid
=
PG_GETARG_OID
(
0
);
return
gp_aovisimap_entry_internal
(
fcinfo
,
aoRelOid
);
return
gp_aovisimap_entry_internal
(
fcinfo
,
aoRelOid
);
}
}
Datum
Datum
gp_aovisimap_entry_name
(
PG_FUNCTION_ARGS
)
gp_aovisimap_entry_name
(
PG_FUNCTION_ARGS
)
{
{
RangeVar
*
parentrv
;
RangeVar
*
parentrv
;
text
*
relname
=
PG_GETARG_TEXT_P
(
0
);
text
*
relname
=
PG_GETARG_TEXT_P
(
0
);
Oid
relid
;
Oid
relid
;
parentrv
=
makeRangeVarFromNameList
(
textToQualifiedNameList
(
relname
));
parentrv
=
makeRangeVarFromNameList
(
textToQualifiedNameList
(
relname
));
relid
=
RangeVarGetRelid
(
parentrv
,
false
);
relid
=
RangeVarGetRelid
(
parentrv
,
false
);
...
...
src/backend/access/appendonly/appendonlyam.c
浏览文件 @
2ec69545
...
@@ -1763,8 +1763,8 @@ appendonly_beginrangescan(Relation relation,
...
@@ -1763,8 +1763,8 @@ appendonly_beginrangescan(Relation relation,
for
(
i
=
0
;
i
<
segfile_count
;
i
++
)
for
(
i
=
0
;
i
<
segfile_count
;
i
++
)
{
{
seginfo
[
i
]
=
GetFileSegInfo
(
relation
,
appendOnlyMetaDataSnapshot
,
seginfo
[
i
]
=
GetFileSegInfo
(
relation
,
appendOnlyMetaDataSnapshot
,
segfile_no_arr
[
i
]);
segfile_no_arr
[
i
]);
}
}
return
appendonly_beginrangescan_internal
(
relation
,
return
appendonly_beginrangescan_internal
(
relation
,
snapshot
,
snapshot
,
...
@@ -1975,7 +1975,7 @@ static bool
...
@@ -1975,7 +1975,7 @@ static bool
fetchNextBlock
(
AppendOnlyFetchDesc
aoFetchDesc
)
fetchNextBlock
(
AppendOnlyFetchDesc
aoFetchDesc
)
{
{
AppendOnlyExecutorReadBlock
*
executorReadBlock
=
AppendOnlyExecutorReadBlock
*
executorReadBlock
=
&
aoFetchDesc
->
executorReadBlock
;
&
aoFetchDesc
->
executorReadBlock
;
/*
/*
* Try to read next block.
* Try to read next block.
...
...
src/backend/access/appendonly/appendonlyblockdirectory.c
浏览文件 @
2ec69545
此差异已折叠。
点击以展开。
src/backend/access/appendonly/appendonlytid.c
浏览文件 @
2ec69545
此差异已折叠。
点击以展开。
src/backend/access/appendonly/appendonlywriter.c
浏览文件 @
2ec69545
此差异已折叠。
点击以展开。
src/backend/access/appendonly/test/aomd_test.c
浏览文件 @
2ec69545
此差异已折叠。
点击以展开。
src/backend/access/appendonly/test/appendonly_visimap_test.c
浏览文件 @
2ec69545
...
@@ -17,7 +17,8 @@ test__AppendOnlyVisimapDelete_Finish_outoforder(void **state)
...
@@ -17,7 +17,8 @@ test__AppendOnlyVisimapDelete_Finish_outoforder(void **state)
AppendOnlyVisiMapDeleteData
val
;
AppendOnlyVisiMapDeleteData
val
;
AppendOnlyVisimapDelete
visiMapDelete
;
AppendOnlyVisimapDelete
visiMapDelete
;
AppendOnlyVisimap
visiMap
;
AppendOnlyVisimap
visiMap
;
bool
found
;
bool
found
;
visiMapDelete
.
visiMap
=
&
visiMap
;
visiMapDelete
.
visiMap
=
&
visiMap
;
visiMap
.
visimapEntry
.
segmentFileNum
=
2
;
visiMap
.
visimapEntry
.
segmentFileNum
=
2
;
visiMap
.
visimapEntry
.
firstRowNum
=
32768
;
visiMap
.
visimapEntry
.
firstRowNum
=
32768
;
...
@@ -32,9 +33,9 @@ test__AppendOnlyVisimapDelete_Finish_outoforder(void **state)
...
@@ -32,9 +33,9 @@ test__AppendOnlyVisimapDelete_Finish_outoforder(void **state)
will_return
(
AppendOnlyVisimapEntry_HasChanged
,
true
);
will_return
(
AppendOnlyVisimapEntry_HasChanged
,
true
);
#ifdef USE_ASSERT_CHECKING
#ifdef USE_ASSERT_CHECKING
/*
/*
* AppendOnlyVisimap_Store calls
* AppendOnlyVisimap_Store calls Assert(AppendOnlyVisimapEntry_IsValid)
* Assert(AppendOnlyVisimapEntry_IsValid)
*/
*/
expect_any
(
AppendOnlyVisimapEntry_IsValid
,
visiMapEntry
);
expect_any
(
AppendOnlyVisimapEntry_IsValid
,
visiMapEntry
);
will_return
(
AppendOnlyVisimapEntry_IsValid
,
true
);
will_return
(
AppendOnlyVisimapEntry_IsValid
,
true
);
...
@@ -65,13 +66,13 @@ test__AppendOnlyVisimapDelete_Finish_outoforder(void **state)
...
@@ -65,13 +66,13 @@ test__AppendOnlyVisimapDelete_Finish_outoforder(void **state)
}
}
int
int
main
(
int
argc
,
char
*
argv
[])
main
(
int
argc
,
char
*
argv
[])
{
{
cmockery_parse_arguments
(
argc
,
argv
);
cmockery_parse_arguments
(
argc
,
argv
);
const
UnitTest
tests
[]
=
{
const
UnitTest
tests
[]
=
{
unit_test
(
test__AppendOnlyVisimapDelete_Finish_outoforder
)
unit_test
(
test__AppendOnlyVisimapDelete_Finish_outoforder
)
};
};
MemoryContextInit
();
MemoryContextInit
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录