mirror of https://github.com/citusdata/citus.git
Merge pull request #4557 from citusdata/columnar_rename_funcs
Don't use 'cstore' in symbolspull/4552/head
commit
9051bf485f
|
@ -35,12 +35,12 @@
|
||||||
#define DEFAULT_COMPRESSION_TYPE COMPRESSION_PG_LZ
|
#define DEFAULT_COMPRESSION_TYPE COMPRESSION_PG_LZ
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int cstore_compression = DEFAULT_COMPRESSION_TYPE;
|
int columnar_compression = DEFAULT_COMPRESSION_TYPE;
|
||||||
int cstore_stripe_row_count = DEFAULT_STRIPE_ROW_COUNT;
|
int columnar_stripe_row_count = DEFAULT_STRIPE_ROW_COUNT;
|
||||||
int cstore_chunk_row_count = DEFAULT_CHUNK_ROW_COUNT;
|
int columnar_chunk_row_count = DEFAULT_CHUNK_ROW_COUNT;
|
||||||
int columnar_compression_level = 3;
|
int columnar_compression_level = 3;
|
||||||
|
|
||||||
static const struct config_enum_entry cstore_compression_options[] =
|
static const struct config_enum_entry columnar_compression_options[] =
|
||||||
{
|
{
|
||||||
{ "none", COMPRESSION_NONE, false },
|
{ "none", COMPRESSION_NONE, false },
|
||||||
{ "pglz", COMPRESSION_PG_LZ, false },
|
{ "pglz", COMPRESSION_PG_LZ, false },
|
||||||
|
@ -54,14 +54,14 @@ static const struct config_enum_entry cstore_compression_options[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
cstore_init()
|
columnar_init_gucs()
|
||||||
{
|
{
|
||||||
DefineCustomEnumVariable("columnar.compression",
|
DefineCustomEnumVariable("columnar.compression",
|
||||||
"Compression type for cstore.",
|
"Compression type for cstore.",
|
||||||
NULL,
|
NULL,
|
||||||
&cstore_compression,
|
&columnar_compression,
|
||||||
DEFAULT_COMPRESSION_TYPE,
|
DEFAULT_COMPRESSION_TYPE,
|
||||||
cstore_compression_options,
|
columnar_compression_options,
|
||||||
PGC_USERSET,
|
PGC_USERSET,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -84,7 +84,7 @@ cstore_init()
|
||||||
DefineCustomIntVariable("columnar.stripe_row_count",
|
DefineCustomIntVariable("columnar.stripe_row_count",
|
||||||
"Maximum number of tuples per stripe.",
|
"Maximum number of tuples per stripe.",
|
||||||
NULL,
|
NULL,
|
||||||
&cstore_stripe_row_count,
|
&columnar_stripe_row_count,
|
||||||
DEFAULT_STRIPE_ROW_COUNT,
|
DEFAULT_STRIPE_ROW_COUNT,
|
||||||
STRIPE_ROW_COUNT_MINIMUM,
|
STRIPE_ROW_COUNT_MINIMUM,
|
||||||
STRIPE_ROW_COUNT_MAXIMUM,
|
STRIPE_ROW_COUNT_MAXIMUM,
|
||||||
|
@ -97,7 +97,7 @@ cstore_init()
|
||||||
DefineCustomIntVariable("columnar.chunk_row_count",
|
DefineCustomIntVariable("columnar.chunk_row_count",
|
||||||
"Maximum number of rows per chunk.",
|
"Maximum number of rows per chunk.",
|
||||||
NULL,
|
NULL,
|
||||||
&cstore_chunk_row_count,
|
&columnar_chunk_row_count,
|
||||||
DEFAULT_CHUNK_ROW_COUNT,
|
DEFAULT_CHUNK_ROW_COUNT,
|
||||||
CHUNK_ROW_COUNT_MINIMUM,
|
CHUNK_ROW_COUNT_MINIMUM,
|
||||||
CHUNK_ROW_COUNT_MAXIMUM,
|
CHUNK_ROW_COUNT_MAXIMUM,
|
||||||
|
@ -120,13 +120,13 @@ ParseCompressionType(const char *compressionTypeString)
|
||||||
Assert(compressionTypeString != NULL);
|
Assert(compressionTypeString != NULL);
|
||||||
|
|
||||||
for (int compressionIndex = 0;
|
for (int compressionIndex = 0;
|
||||||
cstore_compression_options[compressionIndex].name != NULL;
|
columnar_compression_options[compressionIndex].name != NULL;
|
||||||
compressionIndex++)
|
compressionIndex++)
|
||||||
{
|
{
|
||||||
const char *compressionName = cstore_compression_options[compressionIndex].name;
|
const char *compressionName = columnar_compression_options[compressionIndex].name;
|
||||||
if (strncmp(compressionTypeString, compressionName, NAMEDATALEN) == 0)
|
if (strncmp(compressionTypeString, compressionName, NAMEDATALEN) == 0)
|
||||||
{
|
{
|
||||||
return cstore_compression_options[compressionIndex].val;
|
return columnar_compression_options[compressionIndex].val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,14 +143,14 @@ const char *
|
||||||
CompressionTypeStr(CompressionType requestedType)
|
CompressionTypeStr(CompressionType requestedType)
|
||||||
{
|
{
|
||||||
for (int compressionIndex = 0;
|
for (int compressionIndex = 0;
|
||||||
cstore_compression_options[compressionIndex].name != NULL;
|
columnar_compression_options[compressionIndex].name != NULL;
|
||||||
compressionIndex++)
|
compressionIndex++)
|
||||||
{
|
{
|
||||||
CompressionType compressionType =
|
CompressionType compressionType =
|
||||||
cstore_compression_options[compressionIndex].val;
|
columnar_compression_options[compressionIndex].val;
|
||||||
if (compressionType == requestedType)
|
if (compressionType == requestedType)
|
||||||
{
|
{
|
||||||
return cstore_compression_options[compressionIndex].name;
|
return columnar_compression_options[compressionIndex].name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* cstore_customscan.c
|
* columnar_customscan.c
|
||||||
*
|
*
|
||||||
* This file contains the implementation of a postgres custom scan that
|
* This file contains the implementation of a postgres custom scan that
|
||||||
* we use to push down the projections into the table access methods.
|
* we use to push down the projections into the table access methods.
|
||||||
|
@ -29,85 +29,86 @@
|
||||||
#include "columnar/cstore_customscan.h"
|
#include "columnar/cstore_customscan.h"
|
||||||
#include "columnar/cstore_tableam.h"
|
#include "columnar/cstore_tableam.h"
|
||||||
|
|
||||||
typedef struct CStoreScanPath
|
typedef struct ColumnarScanPath
|
||||||
{
|
{
|
||||||
CustomPath custom_path;
|
CustomPath custom_path;
|
||||||
|
|
||||||
/* place for local state during planning */
|
/* place for local state during planning */
|
||||||
} CStoreScanPath;
|
} ColumnarScanPath;
|
||||||
|
|
||||||
typedef struct CStoreScanScan
|
typedef struct ColumnarScanScan
|
||||||
{
|
{
|
||||||
CustomScan custom_scan;
|
CustomScan custom_scan;
|
||||||
|
|
||||||
/* place for local state during execution */
|
/* place for local state during execution */
|
||||||
} CStoreScanScan;
|
} ColumnarScanScan;
|
||||||
|
|
||||||
typedef struct CStoreScanState
|
typedef struct ColumnarScanState
|
||||||
{
|
{
|
||||||
CustomScanState custom_scanstate;
|
CustomScanState custom_scanstate;
|
||||||
|
|
||||||
List *qual;
|
List *qual;
|
||||||
} CStoreScanState;
|
} ColumnarScanState;
|
||||||
|
|
||||||
|
|
||||||
static void CStoreSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
static void ColumnarSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
||||||
RangeTblEntry *rte);
|
RangeTblEntry *rte);
|
||||||
static Path * CreateCStoreScanPath(RelOptInfo *rel, RangeTblEntry *rte);
|
static Path * CreateColumnarScanPath(RelOptInfo *rel, RangeTblEntry *rte);
|
||||||
static Cost CStoreScanCost(RangeTblEntry *rte);
|
static Cost ColumnarScanCost(RangeTblEntry *rte);
|
||||||
static Plan * CStoreScanPath_PlanCustomPath(PlannerInfo *root,
|
static Plan * ColumnarScanPath_PlanCustomPath(PlannerInfo *root,
|
||||||
RelOptInfo *rel,
|
RelOptInfo *rel,
|
||||||
struct CustomPath *best_path,
|
struct CustomPath *best_path,
|
||||||
List *tlist,
|
List *tlist,
|
||||||
List *clauses,
|
List *clauses,
|
||||||
List *custom_plans);
|
List *custom_plans);
|
||||||
|
|
||||||
static Node * CStoreScan_CreateCustomScanState(CustomScan *cscan);
|
static Node * ColumnarScan_CreateCustomScanState(CustomScan *cscan);
|
||||||
|
|
||||||
static void CStoreScan_BeginCustomScan(CustomScanState *node, EState *estate, int eflags);
|
static void ColumnarScan_BeginCustomScan(CustomScanState *node, EState *estate, int
|
||||||
static TupleTableSlot * CStoreScan_ExecCustomScan(CustomScanState *node);
|
eflags);
|
||||||
static void CStoreScan_EndCustomScan(CustomScanState *node);
|
static TupleTableSlot * ColumnarScan_ExecCustomScan(CustomScanState *node);
|
||||||
static void CStoreScan_ReScanCustomScan(CustomScanState *node);
|
static void ColumnarScan_EndCustomScan(CustomScanState *node);
|
||||||
static void CStoreScan_ExplainCustomScan(CustomScanState *node, List *ancestors,
|
static void ColumnarScan_ReScanCustomScan(CustomScanState *node);
|
||||||
ExplainState *es);
|
static void ColumnarScan_ExplainCustomScan(CustomScanState *node, List *ancestors,
|
||||||
|
ExplainState *es);
|
||||||
|
|
||||||
/* saved hook value in case of unload */
|
/* saved hook value in case of unload */
|
||||||
static set_rel_pathlist_hook_type PreviousSetRelPathlistHook = NULL;
|
static set_rel_pathlist_hook_type PreviousSetRelPathlistHook = NULL;
|
||||||
|
|
||||||
static bool EnableCStoreCustomScan = true;
|
static bool EnableColumnarCustomScan = true;
|
||||||
|
|
||||||
|
|
||||||
const struct CustomPathMethods CStoreScanPathMethods = {
|
const struct CustomPathMethods ColumnarScanPathMethods = {
|
||||||
.CustomName = "ColumnarScan",
|
.CustomName = "ColumnarScan",
|
||||||
.PlanCustomPath = CStoreScanPath_PlanCustomPath,
|
.PlanCustomPath = ColumnarScanPath_PlanCustomPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct CustomScanMethods CStoreScanScanMethods = {
|
const struct CustomScanMethods ColumnarScanScanMethods = {
|
||||||
.CustomName = "ColumnarScan",
|
.CustomName = "ColumnarScan",
|
||||||
.CreateCustomScanState = CStoreScan_CreateCustomScanState,
|
.CreateCustomScanState = ColumnarScan_CreateCustomScanState,
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct CustomExecMethods CStoreExecuteMethods = {
|
const struct CustomExecMethods ColumnarExecuteMethods = {
|
||||||
.CustomName = "ColumnarScan",
|
.CustomName = "ColumnarScan",
|
||||||
|
|
||||||
.BeginCustomScan = CStoreScan_BeginCustomScan,
|
.BeginCustomScan = ColumnarScan_BeginCustomScan,
|
||||||
.ExecCustomScan = CStoreScan_ExecCustomScan,
|
.ExecCustomScan = ColumnarScan_ExecCustomScan,
|
||||||
.EndCustomScan = CStoreScan_EndCustomScan,
|
.EndCustomScan = ColumnarScan_EndCustomScan,
|
||||||
.ReScanCustomScan = CStoreScan_ReScanCustomScan,
|
.ReScanCustomScan = ColumnarScan_ReScanCustomScan,
|
||||||
|
|
||||||
.ExplainCustomScan = CStoreScan_ExplainCustomScan,
|
.ExplainCustomScan = ColumnarScan_ExplainCustomScan,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cstore_customscan_init installs the hook required to intercept the postgres planner and
|
* columnar_customscan_init installs the hook required to intercept the postgres planner and
|
||||||
* provide extra paths for cstore tables
|
* provide extra paths for cstore tables
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
cstore_customscan_init()
|
columnar_customscan_init()
|
||||||
{
|
{
|
||||||
PreviousSetRelPathlistHook = set_rel_pathlist_hook;
|
PreviousSetRelPathlistHook = set_rel_pathlist_hook;
|
||||||
set_rel_pathlist_hook = CStoreSetRelPathlistHook;
|
set_rel_pathlist_hook = ColumnarSetRelPathlistHook;
|
||||||
|
|
||||||
/* register customscan specific GUC's */
|
/* register customscan specific GUC's */
|
||||||
DefineCustomBoolVariable(
|
DefineCustomBoolVariable(
|
||||||
|
@ -115,7 +116,7 @@ cstore_customscan_init()
|
||||||
gettext_noop("Enables the use of a custom scan to push projections and quals "
|
gettext_noop("Enables the use of a custom scan to push projections and quals "
|
||||||
"into the storage layer"),
|
"into the storage layer"),
|
||||||
NULL,
|
NULL,
|
||||||
&EnableCStoreCustomScan,
|
&EnableColumnarCustomScan,
|
||||||
true,
|
true,
|
||||||
PGC_USERSET,
|
PGC_USERSET,
|
||||||
GUC_NO_SHOW_ALL,
|
GUC_NO_SHOW_ALL,
|
||||||
|
@ -135,8 +136,8 @@ clear_paths(RelOptInfo *rel)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CStoreSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
ColumnarSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
||||||
RangeTblEntry *rte)
|
RangeTblEntry *rte)
|
||||||
{
|
{
|
||||||
/* call into previous hook if assigned */
|
/* call into previous hook if assigned */
|
||||||
if (PreviousSetRelPathlistHook)
|
if (PreviousSetRelPathlistHook)
|
||||||
|
@ -144,7 +145,7 @@ CStoreSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
||||||
PreviousSetRelPathlistHook(root, rel, rti, rte);
|
PreviousSetRelPathlistHook(root, rel, rti, rte);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EnableCStoreCustomScan)
|
if (!EnableColumnarCustomScan)
|
||||||
{
|
{
|
||||||
/* custon scans are disabled, use normal table access method api instead */
|
/* custon scans are disabled, use normal table access method api instead */
|
||||||
return;
|
return;
|
||||||
|
@ -170,7 +171,7 @@ CStoreSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
||||||
errmsg("sample scans not supported on columnar tables")));
|
errmsg("sample scans not supported on columnar tables")));
|
||||||
}
|
}
|
||||||
|
|
||||||
Path *customPath = CreateCStoreScanPath(rel, rte);
|
Path *customPath = CreateColumnarScanPath(rel, rte);
|
||||||
|
|
||||||
ereport(DEBUG1, (errmsg("pathlist hook for cstore table am")));
|
ereport(DEBUG1, (errmsg("pathlist hook for cstore table am")));
|
||||||
|
|
||||||
|
@ -183,16 +184,16 @@ CStoreSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
||||||
|
|
||||||
|
|
||||||
static Path *
|
static Path *
|
||||||
CreateCStoreScanPath(RelOptInfo *rel, RangeTblEntry *rte)
|
CreateColumnarScanPath(RelOptInfo *rel, RangeTblEntry *rte)
|
||||||
{
|
{
|
||||||
CStoreScanPath *cspath = (CStoreScanPath *) newNode(sizeof(CStoreScanPath),
|
ColumnarScanPath *cspath = (ColumnarScanPath *) newNode(sizeof(ColumnarScanPath),
|
||||||
T_CustomPath);
|
T_CustomPath);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* popuate custom path information
|
* popuate custom path information
|
||||||
*/
|
*/
|
||||||
CustomPath *cpath = &cspath->custom_path;
|
CustomPath *cpath = &cspath->custom_path;
|
||||||
cpath->methods = &CStoreScanPathMethods;
|
cpath->methods = &ColumnarScanPathMethods;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* populate generic path information
|
* populate generic path information
|
||||||
|
@ -208,19 +209,19 @@ CreateCStoreScanPath(RelOptInfo *rel, RangeTblEntry *rte)
|
||||||
*/
|
*/
|
||||||
path->rows = rel->rows;
|
path->rows = rel->rows;
|
||||||
path->startup_cost = 0;
|
path->startup_cost = 0;
|
||||||
path->total_cost = path->startup_cost + CStoreScanCost(rte);
|
path->total_cost = path->startup_cost + ColumnarScanCost(rte);
|
||||||
|
|
||||||
return (Path *) cspath;
|
return (Path *) cspath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreScanCost calculates the cost of scanning the cstore table. The cost is estimated
|
* ColumnarScanCost calculates the cost of scanning the cstore table. The cost is estimated
|
||||||
* by using all stripe metadata to estimate based on the columns to read how many pages
|
* by using all stripe metadata to estimate based on the columns to read how many pages
|
||||||
* need to be read.
|
* need to be read.
|
||||||
*/
|
*/
|
||||||
static Cost
|
static Cost
|
||||||
CStoreScanCost(RangeTblEntry *rte)
|
ColumnarScanCost(RangeTblEntry *rte)
|
||||||
{
|
{
|
||||||
Relation rel = RelationIdGetRelation(rte->relid);
|
Relation rel = RelationIdGetRelation(rte->relid);
|
||||||
List *stripeList = StripesForRelfilenode(rel->rd_node);
|
List *stripeList = StripesForRelfilenode(rel->rd_node);
|
||||||
|
@ -249,18 +250,18 @@ CStoreScanCost(RangeTblEntry *rte)
|
||||||
|
|
||||||
|
|
||||||
static Plan *
|
static Plan *
|
||||||
CStoreScanPath_PlanCustomPath(PlannerInfo *root,
|
ColumnarScanPath_PlanCustomPath(PlannerInfo *root,
|
||||||
RelOptInfo *rel,
|
RelOptInfo *rel,
|
||||||
struct CustomPath *best_path,
|
struct CustomPath *best_path,
|
||||||
List *tlist,
|
List *tlist,
|
||||||
List *clauses,
|
List *clauses,
|
||||||
List *custom_plans)
|
List *custom_plans)
|
||||||
{
|
{
|
||||||
CStoreScanScan *plan = (CStoreScanScan *) newNode(sizeof(CStoreScanScan),
|
ColumnarScanScan *plan = (ColumnarScanScan *) newNode(sizeof(ColumnarScanScan),
|
||||||
T_CustomScan);
|
T_CustomScan);
|
||||||
|
|
||||||
CustomScan *cscan = &plan->custom_scan;
|
CustomScan *cscan = &plan->custom_scan;
|
||||||
cscan->methods = &CStoreScanScanMethods;
|
cscan->methods = &ColumnarScanScanMethods;
|
||||||
|
|
||||||
/* Reduce RestrictInfo list to bare expressions; ignore pseudoconstants */
|
/* Reduce RestrictInfo list to bare expressions; ignore pseudoconstants */
|
||||||
clauses = extract_actual_clauses(clauses, false);
|
clauses = extract_actual_clauses(clauses, false);
|
||||||
|
@ -274,13 +275,13 @@ CStoreScanPath_PlanCustomPath(PlannerInfo *root,
|
||||||
|
|
||||||
|
|
||||||
static Node *
|
static Node *
|
||||||
CStoreScan_CreateCustomScanState(CustomScan *cscan)
|
ColumnarScan_CreateCustomScanState(CustomScan *cscan)
|
||||||
{
|
{
|
||||||
CStoreScanState *cstorescanstate = (CStoreScanState *) newNode(
|
ColumnarScanState *cstorescanstate = (ColumnarScanState *) newNode(
|
||||||
sizeof(CStoreScanState), T_CustomScanState);
|
sizeof(ColumnarScanState), T_CustomScanState);
|
||||||
|
|
||||||
CustomScanState *cscanstate = &cstorescanstate->custom_scanstate;
|
CustomScanState *cscanstate = &cstorescanstate->custom_scanstate;
|
||||||
cscanstate->methods = &CStoreExecuteMethods;
|
cscanstate->methods = &ColumnarExecuteMethods;
|
||||||
|
|
||||||
cstorescanstate->qual = cscan->scan.plan.qual;
|
cstorescanstate->qual = cscan->scan.plan.qual;
|
||||||
|
|
||||||
|
@ -289,14 +290,14 @@ CStoreScan_CreateCustomScanState(CustomScan *cscan)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CStoreScan_BeginCustomScan(CustomScanState *cscanstate, EState *estate, int eflags)
|
ColumnarScan_BeginCustomScan(CustomScanState *cscanstate, EState *estate, int eflags)
|
||||||
{
|
{
|
||||||
/* scan slot is already initialized */
|
/* scan slot is already initialized */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Bitmapset *
|
static Bitmapset *
|
||||||
CStoreAttrNeeded(ScanState *ss)
|
ColumnarAttrNeeded(ScanState *ss)
|
||||||
{
|
{
|
||||||
TupleTableSlot *slot = ss->ss_ScanTupleSlot;
|
TupleTableSlot *slot = ss->ss_ScanTupleSlot;
|
||||||
int natts = slot->tts_tupleDescriptor->natts;
|
int natts = slot->tts_tupleDescriptor->natts;
|
||||||
|
@ -337,7 +338,7 @@ CStoreAttrNeeded(ScanState *ss)
|
||||||
|
|
||||||
|
|
||||||
static TupleTableSlot *
|
static TupleTableSlot *
|
||||||
CStoreScanNext(CStoreScanState *cstorescanstate)
|
ColumnarScanNext(ColumnarScanState *cstorescanstate)
|
||||||
{
|
{
|
||||||
CustomScanState *node = (CustomScanState *) cstorescanstate;
|
CustomScanState *node = (CustomScanState *) cstorescanstate;
|
||||||
|
|
||||||
|
@ -353,16 +354,16 @@ CStoreScanNext(CStoreScanState *cstorescanstate)
|
||||||
{
|
{
|
||||||
/* the cstore access method does not use the flags, they are specific to heap */
|
/* the cstore access method does not use the flags, they are specific to heap */
|
||||||
uint32 flags = 0;
|
uint32 flags = 0;
|
||||||
Bitmapset *attr_needed = CStoreAttrNeeded(&node->ss);
|
Bitmapset *attr_needed = ColumnarAttrNeeded(&node->ss);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We reach here if the scan is not parallel, or if we're serially
|
* We reach here if the scan is not parallel, or if we're serially
|
||||||
* executing a scan that was planned to be parallel.
|
* executing a scan that was planned to be parallel.
|
||||||
*/
|
*/
|
||||||
scandesc = cstore_beginscan_extended(node->ss.ss_currentRelation,
|
scandesc = columnar_beginscan_extended(node->ss.ss_currentRelation,
|
||||||
estate->es_snapshot,
|
estate->es_snapshot,
|
||||||
0, NULL, NULL, flags, attr_needed,
|
0, NULL, NULL, flags, attr_needed,
|
||||||
cstorescanstate->qual);
|
cstorescanstate->qual);
|
||||||
bms_free(attr_needed);
|
bms_free(attr_needed);
|
||||||
|
|
||||||
node->ss.ss_currentScanDesc = scandesc;
|
node->ss.ss_currentScanDesc = scandesc;
|
||||||
|
@ -383,23 +384,23 @@ CStoreScanNext(CStoreScanState *cstorescanstate)
|
||||||
* SeqRecheck -- access method routine to recheck a tuple in EvalPlanQual
|
* SeqRecheck -- access method routine to recheck a tuple in EvalPlanQual
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
CStoreScanRecheck(CStoreScanState *node, TupleTableSlot *slot)
|
ColumnarScanRecheck(ColumnarScanState *node, TupleTableSlot *slot)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TupleTableSlot *
|
static TupleTableSlot *
|
||||||
CStoreScan_ExecCustomScan(CustomScanState *node)
|
ColumnarScan_ExecCustomScan(CustomScanState *node)
|
||||||
{
|
{
|
||||||
return ExecScan(&node->ss,
|
return ExecScan(&node->ss,
|
||||||
(ExecScanAccessMtd) CStoreScanNext,
|
(ExecScanAccessMtd) ColumnarScanNext,
|
||||||
(ExecScanRecheckMtd) CStoreScanRecheck);
|
(ExecScanRecheckMtd) ColumnarScanRecheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CStoreScan_EndCustomScan(CustomScanState *node)
|
ColumnarScan_EndCustomScan(CustomScanState *node)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* get information from node
|
* get information from node
|
||||||
|
@ -431,7 +432,7 @@ CStoreScan_EndCustomScan(CustomScanState *node)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CStoreScan_ReScanCustomScan(CustomScanState *node)
|
ColumnarScan_ReScanCustomScan(CustomScanState *node)
|
||||||
{
|
{
|
||||||
TableScanDesc scanDesc = node->ss.ss_currentScanDesc;
|
TableScanDesc scanDesc = node->ss.ss_currentScanDesc;
|
||||||
if (scanDesc != NULL)
|
if (scanDesc != NULL)
|
||||||
|
@ -442,8 +443,8 @@ CStoreScan_ReScanCustomScan(CustomScanState *node)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CStoreScan_ExplainCustomScan(CustomScanState *node, List *ancestors,
|
ColumnarScan_ExplainCustomScan(CustomScanState *node, List *ancestors,
|
||||||
ExplainState *es)
|
ExplainState *es)
|
||||||
{
|
{
|
||||||
TableScanDesc scanDesc = node->ss.ss_currentScanDesc;
|
TableScanDesc scanDesc = node->ss.ss_currentScanDesc;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* cstore_metadata_tables.c
|
* columnar_metadata_tables.c
|
||||||
*
|
*
|
||||||
* Copyright (c), Citus Data, Inc.
|
* Copyright (c), Citus Data, Inc.
|
||||||
*
|
*
|
||||||
|
@ -79,13 +79,13 @@ static void GetHighestUsedAddressAndId(uint64 storageId,
|
||||||
uint64 *highestUsedAddress,
|
uint64 *highestUsedAddress,
|
||||||
uint64 *highestUsedId);
|
uint64 *highestUsedId);
|
||||||
static List * ReadDataFileStripeList(uint64 storageId, Snapshot snapshot);
|
static List * ReadDataFileStripeList(uint64 storageId, Snapshot snapshot);
|
||||||
static Oid CStoreStripesRelationId(void);
|
static Oid ColumnarStripesRelationId(void);
|
||||||
static Oid CStoreStripesIndexRelationId(void);
|
static Oid ColumnarStripesIndexRelationId(void);
|
||||||
static Oid ColumnarOptionsRelationId(void);
|
static Oid ColumnarOptionsRelationId(void);
|
||||||
static Oid ColumnarOptionsIndexRegclass(void);
|
static Oid ColumnarOptionsIndexRegclass(void);
|
||||||
static Oid CStoreSkipNodesRelationId(void);
|
static Oid ColumnarSkipNodesRelationId(void);
|
||||||
static Oid CStoreSkipNodesIndexRelationId(void);
|
static Oid ColumnarSkipNodesIndexRelationId(void);
|
||||||
static Oid CStoreNamespaceId(void);
|
static Oid ColumnarNamespaceId(void);
|
||||||
static ModifyState * StartModifyRelation(Relation rel);
|
static ModifyState * StartModifyRelation(Relation rel);
|
||||||
static void InsertTupleAndEnforceConstraints(ModifyState *state, Datum *values,
|
static void InsertTupleAndEnforceConstraints(ModifyState *state, Datum *values,
|
||||||
bool *nulls);
|
bool *nulls);
|
||||||
|
@ -102,18 +102,18 @@ static bool WriteColumnarOptions(Oid regclass, ColumnarOptions *options, bool ov
|
||||||
PG_FUNCTION_INFO_V1(columnar_relation_storageid);
|
PG_FUNCTION_INFO_V1(columnar_relation_storageid);
|
||||||
|
|
||||||
/* constants for columnar.options */
|
/* constants for columnar.options */
|
||||||
#define Natts_cstore_options 5
|
#define Natts_columnar_options 5
|
||||||
#define Anum_cstore_options_regclass 1
|
#define Anum_columnar_options_regclass 1
|
||||||
#define Anum_cstore_options_chunk_row_count 2
|
#define Anum_columnar_options_chunk_row_count 2
|
||||||
#define Anum_cstore_options_stripe_row_count 3
|
#define Anum_columnar_options_stripe_row_count 3
|
||||||
#define Anum_cstore_options_compression_level 4
|
#define Anum_columnar_options_compression_level 4
|
||||||
#define Anum_cstore_options_compression 5
|
#define Anum_columnar_options_compression 5
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* columnar.options definition.
|
* columnar.options definition.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
typedef struct FormData_cstore_options
|
typedef struct FormData_columnar_options
|
||||||
{
|
{
|
||||||
Oid regclass;
|
Oid regclass;
|
||||||
int32 chunk_row_count;
|
int32 chunk_row_count;
|
||||||
|
@ -123,37 +123,37 @@ typedef struct FormData_cstore_options
|
||||||
|
|
||||||
#ifdef CATALOG_VARLEN /* variable-length fields start here */
|
#ifdef CATALOG_VARLEN /* variable-length fields start here */
|
||||||
#endif
|
#endif
|
||||||
} FormData_cstore_options;
|
} FormData_columnar_options;
|
||||||
typedef FormData_cstore_options *Form_cstore_options;
|
typedef FormData_columnar_options *Form_columnar_options;
|
||||||
|
|
||||||
|
|
||||||
/* constants for cstore_stripe */
|
/* constants for columnar_stripe */
|
||||||
#define Natts_cstore_stripes 8
|
#define Natts_columnar_stripes 8
|
||||||
#define Anum_cstore_stripes_storageid 1
|
#define Anum_columnar_stripes_storageid 1
|
||||||
#define Anum_cstore_stripes_stripe 2
|
#define Anum_columnar_stripes_stripe 2
|
||||||
#define Anum_cstore_stripes_file_offset 3
|
#define Anum_columnar_stripes_file_offset 3
|
||||||
#define Anum_cstore_stripes_data_length 4
|
#define Anum_columnar_stripes_data_length 4
|
||||||
#define Anum_cstore_stripes_column_count 5
|
#define Anum_columnar_stripes_column_count 5
|
||||||
#define Anum_cstore_stripes_chunk_count 6
|
#define Anum_columnar_stripes_chunk_count 6
|
||||||
#define Anum_cstore_stripes_chunk_row_count 7
|
#define Anum_columnar_stripes_chunk_row_count 7
|
||||||
#define Anum_cstore_stripes_row_count 8
|
#define Anum_columnar_stripes_row_count 8
|
||||||
|
|
||||||
/* constants for cstore_skipnodes */
|
/* constants for columnar_skipnodes */
|
||||||
#define Natts_cstore_skipnodes 14
|
#define Natts_columnar_skipnodes 14
|
||||||
#define Anum_cstore_skipnodes_storageid 1
|
#define Anum_columnar_skipnodes_storageid 1
|
||||||
#define Anum_cstore_skipnodes_stripe 2
|
#define Anum_columnar_skipnodes_stripe 2
|
||||||
#define Anum_cstore_skipnodes_attr 3
|
#define Anum_columnar_skipnodes_attr 3
|
||||||
#define Anum_cstore_skipnodes_chunk 4
|
#define Anum_columnar_skipnodes_chunk 4
|
||||||
#define Anum_cstore_skipnodes_row_count 5
|
#define Anum_columnar_skipnodes_row_count 5
|
||||||
#define Anum_cstore_skipnodes_minimum_value 6
|
#define Anum_columnar_skipnodes_minimum_value 6
|
||||||
#define Anum_cstore_skipnodes_maximum_value 7
|
#define Anum_columnar_skipnodes_maximum_value 7
|
||||||
#define Anum_cstore_skipnodes_value_stream_offset 8
|
#define Anum_columnar_skipnodes_value_stream_offset 8
|
||||||
#define Anum_cstore_skipnodes_value_stream_length 9
|
#define Anum_columnar_skipnodes_value_stream_length 9
|
||||||
#define Anum_cstore_skipnodes_exists_stream_offset 10
|
#define Anum_columnar_skipnodes_exists_stream_offset 10
|
||||||
#define Anum_cstore_skipnodes_exists_stream_length 11
|
#define Anum_columnar_skipnodes_exists_stream_length 11
|
||||||
#define Anum_cstore_skipnodes_value_compression_type 12
|
#define Anum_columnar_skipnodes_value_compression_type 12
|
||||||
#define Anum_cstore_skipnodes_value_compression_level 13
|
#define Anum_columnar_skipnodes_value_compression_level 13
|
||||||
#define Anum_cstore_skipnodes_value_decompressed_size 14
|
#define Anum_columnar_skipnodes_value_decompressed_size 14
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -173,9 +173,9 @@ InitColumnarOptions(Oid regclass)
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnarOptions defaultOptions = {
|
ColumnarOptions defaultOptions = {
|
||||||
.chunkRowCount = cstore_chunk_row_count,
|
.chunkRowCount = columnar_chunk_row_count,
|
||||||
.stripeRowCount = cstore_stripe_row_count,
|
.stripeRowCount = columnar_stripe_row_count,
|
||||||
.compressionType = cstore_compression,
|
.compressionType = columnar_compression,
|
||||||
.compressionLevel = columnar_compression_level
|
.compressionLevel = columnar_compression_level
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -214,8 +214,8 @@ WriteColumnarOptions(Oid regclass, ColumnarOptions *options, bool overwrite)
|
||||||
|
|
||||||
bool written = false;
|
bool written = false;
|
||||||
|
|
||||||
bool nulls[Natts_cstore_options] = { 0 };
|
bool nulls[Natts_columnar_options] = { 0 };
|
||||||
Datum values[Natts_cstore_options] = {
|
Datum values[Natts_columnar_options] = {
|
||||||
ObjectIdGetDatum(regclass),
|
ObjectIdGetDatum(regclass),
|
||||||
Int32GetDatum(options->chunkRowCount),
|
Int32GetDatum(options->chunkRowCount),
|
||||||
Int32GetDatum(options->stripeRowCount),
|
Int32GetDatum(options->stripeRowCount),
|
||||||
|
@ -225,7 +225,7 @@ WriteColumnarOptions(Oid regclass, ColumnarOptions *options, bool overwrite)
|
||||||
|
|
||||||
NameData compressionName = { 0 };
|
NameData compressionName = { 0 };
|
||||||
namestrcpy(&compressionName, CompressionTypeStr(options->compressionType));
|
namestrcpy(&compressionName, CompressionTypeStr(options->compressionType));
|
||||||
values[Anum_cstore_options_compression - 1] = NameGetDatum(&compressionName);
|
values[Anum_columnar_options_compression - 1] = NameGetDatum(&compressionName);
|
||||||
|
|
||||||
/* create heap tuple and insert into catalog table */
|
/* create heap tuple and insert into catalog table */
|
||||||
Relation columnarOptions = relation_open(ColumnarOptionsRelationId(),
|
Relation columnarOptions = relation_open(ColumnarOptionsRelationId(),
|
||||||
|
@ -234,7 +234,8 @@ WriteColumnarOptions(Oid regclass, ColumnarOptions *options, bool overwrite)
|
||||||
|
|
||||||
/* find existing item to perform update if exist */
|
/* find existing item to perform update if exist */
|
||||||
ScanKeyData scanKey[1] = { 0 };
|
ScanKeyData scanKey[1] = { 0 };
|
||||||
ScanKeyInit(&scanKey[0], Anum_cstore_options_regclass, BTEqualStrategyNumber, F_OIDEQ,
|
ScanKeyInit(&scanKey[0], Anum_columnar_options_regclass, BTEqualStrategyNumber,
|
||||||
|
F_OIDEQ,
|
||||||
ObjectIdGetDatum(regclass));
|
ObjectIdGetDatum(regclass));
|
||||||
|
|
||||||
Relation index = index_open(ColumnarOptionsIndexRegclass(), AccessShareLock);
|
Relation index = index_open(ColumnarOptionsIndexRegclass(), AccessShareLock);
|
||||||
|
@ -248,11 +249,11 @@ WriteColumnarOptions(Oid regclass, ColumnarOptions *options, bool overwrite)
|
||||||
{
|
{
|
||||||
/* TODO check if the options are actually different, skip if not changed */
|
/* TODO check if the options are actually different, skip if not changed */
|
||||||
/* update existing record */
|
/* update existing record */
|
||||||
bool update[Natts_cstore_options] = { 0 };
|
bool update[Natts_columnar_options] = { 0 };
|
||||||
update[Anum_cstore_options_chunk_row_count - 1] = true;
|
update[Anum_columnar_options_chunk_row_count - 1] = true;
|
||||||
update[Anum_cstore_options_stripe_row_count - 1] = true;
|
update[Anum_columnar_options_stripe_row_count - 1] = true;
|
||||||
update[Anum_cstore_options_compression_level - 1] = true;
|
update[Anum_columnar_options_compression_level - 1] = true;
|
||||||
update[Anum_cstore_options_compression - 1] = true;
|
update[Anum_columnar_options_compression - 1] = true;
|
||||||
|
|
||||||
HeapTuple tuple = heap_modify_tuple(heapTuple, tupleDescriptor,
|
HeapTuple tuple = heap_modify_tuple(heapTuple, tupleDescriptor,
|
||||||
values, nulls, update);
|
values, nulls, update);
|
||||||
|
@ -303,7 +304,8 @@ DeleteColumnarTableOptions(Oid regclass, bool missingOk)
|
||||||
|
|
||||||
/* find existing item to remove */
|
/* find existing item to remove */
|
||||||
ScanKeyData scanKey[1] = { 0 };
|
ScanKeyData scanKey[1] = { 0 };
|
||||||
ScanKeyInit(&scanKey[0], Anum_cstore_options_regclass, BTEqualStrategyNumber, F_OIDEQ,
|
ScanKeyInit(&scanKey[0], Anum_columnar_options_regclass, BTEqualStrategyNumber,
|
||||||
|
F_OIDEQ,
|
||||||
ObjectIdGetDatum(regclass));
|
ObjectIdGetDatum(regclass));
|
||||||
|
|
||||||
Relation index = index_open(ColumnarOptionsIndexRegclass(), AccessShareLock);
|
Relation index = index_open(ColumnarOptionsIndexRegclass(), AccessShareLock);
|
||||||
|
@ -336,7 +338,8 @@ ReadColumnarOptions(Oid regclass, ColumnarOptions *options)
|
||||||
{
|
{
|
||||||
ScanKeyData scanKey[1];
|
ScanKeyData scanKey[1];
|
||||||
|
|
||||||
ScanKeyInit(&scanKey[0], Anum_cstore_options_regclass, BTEqualStrategyNumber, F_OIDEQ,
|
ScanKeyInit(&scanKey[0], Anum_columnar_options_regclass, BTEqualStrategyNumber,
|
||||||
|
F_OIDEQ,
|
||||||
ObjectIdGetDatum(regclass));
|
ObjectIdGetDatum(regclass));
|
||||||
|
|
||||||
Oid columnarOptionsOid = ColumnarOptionsRelationId();
|
Oid columnarOptionsOid = ColumnarOptionsRelationId();
|
||||||
|
@ -365,7 +368,7 @@ ReadColumnarOptions(Oid regclass, ColumnarOptions *options)
|
||||||
HeapTuple heapTuple = systable_getnext(scanDescriptor);
|
HeapTuple heapTuple = systable_getnext(scanDescriptor);
|
||||||
if (HeapTupleIsValid(heapTuple))
|
if (HeapTupleIsValid(heapTuple))
|
||||||
{
|
{
|
||||||
Form_cstore_options tupOptions = (Form_cstore_options) GETSTRUCT(heapTuple);
|
Form_columnar_options tupOptions = (Form_columnar_options) GETSTRUCT(heapTuple);
|
||||||
|
|
||||||
options->chunkRowCount = tupOptions->chunk_row_count;
|
options->chunkRowCount = tupOptions->chunk_row_count;
|
||||||
options->stripeRowCount = tupOptions->stripe_row_count;
|
options->stripeRowCount = tupOptions->stripe_row_count;
|
||||||
|
@ -375,9 +378,9 @@ ReadColumnarOptions(Oid regclass, ColumnarOptions *options)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* populate options with system defaults */
|
/* populate options with system defaults */
|
||||||
options->compressionType = cstore_compression;
|
options->compressionType = columnar_compression;
|
||||||
options->stripeRowCount = cstore_stripe_row_count;
|
options->stripeRowCount = columnar_stripe_row_count;
|
||||||
options->chunkRowCount = cstore_chunk_row_count;
|
options->chunkRowCount = columnar_chunk_row_count;
|
||||||
options->compressionLevel = columnar_compression_level;
|
options->compressionLevel = columnar_compression_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +394,7 @@ ReadColumnarOptions(Oid regclass, ColumnarOptions *options)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SaveStripeSkipList saves StripeSkipList for a given stripe as rows
|
* SaveStripeSkipList saves StripeSkipList for a given stripe as rows
|
||||||
* of cstore_skipnodes.
|
* of columnar_skipnodes.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SaveStripeSkipList(RelFileNode relfilenode, uint64 stripe, StripeSkipList *stripeSkipList,
|
SaveStripeSkipList(RelFileNode relfilenode, uint64 stripe, StripeSkipList *stripeSkipList,
|
||||||
|
@ -402,7 +405,7 @@ SaveStripeSkipList(RelFileNode relfilenode, uint64 stripe, StripeSkipList *strip
|
||||||
uint32 columnCount = stripeSkipList->columnCount;
|
uint32 columnCount = stripeSkipList->columnCount;
|
||||||
|
|
||||||
ColumnarMetapage *metapage = ReadMetapage(relfilenode, false);
|
ColumnarMetapage *metapage = ReadMetapage(relfilenode, false);
|
||||||
Oid cstoreSkipNodesOid = CStoreSkipNodesRelationId();
|
Oid cstoreSkipNodesOid = ColumnarSkipNodesRelationId();
|
||||||
Relation cstoreSkipNodes = table_open(cstoreSkipNodesOid, RowExclusiveLock);
|
Relation cstoreSkipNodes = table_open(cstoreSkipNodesOid, RowExclusiveLock);
|
||||||
ModifyState *modifyState = StartModifyRelation(cstoreSkipNodes);
|
ModifyState *modifyState = StartModifyRelation(cstoreSkipNodes);
|
||||||
|
|
||||||
|
@ -413,7 +416,7 @@ SaveStripeSkipList(RelFileNode relfilenode, uint64 stripe, StripeSkipList *strip
|
||||||
ColumnChunkSkipNode *skipNode =
|
ColumnChunkSkipNode *skipNode =
|
||||||
&stripeSkipList->chunkSkipNodeArray[columnIndex][chunkIndex];
|
&stripeSkipList->chunkSkipNodeArray[columnIndex][chunkIndex];
|
||||||
|
|
||||||
Datum values[Natts_cstore_skipnodes] = {
|
Datum values[Natts_columnar_skipnodes] = {
|
||||||
UInt64GetDatum(metapage->storageId),
|
UInt64GetDatum(metapage->storageId),
|
||||||
Int64GetDatum(stripe),
|
Int64GetDatum(stripe),
|
||||||
Int32GetDatum(columnIndex + 1),
|
Int32GetDatum(columnIndex + 1),
|
||||||
|
@ -430,21 +433,21 @@ SaveStripeSkipList(RelFileNode relfilenode, uint64 stripe, StripeSkipList *strip
|
||||||
Int64GetDatum(skipNode->decompressedValueSize)
|
Int64GetDatum(skipNode->decompressedValueSize)
|
||||||
};
|
};
|
||||||
|
|
||||||
bool nulls[Natts_cstore_skipnodes] = { false };
|
bool nulls[Natts_columnar_skipnodes] = { false };
|
||||||
|
|
||||||
if (skipNode->hasMinMax)
|
if (skipNode->hasMinMax)
|
||||||
{
|
{
|
||||||
values[Anum_cstore_skipnodes_minimum_value - 1] =
|
values[Anum_columnar_skipnodes_minimum_value - 1] =
|
||||||
PointerGetDatum(DatumToBytea(skipNode->minimumValue,
|
PointerGetDatum(DatumToBytea(skipNode->minimumValue,
|
||||||
&tupleDescriptor->attrs[columnIndex]));
|
&tupleDescriptor->attrs[columnIndex]));
|
||||||
values[Anum_cstore_skipnodes_maximum_value - 1] =
|
values[Anum_columnar_skipnodes_maximum_value - 1] =
|
||||||
PointerGetDatum(DatumToBytea(skipNode->maximumValue,
|
PointerGetDatum(DatumToBytea(skipNode->maximumValue,
|
||||||
&tupleDescriptor->attrs[columnIndex]));
|
&tupleDescriptor->attrs[columnIndex]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nulls[Anum_cstore_skipnodes_minimum_value - 1] = true;
|
nulls[Anum_columnar_skipnodes_minimum_value - 1] = true;
|
||||||
nulls[Anum_cstore_skipnodes_maximum_value - 1] = true;
|
nulls[Anum_columnar_skipnodes_maximum_value - 1] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertTupleAndEnforceConstraints(modifyState, values, nulls);
|
InsertTupleAndEnforceConstraints(modifyState, values, nulls);
|
||||||
|
@ -472,13 +475,13 @@ ReadStripeSkipList(RelFileNode relfilenode, uint64 stripe, TupleDesc tupleDescri
|
||||||
|
|
||||||
ColumnarMetapage *metapage = ReadMetapage(relfilenode, false);
|
ColumnarMetapage *metapage = ReadMetapage(relfilenode, false);
|
||||||
|
|
||||||
Oid cstoreSkipNodesOid = CStoreSkipNodesRelationId();
|
Oid cstoreSkipNodesOid = ColumnarSkipNodesRelationId();
|
||||||
Relation cstoreSkipNodes = table_open(cstoreSkipNodesOid, AccessShareLock);
|
Relation cstoreSkipNodes = table_open(cstoreSkipNodesOid, AccessShareLock);
|
||||||
Relation index = index_open(CStoreSkipNodesIndexRelationId(), AccessShareLock);
|
Relation index = index_open(ColumnarSkipNodesIndexRelationId(), AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&scanKey[0], Anum_cstore_skipnodes_storageid,
|
ScanKeyInit(&scanKey[0], Anum_columnar_skipnodes_storageid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ, UInt64GetDatum(metapage->storageId));
|
BTEqualStrategyNumber, F_OIDEQ, UInt64GetDatum(metapage->storageId));
|
||||||
ScanKeyInit(&scanKey[1], Anum_cstore_skipnodes_stripe,
|
ScanKeyInit(&scanKey[1], Anum_columnar_skipnodes_stripe,
|
||||||
BTEqualStrategyNumber, F_OIDEQ, Int32GetDatum(stripe));
|
BTEqualStrategyNumber, F_OIDEQ, Int32GetDatum(stripe));
|
||||||
|
|
||||||
SysScanDesc scanDescriptor = systable_beginscan_ordered(cstoreSkipNodes, index, NULL,
|
SysScanDesc scanDescriptor = systable_beginscan_ordered(cstoreSkipNodes, index, NULL,
|
||||||
|
@ -496,14 +499,14 @@ ReadStripeSkipList(RelFileNode relfilenode, uint64 stripe, TupleDesc tupleDescri
|
||||||
|
|
||||||
while (HeapTupleIsValid(heapTuple = systable_getnext(scanDescriptor)))
|
while (HeapTupleIsValid(heapTuple = systable_getnext(scanDescriptor)))
|
||||||
{
|
{
|
||||||
Datum datumArray[Natts_cstore_skipnodes];
|
Datum datumArray[Natts_columnar_skipnodes];
|
||||||
bool isNullArray[Natts_cstore_skipnodes];
|
bool isNullArray[Natts_columnar_skipnodes];
|
||||||
|
|
||||||
heap_deform_tuple(heapTuple, RelationGetDescr(cstoreSkipNodes), datumArray,
|
heap_deform_tuple(heapTuple, RelationGetDescr(cstoreSkipNodes), datumArray,
|
||||||
isNullArray);
|
isNullArray);
|
||||||
|
|
||||||
int32 attr = DatumGetInt32(datumArray[Anum_cstore_skipnodes_attr - 1]);
|
int32 attr = DatumGetInt32(datumArray[Anum_columnar_skipnodes_attr - 1]);
|
||||||
int32 chunkIndex = DatumGetInt32(datumArray[Anum_cstore_skipnodes_chunk - 1]);
|
int32 chunkIndex = DatumGetInt32(datumArray[Anum_columnar_skipnodes_chunk - 1]);
|
||||||
|
|
||||||
if (attr <= 0 || attr > columnCount)
|
if (attr <= 0 || attr > columnCount)
|
||||||
{
|
{
|
||||||
|
@ -521,34 +524,36 @@ ReadStripeSkipList(RelFileNode relfilenode, uint64 stripe, TupleDesc tupleDescri
|
||||||
|
|
||||||
ColumnChunkSkipNode *skipNode =
|
ColumnChunkSkipNode *skipNode =
|
||||||
&skipList->chunkSkipNodeArray[columnIndex][chunkIndex];
|
&skipList->chunkSkipNodeArray[columnIndex][chunkIndex];
|
||||||
skipNode->rowCount = DatumGetInt64(datumArray[Anum_cstore_skipnodes_row_count -
|
skipNode->rowCount = DatumGetInt64(datumArray[Anum_columnar_skipnodes_row_count -
|
||||||
1]);
|
1]);
|
||||||
skipNode->valueChunkOffset =
|
skipNode->valueChunkOffset =
|
||||||
DatumGetInt64(datumArray[Anum_cstore_skipnodes_value_stream_offset - 1]);
|
DatumGetInt64(datumArray[Anum_columnar_skipnodes_value_stream_offset - 1]);
|
||||||
skipNode->valueLength =
|
skipNode->valueLength =
|
||||||
DatumGetInt64(datumArray[Anum_cstore_skipnodes_value_stream_length - 1]);
|
DatumGetInt64(datumArray[Anum_columnar_skipnodes_value_stream_length - 1]);
|
||||||
skipNode->existsChunkOffset =
|
skipNode->existsChunkOffset =
|
||||||
DatumGetInt64(datumArray[Anum_cstore_skipnodes_exists_stream_offset - 1]);
|
DatumGetInt64(datumArray[Anum_columnar_skipnodes_exists_stream_offset - 1]);
|
||||||
skipNode->existsLength =
|
skipNode->existsLength =
|
||||||
DatumGetInt64(datumArray[Anum_cstore_skipnodes_exists_stream_length - 1]);
|
DatumGetInt64(datumArray[Anum_columnar_skipnodes_exists_stream_length - 1]);
|
||||||
skipNode->valueCompressionType =
|
skipNode->valueCompressionType =
|
||||||
DatumGetInt32(datumArray[Anum_cstore_skipnodes_value_compression_type - 1]);
|
DatumGetInt32(datumArray[Anum_columnar_skipnodes_value_compression_type - 1]);
|
||||||
skipNode->valueCompressionLevel =
|
skipNode->valueCompressionLevel =
|
||||||
DatumGetInt32(datumArray[Anum_cstore_skipnodes_value_compression_level - 1]);
|
DatumGetInt32(datumArray[Anum_columnar_skipnodes_value_compression_level -
|
||||||
|
1]);
|
||||||
skipNode->decompressedValueSize =
|
skipNode->decompressedValueSize =
|
||||||
DatumGetInt64(datumArray[Anum_cstore_skipnodes_value_decompressed_size - 1]);
|
DatumGetInt64(datumArray[Anum_columnar_skipnodes_value_decompressed_size -
|
||||||
|
1]);
|
||||||
|
|
||||||
if (isNullArray[Anum_cstore_skipnodes_minimum_value - 1] ||
|
if (isNullArray[Anum_columnar_skipnodes_minimum_value - 1] ||
|
||||||
isNullArray[Anum_cstore_skipnodes_maximum_value - 1])
|
isNullArray[Anum_columnar_skipnodes_maximum_value - 1])
|
||||||
{
|
{
|
||||||
skipNode->hasMinMax = false;
|
skipNode->hasMinMax = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bytea *minValue = DatumGetByteaP(
|
bytea *minValue = DatumGetByteaP(
|
||||||
datumArray[Anum_cstore_skipnodes_minimum_value - 1]);
|
datumArray[Anum_columnar_skipnodes_minimum_value - 1]);
|
||||||
bytea *maxValue = DatumGetByteaP(
|
bytea *maxValue = DatumGetByteaP(
|
||||||
datumArray[Anum_cstore_skipnodes_maximum_value - 1]);
|
datumArray[Anum_columnar_skipnodes_maximum_value - 1]);
|
||||||
|
|
||||||
skipNode->minimumValue =
|
skipNode->minimumValue =
|
||||||
ByteaToDatum(minValue, &tupleDescriptor->attrs[columnIndex]);
|
ByteaToDatum(minValue, &tupleDescriptor->attrs[columnIndex]);
|
||||||
|
@ -568,13 +573,13 @@ ReadStripeSkipList(RelFileNode relfilenode, uint64 stripe, TupleDesc tupleDescri
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* InsertStripeMetadataRow adds a row to cstore_stripes.
|
* InsertStripeMetadataRow adds a row to columnar_stripes.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
InsertStripeMetadataRow(uint64 storageId, StripeMetadata *stripe)
|
InsertStripeMetadataRow(uint64 storageId, StripeMetadata *stripe)
|
||||||
{
|
{
|
||||||
bool nulls[Natts_cstore_stripes] = { 0 };
|
bool nulls[Natts_columnar_stripes] = { 0 };
|
||||||
Datum values[Natts_cstore_stripes] = {
|
Datum values[Natts_columnar_stripes] = {
|
||||||
UInt64GetDatum(storageId),
|
UInt64GetDatum(storageId),
|
||||||
Int64GetDatum(stripe->id),
|
Int64GetDatum(stripe->id),
|
||||||
Int64GetDatum(stripe->fileOffset),
|
Int64GetDatum(stripe->fileOffset),
|
||||||
|
@ -585,7 +590,7 @@ InsertStripeMetadataRow(uint64 storageId, StripeMetadata *stripe)
|
||||||
Int64GetDatum(stripe->rowCount)
|
Int64GetDatum(stripe->rowCount)
|
||||||
};
|
};
|
||||||
|
|
||||||
Oid cstoreStripesOid = CStoreStripesRelationId();
|
Oid cstoreStripesOid = ColumnarStripesRelationId();
|
||||||
Relation cstoreStripes = table_open(cstoreStripesOid, RowExclusiveLock);
|
Relation cstoreStripes = table_open(cstoreStripesOid, RowExclusiveLock);
|
||||||
|
|
||||||
ModifyState *modifyState = StartModifyRelation(cstoreStripes);
|
ModifyState *modifyState = StartModifyRelation(cstoreStripes);
|
||||||
|
@ -679,7 +684,7 @@ GetHighestUsedAddressAndId(uint64 storageId,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ReserveStripe reserves and stripe of given size for the given relation,
|
* ReserveStripe reserves and stripe of given size for the given relation,
|
||||||
* and inserts it into cstore_stripes. It is guaranteed that concurrent
|
* and inserts it into columnar_stripes. It is guaranteed that concurrent
|
||||||
* writes won't overwrite the returned stripe.
|
* writes won't overwrite the returned stripe.
|
||||||
*/
|
*/
|
||||||
StripeMetadata
|
StripeMetadata
|
||||||
|
@ -760,13 +765,13 @@ ReadDataFileStripeList(uint64 storageId, Snapshot snapshot)
|
||||||
ScanKeyData scanKey[1];
|
ScanKeyData scanKey[1];
|
||||||
HeapTuple heapTuple;
|
HeapTuple heapTuple;
|
||||||
|
|
||||||
ScanKeyInit(&scanKey[0], Anum_cstore_stripes_storageid,
|
ScanKeyInit(&scanKey[0], Anum_columnar_stripes_storageid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ, Int32GetDatum(storageId));
|
BTEqualStrategyNumber, F_OIDEQ, Int32GetDatum(storageId));
|
||||||
|
|
||||||
Oid cstoreStripesOid = CStoreStripesRelationId();
|
Oid cstoreStripesOid = ColumnarStripesRelationId();
|
||||||
|
|
||||||
Relation cstoreStripes = table_open(cstoreStripesOid, AccessShareLock);
|
Relation cstoreStripes = table_open(cstoreStripesOid, AccessShareLock);
|
||||||
Relation index = index_open(CStoreStripesIndexRelationId(), AccessShareLock);
|
Relation index = index_open(ColumnarStripesIndexRelationId(), AccessShareLock);
|
||||||
TupleDesc tupleDescriptor = RelationGetDescr(cstoreStripes);
|
TupleDesc tupleDescriptor = RelationGetDescr(cstoreStripes);
|
||||||
|
|
||||||
SysScanDesc scanDescriptor = systable_beginscan_ordered(cstoreStripes, index,
|
SysScanDesc scanDescriptor = systable_beginscan_ordered(cstoreStripes, index,
|
||||||
|
@ -775,25 +780,25 @@ ReadDataFileStripeList(uint64 storageId, Snapshot snapshot)
|
||||||
|
|
||||||
while (HeapTupleIsValid(heapTuple = systable_getnext(scanDescriptor)))
|
while (HeapTupleIsValid(heapTuple = systable_getnext(scanDescriptor)))
|
||||||
{
|
{
|
||||||
Datum datumArray[Natts_cstore_stripes];
|
Datum datumArray[Natts_columnar_stripes];
|
||||||
bool isNullArray[Natts_cstore_stripes];
|
bool isNullArray[Natts_columnar_stripes];
|
||||||
|
|
||||||
heap_deform_tuple(heapTuple, tupleDescriptor, datumArray, isNullArray);
|
heap_deform_tuple(heapTuple, tupleDescriptor, datumArray, isNullArray);
|
||||||
|
|
||||||
StripeMetadata *stripeMetadata = palloc0(sizeof(StripeMetadata));
|
StripeMetadata *stripeMetadata = palloc0(sizeof(StripeMetadata));
|
||||||
stripeMetadata->id = DatumGetInt64(datumArray[Anum_cstore_stripes_stripe - 1]);
|
stripeMetadata->id = DatumGetInt64(datumArray[Anum_columnar_stripes_stripe - 1]);
|
||||||
stripeMetadata->fileOffset = DatumGetInt64(
|
stripeMetadata->fileOffset = DatumGetInt64(
|
||||||
datumArray[Anum_cstore_stripes_file_offset - 1]);
|
datumArray[Anum_columnar_stripes_file_offset - 1]);
|
||||||
stripeMetadata->dataLength = DatumGetInt64(
|
stripeMetadata->dataLength = DatumGetInt64(
|
||||||
datumArray[Anum_cstore_stripes_data_length - 1]);
|
datumArray[Anum_columnar_stripes_data_length - 1]);
|
||||||
stripeMetadata->columnCount = DatumGetInt32(
|
stripeMetadata->columnCount = DatumGetInt32(
|
||||||
datumArray[Anum_cstore_stripes_column_count - 1]);
|
datumArray[Anum_columnar_stripes_column_count - 1]);
|
||||||
stripeMetadata->chunkCount = DatumGetInt32(
|
stripeMetadata->chunkCount = DatumGetInt32(
|
||||||
datumArray[Anum_cstore_stripes_chunk_count - 1]);
|
datumArray[Anum_columnar_stripes_chunk_count - 1]);
|
||||||
stripeMetadata->chunkRowCount = DatumGetInt32(
|
stripeMetadata->chunkRowCount = DatumGetInt32(
|
||||||
datumArray[Anum_cstore_stripes_chunk_row_count - 1]);
|
datumArray[Anum_columnar_stripes_chunk_row_count - 1]);
|
||||||
stripeMetadata->rowCount = DatumGetInt64(
|
stripeMetadata->rowCount = DatumGetInt64(
|
||||||
datumArray[Anum_cstore_stripes_row_count - 1]);
|
datumArray[Anum_columnar_stripes_row_count - 1]);
|
||||||
|
|
||||||
stripeMetadataList = lappend(stripeMetadataList, stripeMetadata);
|
stripeMetadataList = lappend(stripeMetadataList, stripeMetadata);
|
||||||
}
|
}
|
||||||
|
@ -807,7 +812,7 @@ ReadDataFileStripeList(uint64 storageId, Snapshot snapshot)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DeleteMetadataRows removes the rows with given relfilenode from cstore_stripes.
|
* DeleteMetadataRows removes the rows with given relfilenode from columnar_stripes.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
DeleteMetadataRows(RelFileNode relfilenode)
|
DeleteMetadataRows(RelFileNode relfilenode)
|
||||||
|
@ -833,10 +838,10 @@ DeleteMetadataRows(RelFileNode relfilenode)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScanKeyInit(&scanKey[0], Anum_cstore_stripes_storageid,
|
ScanKeyInit(&scanKey[0], Anum_columnar_stripes_storageid,
|
||||||
BTEqualStrategyNumber, F_INT8EQ, UInt64GetDatum(metapage->storageId));
|
BTEqualStrategyNumber, F_INT8EQ, UInt64GetDatum(metapage->storageId));
|
||||||
|
|
||||||
Oid cstoreStripesOid = CStoreStripesRelationId();
|
Oid cstoreStripesOid = ColumnarStripesRelationId();
|
||||||
Relation cstoreStripes = try_relation_open(cstoreStripesOid, AccessShareLock);
|
Relation cstoreStripes = try_relation_open(cstoreStripesOid, AccessShareLock);
|
||||||
if (cstoreStripes == NULL)
|
if (cstoreStripes == NULL)
|
||||||
{
|
{
|
||||||
|
@ -844,7 +849,7 @@ DeleteMetadataRows(RelFileNode relfilenode)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Relation index = index_open(CStoreStripesIndexRelationId(), AccessShareLock);
|
Relation index = index_open(ColumnarStripesIndexRelationId(), AccessShareLock);
|
||||||
|
|
||||||
SysScanDesc scanDescriptor = systable_beginscan_ordered(cstoreStripes, index, NULL,
|
SysScanDesc scanDescriptor = systable_beginscan_ordered(cstoreStripes, index, NULL,
|
||||||
1, scanKey);
|
1, scanKey);
|
||||||
|
@ -1046,24 +1051,24 @@ ByteaToDatum(bytea *bytes, Form_pg_attribute attrForm)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreStripesRelationId returns relation id of cstore_stripes.
|
* ColumnarStripesRelationId returns relation id of columnar_stripes.
|
||||||
* TODO: should we cache this similar to citus?
|
* TODO: should we cache this similar to citus?
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
CStoreStripesRelationId(void)
|
ColumnarStripesRelationId(void)
|
||||||
{
|
{
|
||||||
return get_relname_relid("columnar_stripes", CStoreNamespaceId());
|
return get_relname_relid("columnar_stripes", ColumnarNamespaceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreStripesIndexRelationId returns relation id of cstore_stripes_idx.
|
* ColumnarStripesIndexRelationId returns relation id of columnar_stripes_idx.
|
||||||
* TODO: should we cache this similar to citus?
|
* TODO: should we cache this similar to citus?
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
CStoreStripesIndexRelationId(void)
|
ColumnarStripesIndexRelationId(void)
|
||||||
{
|
{
|
||||||
return get_relname_relid("columnar_stripes_pkey", CStoreNamespaceId());
|
return get_relname_relid("columnar_stripes_pkey", ColumnarNamespaceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1073,7 +1078,7 @@ CStoreStripesIndexRelationId(void)
|
||||||
static Oid
|
static Oid
|
||||||
ColumnarOptionsRelationId(void)
|
ColumnarOptionsRelationId(void)
|
||||||
{
|
{
|
||||||
return get_relname_relid("options", CStoreNamespaceId());
|
return get_relname_relid("options", ColumnarNamespaceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1083,38 +1088,38 @@ ColumnarOptionsRelationId(void)
|
||||||
static Oid
|
static Oid
|
||||||
ColumnarOptionsIndexRegclass(void)
|
ColumnarOptionsIndexRegclass(void)
|
||||||
{
|
{
|
||||||
return get_relname_relid("options_pkey", CStoreNamespaceId());
|
return get_relname_relid("options_pkey", ColumnarNamespaceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreSkipNodesRelationId returns relation id of cstore_skipnodes.
|
* ColumnarSkipNodesRelationId returns relation id of columnar_skipnodes.
|
||||||
* TODO: should we cache this similar to citus?
|
* TODO: should we cache this similar to citus?
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
CStoreSkipNodesRelationId(void)
|
ColumnarSkipNodesRelationId(void)
|
||||||
{
|
{
|
||||||
return get_relname_relid("columnar_skipnodes", CStoreNamespaceId());
|
return get_relname_relid("columnar_skipnodes", ColumnarNamespaceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreSkipNodesIndexRelationId returns relation id of cstore_skipnodes_pkey.
|
* ColumnarSkipNodesIndexRelationId returns relation id of columnar_skipnodes_pkey.
|
||||||
* TODO: should we cache this similar to citus?
|
* TODO: should we cache this similar to citus?
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
CStoreSkipNodesIndexRelationId(void)
|
ColumnarSkipNodesIndexRelationId(void)
|
||||||
{
|
{
|
||||||
return get_relname_relid("columnar_skipnodes_pkey", CStoreNamespaceId());
|
return get_relname_relid("columnar_skipnodes_pkey", ColumnarNamespaceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreNamespaceId returns namespace id of the schema we store cstore
|
* ColumnarNamespaceId returns namespace id of the schema we store cstore
|
||||||
* related tables.
|
* related tables.
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
CStoreNamespaceId(void)
|
ColumnarNamespaceId(void)
|
||||||
{
|
{
|
||||||
return get_namespace_oid("columnar", false);
|
return get_namespace_oid("columnar", false);
|
||||||
}
|
}
|
||||||
|
@ -1201,7 +1206,7 @@ GetNextStorageId(void)
|
||||||
{
|
{
|
||||||
Oid savedUserId = InvalidOid;
|
Oid savedUserId = InvalidOid;
|
||||||
int savedSecurityContext = 0;
|
int savedSecurityContext = 0;
|
||||||
Oid sequenceId = get_relname_relid("storageid_seq", CStoreNamespaceId());
|
Oid sequenceId = get_relname_relid("storageid_seq", ColumnarNamespaceId());
|
||||||
Datum sequenceIdDatum = ObjectIdGetDatum(sequenceId);
|
Datum sequenceIdDatum = ObjectIdGetDatum(sequenceId);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1236,7 +1241,7 @@ columnar_relation_storageid(PG_FUNCTION_ARGS)
|
||||||
#if HAS_TABLEAM
|
#if HAS_TABLEAM
|
||||||
Oid relationId = PG_GETARG_OID(0);
|
Oid relationId = PG_GETARG_OID(0);
|
||||||
Relation relation = relation_open(relationId, AccessShareLock);
|
Relation relation = relation_open(relationId, AccessShareLock);
|
||||||
if (IsCStoreTableAmTable(relationId))
|
if (IsColumnarTableAmTable(relationId))
|
||||||
{
|
{
|
||||||
ColumnarMetapage *metadata = ReadMetapage(relation->rd_node, true);
|
ColumnarMetapage *metadata = ReadMetapage(relation->rd_node, true);
|
||||||
if (metadata != NULL)
|
if (metadata != NULL)
|
||||||
|
|
|
@ -80,12 +80,12 @@ static Datum ColumnDefaultValue(TupleConstr *tupleConstraints,
|
||||||
Form_pg_attribute attributeForm);
|
Form_pg_attribute attributeForm);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreBeginRead initializes a cstore read operation. This function returns a
|
* ColumnarBeginRead initializes a cstore read operation. This function returns a
|
||||||
* read handle that's used during reading rows and finishing the read operation.
|
* read handle that's used during reading rows and finishing the read operation.
|
||||||
*/
|
*/
|
||||||
TableReadState *
|
TableReadState *
|
||||||
CStoreBeginRead(Relation relation, TupleDesc tupleDescriptor,
|
ColumnarBeginRead(Relation relation, TupleDesc tupleDescriptor,
|
||||||
List *projectedColumnList, List *whereClauseList)
|
List *projectedColumnList, List *whereClauseList)
|
||||||
{
|
{
|
||||||
List *stripeList = StripesForRelfilenode(relation->rd_node);
|
List *stripeList = StripesForRelfilenode(relation->rd_node);
|
||||||
|
|
||||||
|
@ -117,12 +117,12 @@ CStoreBeginRead(Relation relation, TupleDesc tupleDescriptor,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreReadNextRow tries to read a row from the cstore file. On success, it sets
|
* ColumnarReadNextRow tries to read a row from the cstore file. On success, it sets
|
||||||
* column values and nulls, and returns true. If there are no more rows to read,
|
* column values and nulls, and returns true. If there are no more rows to read,
|
||||||
* the function returns false.
|
* the function returns false.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
CStoreReadNextRow(TableReadState *readState, Datum *columnValues, bool *columnNulls)
|
ColumnarReadNextRow(TableReadState *readState, Datum *columnValues, bool *columnNulls)
|
||||||
{
|
{
|
||||||
StripeMetadata *stripeMetadata = readState->currentStripeMetadata;
|
StripeMetadata *stripeMetadata = readState->currentStripeMetadata;
|
||||||
MemoryContext oldContext = NULL;
|
MemoryContext oldContext = NULL;
|
||||||
|
@ -223,11 +223,11 @@ CStoreReadNextRow(TableReadState *readState, Datum *columnValues, bool *columnNu
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreRescan clears the position where we were scanning so that the next read starts at
|
* ColumnarRescan clears the position where we were scanning so that the next read starts at
|
||||||
* the beginning again
|
* the beginning again
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CStoreRescan(TableReadState *readState)
|
ColumnarRescan(TableReadState *readState)
|
||||||
{
|
{
|
||||||
readState->stripeBuffers = NULL;
|
readState->stripeBuffers = NULL;
|
||||||
readState->readStripeCount = 0;
|
readState->readStripeCount = 0;
|
||||||
|
@ -237,7 +237,7 @@ CStoreRescan(TableReadState *readState)
|
||||||
|
|
||||||
/* Finishes a cstore read operation. */
|
/* Finishes a cstore read operation. */
|
||||||
void
|
void
|
||||||
CStoreEndRead(TableReadState *readState)
|
ColumnarEndRead(TableReadState *readState)
|
||||||
{
|
{
|
||||||
MemoryContextDelete(readState->stripeReadContext);
|
MemoryContextDelete(readState->stripeReadContext);
|
||||||
list_free_deep(readState->stripeList);
|
list_free_deep(readState->stripeList);
|
||||||
|
@ -311,9 +311,9 @@ FreeChunkData(ChunkData *chunkData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* CStoreTableRowCount returns the exact row count of a table using skiplists */
|
/* ColumnarTableRowCount returns the exact row count of a table using skiplists */
|
||||||
uint64
|
uint64
|
||||||
CStoreTableRowCount(Relation relation)
|
ColumnarTableRowCount(Relation relation)
|
||||||
{
|
{
|
||||||
ListCell *stripeMetadataCell = NULL;
|
ListCell *stripeMetadataCell = NULL;
|
||||||
uint64 totalRowCount = 0;
|
uint64 totalRowCount = 0;
|
||||||
|
|
|
@ -69,10 +69,10 @@
|
||||||
#define VACUUM_TRUNCATE_LOCK_TIMEOUT 4500 /* ms */
|
#define VACUUM_TRUNCATE_LOCK_TIMEOUT 4500 /* ms */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreScanDescData is the scan state passed between beginscan(),
|
* ColumnarScanDescData is the scan state passed between beginscan(),
|
||||||
* getnextslot(), rescan(), and endscan() calls.
|
* getnextslot(), rescan(), and endscan() calls.
|
||||||
*/
|
*/
|
||||||
typedef struct CStoreScanDescData
|
typedef struct ColumnarScanDescData
|
||||||
{
|
{
|
||||||
TableScanDescData cs_base;
|
TableScanDescData cs_base;
|
||||||
TableReadState *cs_readState;
|
TableReadState *cs_readState;
|
||||||
|
@ -90,26 +90,26 @@ typedef struct CStoreScanDescData
|
||||||
* number so we can construct an item pointer based on that.
|
* number so we can construct an item pointer based on that.
|
||||||
*/
|
*/
|
||||||
int rowNumber;
|
int rowNumber;
|
||||||
} CStoreScanDescData;
|
} ColumnarScanDescData;
|
||||||
|
|
||||||
typedef struct CStoreScanDescData *CStoreScanDesc;
|
typedef struct ColumnarScanDescData *ColumnarScanDesc;
|
||||||
|
|
||||||
static object_access_hook_type PrevObjectAccessHook = NULL;
|
static object_access_hook_type PrevObjectAccessHook = NULL;
|
||||||
|
|
||||||
/* forward declaration for static functions */
|
/* forward declaration for static functions */
|
||||||
static void CStoreTableDropHook(Oid tgid);
|
static void ColumnarTableDropHook(Oid tgid);
|
||||||
static void CStoreTriggerCreateHook(Oid tgid);
|
static void ColumnarTriggerCreateHook(Oid tgid);
|
||||||
static void CStoreTableAMObjectAccessHook(ObjectAccessType access, Oid classId,
|
static void ColumnarTableAMObjectAccessHook(ObjectAccessType access, Oid classId,
|
||||||
Oid objectId, int subId,
|
Oid objectId, int subId,
|
||||||
void *arg);
|
void *arg);
|
||||||
static bool ConditionalLockRelationWithTimeout(Relation rel, LOCKMODE lockMode,
|
static bool ConditionalLockRelationWithTimeout(Relation rel, LOCKMODE lockMode,
|
||||||
int timeout, int retryInterval);
|
int timeout, int retryInterval);
|
||||||
static void LogRelationStats(Relation rel, int elevel);
|
static void LogRelationStats(Relation rel, int elevel);
|
||||||
static void TruncateCStore(Relation rel, int elevel);
|
static void TruncateColumnar(Relation rel, int elevel);
|
||||||
static HeapTuple ColumnarSlotCopyHeapTuple(TupleTableSlot *slot);
|
static HeapTuple ColumnarSlotCopyHeapTuple(TupleTableSlot *slot);
|
||||||
static void ColumnarCheckLogicalReplication(Relation rel);
|
static void ColumnarCheckLogicalReplication(Relation rel);
|
||||||
|
|
||||||
/* Custom tuple slot ops used for columnar. Initialized in cstore_tableam_init(). */
|
/* Custom tuple slot ops used for columnar. Initialized in columnar_tableam_init(). */
|
||||||
TupleTableSlotOps TTSOpsColumnar;
|
TupleTableSlotOps TTSOpsColumnar;
|
||||||
|
|
||||||
static List *
|
static List *
|
||||||
|
@ -142,17 +142,17 @@ RelationColumnList(Relation rel)
|
||||||
|
|
||||||
|
|
||||||
static const TupleTableSlotOps *
|
static const TupleTableSlotOps *
|
||||||
cstore_slot_callbacks(Relation relation)
|
columnar_slot_callbacks(Relation relation)
|
||||||
{
|
{
|
||||||
return &TTSOpsColumnar;
|
return &TTSOpsColumnar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TableScanDesc
|
static TableScanDesc
|
||||||
cstore_beginscan(Relation relation, Snapshot snapshot,
|
columnar_beginscan(Relation relation, Snapshot snapshot,
|
||||||
int nkeys, ScanKey key,
|
int nkeys, ScanKey key,
|
||||||
ParallelTableScanDesc parallel_scan,
|
ParallelTableScanDesc parallel_scan,
|
||||||
uint32 flags)
|
uint32 flags)
|
||||||
{
|
{
|
||||||
int natts = relation->rd_att->natts;
|
int natts = relation->rd_att->natts;
|
||||||
Bitmapset *attr_needed = NULL;
|
Bitmapset *attr_needed = NULL;
|
||||||
|
@ -162,9 +162,9 @@ cstore_beginscan(Relation relation, Snapshot snapshot,
|
||||||
/* the cstore access method does not use the flags, they are specific to heap */
|
/* the cstore access method does not use the flags, they are specific to heap */
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
TableScanDesc scandesc = cstore_beginscan_extended(relation, snapshot, nkeys, key,
|
TableScanDesc scandesc = columnar_beginscan_extended(relation, snapshot, nkeys, key,
|
||||||
parallel_scan,
|
parallel_scan,
|
||||||
flags, attr_needed, NULL);
|
flags, attr_needed, NULL);
|
||||||
|
|
||||||
pfree(attr_needed);
|
pfree(attr_needed);
|
||||||
|
|
||||||
|
@ -173,10 +173,10 @@ cstore_beginscan(Relation relation, Snapshot snapshot,
|
||||||
|
|
||||||
|
|
||||||
TableScanDesc
|
TableScanDesc
|
||||||
cstore_beginscan_extended(Relation relation, Snapshot snapshot,
|
columnar_beginscan_extended(Relation relation, Snapshot snapshot,
|
||||||
int nkeys, ScanKey key,
|
int nkeys, ScanKey key,
|
||||||
ParallelTableScanDesc parallel_scan,
|
ParallelTableScanDesc parallel_scan,
|
||||||
uint32 flags, Bitmapset *attr_needed, List *scanQual)
|
uint32 flags, Bitmapset *attr_needed, List *scanQual)
|
||||||
{
|
{
|
||||||
Oid relfilenode = relation->rd_node.relNode;
|
Oid relfilenode = relation->rd_node.relNode;
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ cstore_beginscan_extended(Relation relation, Snapshot snapshot,
|
||||||
|
|
||||||
MemoryContext oldContext = MemoryContextSwitchTo(scanContext);
|
MemoryContext oldContext = MemoryContextSwitchTo(scanContext);
|
||||||
|
|
||||||
CStoreScanDesc scan = palloc(sizeof(CStoreScanDescData));
|
ColumnarScanDesc scan = palloc(sizeof(ColumnarScanDescData));
|
||||||
scan->cs_base.rs_rd = relation;
|
scan->cs_base.rs_rd = relation;
|
||||||
scan->cs_base.rs_snapshot = snapshot;
|
scan->cs_base.rs_snapshot = snapshot;
|
||||||
scan->cs_base.rs_nkeys = nkeys;
|
scan->cs_base.rs_nkeys = nkeys;
|
||||||
|
@ -228,12 +228,12 @@ cstore_beginscan_extended(Relation relation, Snapshot snapshot,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* init_cstore_read_state initializes a column store table read and returns the
|
* init_columnar_read_state initializes a column store table read and returns the
|
||||||
* state.
|
* state.
|
||||||
*/
|
*/
|
||||||
static TableReadState *
|
static TableReadState *
|
||||||
init_cstore_read_state(Relation relation, TupleDesc tupdesc, Bitmapset *attr_needed,
|
init_columnar_read_state(Relation relation, TupleDesc tupdesc, Bitmapset *attr_needed,
|
||||||
List *scanQual)
|
List *scanQual)
|
||||||
{
|
{
|
||||||
List *columnList = RelationColumnList(relation);
|
List *columnList = RelationColumnList(relation);
|
||||||
ListCell *columnCell = NULL;
|
ListCell *columnCell = NULL;
|
||||||
|
@ -250,41 +250,41 @@ init_cstore_read_state(Relation relation, TupleDesc tupdesc, Bitmapset *attr_nee
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TableReadState *readState = CStoreBeginRead(relation, tupdesc, neededColumnList,
|
TableReadState *readState = ColumnarBeginRead(relation, tupdesc, neededColumnList,
|
||||||
scanQual);
|
scanQual);
|
||||||
|
|
||||||
return readState;
|
return readState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_endscan(TableScanDesc sscan)
|
columnar_endscan(TableScanDesc sscan)
|
||||||
{
|
{
|
||||||
CStoreScanDesc scan = (CStoreScanDesc) sscan;
|
ColumnarScanDesc scan = (ColumnarScanDesc) sscan;
|
||||||
if (scan->cs_readState != NULL)
|
if (scan->cs_readState != NULL)
|
||||||
{
|
{
|
||||||
CStoreEndRead(scan->cs_readState);
|
ColumnarEndRead(scan->cs_readState);
|
||||||
scan->cs_readState = NULL;
|
scan->cs_readState = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_rescan(TableScanDesc sscan, ScanKey key, bool set_params,
|
columnar_rescan(TableScanDesc sscan, ScanKey key, bool set_params,
|
||||||
bool allow_strat, bool allow_sync, bool allow_pagemode)
|
bool allow_strat, bool allow_sync, bool allow_pagemode)
|
||||||
{
|
{
|
||||||
CStoreScanDesc scan = (CStoreScanDesc) sscan;
|
ColumnarScanDesc scan = (ColumnarScanDesc) sscan;
|
||||||
if (scan->cs_readState != NULL)
|
if (scan->cs_readState != NULL)
|
||||||
{
|
{
|
||||||
CStoreRescan(scan->cs_readState);
|
ColumnarRescan(scan->cs_readState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cstore_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
|
columnar_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
|
||||||
{
|
{
|
||||||
CStoreScanDesc scan = (CStoreScanDesc) sscan;
|
ColumnarScanDesc scan = (ColumnarScanDesc) sscan;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if this is the first row, initialize read state.
|
* if this is the first row, initialize read state.
|
||||||
|
@ -293,15 +293,15 @@ cstore_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot
|
||||||
{
|
{
|
||||||
MemoryContext oldContext = MemoryContextSwitchTo(scan->scanContext);
|
MemoryContext oldContext = MemoryContextSwitchTo(scan->scanContext);
|
||||||
scan->cs_readState =
|
scan->cs_readState =
|
||||||
init_cstore_read_state(scan->cs_base.rs_rd, slot->tts_tupleDescriptor,
|
init_columnar_read_state(scan->cs_base.rs_rd, slot->tts_tupleDescriptor,
|
||||||
scan->attr_needed, scan->scanQual);
|
scan->attr_needed, scan->scanQual);
|
||||||
MemoryContextSwitchTo(oldContext);
|
MemoryContextSwitchTo(oldContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecClearTuple(slot);
|
ExecClearTuple(slot);
|
||||||
|
|
||||||
bool nextRowFound = CStoreReadNextRow(scan->cs_readState, slot->tts_values,
|
bool nextRowFound = ColumnarReadNextRow(scan->cs_readState, slot->tts_values,
|
||||||
slot->tts_isnull);
|
slot->tts_isnull);
|
||||||
|
|
||||||
if (!nextRowFound)
|
if (!nextRowFound)
|
||||||
{
|
{
|
||||||
|
@ -328,28 +328,28 @@ cstore_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot
|
||||||
|
|
||||||
|
|
||||||
static Size
|
static Size
|
||||||
cstore_parallelscan_estimate(Relation rel)
|
columnar_parallelscan_estimate(Relation rel)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_parallelscan_estimate not implemented");
|
elog(ERROR, "columnar_parallelscan_estimate not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Size
|
static Size
|
||||||
cstore_parallelscan_initialize(Relation rel, ParallelTableScanDesc pscan)
|
columnar_parallelscan_initialize(Relation rel, ParallelTableScanDesc pscan)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_parallelscan_initialize not implemented");
|
elog(ERROR, "columnar_parallelscan_initialize not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_parallelscan_reinitialize(Relation rel, ParallelTableScanDesc pscan)
|
columnar_parallelscan_reinitialize(Relation rel, ParallelTableScanDesc pscan)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_parallelscan_reinitialize not implemented");
|
elog(ERROR, "columnar_parallelscan_reinitialize not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static IndexFetchTableData *
|
static IndexFetchTableData *
|
||||||
cstore_index_fetch_begin(Relation rel)
|
columnar_index_fetch_begin(Relation rel)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("indexes not supported for columnar tables")));
|
errmsg("indexes not supported for columnar tables")));
|
||||||
|
@ -357,7 +357,7 @@ cstore_index_fetch_begin(Relation rel)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_index_fetch_reset(IndexFetchTableData *scan)
|
columnar_index_fetch_reset(IndexFetchTableData *scan)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("indexes not supported for columnar tables")));
|
errmsg("indexes not supported for columnar tables")));
|
||||||
|
@ -365,7 +365,7 @@ cstore_index_fetch_reset(IndexFetchTableData *scan)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_index_fetch_end(IndexFetchTableData *scan)
|
columnar_index_fetch_end(IndexFetchTableData *scan)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("indexes not supported for columnar tables")));
|
errmsg("indexes not supported for columnar tables")));
|
||||||
|
@ -373,11 +373,11 @@ cstore_index_fetch_end(IndexFetchTableData *scan)
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cstore_index_fetch_tuple(struct IndexFetchTableData *scan,
|
columnar_index_fetch_tuple(struct IndexFetchTableData *scan,
|
||||||
ItemPointer tid,
|
ItemPointer tid,
|
||||||
Snapshot snapshot,
|
Snapshot snapshot,
|
||||||
TupleTableSlot *slot,
|
TupleTableSlot *slot,
|
||||||
bool *call_again, bool *all_dead)
|
bool *call_again, bool *all_dead)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("indexes not supported for columnar tables")));
|
errmsg("indexes not supported for columnar tables")));
|
||||||
|
@ -385,58 +385,58 @@ cstore_index_fetch_tuple(struct IndexFetchTableData *scan,
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cstore_fetch_row_version(Relation relation,
|
columnar_fetch_row_version(Relation relation,
|
||||||
ItemPointer tid,
|
ItemPointer tid,
|
||||||
Snapshot snapshot,
|
Snapshot snapshot,
|
||||||
TupleTableSlot *slot)
|
TupleTableSlot *slot)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_fetch_row_version not implemented");
|
elog(ERROR, "columnar_fetch_row_version not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_get_latest_tid(TableScanDesc sscan,
|
columnar_get_latest_tid(TableScanDesc sscan,
|
||||||
ItemPointer tid)
|
ItemPointer tid)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_get_latest_tid not implemented");
|
elog(ERROR, "columnar_get_latest_tid not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cstore_tuple_tid_valid(TableScanDesc scan, ItemPointer tid)
|
columnar_tuple_tid_valid(TableScanDesc scan, ItemPointer tid)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_tuple_tid_valid not implemented");
|
elog(ERROR, "columnar_tuple_tid_valid not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cstore_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
|
columnar_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
|
||||||
Snapshot snapshot)
|
Snapshot snapshot)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TransactionId
|
static TransactionId
|
||||||
cstore_compute_xid_horizon_for_tuples(Relation rel,
|
columnar_compute_xid_horizon_for_tuples(Relation rel,
|
||||||
ItemPointerData *tids,
|
ItemPointerData *tids,
|
||||||
int nitems)
|
int nitems)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_compute_xid_horizon_for_tuples not implemented");
|
elog(ERROR, "columnar_compute_xid_horizon_for_tuples not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
|
columnar_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
|
||||||
int options, BulkInsertState bistate)
|
int options, BulkInsertState bistate)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* cstore_init_write_state allocates the write state in a longer
|
* columnar_init_write_state allocates the write state in a longer
|
||||||
* lasting context, so no need to worry about it.
|
* lasting context, so no need to worry about it.
|
||||||
*/
|
*/
|
||||||
TableWriteState *writeState = cstore_init_write_state(relation,
|
TableWriteState *writeState = columnar_init_write_state(relation,
|
||||||
RelationGetDescr(relation),
|
RelationGetDescr(relation),
|
||||||
GetCurrentSubTransactionId());
|
GetCurrentSubTransactionId());
|
||||||
|
|
||||||
MemoryContext oldContext = MemoryContextSwitchTo(writeState->perTupleContext);
|
MemoryContext oldContext = MemoryContextSwitchTo(writeState->perTupleContext);
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ cstore_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
|
||||||
|
|
||||||
slot_getallattrs(slot);
|
slot_getallattrs(slot);
|
||||||
|
|
||||||
CStoreWriteRow(writeState, slot->tts_values, slot->tts_isnull);
|
ColumnarWriteRow(writeState, slot->tts_values, slot->tts_isnull);
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldContext);
|
MemoryContextSwitchTo(oldContext);
|
||||||
MemoryContextReset(writeState->perTupleContext);
|
MemoryContextReset(writeState->perTupleContext);
|
||||||
|
@ -462,29 +462,29 @@ cstore_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_tuple_insert_speculative(Relation relation, TupleTableSlot *slot,
|
columnar_tuple_insert_speculative(Relation relation, TupleTableSlot *slot,
|
||||||
CommandId cid, int options,
|
CommandId cid, int options,
|
||||||
BulkInsertState bistate, uint32 specToken)
|
BulkInsertState bistate, uint32 specToken)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_tuple_insert_speculative not implemented");
|
elog(ERROR, "columnar_tuple_insert_speculative not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
|
columnar_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
|
||||||
uint32 specToken, bool succeeded)
|
uint32 specToken, bool succeeded)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_tuple_complete_speculative not implemented");
|
elog(ERROR, "columnar_tuple_complete_speculative not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
|
columnar_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
|
||||||
CommandId cid, int options, BulkInsertState bistate)
|
CommandId cid, int options, BulkInsertState bistate)
|
||||||
{
|
{
|
||||||
TableWriteState *writeState = cstore_init_write_state(relation,
|
TableWriteState *writeState = columnar_init_write_state(relation,
|
||||||
RelationGetDescr(relation),
|
RelationGetDescr(relation),
|
||||||
GetCurrentSubTransactionId());
|
GetCurrentSubTransactionId());
|
||||||
|
|
||||||
ColumnarCheckLogicalReplication(relation);
|
ColumnarCheckLogicalReplication(relation);
|
||||||
for (int i = 0; i < ntuples; i++)
|
for (int i = 0; i < ntuples; i++)
|
||||||
|
@ -504,7 +504,7 @@ cstore_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
|
||||||
|
|
||||||
slot_getallattrs(tupleSlot);
|
slot_getallattrs(tupleSlot);
|
||||||
|
|
||||||
CStoreWriteRow(writeState, tupleSlot->tts_values, tupleSlot->tts_isnull);
|
ColumnarWriteRow(writeState, tupleSlot->tts_values, tupleSlot->tts_isnull);
|
||||||
MemoryContextSwitchTo(oldContext);
|
MemoryContextSwitchTo(oldContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,36 +513,36 @@ cstore_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
|
||||||
|
|
||||||
|
|
||||||
static TM_Result
|
static TM_Result
|
||||||
cstore_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
|
columnar_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
|
||||||
Snapshot snapshot, Snapshot crosscheck, bool wait,
|
Snapshot snapshot, Snapshot crosscheck, bool wait,
|
||||||
TM_FailureData *tmfd, bool changingPart)
|
TM_FailureData *tmfd, bool changingPart)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_tuple_delete not implemented");
|
elog(ERROR, "columnar_tuple_delete not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TM_Result
|
static TM_Result
|
||||||
cstore_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot,
|
columnar_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot,
|
||||||
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
|
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
|
||||||
bool wait, TM_FailureData *tmfd,
|
bool wait, TM_FailureData *tmfd,
|
||||||
LockTupleMode *lockmode, bool *update_indexes)
|
LockTupleMode *lockmode, bool *update_indexes)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_tuple_update not implemented");
|
elog(ERROR, "columnar_tuple_update not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TM_Result
|
static TM_Result
|
||||||
cstore_tuple_lock(Relation relation, ItemPointer tid, Snapshot snapshot,
|
columnar_tuple_lock(Relation relation, ItemPointer tid, Snapshot snapshot,
|
||||||
TupleTableSlot *slot, CommandId cid, LockTupleMode mode,
|
TupleTableSlot *slot, CommandId cid, LockTupleMode mode,
|
||||||
LockWaitPolicy wait_policy, uint8 flags,
|
LockWaitPolicy wait_policy, uint8 flags,
|
||||||
TM_FailureData *tmfd)
|
TM_FailureData *tmfd)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_tuple_lock not implemented");
|
elog(ERROR, "columnar_tuple_lock not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_finish_bulk_insert(Relation relation, int options)
|
columnar_finish_bulk_insert(Relation relation, int options)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Nothing to do here. We keep write states live until transaction end.
|
* Nothing to do here. We keep write states live until transaction end.
|
||||||
|
@ -551,11 +551,11 @@ cstore_finish_bulk_insert(Relation relation, int options)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_relation_set_new_filenode(Relation rel,
|
columnar_relation_set_new_filenode(Relation rel,
|
||||||
const RelFileNode *newrnode,
|
const RelFileNode *newrnode,
|
||||||
char persistence,
|
char persistence,
|
||||||
TransactionId *freezeXid,
|
TransactionId *freezeXid,
|
||||||
MultiXactId *minmulti)
|
MultiXactId *minmulti)
|
||||||
{
|
{
|
||||||
if (persistence != RELPERSISTENCE_PERMANENT)
|
if (persistence != RELPERSISTENCE_PERMANENT)
|
||||||
{
|
{
|
||||||
|
@ -584,7 +584,7 @@ cstore_relation_set_new_filenode(Relation rel,
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_relation_nontransactional_truncate(Relation rel)
|
columnar_relation_nontransactional_truncate(Relation rel)
|
||||||
{
|
{
|
||||||
RelFileNode relfilenode = rel->rd_node;
|
RelFileNode relfilenode = rel->rd_node;
|
||||||
|
|
||||||
|
@ -607,28 +607,28 @@ cstore_relation_nontransactional_truncate(Relation rel)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_relation_copy_data(Relation rel, const RelFileNode *newrnode)
|
columnar_relation_copy_data(Relation rel, const RelFileNode *newrnode)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_relation_copy_data not implemented");
|
elog(ERROR, "columnar_relation_copy_data not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cstore_relation_copy_for_cluster is called on VACUUM FULL, at which
|
* columnar_relation_copy_for_cluster is called on VACUUM FULL, at which
|
||||||
* we should copy data from OldHeap to NewHeap.
|
* we should copy data from OldHeap to NewHeap.
|
||||||
*
|
*
|
||||||
* In general TableAM case this can also be called for the CLUSTER command
|
* In general TableAM case this can also be called for the CLUSTER command
|
||||||
* which is not applicable for cstore since it doesn't support indexes.
|
* which is not applicable for cstore since it doesn't support indexes.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
cstore_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
columnar_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
||||||
Relation OldIndex, bool use_sort,
|
Relation OldIndex, bool use_sort,
|
||||||
TransactionId OldestXmin,
|
TransactionId OldestXmin,
|
||||||
TransactionId *xid_cutoff,
|
TransactionId *xid_cutoff,
|
||||||
MultiXactId *multi_cutoff,
|
MultiXactId *multi_cutoff,
|
||||||
double *num_tuples,
|
double *num_tuples,
|
||||||
double *tups_vacuumed,
|
double *tups_vacuumed,
|
||||||
double *tups_recently_dead)
|
double *tups_recently_dead)
|
||||||
{
|
{
|
||||||
TupleDesc sourceDesc = RelationGetDescr(OldHeap);
|
TupleDesc sourceDesc = RelationGetDescr(OldHeap);
|
||||||
TupleDesc targetDesc = RelationGetDescr(NewHeap);
|
TupleDesc targetDesc = RelationGetDescr(NewHeap);
|
||||||
|
@ -650,37 +650,37 @@ cstore_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
||||||
ColumnarOptions cstoreOptions = { 0 };
|
ColumnarOptions cstoreOptions = { 0 };
|
||||||
ReadColumnarOptions(OldHeap->rd_id, &cstoreOptions);
|
ReadColumnarOptions(OldHeap->rd_id, &cstoreOptions);
|
||||||
|
|
||||||
TableWriteState *writeState = CStoreBeginWrite(NewHeap->rd_node,
|
TableWriteState *writeState = ColumnarBeginWrite(NewHeap->rd_node,
|
||||||
cstoreOptions,
|
cstoreOptions,
|
||||||
targetDesc);
|
targetDesc);
|
||||||
|
|
||||||
TableReadState *readState = CStoreBeginRead(OldHeap, sourceDesc,
|
TableReadState *readState = ColumnarBeginRead(OldHeap, sourceDesc,
|
||||||
RelationColumnList(OldHeap), NULL);
|
RelationColumnList(OldHeap), NULL);
|
||||||
|
|
||||||
Datum *values = palloc0(sourceDesc->natts * sizeof(Datum));
|
Datum *values = palloc0(sourceDesc->natts * sizeof(Datum));
|
||||||
bool *nulls = palloc0(sourceDesc->natts * sizeof(bool));
|
bool *nulls = palloc0(sourceDesc->natts * sizeof(bool));
|
||||||
|
|
||||||
*num_tuples = 0;
|
*num_tuples = 0;
|
||||||
|
|
||||||
while (CStoreReadNextRow(readState, values, nulls))
|
while (ColumnarReadNextRow(readState, values, nulls))
|
||||||
{
|
{
|
||||||
CStoreWriteRow(writeState, values, nulls);
|
ColumnarWriteRow(writeState, values, nulls);
|
||||||
(*num_tuples)++;
|
(*num_tuples)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*tups_vacuumed = 0;
|
*tups_vacuumed = 0;
|
||||||
|
|
||||||
CStoreEndWrite(writeState);
|
ColumnarEndWrite(writeState);
|
||||||
CStoreEndRead(readState);
|
ColumnarEndRead(readState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cstore_vacuum_rel implements VACUUM without FULL option.
|
* columnar_vacuum_rel implements VACUUM without FULL option.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
cstore_vacuum_rel(Relation rel, VacuumParams *params,
|
columnar_vacuum_rel(Relation rel, VacuumParams *params,
|
||||||
BufferAccessStrategy bstrategy)
|
BufferAccessStrategy bstrategy)
|
||||||
{
|
{
|
||||||
int elevel = (params->options & VACOPT_VERBOSE) ? INFO : DEBUG2;
|
int elevel = (params->options & VACOPT_VERBOSE) ? INFO : DEBUG2;
|
||||||
|
|
||||||
|
@ -695,7 +695,7 @@ cstore_vacuum_rel(Relation rel, VacuumParams *params,
|
||||||
*/
|
*/
|
||||||
if (params->truncate == VACOPT_TERNARY_ENABLED)
|
if (params->truncate == VACOPT_TERNARY_ENABLED)
|
||||||
{
|
{
|
||||||
TruncateCStore(rel, elevel);
|
TruncateColumnar(rel, elevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,14 +813,14 @@ LogRelationStats(Relation rel, int elevel)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TruncateCStore truncates the unused space at the end of main fork for
|
* TruncateColumnar truncates the unused space at the end of main fork for
|
||||||
* a cstore table. This unused space can be created by aborted transactions.
|
* a cstore table. This unused space can be created by aborted transactions.
|
||||||
*
|
*
|
||||||
* This implementation is based on heap_vacuum_rel in vacuumlazy.c with some
|
* This implementation is based on heap_vacuum_rel in vacuumlazy.c with some
|
||||||
* changes so it suits columnar store relations.
|
* changes so it suits columnar store relations.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
TruncateCStore(Relation rel, int elevel)
|
TruncateColumnar(Relation rel, int elevel)
|
||||||
{
|
{
|
||||||
PGRUsage ru0;
|
PGRUsage ru0;
|
||||||
|
|
||||||
|
@ -939,23 +939,23 @@ ConditionalLockRelationWithTimeout(Relation rel, LOCKMODE lockMode, int timeout,
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cstore_scan_analyze_next_block(TableScanDesc scan, BlockNumber blockno,
|
columnar_scan_analyze_next_block(TableScanDesc scan, BlockNumber blockno,
|
||||||
BufferAccessStrategy bstrategy)
|
BufferAccessStrategy bstrategy)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Our access method is not pages based, i.e. tuples are not confined
|
* Our access method is not pages based, i.e. tuples are not confined
|
||||||
* to pages boundaries. So not much to do here. We return true anyway
|
* to pages boundaries. So not much to do here. We return true anyway
|
||||||
* so acquire_sample_rows() in analyze.c would call our
|
* so acquire_sample_rows() in analyze.c would call our
|
||||||
* cstore_scan_analyze_next_tuple() callback.
|
* columnar_scan_analyze_next_tuple() callback.
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cstore_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
|
columnar_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
|
||||||
double *liverows, double *deadrows,
|
double *liverows, double *deadrows,
|
||||||
TupleTableSlot *slot)
|
TupleTableSlot *slot)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Currently we don't do anything smart to reduce number of rows returned
|
* Currently we don't do anything smart to reduce number of rows returned
|
||||||
|
@ -964,11 +964,11 @@ cstore_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
|
||||||
* tuples from those pages.
|
* tuples from those pages.
|
||||||
*
|
*
|
||||||
* We could do something like that here by choosing sample stripes or chunks,
|
* We could do something like that here by choosing sample stripes or chunks,
|
||||||
* but getting that correct might need quite some work. Since cstore_fdw's
|
* but getting that correct might need quite some work. Since columnar_fdw's
|
||||||
* ANALYZE scanned all rows, as a starter we do the same here and scan all
|
* ANALYZE scanned all rows, as a starter we do the same here and scan all
|
||||||
* rows.
|
* rows.
|
||||||
*/
|
*/
|
||||||
if (cstore_getnextslot(scan, ForwardScanDirection, slot))
|
if (columnar_getnextslot(scan, ForwardScanDirection, slot))
|
||||||
{
|
{
|
||||||
(*liverows)++;
|
(*liverows)++;
|
||||||
return true;
|
return true;
|
||||||
|
@ -979,17 +979,17 @@ cstore_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
|
||||||
|
|
||||||
|
|
||||||
static double
|
static double
|
||||||
cstore_index_build_range_scan(Relation heapRelation,
|
columnar_index_build_range_scan(Relation heapRelation,
|
||||||
Relation indexRelation,
|
Relation indexRelation,
|
||||||
IndexInfo *indexInfo,
|
IndexInfo *indexInfo,
|
||||||
bool allow_sync,
|
bool allow_sync,
|
||||||
bool anyvisible,
|
bool anyvisible,
|
||||||
bool progress,
|
bool progress,
|
||||||
BlockNumber start_blockno,
|
BlockNumber start_blockno,
|
||||||
BlockNumber numblocks,
|
BlockNumber numblocks,
|
||||||
IndexBuildCallback callback,
|
IndexBuildCallback callback,
|
||||||
void *callback_state,
|
void *callback_state,
|
||||||
TableScanDesc scan)
|
TableScanDesc scan)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("indexes not supported for columnar tables")));
|
errmsg("indexes not supported for columnar tables")));
|
||||||
|
@ -997,11 +997,11 @@ cstore_index_build_range_scan(Relation heapRelation,
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_index_validate_scan(Relation heapRelation,
|
columnar_index_validate_scan(Relation heapRelation,
|
||||||
Relation indexRelation,
|
Relation indexRelation,
|
||||||
IndexInfo *indexInfo,
|
IndexInfo *indexInfo,
|
||||||
Snapshot snapshot,
|
Snapshot snapshot,
|
||||||
ValidateIndexState *state)
|
ValidateIndexState *state)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("indexes not supported for columnar tables")));
|
errmsg("indexes not supported for columnar tables")));
|
||||||
|
@ -1009,7 +1009,7 @@ cstore_index_validate_scan(Relation heapRelation,
|
||||||
|
|
||||||
|
|
||||||
static uint64
|
static uint64
|
||||||
cstore_relation_size(Relation rel, ForkNumber forkNumber)
|
columnar_relation_size(Relation rel, ForkNumber forkNumber)
|
||||||
{
|
{
|
||||||
uint64 nblocks = 0;
|
uint64 nblocks = 0;
|
||||||
|
|
||||||
|
@ -1034,20 +1034,20 @@ cstore_relation_size(Relation rel, ForkNumber forkNumber)
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cstore_relation_needs_toast_table(Relation rel)
|
columnar_relation_needs_toast_table(Relation rel)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstore_estimate_rel_size(Relation rel, int32 *attr_widths,
|
columnar_estimate_rel_size(Relation rel, int32 *attr_widths,
|
||||||
BlockNumber *pages, double *tuples,
|
BlockNumber *pages, double *tuples,
|
||||||
double *allvisfrac)
|
double *allvisfrac)
|
||||||
{
|
{
|
||||||
RelationOpenSmgr(rel);
|
RelationOpenSmgr(rel);
|
||||||
*pages = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM);
|
*pages = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM);
|
||||||
*tuples = CStoreTableRowCount(rel);
|
*tuples = ColumnarTableRowCount(rel);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Append-only, so everything is visible except in-progress or rolled-back
|
* Append-only, so everything is visible except in-progress or rolled-back
|
||||||
|
@ -1060,22 +1060,22 @@ cstore_estimate_rel_size(Relation rel, int32 *attr_widths,
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cstore_scan_sample_next_block(TableScanDesc scan, SampleScanState *scanstate)
|
columnar_scan_sample_next_block(TableScanDesc scan, SampleScanState *scanstate)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_scan_sample_next_block not implemented");
|
elog(ERROR, "columnar_scan_sample_next_block not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cstore_scan_sample_next_tuple(TableScanDesc scan, SampleScanState *scanstate,
|
columnar_scan_sample_next_tuple(TableScanDesc scan, SampleScanState *scanstate,
|
||||||
TupleTableSlot *slot)
|
TupleTableSlot *slot)
|
||||||
{
|
{
|
||||||
elog(ERROR, "columnar_scan_sample_next_tuple not implemented");
|
elog(ERROR, "columnar_scan_sample_next_tuple not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CStoreXactCallback(XactEvent event, void *arg)
|
ColumnarXactCallback(XactEvent event, void *arg)
|
||||||
{
|
{
|
||||||
switch (event)
|
switch (event)
|
||||||
{
|
{
|
||||||
|
@ -1106,8 +1106,8 @@ CStoreXactCallback(XactEvent event, void *arg)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CStoreSubXactCallback(SubXactEvent event, SubTransactionId mySubid,
|
ColumnarSubXactCallback(SubXactEvent event, SubTransactionId mySubid,
|
||||||
SubTransactionId parentSubid, void *arg)
|
SubTransactionId parentSubid, void *arg)
|
||||||
{
|
{
|
||||||
switch (event)
|
switch (event)
|
||||||
{
|
{
|
||||||
|
@ -1134,15 +1134,15 @@ CStoreSubXactCallback(SubXactEvent event, SubTransactionId mySubid,
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cstore_tableam_init()
|
columnar_tableam_init()
|
||||||
{
|
{
|
||||||
RegisterXactCallback(CStoreXactCallback, NULL);
|
RegisterXactCallback(ColumnarXactCallback, NULL);
|
||||||
RegisterSubXactCallback(CStoreSubXactCallback, NULL);
|
RegisterSubXactCallback(ColumnarSubXactCallback, NULL);
|
||||||
|
|
||||||
PrevObjectAccessHook = object_access_hook;
|
PrevObjectAccessHook = object_access_hook;
|
||||||
object_access_hook = CStoreTableAMObjectAccessHook;
|
object_access_hook = ColumnarTableAMObjectAccessHook;
|
||||||
|
|
||||||
cstore_customscan_init();
|
columnar_customscan_init();
|
||||||
|
|
||||||
TTSOpsColumnar = TTSOpsVirtual;
|
TTSOpsColumnar = TTSOpsVirtual;
|
||||||
TTSOpsColumnar.copy_heap_tuple = ColumnarSlotCopyHeapTuple;
|
TTSOpsColumnar.copy_heap_tuple = ColumnarSlotCopyHeapTuple;
|
||||||
|
@ -1150,7 +1150,7 @@ cstore_tableam_init()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cstore_tableam_finish()
|
columnar_tableam_finish()
|
||||||
{
|
{
|
||||||
object_access_hook = PrevObjectAccessHook;
|
object_access_hook = PrevObjectAccessHook;
|
||||||
}
|
}
|
||||||
|
@ -1162,7 +1162,7 @@ cstore_tableam_finish()
|
||||||
int64
|
int64
|
||||||
ColumnarGetChunksFiltered(TableScanDesc scanDesc)
|
ColumnarGetChunksFiltered(TableScanDesc scanDesc)
|
||||||
{
|
{
|
||||||
CStoreScanDesc cstoreScanDesc = (CStoreScanDesc) scanDesc;
|
ColumnarScanDesc cstoreScanDesc = (ColumnarScanDesc) scanDesc;
|
||||||
TableReadState *readState = cstoreScanDesc->cs_readState;
|
TableReadState *readState = cstoreScanDesc->cs_readState;
|
||||||
|
|
||||||
if (readState != NULL)
|
if (readState != NULL)
|
||||||
|
@ -1193,7 +1193,7 @@ ColumnarSlotCopyHeapTuple(TupleTableSlot *slot)
|
||||||
* requires it. See the qsort in acquire_sample_rows() and
|
* requires it. See the qsort in acquire_sample_rows() and
|
||||||
* also compare_rows in backend/commands/analyze.c.
|
* also compare_rows in backend/commands/analyze.c.
|
||||||
*
|
*
|
||||||
* slot->tts_tid is filled in cstore_getnextslot.
|
* slot->tts_tid is filled in columnar_getnextslot.
|
||||||
*/
|
*/
|
||||||
tuple->t_self = slot->tts_tid;
|
tuple->t_self = slot->tts_tid;
|
||||||
|
|
||||||
|
@ -1202,12 +1202,12 @@ ColumnarSlotCopyHeapTuple(TupleTableSlot *slot)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreTableDropHook
|
* ColumnarTableDropHook
|
||||||
*
|
*
|
||||||
* Clean-up resources for columnar tables.
|
* Clean-up resources for columnar tables.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
CStoreTableDropHook(Oid relid)
|
ColumnarTableDropHook(Oid relid)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Lock relation to prevent it from being dropped and to avoid
|
* Lock relation to prevent it from being dropped and to avoid
|
||||||
|
@ -1215,7 +1215,7 @@ CStoreTableDropHook(Oid relid)
|
||||||
*/
|
*/
|
||||||
LockRelationOid(relid, AccessShareLock);
|
LockRelationOid(relid, AccessShareLock);
|
||||||
|
|
||||||
if (IsCStoreTableAmTable(relid))
|
if (IsColumnarTableAmTable(relid))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Drop metadata. No need to drop storage here since for
|
* Drop metadata. No need to drop storage here since for
|
||||||
|
@ -1239,7 +1239,7 @@ CStoreTableDropHook(Oid relid)
|
||||||
* Reject AFTER ... FOR EACH ROW triggers on columnar tables.
|
* Reject AFTER ... FOR EACH ROW triggers on columnar tables.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
CStoreTriggerCreateHook(Oid tgid)
|
ColumnarTriggerCreateHook(Oid tgid)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Fetch the pg_trigger tuple by the Oid of the trigger
|
* Fetch the pg_trigger tuple by the Oid of the trigger
|
||||||
|
@ -1272,7 +1272,7 @@ CStoreTriggerCreateHook(Oid tgid)
|
||||||
table_close(tgrel, AccessShareLock);
|
table_close(tgrel, AccessShareLock);
|
||||||
|
|
||||||
if (TRIGGER_FOR_ROW(tgtype) && TRIGGER_FOR_AFTER(tgtype) &&
|
if (TRIGGER_FOR_ROW(tgtype) && TRIGGER_FOR_AFTER(tgtype) &&
|
||||||
IsCStoreTableAmTable(tgrelid))
|
IsColumnarTableAmTable(tgrelid))
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg(
|
errmsg(
|
||||||
|
@ -1286,8 +1286,8 @@ CStoreTriggerCreateHook(Oid tgid)
|
||||||
* Capture create/drop events and dispatch to the proper action.
|
* Capture create/drop events and dispatch to the proper action.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
CStoreTableAMObjectAccessHook(ObjectAccessType access, Oid classId, Oid objectId,
|
ColumnarTableAMObjectAccessHook(ObjectAccessType access, Oid classId, Oid objectId,
|
||||||
int subId, void *arg)
|
int subId, void *arg)
|
||||||
{
|
{
|
||||||
if (PrevObjectAccessHook)
|
if (PrevObjectAccessHook)
|
||||||
{
|
{
|
||||||
|
@ -1297,21 +1297,21 @@ CStoreTableAMObjectAccessHook(ObjectAccessType access, Oid classId, Oid objectId
|
||||||
/* dispatch to the proper action */
|
/* dispatch to the proper action */
|
||||||
if (access == OAT_DROP && classId == RelationRelationId && !OidIsValid(subId))
|
if (access == OAT_DROP && classId == RelationRelationId && !OidIsValid(subId))
|
||||||
{
|
{
|
||||||
CStoreTableDropHook(objectId);
|
ColumnarTableDropHook(objectId);
|
||||||
}
|
}
|
||||||
else if (access == OAT_POST_CREATE && classId == TriggerRelationId)
|
else if (access == OAT_POST_CREATE && classId == TriggerRelationId)
|
||||||
{
|
{
|
||||||
CStoreTriggerCreateHook(objectId);
|
ColumnarTriggerCreateHook(objectId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IsCStoreTableAmTable returns true if relation has cstore_tableam
|
* IsColumnarTableAmTable returns true if relation has columnar_tableam
|
||||||
* access method. This can be called before extension creation.
|
* access method. This can be called before extension creation.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
IsCStoreTableAmTable(Oid relationId)
|
IsColumnarTableAmTable(Oid relationId)
|
||||||
{
|
{
|
||||||
if (!OidIsValid(relationId))
|
if (!OidIsValid(relationId))
|
||||||
{
|
{
|
||||||
|
@ -1330,66 +1330,66 @@ IsCStoreTableAmTable(Oid relationId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const TableAmRoutine cstore_am_methods = {
|
static const TableAmRoutine columnar_am_methods = {
|
||||||
.type = T_TableAmRoutine,
|
.type = T_TableAmRoutine,
|
||||||
|
|
||||||
.slot_callbacks = cstore_slot_callbacks,
|
.slot_callbacks = columnar_slot_callbacks,
|
||||||
|
|
||||||
.scan_begin = cstore_beginscan,
|
.scan_begin = columnar_beginscan,
|
||||||
.scan_end = cstore_endscan,
|
.scan_end = columnar_endscan,
|
||||||
.scan_rescan = cstore_rescan,
|
.scan_rescan = columnar_rescan,
|
||||||
.scan_getnextslot = cstore_getnextslot,
|
.scan_getnextslot = columnar_getnextslot,
|
||||||
|
|
||||||
.parallelscan_estimate = cstore_parallelscan_estimate,
|
.parallelscan_estimate = columnar_parallelscan_estimate,
|
||||||
.parallelscan_initialize = cstore_parallelscan_initialize,
|
.parallelscan_initialize = columnar_parallelscan_initialize,
|
||||||
.parallelscan_reinitialize = cstore_parallelscan_reinitialize,
|
.parallelscan_reinitialize = columnar_parallelscan_reinitialize,
|
||||||
|
|
||||||
.index_fetch_begin = cstore_index_fetch_begin,
|
.index_fetch_begin = columnar_index_fetch_begin,
|
||||||
.index_fetch_reset = cstore_index_fetch_reset,
|
.index_fetch_reset = columnar_index_fetch_reset,
|
||||||
.index_fetch_end = cstore_index_fetch_end,
|
.index_fetch_end = columnar_index_fetch_end,
|
||||||
.index_fetch_tuple = cstore_index_fetch_tuple,
|
.index_fetch_tuple = columnar_index_fetch_tuple,
|
||||||
|
|
||||||
.tuple_fetch_row_version = cstore_fetch_row_version,
|
.tuple_fetch_row_version = columnar_fetch_row_version,
|
||||||
.tuple_get_latest_tid = cstore_get_latest_tid,
|
.tuple_get_latest_tid = columnar_get_latest_tid,
|
||||||
.tuple_tid_valid = cstore_tuple_tid_valid,
|
.tuple_tid_valid = columnar_tuple_tid_valid,
|
||||||
.tuple_satisfies_snapshot = cstore_tuple_satisfies_snapshot,
|
.tuple_satisfies_snapshot = columnar_tuple_satisfies_snapshot,
|
||||||
.compute_xid_horizon_for_tuples = cstore_compute_xid_horizon_for_tuples,
|
.compute_xid_horizon_for_tuples = columnar_compute_xid_horizon_for_tuples,
|
||||||
|
|
||||||
.tuple_insert = cstore_tuple_insert,
|
.tuple_insert = columnar_tuple_insert,
|
||||||
.tuple_insert_speculative = cstore_tuple_insert_speculative,
|
.tuple_insert_speculative = columnar_tuple_insert_speculative,
|
||||||
.tuple_complete_speculative = cstore_tuple_complete_speculative,
|
.tuple_complete_speculative = columnar_tuple_complete_speculative,
|
||||||
.multi_insert = cstore_multi_insert,
|
.multi_insert = columnar_multi_insert,
|
||||||
.tuple_delete = cstore_tuple_delete,
|
.tuple_delete = columnar_tuple_delete,
|
||||||
.tuple_update = cstore_tuple_update,
|
.tuple_update = columnar_tuple_update,
|
||||||
.tuple_lock = cstore_tuple_lock,
|
.tuple_lock = columnar_tuple_lock,
|
||||||
.finish_bulk_insert = cstore_finish_bulk_insert,
|
.finish_bulk_insert = columnar_finish_bulk_insert,
|
||||||
|
|
||||||
.relation_set_new_filenode = cstore_relation_set_new_filenode,
|
.relation_set_new_filenode = columnar_relation_set_new_filenode,
|
||||||
.relation_nontransactional_truncate = cstore_relation_nontransactional_truncate,
|
.relation_nontransactional_truncate = columnar_relation_nontransactional_truncate,
|
||||||
.relation_copy_data = cstore_relation_copy_data,
|
.relation_copy_data = columnar_relation_copy_data,
|
||||||
.relation_copy_for_cluster = cstore_relation_copy_for_cluster,
|
.relation_copy_for_cluster = columnar_relation_copy_for_cluster,
|
||||||
.relation_vacuum = cstore_vacuum_rel,
|
.relation_vacuum = columnar_vacuum_rel,
|
||||||
.scan_analyze_next_block = cstore_scan_analyze_next_block,
|
.scan_analyze_next_block = columnar_scan_analyze_next_block,
|
||||||
.scan_analyze_next_tuple = cstore_scan_analyze_next_tuple,
|
.scan_analyze_next_tuple = columnar_scan_analyze_next_tuple,
|
||||||
.index_build_range_scan = cstore_index_build_range_scan,
|
.index_build_range_scan = columnar_index_build_range_scan,
|
||||||
.index_validate_scan = cstore_index_validate_scan,
|
.index_validate_scan = columnar_index_validate_scan,
|
||||||
|
|
||||||
.relation_size = cstore_relation_size,
|
.relation_size = columnar_relation_size,
|
||||||
.relation_needs_toast_table = cstore_relation_needs_toast_table,
|
.relation_needs_toast_table = columnar_relation_needs_toast_table,
|
||||||
|
|
||||||
.relation_estimate_size = cstore_estimate_rel_size,
|
.relation_estimate_size = columnar_estimate_rel_size,
|
||||||
|
|
||||||
.scan_bitmap_next_block = NULL,
|
.scan_bitmap_next_block = NULL,
|
||||||
.scan_bitmap_next_tuple = NULL,
|
.scan_bitmap_next_tuple = NULL,
|
||||||
.scan_sample_next_block = cstore_scan_sample_next_block,
|
.scan_sample_next_block = columnar_scan_sample_next_block,
|
||||||
.scan_sample_next_tuple = cstore_scan_sample_next_tuple
|
.scan_sample_next_tuple = columnar_scan_sample_next_tuple
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const TableAmRoutine *
|
const TableAmRoutine *
|
||||||
GetColumnarTableAmRoutine(void)
|
GetColumnarTableAmRoutine(void)
|
||||||
{
|
{
|
||||||
return &cstore_am_methods;
|
return &columnar_am_methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1397,7 +1397,7 @@ PG_FUNCTION_INFO_V1(columnar_handler);
|
||||||
Datum
|
Datum
|
||||||
columnar_handler(PG_FUNCTION_ARGS)
|
columnar_handler(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
PG_RETURN_POINTER(&cstore_am_methods);
|
PG_RETURN_POINTER(&columnar_am_methods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1573,7 +1573,7 @@ alter_columnar_table_set(PG_FUNCTION_ARGS)
|
||||||
Oid relationId = PG_GETARG_OID(0);
|
Oid relationId = PG_GETARG_OID(0);
|
||||||
|
|
||||||
Relation rel = table_open(relationId, AccessExclusiveLock); /* ALTER TABLE LOCK */
|
Relation rel = table_open(relationId, AccessExclusiveLock); /* ALTER TABLE LOCK */
|
||||||
if (!IsCStoreTableAmTable(relationId))
|
if (!IsColumnarTableAmTable(relationId))
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errmsg("table %s is not a columnar table",
|
ereport(ERROR, (errmsg("table %s is not a columnar table",
|
||||||
quote_identifier(RelationGetRelationName(rel)))));
|
quote_identifier(RelationGetRelationName(rel)))));
|
||||||
|
@ -1680,7 +1680,7 @@ alter_columnar_table_reset(PG_FUNCTION_ARGS)
|
||||||
Oid relationId = PG_GETARG_OID(0);
|
Oid relationId = PG_GETARG_OID(0);
|
||||||
|
|
||||||
Relation rel = table_open(relationId, AccessExclusiveLock); /* ALTER TABLE LOCK */
|
Relation rel = table_open(relationId, AccessExclusiveLock); /* ALTER TABLE LOCK */
|
||||||
if (!IsCStoreTableAmTable(relationId))
|
if (!IsColumnarTableAmTable(relationId))
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errmsg("table %s is not a columnar table",
|
ereport(ERROR, (errmsg("table %s is not a columnar table",
|
||||||
quote_identifier(RelationGetRelationName(rel)))));
|
quote_identifier(RelationGetRelationName(rel)))));
|
||||||
|
@ -1695,7 +1695,7 @@ alter_columnar_table_reset(PG_FUNCTION_ARGS)
|
||||||
/* chunk_row_count => true */
|
/* chunk_row_count => true */
|
||||||
if (!PG_ARGISNULL(1) && PG_GETARG_BOOL(1))
|
if (!PG_ARGISNULL(1) && PG_GETARG_BOOL(1))
|
||||||
{
|
{
|
||||||
options.chunkRowCount = cstore_chunk_row_count;
|
options.chunkRowCount = columnar_chunk_row_count;
|
||||||
ereport(DEBUG1,
|
ereport(DEBUG1,
|
||||||
(errmsg("resetting chunk row count to %d", options.chunkRowCount)));
|
(errmsg("resetting chunk row count to %d", options.chunkRowCount)));
|
||||||
}
|
}
|
||||||
|
@ -1703,7 +1703,7 @@ alter_columnar_table_reset(PG_FUNCTION_ARGS)
|
||||||
/* stripe_row_count => true */
|
/* stripe_row_count => true */
|
||||||
if (!PG_ARGISNULL(2) && PG_GETARG_BOOL(2))
|
if (!PG_ARGISNULL(2) && PG_GETARG_BOOL(2))
|
||||||
{
|
{
|
||||||
options.stripeRowCount = cstore_stripe_row_count;
|
options.stripeRowCount = columnar_stripe_row_count;
|
||||||
ereport(DEBUG1,
|
ereport(DEBUG1,
|
||||||
(errmsg("resetting stripe row count to " UINT64_FORMAT,
|
(errmsg("resetting stripe row count to " UINT64_FORMAT,
|
||||||
options.stripeRowCount)));
|
options.stripeRowCount)));
|
||||||
|
@ -1712,7 +1712,7 @@ alter_columnar_table_reset(PG_FUNCTION_ARGS)
|
||||||
/* compression => true */
|
/* compression => true */
|
||||||
if (!PG_ARGISNULL(3) && PG_GETARG_BOOL(3))
|
if (!PG_ARGISNULL(3) && PG_GETARG_BOOL(3))
|
||||||
{
|
{
|
||||||
options.compressionType = cstore_compression;
|
options.compressionType = columnar_compression;
|
||||||
ereport(DEBUG1, (errmsg("resetting compression to %s",
|
ereport(DEBUG1, (errmsg("resetting compression to %s",
|
||||||
CompressionTypeStr(options.compressionType))));
|
CompressionTypeStr(options.compressionType))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,16 +53,16 @@ static Datum DatumCopy(Datum datum, bool datumTypeByValue, int datumTypeLength);
|
||||||
static StringInfo CopyStringInfo(StringInfo sourceString);
|
static StringInfo CopyStringInfo(StringInfo sourceString);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreBeginWrite initializes a cstore data load operation and returns a table
|
* ColumnarBeginWrite initializes a cstore data load operation and returns a table
|
||||||
* handle. This handle should be used for adding the row values and finishing the
|
* handle. This handle should be used for adding the row values and finishing the
|
||||||
* data load operation. If the cstore footer file already exists, we read the
|
* data load operation. If the cstore footer file already exists, we read the
|
||||||
* footer and then seek to right after the last stripe where the new stripes
|
* footer and then seek to right after the last stripe where the new stripes
|
||||||
* will be added.
|
* will be added.
|
||||||
*/
|
*/
|
||||||
TableWriteState *
|
TableWriteState *
|
||||||
CStoreBeginWrite(RelFileNode relfilenode,
|
ColumnarBeginWrite(RelFileNode relfilenode,
|
||||||
ColumnarOptions options,
|
ColumnarOptions options,
|
||||||
TupleDesc tupleDescriptor)
|
TupleDesc tupleDescriptor)
|
||||||
{
|
{
|
||||||
/* get comparison function pointers for each of the columns */
|
/* get comparison function pointers for each of the columns */
|
||||||
uint32 columnCount = tupleDescriptor->natts;
|
uint32 columnCount = tupleDescriptor->natts;
|
||||||
|
@ -110,7 +110,7 @@ CStoreBeginWrite(RelFileNode relfilenode,
|
||||||
writeState->chunkData = chunkData;
|
writeState->chunkData = chunkData;
|
||||||
writeState->compressionBuffer = NULL;
|
writeState->compressionBuffer = NULL;
|
||||||
writeState->perTupleContext = AllocSetContextCreate(CurrentMemoryContext,
|
writeState->perTupleContext = AllocSetContextCreate(CurrentMemoryContext,
|
||||||
"CStore per tuple context",
|
"Columnar per tuple context",
|
||||||
ALLOCSET_DEFAULT_SIZES);
|
ALLOCSET_DEFAULT_SIZES);
|
||||||
|
|
||||||
return writeState;
|
return writeState;
|
||||||
|
@ -118,7 +118,7 @@ CStoreBeginWrite(RelFileNode relfilenode,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreWriteRow adds a row to the cstore file. If the stripe is not initialized,
|
* ColumnarWriteRow adds a row to the cstore file. If the stripe is not initialized,
|
||||||
* we create structures to hold stripe data and skip list. Then, we serialize and
|
* we create structures to hold stripe data and skip list. Then, we serialize and
|
||||||
* append data to serialized value buffer for each of the columns and update
|
* append data to serialized value buffer for each of the columns and update
|
||||||
* corresponding skip nodes. Then, whole chunk data is compressed at every
|
* corresponding skip nodes. Then, whole chunk data is compressed at every
|
||||||
|
@ -126,7 +126,7 @@ CStoreBeginWrite(RelFileNode relfilenode,
|
||||||
* the stripe, and add its metadata to the table footer.
|
* the stripe, and add its metadata to the table footer.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CStoreWriteRow(TableWriteState *writeState, Datum *columnValues, bool *columnNulls)
|
ColumnarWriteRow(TableWriteState *writeState, Datum *columnValues, bool *columnNulls)
|
||||||
{
|
{
|
||||||
uint32 columnIndex = 0;
|
uint32 columnIndex = 0;
|
||||||
StripeBuffers *stripeBuffers = writeState->stripeBuffers;
|
StripeBuffers *stripeBuffers = writeState->stripeBuffers;
|
||||||
|
@ -206,7 +206,7 @@ CStoreWriteRow(TableWriteState *writeState, Datum *columnValues, bool *columnNul
|
||||||
stripeBuffers->rowCount++;
|
stripeBuffers->rowCount++;
|
||||||
if (stripeBuffers->rowCount >= options->stripeRowCount)
|
if (stripeBuffers->rowCount >= options->stripeRowCount)
|
||||||
{
|
{
|
||||||
CStoreFlushPendingWrites(writeState);
|
ColumnarFlushPendingWrites(writeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldContext);
|
MemoryContextSwitchTo(oldContext);
|
||||||
|
@ -214,15 +214,15 @@ CStoreWriteRow(TableWriteState *writeState, Datum *columnValues, bool *columnNul
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreEndWrite finishes a cstore data load operation. If we have an unflushed
|
* ColumnarEndWrite finishes a cstore data load operation. If we have an unflushed
|
||||||
* stripe, we flush it. Then, we sync and close the cstore data file. Last, we
|
* stripe, we flush it. Then, we sync and close the cstore data file. Last, we
|
||||||
* flush the footer to a temporary file, and atomically rename this temporary
|
* flush the footer to a temporary file, and atomically rename this temporary
|
||||||
* file to the original footer file.
|
* file to the original footer file.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CStoreEndWrite(TableWriteState *writeState)
|
ColumnarEndWrite(TableWriteState *writeState)
|
||||||
{
|
{
|
||||||
CStoreFlushPendingWrites(writeState);
|
ColumnarFlushPendingWrites(writeState);
|
||||||
|
|
||||||
MemoryContextDelete(writeState->stripeWriteContext);
|
MemoryContextDelete(writeState->stripeWriteContext);
|
||||||
pfree(writeState->comparisonFunctionArray);
|
pfree(writeState->comparisonFunctionArray);
|
||||||
|
@ -232,7 +232,7 @@ CStoreEndWrite(TableWriteState *writeState)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CStoreFlushPendingWrites(TableWriteState *writeState)
|
ColumnarFlushPendingWrites(TableWriteState *writeState)
|
||||||
{
|
{
|
||||||
StripeBuffers *stripeBuffers = writeState->stripeBuffers;
|
StripeBuffers *stripeBuffers = writeState->stripeBuffers;
|
||||||
if (stripeBuffers != NULL)
|
if (stripeBuffers != NULL)
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
void
|
void
|
||||||
columnar_init(void)
|
columnar_init(void)
|
||||||
{
|
{
|
||||||
cstore_init();
|
columnar_init_gucs();
|
||||||
#ifdef HAS_TABLEAM
|
#ifdef HAS_TABLEAM
|
||||||
cstore_tableam_init();
|
columnar_tableam_init();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,6 @@ void
|
||||||
columnar_fini(void)
|
columnar_fini(void)
|
||||||
{
|
{
|
||||||
#if HAS_TABLEAM
|
#if HAS_TABLEAM
|
||||||
cstore_tableam_finish();
|
columnar_tableam_finish();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,8 @@ CleanupWriteStateMap(void *arg)
|
||||||
|
|
||||||
|
|
||||||
TableWriteState *
|
TableWriteState *
|
||||||
cstore_init_write_state(Relation relation, TupleDesc tupdesc,
|
columnar_init_write_state(Relation relation, TupleDesc tupdesc,
|
||||||
SubTransactionId currentSubXid)
|
SubTransactionId currentSubXid)
|
||||||
{
|
{
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
|
@ -182,9 +182,9 @@ cstore_init_write_state(Relation relation, TupleDesc tupdesc,
|
||||||
ReadColumnarOptions(relation->rd_id, &cstoreOptions);
|
ReadColumnarOptions(relation->rd_id, &cstoreOptions);
|
||||||
|
|
||||||
SubXidWriteState *stackEntry = palloc0(sizeof(SubXidWriteState));
|
SubXidWriteState *stackEntry = palloc0(sizeof(SubXidWriteState));
|
||||||
stackEntry->writeState = CStoreBeginWrite(relation->rd_node,
|
stackEntry->writeState = ColumnarBeginWrite(relation->rd_node,
|
||||||
cstoreOptions,
|
cstoreOptions,
|
||||||
tupdesc);
|
tupdesc);
|
||||||
stackEntry->subXid = currentSubXid;
|
stackEntry->subXid = currentSubXid;
|
||||||
stackEntry->next = hashEntry->writeStateStack;
|
stackEntry->next = hashEntry->writeStateStack;
|
||||||
hashEntry->writeStateStack = stackEntry;
|
hashEntry->writeStateStack = stackEntry;
|
||||||
|
@ -215,7 +215,7 @@ FlushWriteStateForRelfilenode(Oid relfilenode, SubTransactionId currentSubXid)
|
||||||
SubXidWriteState *stackEntry = entry->writeStateStack;
|
SubXidWriteState *stackEntry = entry->writeStateStack;
|
||||||
if (stackEntry->subXid == currentSubXid)
|
if (stackEntry->subXid == currentSubXid)
|
||||||
{
|
{
|
||||||
CStoreFlushPendingWrites(stackEntry->writeState);
|
ColumnarFlushPendingWrites(stackEntry->writeState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ PopWriteStateForAllRels(SubTransactionId currentSubXid, SubTransactionId parentS
|
||||||
{
|
{
|
||||||
if (commit)
|
if (commit)
|
||||||
{
|
{
|
||||||
CStoreEndWrite(stackHead->writeState);
|
ColumnarEndWrite(stackHead->writeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->writeStateStack = stackHead->next;
|
entry->writeStateStack = stackHead->next;
|
||||||
|
|
|
@ -660,7 +660,7 @@ GetPreLoadTableCreationCommands(Oid relationId, bool includeSequenceDefaults,
|
||||||
#if PG_VERSION_NUM >= 120000
|
#if PG_VERSION_NUM >= 120000
|
||||||
|
|
||||||
/* add columnar options for cstore tables */
|
/* add columnar options for cstore tables */
|
||||||
if (accessMethod == NULL && IsCStoreTableAmTable(relationId))
|
if (accessMethod == NULL && IsColumnarTableAmTable(relationId))
|
||||||
{
|
{
|
||||||
TableDDLCommand *cstoreOptionsDDL = ColumnarGetTableOptionsDDL(relationId);
|
TableDDLCommand *cstoreOptionsDDL = ColumnarGetTableOptionsDDL(relationId);
|
||||||
if (cstoreOptionsDDL != NULL)
|
if (cstoreOptionsDDL != NULL)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* cstore.h
|
* cstore.h
|
||||||
*
|
*
|
||||||
* Type and function declarations for CStore
|
* Type and function declarations for Columnar
|
||||||
*
|
*
|
||||||
* Copyright (c) 2016, Citus Data, Inc.
|
* Copyright (c) 2016, Citus Data, Inc.
|
||||||
*
|
*
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
#define COMPRESSION_STRING_NONE "none"
|
#define COMPRESSION_STRING_NONE "none"
|
||||||
#define COMPRESSION_STRING_PG_LZ "pglz"
|
#define COMPRESSION_STRING_PG_LZ "pglz"
|
||||||
|
|
||||||
/* CStore file signature */
|
/* Columnar file signature */
|
||||||
#define CSTORE_MAGIC_NUMBER "citus_cstore"
|
#define CSTORE_MAGIC_NUMBER "citus_cstore"
|
||||||
#define CSTORE_VERSION_MAJOR 1
|
#define CSTORE_VERSION_MAJOR 1
|
||||||
#define CSTORE_VERSION_MINOR 7
|
#define CSTORE_VERSION_MINOR 7
|
||||||
|
@ -265,34 +265,34 @@ typedef struct TableWriteState
|
||||||
StringInfo compressionBuffer;
|
StringInfo compressionBuffer;
|
||||||
} TableWriteState;
|
} TableWriteState;
|
||||||
|
|
||||||
extern int cstore_compression;
|
extern int columnar_compression;
|
||||||
extern int cstore_stripe_row_count;
|
extern int columnar_stripe_row_count;
|
||||||
extern int cstore_chunk_row_count;
|
extern int columnar_chunk_row_count;
|
||||||
extern int columnar_compression_level;
|
extern int columnar_compression_level;
|
||||||
|
|
||||||
extern void cstore_init(void);
|
extern void columnar_init_gucs(void);
|
||||||
|
|
||||||
extern CompressionType ParseCompressionType(const char *compressionTypeString);
|
extern CompressionType ParseCompressionType(const char *compressionTypeString);
|
||||||
|
|
||||||
/* Function declarations for writing to a cstore file */
|
/* Function declarations for writing to a cstore file */
|
||||||
extern TableWriteState * CStoreBeginWrite(RelFileNode relfilenode,
|
extern TableWriteState * ColumnarBeginWrite(RelFileNode relfilenode,
|
||||||
ColumnarOptions options,
|
ColumnarOptions options,
|
||||||
TupleDesc tupleDescriptor);
|
TupleDesc tupleDescriptor);
|
||||||
extern void CStoreWriteRow(TableWriteState *state, Datum *columnValues,
|
extern void ColumnarWriteRow(TableWriteState *state, Datum *columnValues,
|
||||||
bool *columnNulls);
|
bool *columnNulls);
|
||||||
extern void CStoreFlushPendingWrites(TableWriteState *state);
|
extern void ColumnarFlushPendingWrites(TableWriteState *state);
|
||||||
extern void CStoreEndWrite(TableWriteState *state);
|
extern void ColumnarEndWrite(TableWriteState *state);
|
||||||
extern bool ContainsPendingWrites(TableWriteState *state);
|
extern bool ContainsPendingWrites(TableWriteState *state);
|
||||||
|
|
||||||
/* Function declarations for reading from a cstore file */
|
/* Function declarations for reading from a cstore file */
|
||||||
extern TableReadState * CStoreBeginRead(Relation relation,
|
extern TableReadState * ColumnarBeginRead(Relation relation,
|
||||||
TupleDesc tupleDescriptor,
|
TupleDesc tupleDescriptor,
|
||||||
List *projectedColumnList, List *qualConditions);
|
List *projectedColumnList,
|
||||||
extern bool CStoreReadFinished(TableReadState *state);
|
List *qualConditions);
|
||||||
extern bool CStoreReadNextRow(TableReadState *state, Datum *columnValues,
|
extern bool ColumnarReadNextRow(TableReadState *state, Datum *columnValues,
|
||||||
bool *columnNulls);
|
bool *columnNulls);
|
||||||
extern void CStoreRescan(TableReadState *readState);
|
extern void ColumnarRescan(TableReadState *readState);
|
||||||
extern void CStoreEndRead(TableReadState *state);
|
extern void ColumnarEndRead(TableReadState *state);
|
||||||
|
|
||||||
/* Function declarations for common functions */
|
/* Function declarations for common functions */
|
||||||
extern FmgrInfo * GetFunctionInfoOrNull(Oid typeId, Oid accessMethodId,
|
extern FmgrInfo * GetFunctionInfoOrNull(Oid typeId, Oid accessMethodId,
|
||||||
|
@ -300,7 +300,7 @@ extern FmgrInfo * GetFunctionInfoOrNull(Oid typeId, Oid accessMethodId,
|
||||||
extern ChunkData * CreateEmptyChunkData(uint32 columnCount, bool *columnMask,
|
extern ChunkData * CreateEmptyChunkData(uint32 columnCount, bool *columnMask,
|
||||||
uint32 chunkRowCount);
|
uint32 chunkRowCount);
|
||||||
extern void FreeChunkData(ChunkData *chunkData);
|
extern void FreeChunkData(ChunkData *chunkData);
|
||||||
extern uint64 CStoreTableRowCount(Relation relation);
|
extern uint64 ColumnarTableRowCount(Relation relation);
|
||||||
extern bool CompressBuffer(StringInfo inputBuffer,
|
extern bool CompressBuffer(StringInfo inputBuffer,
|
||||||
StringInfo outputBuffer,
|
StringInfo outputBuffer,
|
||||||
CompressionType compressionType,
|
CompressionType compressionType,
|
||||||
|
@ -309,7 +309,7 @@ extern StringInfo DecompressBuffer(StringInfo buffer, CompressionType compressio
|
||||||
uint64 decompressedSize);
|
uint64 decompressedSize);
|
||||||
extern const char * CompressionTypeStr(CompressionType type);
|
extern const char * CompressionTypeStr(CompressionType type);
|
||||||
|
|
||||||
/* cstore_metadata_tables.c */
|
/* columnar_metadata_tables.c */
|
||||||
extern void InitColumnarOptions(Oid regclass);
|
extern void InitColumnarOptions(Oid regclass);
|
||||||
extern void SetColumnarOptions(Oid regclass, ColumnarOptions *options);
|
extern void SetColumnarOptions(Oid regclass, ColumnarOptions *options);
|
||||||
extern bool DeleteColumnarTableOptions(Oid regclass, bool missingOk);
|
extern bool DeleteColumnarTableOptions(Oid regclass, bool missingOk);
|
||||||
|
@ -317,9 +317,9 @@ extern bool ReadColumnarOptions(Oid regclass, ColumnarOptions *options);
|
||||||
extern void WriteToSmgr(Relation relation, uint64 logicalOffset,
|
extern void WriteToSmgr(Relation relation, uint64 logicalOffset,
|
||||||
char *data, uint32 dataLength);
|
char *data, uint32 dataLength);
|
||||||
extern StringInfo ReadFromSmgr(Relation rel, uint64 offset, uint32 size);
|
extern StringInfo ReadFromSmgr(Relation rel, uint64 offset, uint32 size);
|
||||||
extern bool IsCStoreTableAmTable(Oid relationId);
|
extern bool IsColumnarTableAmTable(Oid relationId);
|
||||||
|
|
||||||
/* cstore_metadata_tables.c */
|
/* columnar_metadata_tables.c */
|
||||||
extern void DeleteMetadataRows(RelFileNode relfilenode);
|
extern void DeleteMetadataRows(RelFileNode relfilenode);
|
||||||
extern List * StripesForRelfilenode(RelFileNode relfilenode);
|
extern List * StripesForRelfilenode(RelFileNode relfilenode);
|
||||||
extern uint64 GetHighestUsedAddress(RelFileNode relfilenode);
|
extern uint64 GetHighestUsedAddress(RelFileNode relfilenode);
|
||||||
|
@ -336,9 +336,9 @@ extern Datum columnar_relation_storageid(PG_FUNCTION_ARGS);
|
||||||
|
|
||||||
|
|
||||||
/* write_state_management.c */
|
/* write_state_management.c */
|
||||||
extern TableWriteState * cstore_init_write_state(Relation relation, TupleDesc
|
extern TableWriteState * columnar_init_write_state(Relation relation, TupleDesc
|
||||||
tupdesc,
|
tupdesc,
|
||||||
SubTransactionId currentSubXid);
|
SubTransactionId currentSubXid);
|
||||||
extern void FlushWriteStateForRelfilenode(Oid relfilenode, SubTransactionId
|
extern void FlushWriteStateForRelfilenode(Oid relfilenode, SubTransactionId
|
||||||
currentSubXid);
|
currentSubXid);
|
||||||
extern void FlushWriteStateForAllRels(SubTransactionId currentSubXid, SubTransactionId
|
extern void FlushWriteStateForAllRels(SubTransactionId currentSubXid, SubTransactionId
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#ifndef COLUMNAR_CUSTOMSCAN_H
|
#ifndef COLUMNAR_CUSTOMSCAN_H
|
||||||
#define COLUMNAR_CUSTOMSCAN_H
|
#define COLUMNAR_CUSTOMSCAN_H
|
||||||
|
|
||||||
void cstore_customscan_init(void);
|
void columnar_customscan_init(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* COLUMNAR_CUSTOMSCAN_H */
|
#endif /* COLUMNAR_CUSTOMSCAN_H */
|
||||||
|
|
|
@ -10,16 +10,16 @@
|
||||||
#include "distributed/coordinator_protocol.h"
|
#include "distributed/coordinator_protocol.h"
|
||||||
|
|
||||||
const TableAmRoutine * GetColumnarTableAmRoutine(void);
|
const TableAmRoutine * GetColumnarTableAmRoutine(void);
|
||||||
extern void cstore_tableam_init(void);
|
extern void columnar_tableam_init(void);
|
||||||
extern void cstore_tableam_finish(void);
|
extern void columnar_tableam_finish(void);
|
||||||
|
|
||||||
extern TableScanDesc cstore_beginscan_extended(Relation relation, Snapshot snapshot,
|
extern TableScanDesc columnar_beginscan_extended(Relation relation, Snapshot snapshot,
|
||||||
int nkeys, ScanKey key,
|
int nkeys, ScanKey key,
|
||||||
ParallelTableScanDesc parallel_scan,
|
ParallelTableScanDesc parallel_scan,
|
||||||
uint32 flags, Bitmapset *attr_needed,
|
uint32 flags, Bitmapset *attr_needed,
|
||||||
List *scanQual);
|
List *scanQual);
|
||||||
extern int64 ColumnarGetChunksFiltered(TableScanDesc scanDesc);
|
extern int64 ColumnarGetChunksFiltered(TableScanDesc scanDesc);
|
||||||
extern bool IsCStoreTableAmTable(Oid relationId);
|
extern bool IsColumnarTableAmTable(Oid relationId);
|
||||||
extern TableDDLCommand * ColumnarGetTableOptionsDDL(Oid relationId);
|
extern TableDDLCommand * ColumnarGetTableOptionsDDL(Oid relationId);
|
||||||
extern char * GetShardedTableDDLCommandColumnar(uint64 shardId, void *context);
|
extern char * GetShardedTableDDLCommandColumnar(uint64 shardId, void *context);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue