Skip to content

Commit

Permalink
Refactor internals to support pageinspect (#850)
Browse files Browse the repository at this point in the history
In late december 2024 I was busy supporting pageinspect extension for AO/AOCS relations in out GP6 fork.
Here is prelimitary patch for supporting same in CBDB.
  • Loading branch information
reshke authored Jan 9, 2025
1 parent 3419239 commit dbc7a71
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/backend/access/appendonly/appendonlyam.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ initscan(AppendOnlyScanDesc scan, ScanKey key)
/*
* Open the next file segment to scan and allocate all resources needed for it.
*/
static bool
bool
SetNextFileSegForRead(AppendOnlyScanDesc scan)
{
Relation reln = scan->aos_rd;
Expand Down Expand Up @@ -470,7 +470,7 @@ CloseWritableFileSeg(AppendOnlyInsertDesc aoInsertDesc)

/* ------------------------------------------------------------------------------ */

static void
void
AppendOnlyExecutorReadBlock_GetContents(AppendOnlyExecutorReadBlock *executorReadBlock)
{
VarBlockCheckError varBlockCheckError;
Expand Down Expand Up @@ -669,7 +669,7 @@ AppendOnlyExecutorReadBlock_GetContents(AppendOnlyExecutorReadBlock *executorRea
}
}

static bool
bool
AppendOnlyExecutorReadBlock_GetBlockInfo(AppendOnlyStorageRead *storageRead,
AppendOnlyExecutorReadBlock *executorReadBlock)
{
Expand Down Expand Up @@ -1011,7 +1011,8 @@ AppendOnlyExecutorReadBlock_ProcessTuple(AppendOnlyExecutorReadBlock *executorRe
return valid;
}

static bool

bool
AppendOnlyExecutorReadBlock_ScanNextTuple(AppendOnlyExecutorReadBlock *executorReadBlock,
int nkeys,
ScanKey key,
Expand Down
4 changes: 4 additions & 0 deletions src/backend/cdb/cdbvarblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ VarBlockGetItemPtrAndLen(
VarBlockByteOffset offset;

Assert(varBlockReader != NULL);
Assert(varBlockReader->header);

header = varBlockReader->header;
buffer = (uint8 *) header;
Expand Down Expand Up @@ -804,6 +805,7 @@ VarBlockReaderGetNextItemPtr(

Assert(varBlockReader != NULL);
Assert(itemLen != NULL);
Assert(varBlockReader->header);

if (varBlockReader->nextIndex >=
VarBlockGet_itemCount(varBlockReader->header))
Expand All @@ -828,6 +830,7 @@ VarBlockReaderItemCount(
VarBlockReader *varBlockReader)
{
Assert(varBlockReader != NULL);
Assert(varBlockReader->header != NULL);

return VarBlockGet_itemCount(varBlockReader->header);
}
Expand All @@ -844,6 +847,7 @@ VarBlockReaderGetItemPtr(
uint8 *nextItemPtr;

Assert(varBlockReader != NULL);
Assert(varBlockReader->header);
Assert(itemIndex >= 0);
Assert(itemIndex < VarBlockGet_itemCount(varBlockReader->header));

Expand Down
14 changes: 14 additions & 0 deletions src/include/cdb/cdbappendonlyam.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,18 @@ extern ExprState* appendonly_predicate_pushdown_prepare(AppendOnlyScanDesc scan,
ExprState *qual,
ExprContext *ecxt);

extern bool AppendOnlyExecutorReadBlock_GetBlockInfo(AppendOnlyStorageRead *storageRead,
AppendOnlyExecutorReadBlock *executorReadBlock);

extern void AppendOnlyStorageRead_CloseFile(AppendOnlyStorageRead *storageRead);

extern bool SetNextFileSegForRead(AppendOnlyScanDesc scan);

extern bool AppendOnlyExecutorReadBlock_ScanNextTuple(AppendOnlyExecutorReadBlock *executorReadBlock,
int nkeys,
ScanKey key,
TupleTableSlot *slot);

extern void AppendOnlyExecutorReadBlock_GetContents(AppendOnlyExecutorReadBlock *executorReadBlock);

#endif /* CDBAPPENDONLYAM_H */

0 comments on commit dbc7a71

Please sign in to comment.