Skip to content

Commit

Permalink
[columnar] Delete / Update
Browse files Browse the repository at this point in the history
* Created new metadata table `columnar.row_mask` that will indicate
  which rows can be skipped when reading columnar table.
* When doing delete bit information in row_mask for table / row number
  will be marked.
* Updates are combination of delete and insert
* columnar.create_table_row_mask function can be used to initialize row
  mask for columnar tables.
  • Loading branch information
mkaruza authored and wuputah committed Feb 8, 2023
1 parent 460893f commit f33b0bd
Show file tree
Hide file tree
Showing 25 changed files with 1,630 additions and 147 deletions.
12 changes: 12 additions & 0 deletions columnar/src/backend/columnar/columnar.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ int columnar_compression_level = 3;
bool columnar_enable_parallel_execution = true;
int columnar_min_parallel_processes = 8;
bool columnar_enable_vectorization = true;
bool columnar_enable_dml = true;

static const struct config_enum_entry columnar_compression_options[] =
{
Expand Down Expand Up @@ -154,6 +155,17 @@ columnar_init_gucs()
NULL,
NULL,
NULL);

DefineCustomBoolVariable("columnar.enable_dml",
gettext_noop("Enables DML"),
NULL,
&columnar_enable_dml,
true,
PGC_USERSET,
GUC_NO_SHOW_ALL,
NULL,
NULL,
NULL);
}


Expand Down
2 changes: 1 addition & 1 deletion columnar/src/backend/columnar/columnar.control
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
comment = 'Hydra Columnar extension'
default_version = '11.1-4'
default_version = '11.1-5'
module_pathname = '$libdir/columnar'
relocatable = false
18 changes: 13 additions & 5 deletions columnar/src/backend/columnar/columnar_customscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1851,14 +1851,22 @@ ColumnarAttrNeeded(ScanState *ss, List *customList)
{
Var *var = lfirst(lc);

if (var->varattno < 0)
/*
* We support following special variables with update / delete.
*/
if (var->varattno == SelfItemPointerAttributeNumber ||
var->varattno == TableOidAttributeNumber)
{
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg(
"UPDATE and CTID scans not supported for ColumnarScan")));
continue;
}
else if (var->varattno < SelfItemPointerAttributeNumber)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("MIN / MAX TransactionID or CommandID not supported for ColumnarScan")));
}

if (var->varattno == 0)
if (var->varattno == 0 )
{
elog(DEBUG1, "Need attribute: all");

Expand Down
18 changes: 12 additions & 6 deletions columnar/src/backend/columnar/columnar_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ PG_FUNCTION_INFO_V1(columnar_storage_info);


/*
* columnar_store_memory_stats returns a record of 3 values: size of
* TopMemoryContext, TopTransactionContext, and Write State context.
* columnar_store_memory_stats returns a record of 4 values: size of
* TopMemoryContext, TopTransactionContext, , Write State context and
* Row Mask context.
*/
Datum
columnar_store_memory_stats(PG_FUNCTION_ARGS)
Expand All @@ -52,21 +53,26 @@ columnar_store_memory_stats(PG_FUNCTION_ARGS)
INT8OID, -1, 0);
TupleDescInitEntry(tupleDescriptor, (AttrNumber) 3, "WriteStateContext",
INT8OID, -1, 0);
TupleDescInitEntry(tupleDescriptor, (AttrNumber) 4, "RowMaskWriteStateContext",
INT8OID, -1, 0);

tupleDescriptor = BlessTupleDesc(tupleDescriptor);

MemoryContextCounters transactionCounters = { 0 };
MemoryContextCounters topCounters = { 0 };
MemoryContextCounters writeStateCounters = { 0 };
MemoryContextCounters rowMaskCacheCounters = { 0 };
MemoryContextTotals(TopTransactionContext, &transactionCounters);
MemoryContextTotals(TopMemoryContext, &topCounters);
MemoryContextTotals(GetWriteContextForDebug(), &writeStateCounters);
MemoryContextTotals(GetColumnarWriteContextForDebug(), &writeStateCounters);
MemoryContextTotals(GetRowMaskWriteStateContextForDebug(), &rowMaskCacheCounters);

bool nulls[3] = { false };
Datum values[3] = {
bool nulls[4] = { false };
Datum values[4] = {
Int64GetDatum(topCounters.totalspace),
Int64GetDatum(transactionCounters.totalspace),
Int64GetDatum(writeStateCounters.totalspace)
Int64GetDatum(writeStateCounters.totalspace),
Int64GetDatum(rowMaskCacheCounters.totalspace)
};

HeapTuple tuple = heap_form_tuple(tupleDescriptor, values, nulls);
Expand Down
Loading

0 comments on commit f33b0bd

Please sign in to comment.