mirror of https://github.com/citusdata/citus.git
Merge branch 'master' into fix-bug-create-citus-local-table-with-stats
commit
887b67953b
|
@ -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,83 +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 ColumnarScan_ReScanCustomScan(CustomScanState *node);
|
||||||
|
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 = NULL,
|
.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(
|
||||||
|
@ -113,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,
|
||||||
|
@ -133,7 +136,7 @@ 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 */
|
||||||
|
@ -142,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;
|
||||||
|
@ -168,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")));
|
||||||
|
|
||||||
|
@ -181,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
|
||||||
|
@ -206,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);
|
||||||
|
@ -247,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);
|
||||||
|
@ -272,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;
|
||||||
|
|
||||||
|
@ -287,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;
|
||||||
|
@ -335,7 +338,7 @@ CStoreAttrNeeded(ScanState *ss)
|
||||||
|
|
||||||
|
|
||||||
static TupleTableSlot *
|
static TupleTableSlot *
|
||||||
CStoreScanNext(CStoreScanState *cstorescanstate)
|
ColumnarScanNext(ColumnarScanState *cstorescanstate)
|
||||||
{
|
{
|
||||||
CustomScanState *node = (CustomScanState *) cstorescanstate;
|
CustomScanState *node = (CustomScanState *) cstorescanstate;
|
||||||
|
|
||||||
|
@ -351,13 +354,13 @@ 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);
|
||||||
|
@ -381,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
|
||||||
|
@ -429,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)
|
||||||
|
@ -439,4 +442,19 @@ CStoreScan_ReScanCustomScan(CustomScanState *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
ColumnarScan_ExplainCustomScan(CustomScanState *node, List *ancestors,
|
||||||
|
ExplainState *es)
|
||||||
|
{
|
||||||
|
TableScanDesc scanDesc = node->ss.ss_currentScanDesc;
|
||||||
|
|
||||||
|
if (scanDesc != NULL)
|
||||||
|
{
|
||||||
|
int64 chunksFiltered = ColumnarGetChunksFiltered(scanDesc);
|
||||||
|
ExplainPropertyInteger("Columnar Chunks Removed by Filter", NULL,
|
||||||
|
chunksFiltered, es);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* HAS_TABLEAM */
|
#endif /* HAS_TABLEAM */
|
||||||
|
|
|
@ -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 ColumnarStripeRelationId(void);
|
||||||
static Oid CStoreStripesIndexRelationId(void);
|
static Oid ColumnarStripeIndexRelationId(void);
|
||||||
static Oid ColumnarOptionsRelationId(void);
|
static Oid ColumnarOptionsRelationId(void);
|
||||||
static Oid ColumnarOptionsIndexRegclass(void);
|
static Oid ColumnarOptionsIndexRegclass(void);
|
||||||
static Oid CStoreSkipNodesRelationId(void);
|
static Oid ColumnarChunkRelationId(void);
|
||||||
static Oid CStoreSkipNodesIndexRelationId(void);
|
static Oid ColumnarChunkIndexRelationId(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_stripe 8
|
||||||
#define Anum_cstore_stripes_storageid 1
|
#define Anum_columnar_stripe_storageid 1
|
||||||
#define Anum_cstore_stripes_stripe 2
|
#define Anum_columnar_stripe_stripe 2
|
||||||
#define Anum_cstore_stripes_file_offset 3
|
#define Anum_columnar_stripe_file_offset 3
|
||||||
#define Anum_cstore_stripes_data_length 4
|
#define Anum_columnar_stripe_data_length 4
|
||||||
#define Anum_cstore_stripes_column_count 5
|
#define Anum_columnar_stripe_column_count 5
|
||||||
#define Anum_cstore_stripes_chunk_count 6
|
#define Anum_columnar_stripe_chunk_count 6
|
||||||
#define Anum_cstore_stripes_chunk_row_count 7
|
#define Anum_columnar_stripe_chunk_row_count 7
|
||||||
#define Anum_cstore_stripes_row_count 8
|
#define Anum_columnar_stripe_row_count 8
|
||||||
|
|
||||||
/* constants for cstore_skipnodes */
|
/* constants for columnar.chunk */
|
||||||
#define Natts_cstore_skipnodes 14
|
#define Natts_columnar_chunk 14
|
||||||
#define Anum_cstore_skipnodes_storageid 1
|
#define Anum_columnar_chunk_storageid 1
|
||||||
#define Anum_cstore_skipnodes_stripe 2
|
#define Anum_columnar_chunk_stripe 2
|
||||||
#define Anum_cstore_skipnodes_attr 3
|
#define Anum_columnar_chunk_attr 3
|
||||||
#define Anum_cstore_skipnodes_chunk 4
|
#define Anum_columnar_chunk_chunk 4
|
||||||
#define Anum_cstore_skipnodes_row_count 5
|
#define Anum_columnar_chunk_row_count 5
|
||||||
#define Anum_cstore_skipnodes_minimum_value 6
|
#define Anum_columnar_chunk_minimum_value 6
|
||||||
#define Anum_cstore_skipnodes_maximum_value 7
|
#define Anum_columnar_chunk_maximum_value 7
|
||||||
#define Anum_cstore_skipnodes_value_stream_offset 8
|
#define Anum_columnar_chunk_value_stream_offset 8
|
||||||
#define Anum_cstore_skipnodes_value_stream_length 9
|
#define Anum_columnar_chunk_value_stream_length 9
|
||||||
#define Anum_cstore_skipnodes_exists_stream_offset 10
|
#define Anum_columnar_chunk_exists_stream_offset 10
|
||||||
#define Anum_cstore_skipnodes_exists_stream_length 11
|
#define Anum_columnar_chunk_exists_stream_length 11
|
||||||
#define Anum_cstore_skipnodes_value_compression_type 12
|
#define Anum_columnar_chunk_value_compression_type 12
|
||||||
#define Anum_cstore_skipnodes_value_compression_level 13
|
#define Anum_columnar_chunk_value_compression_level 13
|
||||||
#define Anum_cstore_skipnodes_value_decompressed_size 14
|
#define Anum_columnar_chunk_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,61 +393,61 @@ ReadColumnarOptions(Oid regclass, ColumnarOptions *options)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SaveStripeSkipList saves StripeSkipList for a given stripe as rows
|
* SaveStripeSkipList saves chunkList for a given stripe as rows
|
||||||
* of cstore_skipnodes.
|
* of columnar.chunk.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SaveStripeSkipList(RelFileNode relfilenode, uint64 stripe, StripeSkipList *stripeSkipList,
|
SaveStripeSkipList(RelFileNode relfilenode, uint64 stripe, StripeSkipList *chunkList,
|
||||||
TupleDesc tupleDescriptor)
|
TupleDesc tupleDescriptor)
|
||||||
{
|
{
|
||||||
uint32 columnIndex = 0;
|
uint32 columnIndex = 0;
|
||||||
uint32 chunkIndex = 0;
|
uint32 chunkIndex = 0;
|
||||||
uint32 columnCount = stripeSkipList->columnCount;
|
uint32 columnCount = chunkList->columnCount;
|
||||||
|
|
||||||
ColumnarMetapage *metapage = ReadMetapage(relfilenode, false);
|
ColumnarMetapage *metapage = ReadMetapage(relfilenode, false);
|
||||||
Oid cstoreSkipNodesOid = CStoreSkipNodesRelationId();
|
Oid columnarChunkOid = ColumnarChunkRelationId();
|
||||||
Relation cstoreSkipNodes = table_open(cstoreSkipNodesOid, RowExclusiveLock);
|
Relation columnarChunk = table_open(columnarChunkOid, RowExclusiveLock);
|
||||||
ModifyState *modifyState = StartModifyRelation(cstoreSkipNodes);
|
ModifyState *modifyState = StartModifyRelation(columnarChunk);
|
||||||
|
|
||||||
for (columnIndex = 0; columnIndex < columnCount; columnIndex++)
|
for (columnIndex = 0; columnIndex < columnCount; columnIndex++)
|
||||||
{
|
{
|
||||||
for (chunkIndex = 0; chunkIndex < stripeSkipList->chunkCount; chunkIndex++)
|
for (chunkIndex = 0; chunkIndex < chunkList->chunkCount; chunkIndex++)
|
||||||
{
|
{
|
||||||
ColumnChunkSkipNode *skipNode =
|
ColumnChunkSkipNode *chunk =
|
||||||
&stripeSkipList->chunkSkipNodeArray[columnIndex][chunkIndex];
|
&chunkList->chunkSkipNodeArray[columnIndex][chunkIndex];
|
||||||
|
|
||||||
Datum values[Natts_cstore_skipnodes] = {
|
Datum values[Natts_columnar_chunk] = {
|
||||||
UInt64GetDatum(metapage->storageId),
|
UInt64GetDatum(metapage->storageId),
|
||||||
Int64GetDatum(stripe),
|
Int64GetDatum(stripe),
|
||||||
Int32GetDatum(columnIndex + 1),
|
Int32GetDatum(columnIndex + 1),
|
||||||
Int32GetDatum(chunkIndex),
|
Int32GetDatum(chunkIndex),
|
||||||
Int64GetDatum(skipNode->rowCount),
|
Int64GetDatum(chunk->rowCount),
|
||||||
0, /* to be filled below */
|
0, /* to be filled below */
|
||||||
0, /* to be filled below */
|
0, /* to be filled below */
|
||||||
Int64GetDatum(skipNode->valueChunkOffset),
|
Int64GetDatum(chunk->valueChunkOffset),
|
||||||
Int64GetDatum(skipNode->valueLength),
|
Int64GetDatum(chunk->valueLength),
|
||||||
Int64GetDatum(skipNode->existsChunkOffset),
|
Int64GetDatum(chunk->existsChunkOffset),
|
||||||
Int64GetDatum(skipNode->existsLength),
|
Int64GetDatum(chunk->existsLength),
|
||||||
Int32GetDatum(skipNode->valueCompressionType),
|
Int32GetDatum(chunk->valueCompressionType),
|
||||||
Int32GetDatum(skipNode->valueCompressionLevel),
|
Int32GetDatum(chunk->valueCompressionLevel),
|
||||||
Int64GetDatum(skipNode->decompressedValueSize)
|
Int64GetDatum(chunk->decompressedValueSize)
|
||||||
};
|
};
|
||||||
|
|
||||||
bool nulls[Natts_cstore_skipnodes] = { false };
|
bool nulls[Natts_columnar_chunk] = { false };
|
||||||
|
|
||||||
if (skipNode->hasMinMax)
|
if (chunk->hasMinMax)
|
||||||
{
|
{
|
||||||
values[Anum_cstore_skipnodes_minimum_value - 1] =
|
values[Anum_columnar_chunk_minimum_value - 1] =
|
||||||
PointerGetDatum(DatumToBytea(skipNode->minimumValue,
|
PointerGetDatum(DatumToBytea(chunk->minimumValue,
|
||||||
&tupleDescriptor->attrs[columnIndex]));
|
&tupleDescriptor->attrs[columnIndex]));
|
||||||
values[Anum_cstore_skipnodes_maximum_value - 1] =
|
values[Anum_columnar_chunk_maximum_value - 1] =
|
||||||
PointerGetDatum(DatumToBytea(skipNode->maximumValue,
|
PointerGetDatum(DatumToBytea(chunk->maximumValue,
|
||||||
&tupleDescriptor->attrs[columnIndex]));
|
&tupleDescriptor->attrs[columnIndex]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nulls[Anum_cstore_skipnodes_minimum_value - 1] = true;
|
nulls[Anum_columnar_chunk_minimum_value - 1] = true;
|
||||||
nulls[Anum_cstore_skipnodes_maximum_value - 1] = true;
|
nulls[Anum_columnar_chunk_maximum_value - 1] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertTupleAndEnforceConstraints(modifyState, values, nulls);
|
InsertTupleAndEnforceConstraints(modifyState, values, nulls);
|
||||||
|
@ -452,14 +455,14 @@ SaveStripeSkipList(RelFileNode relfilenode, uint64 stripe, StripeSkipList *strip
|
||||||
}
|
}
|
||||||
|
|
||||||
FinishModifyRelation(modifyState);
|
FinishModifyRelation(modifyState);
|
||||||
table_close(cstoreSkipNodes, NoLock);
|
table_close(columnarChunk, NoLock);
|
||||||
|
|
||||||
CommandCounterIncrement();
|
CommandCounterIncrement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ReadStripeSkipList fetches StripeSkipList for a given stripe.
|
* ReadStripeSkipList fetches chunk metadata for a given stripe.
|
||||||
*/
|
*/
|
||||||
StripeSkipList *
|
StripeSkipList *
|
||||||
ReadStripeSkipList(RelFileNode relfilenode, uint64 stripe, TupleDesc tupleDescriptor,
|
ReadStripeSkipList(RelFileNode relfilenode, uint64 stripe, TupleDesc tupleDescriptor,
|
||||||
|
@ -472,109 +475,109 @@ ReadStripeSkipList(RelFileNode relfilenode, uint64 stripe, TupleDesc tupleDescri
|
||||||
|
|
||||||
ColumnarMetapage *metapage = ReadMetapage(relfilenode, false);
|
ColumnarMetapage *metapage = ReadMetapage(relfilenode, false);
|
||||||
|
|
||||||
Oid cstoreSkipNodesOid = CStoreSkipNodesRelationId();
|
Oid columnarChunkOid = ColumnarChunkRelationId();
|
||||||
Relation cstoreSkipNodes = table_open(cstoreSkipNodesOid, AccessShareLock);
|
Relation columnarChunk = table_open(columnarChunkOid, AccessShareLock);
|
||||||
Relation index = index_open(CStoreSkipNodesIndexRelationId(), AccessShareLock);
|
Relation index = index_open(ColumnarChunkIndexRelationId(), AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&scanKey[0], Anum_cstore_skipnodes_storageid,
|
ScanKeyInit(&scanKey[0], Anum_columnar_chunk_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_chunk_stripe,
|
||||||
BTEqualStrategyNumber, F_OIDEQ, Int32GetDatum(stripe));
|
BTEqualStrategyNumber, F_OIDEQ, Int32GetDatum(stripe));
|
||||||
|
|
||||||
SysScanDesc scanDescriptor = systable_beginscan_ordered(cstoreSkipNodes, index, NULL,
|
SysScanDesc scanDescriptor = systable_beginscan_ordered(columnarChunk, index, NULL,
|
||||||
2, scanKey);
|
2, scanKey);
|
||||||
|
|
||||||
StripeSkipList *skipList = palloc0(sizeof(StripeSkipList));
|
StripeSkipList *chunkList = palloc0(sizeof(StripeSkipList));
|
||||||
skipList->chunkCount = chunkCount;
|
chunkList->chunkCount = chunkCount;
|
||||||
skipList->columnCount = columnCount;
|
chunkList->columnCount = columnCount;
|
||||||
skipList->chunkSkipNodeArray = palloc0(columnCount * sizeof(ColumnChunkSkipNode *));
|
chunkList->chunkSkipNodeArray = palloc0(columnCount * sizeof(ColumnChunkSkipNode *));
|
||||||
for (columnIndex = 0; columnIndex < columnCount; columnIndex++)
|
for (columnIndex = 0; columnIndex < columnCount; columnIndex++)
|
||||||
{
|
{
|
||||||
skipList->chunkSkipNodeArray[columnIndex] =
|
chunkList->chunkSkipNodeArray[columnIndex] =
|
||||||
palloc0(chunkCount * sizeof(ColumnChunkSkipNode));
|
palloc0(chunkCount * sizeof(ColumnChunkSkipNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (HeapTupleIsValid(heapTuple = systable_getnext(scanDescriptor)))
|
while (HeapTupleIsValid(heapTuple = systable_getnext(scanDescriptor)))
|
||||||
{
|
{
|
||||||
Datum datumArray[Natts_cstore_skipnodes];
|
Datum datumArray[Natts_columnar_chunk];
|
||||||
bool isNullArray[Natts_cstore_skipnodes];
|
bool isNullArray[Natts_columnar_chunk];
|
||||||
|
|
||||||
heap_deform_tuple(heapTuple, RelationGetDescr(cstoreSkipNodes), datumArray,
|
heap_deform_tuple(heapTuple, RelationGetDescr(columnarChunk), datumArray,
|
||||||
isNullArray);
|
isNullArray);
|
||||||
|
|
||||||
int32 attr = DatumGetInt32(datumArray[Anum_cstore_skipnodes_attr - 1]);
|
int32 attr = DatumGetInt32(datumArray[Anum_columnar_chunk_attr - 1]);
|
||||||
int32 chunkIndex = DatumGetInt32(datumArray[Anum_cstore_skipnodes_chunk - 1]);
|
int32 chunkIndex = DatumGetInt32(datumArray[Anum_columnar_chunk_chunk - 1]);
|
||||||
|
|
||||||
if (attr <= 0 || attr > columnCount)
|
if (attr <= 0 || attr > columnCount)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errmsg("invalid stripe skipnode entry"),
|
ereport(ERROR, (errmsg("invalid columnar chunk entry"),
|
||||||
errdetail("Attribute number out of range: %d", attr)));
|
errdetail("Attribute number out of range: %d", attr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunkIndex < 0 || chunkIndex >= chunkCount)
|
if (chunkIndex < 0 || chunkIndex >= chunkCount)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errmsg("invalid stripe skipnode entry"),
|
ereport(ERROR, (errmsg("invalid columnar chunk entry"),
|
||||||
errdetail("Chunk number out of range: %d", chunkIndex)));
|
errdetail("Chunk number out of range: %d", chunkIndex)));
|
||||||
}
|
}
|
||||||
|
|
||||||
columnIndex = attr - 1;
|
columnIndex = attr - 1;
|
||||||
|
|
||||||
ColumnChunkSkipNode *skipNode =
|
ColumnChunkSkipNode *chunk =
|
||||||
&skipList->chunkSkipNodeArray[columnIndex][chunkIndex];
|
&chunkList->chunkSkipNodeArray[columnIndex][chunkIndex];
|
||||||
skipNode->rowCount = DatumGetInt64(datumArray[Anum_cstore_skipnodes_row_count -
|
chunk->rowCount = DatumGetInt64(datumArray[Anum_columnar_chunk_row_count -
|
||||||
1]);
|
1]);
|
||||||
skipNode->valueChunkOffset =
|
chunk->valueChunkOffset =
|
||||||
DatumGetInt64(datumArray[Anum_cstore_skipnodes_value_stream_offset - 1]);
|
DatumGetInt64(datumArray[Anum_columnar_chunk_value_stream_offset - 1]);
|
||||||
skipNode->valueLength =
|
chunk->valueLength =
|
||||||
DatumGetInt64(datumArray[Anum_cstore_skipnodes_value_stream_length - 1]);
|
DatumGetInt64(datumArray[Anum_columnar_chunk_value_stream_length - 1]);
|
||||||
skipNode->existsChunkOffset =
|
chunk->existsChunkOffset =
|
||||||
DatumGetInt64(datumArray[Anum_cstore_skipnodes_exists_stream_offset - 1]);
|
DatumGetInt64(datumArray[Anum_columnar_chunk_exists_stream_offset - 1]);
|
||||||
skipNode->existsLength =
|
chunk->existsLength =
|
||||||
DatumGetInt64(datumArray[Anum_cstore_skipnodes_exists_stream_length - 1]);
|
DatumGetInt64(datumArray[Anum_columnar_chunk_exists_stream_length - 1]);
|
||||||
skipNode->valueCompressionType =
|
chunk->valueCompressionType =
|
||||||
DatumGetInt32(datumArray[Anum_cstore_skipnodes_value_compression_type - 1]);
|
DatumGetInt32(datumArray[Anum_columnar_chunk_value_compression_type - 1]);
|
||||||
skipNode->valueCompressionLevel =
|
chunk->valueCompressionLevel =
|
||||||
DatumGetInt32(datumArray[Anum_cstore_skipnodes_value_compression_level - 1]);
|
DatumGetInt32(datumArray[Anum_columnar_chunk_value_compression_level - 1]);
|
||||||
skipNode->decompressedValueSize =
|
chunk->decompressedValueSize =
|
||||||
DatumGetInt64(datumArray[Anum_cstore_skipnodes_value_decompressed_size - 1]);
|
DatumGetInt64(datumArray[Anum_columnar_chunk_value_decompressed_size - 1]);
|
||||||
|
|
||||||
if (isNullArray[Anum_cstore_skipnodes_minimum_value - 1] ||
|
if (isNullArray[Anum_columnar_chunk_minimum_value - 1] ||
|
||||||
isNullArray[Anum_cstore_skipnodes_maximum_value - 1])
|
isNullArray[Anum_columnar_chunk_maximum_value - 1])
|
||||||
{
|
{
|
||||||
skipNode->hasMinMax = false;
|
chunk->hasMinMax = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bytea *minValue = DatumGetByteaP(
|
bytea *minValue = DatumGetByteaP(
|
||||||
datumArray[Anum_cstore_skipnodes_minimum_value - 1]);
|
datumArray[Anum_columnar_chunk_minimum_value - 1]);
|
||||||
bytea *maxValue = DatumGetByteaP(
|
bytea *maxValue = DatumGetByteaP(
|
||||||
datumArray[Anum_cstore_skipnodes_maximum_value - 1]);
|
datumArray[Anum_columnar_chunk_maximum_value - 1]);
|
||||||
|
|
||||||
skipNode->minimumValue =
|
chunk->minimumValue =
|
||||||
ByteaToDatum(minValue, &tupleDescriptor->attrs[columnIndex]);
|
ByteaToDatum(minValue, &tupleDescriptor->attrs[columnIndex]);
|
||||||
skipNode->maximumValue =
|
chunk->maximumValue =
|
||||||
ByteaToDatum(maxValue, &tupleDescriptor->attrs[columnIndex]);
|
ByteaToDatum(maxValue, &tupleDescriptor->attrs[columnIndex]);
|
||||||
|
|
||||||
skipNode->hasMinMax = true;
|
chunk->hasMinMax = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
systable_endscan_ordered(scanDescriptor);
|
systable_endscan_ordered(scanDescriptor);
|
||||||
index_close(index, NoLock);
|
index_close(index, NoLock);
|
||||||
table_close(cstoreSkipNodes, NoLock);
|
table_close(columnarChunk, NoLock);
|
||||||
|
|
||||||
return skipList;
|
return chunkList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* InsertStripeMetadataRow adds a row to cstore_stripes.
|
* InsertStripeMetadataRow adds a row to columnar.stripe.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
InsertStripeMetadataRow(uint64 storageId, StripeMetadata *stripe)
|
InsertStripeMetadataRow(uint64 storageId, StripeMetadata *stripe)
|
||||||
{
|
{
|
||||||
bool nulls[Natts_cstore_stripes] = { 0 };
|
bool nulls[Natts_columnar_stripe] = { 0 };
|
||||||
Datum values[Natts_cstore_stripes] = {
|
Datum values[Natts_columnar_stripe] = {
|
||||||
UInt64GetDatum(storageId),
|
UInt64GetDatum(storageId),
|
||||||
Int64GetDatum(stripe->id),
|
Int64GetDatum(stripe->id),
|
||||||
Int64GetDatum(stripe->fileOffset),
|
Int64GetDatum(stripe->fileOffset),
|
||||||
|
@ -585,10 +588,10 @@ InsertStripeMetadataRow(uint64 storageId, StripeMetadata *stripe)
|
||||||
Int64GetDatum(stripe->rowCount)
|
Int64GetDatum(stripe->rowCount)
|
||||||
};
|
};
|
||||||
|
|
||||||
Oid cstoreStripesOid = CStoreStripesRelationId();
|
Oid columnarStripesOid = ColumnarStripeRelationId();
|
||||||
Relation cstoreStripes = table_open(cstoreStripesOid, RowExclusiveLock);
|
Relation columnarStripes = table_open(columnarStripesOid, RowExclusiveLock);
|
||||||
|
|
||||||
ModifyState *modifyState = StartModifyRelation(cstoreStripes);
|
ModifyState *modifyState = StartModifyRelation(columnarStripes);
|
||||||
|
|
||||||
InsertTupleAndEnforceConstraints(modifyState, values, nulls);
|
InsertTupleAndEnforceConstraints(modifyState, values, nulls);
|
||||||
|
|
||||||
|
@ -596,7 +599,7 @@ InsertStripeMetadataRow(uint64 storageId, StripeMetadata *stripe)
|
||||||
|
|
||||||
CommandCounterIncrement();
|
CommandCounterIncrement();
|
||||||
|
|
||||||
table_close(cstoreStripes, NoLock);
|
table_close(columnarStripes, NoLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -679,7 +682,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.stripe. It is guaranteed that concurrent
|
||||||
* writes won't overwrite the returned stripe.
|
* writes won't overwrite the returned stripe.
|
||||||
*/
|
*/
|
||||||
StripeMetadata
|
StripeMetadata
|
||||||
|
@ -760,54 +763,54 @@ 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_stripe_storageid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ, Int32GetDatum(storageId));
|
BTEqualStrategyNumber, F_OIDEQ, Int32GetDatum(storageId));
|
||||||
|
|
||||||
Oid cstoreStripesOid = CStoreStripesRelationId();
|
Oid columnarStripesOid = ColumnarStripeRelationId();
|
||||||
|
|
||||||
Relation cstoreStripes = table_open(cstoreStripesOid, AccessShareLock);
|
Relation columnarStripes = table_open(columnarStripesOid, AccessShareLock);
|
||||||
Relation index = index_open(CStoreStripesIndexRelationId(), AccessShareLock);
|
Relation index = index_open(ColumnarStripeIndexRelationId(), AccessShareLock);
|
||||||
TupleDesc tupleDescriptor = RelationGetDescr(cstoreStripes);
|
TupleDesc tupleDescriptor = RelationGetDescr(columnarStripes);
|
||||||
|
|
||||||
SysScanDesc scanDescriptor = systable_beginscan_ordered(cstoreStripes, index,
|
SysScanDesc scanDescriptor = systable_beginscan_ordered(columnarStripes, index,
|
||||||
snapshot, 1,
|
snapshot, 1,
|
||||||
scanKey);
|
scanKey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(heapTuple = systable_getnext(scanDescriptor)))
|
while (HeapTupleIsValid(heapTuple = systable_getnext(scanDescriptor)))
|
||||||
{
|
{
|
||||||
Datum datumArray[Natts_cstore_stripes];
|
Datum datumArray[Natts_columnar_stripe];
|
||||||
bool isNullArray[Natts_cstore_stripes];
|
bool isNullArray[Natts_columnar_stripe];
|
||||||
|
|
||||||
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_stripe_stripe - 1]);
|
||||||
stripeMetadata->fileOffset = DatumGetInt64(
|
stripeMetadata->fileOffset = DatumGetInt64(
|
||||||
datumArray[Anum_cstore_stripes_file_offset - 1]);
|
datumArray[Anum_columnar_stripe_file_offset - 1]);
|
||||||
stripeMetadata->dataLength = DatumGetInt64(
|
stripeMetadata->dataLength = DatumGetInt64(
|
||||||
datumArray[Anum_cstore_stripes_data_length - 1]);
|
datumArray[Anum_columnar_stripe_data_length - 1]);
|
||||||
stripeMetadata->columnCount = DatumGetInt32(
|
stripeMetadata->columnCount = DatumGetInt32(
|
||||||
datumArray[Anum_cstore_stripes_column_count - 1]);
|
datumArray[Anum_columnar_stripe_column_count - 1]);
|
||||||
stripeMetadata->chunkCount = DatumGetInt32(
|
stripeMetadata->chunkCount = DatumGetInt32(
|
||||||
datumArray[Anum_cstore_stripes_chunk_count - 1]);
|
datumArray[Anum_columnar_stripe_chunk_count - 1]);
|
||||||
stripeMetadata->chunkRowCount = DatumGetInt32(
|
stripeMetadata->chunkRowCount = DatumGetInt32(
|
||||||
datumArray[Anum_cstore_stripes_chunk_row_count - 1]);
|
datumArray[Anum_columnar_stripe_chunk_row_count - 1]);
|
||||||
stripeMetadata->rowCount = DatumGetInt64(
|
stripeMetadata->rowCount = DatumGetInt64(
|
||||||
datumArray[Anum_cstore_stripes_row_count - 1]);
|
datumArray[Anum_columnar_stripe_row_count - 1]);
|
||||||
|
|
||||||
stripeMetadataList = lappend(stripeMetadataList, stripeMetadata);
|
stripeMetadataList = lappend(stripeMetadataList, stripeMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
systable_endscan_ordered(scanDescriptor);
|
systable_endscan_ordered(scanDescriptor);
|
||||||
index_close(index, NoLock);
|
index_close(index, NoLock);
|
||||||
table_close(cstoreStripes, NoLock);
|
table_close(columnarStripes, NoLock);
|
||||||
|
|
||||||
return stripeMetadataList;
|
return stripeMetadataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DeleteMetadataRows removes the rows with given relfilenode from cstore_stripes.
|
* DeleteMetadataRows removes the rows with given relfilenode from columnar.stripe.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
DeleteMetadataRows(RelFileNode relfilenode)
|
DeleteMetadataRows(RelFileNode relfilenode)
|
||||||
|
@ -833,23 +836,23 @@ DeleteMetadataRows(RelFileNode relfilenode)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScanKeyInit(&scanKey[0], Anum_cstore_stripes_storageid,
|
ScanKeyInit(&scanKey[0], Anum_columnar_stripe_storageid,
|
||||||
BTEqualStrategyNumber, F_INT8EQ, UInt64GetDatum(metapage->storageId));
|
BTEqualStrategyNumber, F_INT8EQ, UInt64GetDatum(metapage->storageId));
|
||||||
|
|
||||||
Oid cstoreStripesOid = CStoreStripesRelationId();
|
Oid columnarStripesOid = ColumnarStripeRelationId();
|
||||||
Relation cstoreStripes = try_relation_open(cstoreStripesOid, AccessShareLock);
|
Relation columnarStripes = try_relation_open(columnarStripesOid, AccessShareLock);
|
||||||
if (cstoreStripes == NULL)
|
if (columnarStripes == NULL)
|
||||||
{
|
{
|
||||||
/* extension has been dropped */
|
/* extension has been dropped */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Relation index = index_open(CStoreStripesIndexRelationId(), AccessShareLock);
|
Relation index = index_open(ColumnarStripeIndexRelationId(), AccessShareLock);
|
||||||
|
|
||||||
SysScanDesc scanDescriptor = systable_beginscan_ordered(cstoreStripes, index, NULL,
|
SysScanDesc scanDescriptor = systable_beginscan_ordered(columnarStripes, index, NULL,
|
||||||
1, scanKey);
|
1, scanKey);
|
||||||
|
|
||||||
ModifyState *modifyState = StartModifyRelation(cstoreStripes);
|
ModifyState *modifyState = StartModifyRelation(columnarStripes);
|
||||||
|
|
||||||
HeapTuple heapTuple = systable_getnext(scanDescriptor);
|
HeapTuple heapTuple = systable_getnext(scanDescriptor);
|
||||||
while (HeapTupleIsValid(heapTuple))
|
while (HeapTupleIsValid(heapTuple))
|
||||||
|
@ -862,7 +865,7 @@ DeleteMetadataRows(RelFileNode relfilenode)
|
||||||
|
|
||||||
systable_endscan_ordered(scanDescriptor);
|
systable_endscan_ordered(scanDescriptor);
|
||||||
index_close(index, NoLock);
|
index_close(index, NoLock);
|
||||||
table_close(cstoreStripes, NoLock);
|
table_close(columnarStripes, NoLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1046,24 +1049,24 @@ ByteaToDatum(bytea *bytes, Form_pg_attribute attrForm)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreStripesRelationId returns relation id of cstore_stripes.
|
* ColumnarStripeRelationId returns relation id of columnar.stripe.
|
||||||
* TODO: should we cache this similar to citus?
|
* TODO: should we cache this similar to citus?
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
CStoreStripesRelationId(void)
|
ColumnarStripeRelationId(void)
|
||||||
{
|
{
|
||||||
return get_relname_relid("columnar_stripes", CStoreNamespaceId());
|
return get_relname_relid("stripe", ColumnarNamespaceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreStripesIndexRelationId returns relation id of cstore_stripes_idx.
|
* ColumnarStripeIndexRelationId returns relation id of columnar.stripe_pkey.
|
||||||
* TODO: should we cache this similar to citus?
|
* TODO: should we cache this similar to citus?
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
CStoreStripesIndexRelationId(void)
|
ColumnarStripeIndexRelationId(void)
|
||||||
{
|
{
|
||||||
return get_relname_relid("columnar_stripes_pkey", CStoreNamespaceId());
|
return get_relname_relid("stripe_pkey", ColumnarNamespaceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1073,7 +1076,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 +1086,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.
|
* ColumnarChunkRelationId returns relation id of columnar.chunk.
|
||||||
* TODO: should we cache this similar to citus?
|
* TODO: should we cache this similar to citus?
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
CStoreSkipNodesRelationId(void)
|
ColumnarChunkRelationId(void)
|
||||||
{
|
{
|
||||||
return get_relname_relid("columnar_skipnodes", CStoreNamespaceId());
|
return get_relname_relid("chunk", ColumnarNamespaceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreSkipNodesIndexRelationId returns relation id of cstore_skipnodes_pkey.
|
* ColumnarChunkIndexRelationId returns relation id of columnar.chunk_pkey.
|
||||||
* TODO: should we cache this similar to citus?
|
* TODO: should we cache this similar to citus?
|
||||||
*/
|
*/
|
||||||
static Oid
|
static Oid
|
||||||
CStoreSkipNodesIndexRelationId(void)
|
ColumnarChunkIndexRelationId(void)
|
||||||
{
|
{
|
||||||
return get_relname_relid("columnar_skipnodes_pkey", CStoreNamespaceId());
|
return get_relname_relid("chunk_pkey", ColumnarNamespaceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreNamespaceId returns namespace id of the schema we store cstore
|
* ColumnarNamespaceId returns namespace id of the schema we store columnar
|
||||||
* 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 +1204,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 +1239,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)
|
||||||
|
|
|
@ -44,7 +44,8 @@ static StripeBuffers * LoadFilteredStripeBuffers(Relation relation,
|
||||||
StripeMetadata *stripeMetadata,
|
StripeMetadata *stripeMetadata,
|
||||||
TupleDesc tupleDescriptor,
|
TupleDesc tupleDescriptor,
|
||||||
List *projectedColumnList,
|
List *projectedColumnList,
|
||||||
List *whereClauseList);
|
List *whereClauseList,
|
||||||
|
int64 *chunksFiltered);
|
||||||
static void ReadStripeNextRow(StripeBuffers *stripeBuffers, List *projectedColumnList,
|
static void ReadStripeNextRow(StripeBuffers *stripeBuffers, List *projectedColumnList,
|
||||||
uint64 chunkIndex, uint64 chunkRowIndex,
|
uint64 chunkIndex, uint64 chunkRowIndex,
|
||||||
ChunkData *chunkData, Datum *columnValues,
|
ChunkData *chunkData, Datum *columnValues,
|
||||||
|
@ -54,7 +55,8 @@ static ColumnBuffers * LoadColumnBuffers(Relation relation,
|
||||||
uint32 chunkCount, uint64 stripeOffset,
|
uint32 chunkCount, uint64 stripeOffset,
|
||||||
Form_pg_attribute attributeForm);
|
Form_pg_attribute attributeForm);
|
||||||
static bool * SelectedChunkMask(StripeSkipList *stripeSkipList,
|
static bool * SelectedChunkMask(StripeSkipList *stripeSkipList,
|
||||||
List *projectedColumnList, List *whereClauseList);
|
List *projectedColumnList, List *whereClauseList,
|
||||||
|
int64 *chunksFiltered);
|
||||||
static List * BuildRestrictInfoList(List *whereClauseList);
|
static List * BuildRestrictInfoList(List *whereClauseList);
|
||||||
static Node * BuildBaseConstraint(Var *variable);
|
static Node * BuildBaseConstraint(Var *variable);
|
||||||
static OpExpr * MakeOpExpression(Var *variable, int16 strategyNumber);
|
static OpExpr * MakeOpExpression(Var *variable, int16 strategyNumber);
|
||||||
|
@ -78,11 +80,11 @@ 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);
|
||||||
|
@ -104,6 +106,7 @@ CStoreBeginRead(Relation relation, TupleDesc tupleDescriptor,
|
||||||
readState->stripeBuffers = NULL;
|
readState->stripeBuffers = NULL;
|
||||||
readState->readStripeCount = 0;
|
readState->readStripeCount = 0;
|
||||||
readState->stripeReadRowCount = 0;
|
readState->stripeReadRowCount = 0;
|
||||||
|
readState->chunksFiltered = 0;
|
||||||
readState->tupleDescriptor = tupleDescriptor;
|
readState->tupleDescriptor = tupleDescriptor;
|
||||||
readState->stripeReadContext = stripeReadContext;
|
readState->stripeReadContext = stripeReadContext;
|
||||||
readState->chunkData = NULL;
|
readState->chunkData = NULL;
|
||||||
|
@ -114,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;
|
||||||
|
@ -153,7 +156,9 @@ CStoreReadNextRow(TableReadState *readState, Datum *columnValues, bool *columnNu
|
||||||
readState->
|
readState->
|
||||||
projectedColumnList,
|
projectedColumnList,
|
||||||
readState->
|
readState->
|
||||||
whereClauseList);
|
whereClauseList,
|
||||||
|
&readState->
|
||||||
|
chunksFiltered);
|
||||||
readState->readStripeCount++;
|
readState->readStripeCount++;
|
||||||
readState->currentStripeMetadata = stripeMetadata;
|
readState->currentStripeMetadata = stripeMetadata;
|
||||||
|
|
||||||
|
@ -218,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;
|
||||||
|
@ -232,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);
|
||||||
|
@ -306,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;
|
||||||
|
@ -332,7 +337,7 @@ CStoreTableRowCount(Relation relation)
|
||||||
static StripeBuffers *
|
static StripeBuffers *
|
||||||
LoadFilteredStripeBuffers(Relation relation, StripeMetadata *stripeMetadata,
|
LoadFilteredStripeBuffers(Relation relation, StripeMetadata *stripeMetadata,
|
||||||
TupleDesc tupleDescriptor, List *projectedColumnList,
|
TupleDesc tupleDescriptor, List *projectedColumnList,
|
||||||
List *whereClauseList)
|
List *whereClauseList, int64 *chunksFiltered)
|
||||||
{
|
{
|
||||||
uint32 columnIndex = 0;
|
uint32 columnIndex = 0;
|
||||||
uint32 columnCount = tupleDescriptor->natts;
|
uint32 columnCount = tupleDescriptor->natts;
|
||||||
|
@ -345,7 +350,7 @@ LoadFilteredStripeBuffers(Relation relation, StripeMetadata *stripeMetadata,
|
||||||
stripeMetadata->chunkCount);
|
stripeMetadata->chunkCount);
|
||||||
|
|
||||||
bool *selectedChunkMask = SelectedChunkMask(stripeSkipList, projectedColumnList,
|
bool *selectedChunkMask = SelectedChunkMask(stripeSkipList, projectedColumnList,
|
||||||
whereClauseList);
|
whereClauseList, chunksFiltered);
|
||||||
|
|
||||||
StripeSkipList *selectedChunkSkipList =
|
StripeSkipList *selectedChunkSkipList =
|
||||||
SelectedChunkSkipList(stripeSkipList, projectedColumnMask,
|
SelectedChunkSkipList(stripeSkipList, projectedColumnMask,
|
||||||
|
@ -474,7 +479,7 @@ LoadColumnBuffers(Relation relation, ColumnChunkSkipNode *chunkSkipNodeArray,
|
||||||
*/
|
*/
|
||||||
static bool *
|
static bool *
|
||||||
SelectedChunkMask(StripeSkipList *stripeSkipList, List *projectedColumnList,
|
SelectedChunkMask(StripeSkipList *stripeSkipList, List *projectedColumnList,
|
||||||
List *whereClauseList)
|
List *whereClauseList, int64 *chunksFiltered)
|
||||||
{
|
{
|
||||||
ListCell *columnCell = NULL;
|
ListCell *columnCell = NULL;
|
||||||
uint32 chunkIndex = 0;
|
uint32 chunkIndex = 0;
|
||||||
|
@ -527,6 +532,7 @@ SelectedChunkMask(StripeSkipList *stripeSkipList, List *projectedColumnList,
|
||||||
if (predicateRefuted)
|
if (predicateRefuted)
|
||||||
{
|
{
|
||||||
selectedChunkMask[chunkIndex] = false;
|
selectedChunkMask[chunkIndex] = false;
|
||||||
|
*chunksFiltered += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,14 +142,14 @@ 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)
|
||||||
|
@ -162,7 +162,7 @@ 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);
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ 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)
|
||||||
|
@ -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,11 +228,11 @@ 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);
|
||||||
|
@ -250,7 +250,7 @@ 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;
|
||||||
|
@ -258,33 +258,33 @@ init_cstore_read_state(Relation relation, TupleDesc tupdesc, Bitmapset *attr_nee
|
||||||
|
|
||||||
|
|
||||||
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,14 +293,14 @@ 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,7 +373,7 @@ 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,
|
||||||
|
@ -385,7 +385,7 @@ 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)
|
||||||
|
@ -395,7 +395,7 @@ cstore_fetch_row_version(Relation relation,
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
@ -403,14 +403,14 @@ cstore_get_latest_tid(TableScanDesc sscan,
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
@ -418,7 +418,7 @@ cstore_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -427,14 +427,14 @@ cstore_compute_xid_horizon_for_tuples(Relation rel,
|
||||||
|
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
|
@ -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,7 +462,7 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -471,7 +471,7 @@ cstore_tuple_insert_speculative(Relation relation, TupleTableSlot *slot,
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
@ -479,10 +479,10 @@ cstore_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
|
||||||
|
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
|
@ -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,7 +513,7 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -522,7 +522,7 @@ cstore_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
@ -532,7 +532,7 @@ cstore_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot,
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
@ -542,7 +542,7 @@ cstore_tuple_lock(Relation relation, ItemPointer tid, Snapshot snapshot,
|
||||||
|
|
||||||
|
|
||||||
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,7 +551,7 @@ 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,
|
||||||
|
@ -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,21 +607,21 @@ 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,
|
||||||
|
@ -650,11 +650,11 @@ 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));
|
||||||
|
@ -662,24 +662,24 @@ cstore_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
||||||
|
|
||||||
*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,21 +939,21 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -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,7 +979,7 @@ 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,
|
||||||
|
@ -997,7 +997,7 @@ 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,
|
||||||
|
@ -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,14 +1060,14 @@ 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");
|
||||||
|
@ -1075,7 +1075,7 @@ cstore_scan_sample_next_tuple(TableScanDesc scan, SampleScanState *scanstate,
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CStoreXactCallback(XactEvent event, void *arg)
|
ColumnarXactCallback(XactEvent event, void *arg)
|
||||||
{
|
{
|
||||||
switch (event)
|
switch (event)
|
||||||
{
|
{
|
||||||
|
@ -1106,7 +1106,7 @@ 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,12 +1150,32 @@ cstore_tableam_init()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cstore_tableam_finish()
|
columnar_tableam_finish()
|
||||||
{
|
{
|
||||||
object_access_hook = PrevObjectAccessHook;
|
object_access_hook = PrevObjectAccessHook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the number of chunks filtered out during the given scan.
|
||||||
|
*/
|
||||||
|
int64
|
||||||
|
ColumnarGetChunksFiltered(TableScanDesc scanDesc)
|
||||||
|
{
|
||||||
|
ColumnarScanDesc cstoreScanDesc = (ColumnarScanDesc) scanDesc;
|
||||||
|
TableReadState *readState = cstoreScanDesc->cs_readState;
|
||||||
|
|
||||||
|
if (readState != NULL)
|
||||||
|
{
|
||||||
|
return readState->chunksFiltered;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implementation of TupleTableSlotOps.copy_heap_tuple for TTSOpsColumnar.
|
* Implementation of TupleTableSlotOps.copy_heap_tuple for TTSOpsColumnar.
|
||||||
*/
|
*/
|
||||||
|
@ -1173,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;
|
||||||
|
|
||||||
|
@ -1182,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
|
||||||
|
@ -1195,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
|
||||||
|
@ -1219,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
|
||||||
|
@ -1252,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(
|
||||||
|
@ -1266,7 +1286,7 @@ 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)
|
||||||
|
@ -1277,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))
|
||||||
{
|
{
|
||||||
|
@ -1310,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1377,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1553,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)))));
|
||||||
|
@ -1660,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)))));
|
||||||
|
@ -1675,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)));
|
||||||
}
|
}
|
||||||
|
@ -1683,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)));
|
||||||
|
@ -1692,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,14 +53,14 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,25 +15,25 @@ CREATE TABLE options (
|
||||||
|
|
||||||
COMMENT ON TABLE options IS 'columnar table specific options, maintained by alter_columnar_table_set';
|
COMMENT ON TABLE options IS 'columnar table specific options, maintained by alter_columnar_table_set';
|
||||||
|
|
||||||
CREATE TABLE columnar_stripes (
|
CREATE TABLE stripe (
|
||||||
storageid bigint NOT NULL,
|
storageid bigint NOT NULL,
|
||||||
stripe bigint NOT NULL,
|
stripeid bigint NOT NULL,
|
||||||
file_offset bigint NOT NULL,
|
file_offset bigint NOT NULL,
|
||||||
data_length bigint NOT NULL,
|
data_length bigint NOT NULL,
|
||||||
column_count int NOT NULL,
|
column_count int NOT NULL,
|
||||||
chunk_count int NOT NULL,
|
chunk_count int NOT NULL,
|
||||||
chunk_row_count int NOT NULL,
|
chunk_row_count int NOT NULL,
|
||||||
row_count bigint NOT NULL,
|
row_count bigint NOT NULL,
|
||||||
PRIMARY KEY (storageid, stripe)
|
PRIMARY KEY (storageid, stripeid)
|
||||||
) WITH (user_catalog_table = true);
|
) WITH (user_catalog_table = true);
|
||||||
|
|
||||||
COMMENT ON TABLE columnar_stripes IS 'Columnar per stripe metadata';
|
COMMENT ON TABLE stripe IS 'Columnar per stripe metadata';
|
||||||
|
|
||||||
CREATE TABLE columnar_skipnodes (
|
CREATE TABLE chunk (
|
||||||
storageid bigint NOT NULL,
|
storageid bigint NOT NULL,
|
||||||
stripe bigint NOT NULL,
|
stripeid bigint NOT NULL,
|
||||||
attr int NOT NULL,
|
attnum int NOT NULL,
|
||||||
chunk int NOT NULL,
|
chunkid int NOT NULL,
|
||||||
row_count bigint NOT NULL,
|
row_count bigint NOT NULL,
|
||||||
minimum_value bytea,
|
minimum_value bytea,
|
||||||
maximum_value bytea,
|
maximum_value bytea,
|
||||||
|
@ -44,11 +44,11 @@ CREATE TABLE columnar_skipnodes (
|
||||||
value_compression_type int NOT NULL,
|
value_compression_type int NOT NULL,
|
||||||
value_compression_level int NOT NULL,
|
value_compression_level int NOT NULL,
|
||||||
value_decompressed_length bigint NOT NULL,
|
value_decompressed_length bigint NOT NULL,
|
||||||
PRIMARY KEY (storageid, stripe, attr, chunk),
|
PRIMARY KEY (storageid, stripeid, attnum, chunkid),
|
||||||
FOREIGN KEY (storageid, stripe) REFERENCES columnar_stripes(storageid, stripe) ON DELETE CASCADE
|
FOREIGN KEY (storageid, stripeid) REFERENCES stripe(storageid, stripeid) ON DELETE CASCADE
|
||||||
) WITH (user_catalog_table = true);
|
) WITH (user_catalog_table = true);
|
||||||
|
|
||||||
COMMENT ON TABLE columnar_skipnodes IS 'Columnar per chunk metadata';
|
COMMENT ON TABLE chunk IS 'Columnar per chunk metadata';
|
||||||
|
|
||||||
DO $proc$
|
DO $proc$
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -29,8 +29,8 @@ IF substring(current_Setting('server_version'), '\d+')::int >= 12 THEN
|
||||||
END IF;
|
END IF;
|
||||||
END$proc$;
|
END$proc$;
|
||||||
|
|
||||||
DROP TABLE columnar_skipnodes;
|
DROP TABLE chunk;
|
||||||
DROP TABLE columnar_stripes;
|
DROP TABLE stripe;
|
||||||
DROP TABLE options;
|
DROP TABLE options;
|
||||||
DROP SEQUENCE storageid_seq;
|
DROP SEQUENCE storageid_seq;
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ 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,7 +182,7 @@ 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;
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "distributed/commands/sequence.h"
|
#include "distributed/commands/sequence.h"
|
||||||
#include "distributed/commands/utility_hook.h"
|
#include "distributed/commands/utility_hook.h"
|
||||||
#include "distributed/listutils.h"
|
#include "distributed/listutils.h"
|
||||||
|
#include "distributed/local_executor.h"
|
||||||
#include "distributed/metadata_sync.h"
|
#include "distributed/metadata_sync.h"
|
||||||
#include "distributed/multi_partitioning_utils.h"
|
#include "distributed/multi_partitioning_utils.h"
|
||||||
#include "distributed/namespace_utils.h"
|
#include "distributed/namespace_utils.h"
|
||||||
|
@ -118,6 +119,14 @@ CreateCitusLocalTable(Oid relationId, bool cascadeViaForeignKeys)
|
||||||
/* enable create_citus_local_table on an empty node */
|
/* enable create_citus_local_table on an empty node */
|
||||||
InsertCoordinatorIfClusterEmpty();
|
InsertCoordinatorIfClusterEmpty();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creating Citus local tables relies on functions that accesses
|
||||||
|
* shards locally (e.g., ExecuteAndLogDDLCommand()). As long as
|
||||||
|
* we don't teach those functions to access shards remotely, we
|
||||||
|
* cannot relax this check.
|
||||||
|
*/
|
||||||
|
SetLocalExecutionStatus(LOCAL_EXECUTION_REQUIRED);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock target relation with an AccessExclusiveLock as we don't want
|
* Lock target relation with an AccessExclusiveLock as we don't want
|
||||||
* multiple backends manipulating this relation. We could actually simply
|
* multiple backends manipulating this relation. We could actually simply
|
||||||
|
|
|
@ -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
|
||||||
|
@ -236,6 +236,7 @@ typedef struct TableReadState
|
||||||
StripeBuffers *stripeBuffers;
|
StripeBuffers *stripeBuffers;
|
||||||
uint32 readStripeCount;
|
uint32 readStripeCount;
|
||||||
uint64 stripeReadRowCount;
|
uint64 stripeReadRowCount;
|
||||||
|
int64 chunksFiltered;
|
||||||
ChunkData *chunkData;
|
ChunkData *chunkData;
|
||||||
int32 deserializedChunkIndex;
|
int32 deserializedChunkIndex;
|
||||||
} TableReadState;
|
} TableReadState;
|
||||||
|
@ -264,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,
|
||||||
|
@ -299,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,
|
||||||
|
@ -308,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);
|
||||||
|
@ -316,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);
|
||||||
|
@ -335,7 +336,7 @@ 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
|
||||||
|
|
|
@ -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 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
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
-- 'postgres' directory is excluded from comparison to have the same result.
|
-- 'postgres' directory is excluded from comparison to have the same result.
|
||||||
-- store postgres database oid
|
-- store postgres database oid
|
||||||
SELECT oid postgres_oid FROM pg_database WHERE datname = 'postgres' \gset
|
SELECT oid postgres_oid FROM pg_database WHERE datname = 'postgres' \gset
|
||||||
SELECT count(distinct storageid) AS columnar_stripes_before_drop FROM columnar.columnar_stripes \gset
|
SELECT count(distinct storageid) AS columnar_stripes_before_drop FROM columnar.stripe \gset
|
||||||
-- DROP columnar tables
|
-- DROP columnar tables
|
||||||
DROP TABLE contestant;
|
DROP TABLE contestant;
|
||||||
DROP TABLE contestant_compressed;
|
DROP TABLE contestant_compressed;
|
||||||
-- make sure DROP deletes metadata
|
-- make sure DROP deletes metadata
|
||||||
SELECT :columnar_stripes_before_drop - count(distinct storageid) FROM columnar.columnar_stripes;
|
SELECT :columnar_stripes_before_drop - count(distinct storageid) FROM columnar.stripe;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
2
|
2
|
||||||
|
@ -27,10 +27,10 @@ SELECT :columnar_stripes_before_drop - count(distinct storageid) FROM columnar.c
|
||||||
CREATE SCHEMA test_schema;
|
CREATE SCHEMA test_schema;
|
||||||
CREATE TABLE test_schema.test_table(data int) USING columnar;
|
CREATE TABLE test_schema.test_table(data int) USING columnar;
|
||||||
INSERT INTO test_schema.test_table VALUES (1);
|
INSERT INTO test_schema.test_table VALUES (1);
|
||||||
SELECT count(*) AS columnar_stripes_before_drop FROM columnar.columnar_stripes \gset
|
SELECT count(*) AS columnar_stripes_before_drop FROM columnar.stripe \gset
|
||||||
DROP SCHEMA test_schema CASCADE;
|
DROP SCHEMA test_schema CASCADE;
|
||||||
NOTICE: drop cascades to table test_schema.test_table
|
NOTICE: drop cascades to table test_schema.test_table
|
||||||
SELECT :columnar_stripes_before_drop - count(distinct storageid) FROM columnar.columnar_stripes;
|
SELECT :columnar_stripes_before_drop - count(distinct storageid) FROM columnar.stripe;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
|
|
|
@ -68,13 +68,13 @@ SELECT * FROM t_view a ORDER BY a;
|
||||||
-- verify that we have created metadata entries for the materialized view
|
-- verify that we have created metadata entries for the materialized view
|
||||||
SELECT columnar_relation_storageid(oid) AS storageid
|
SELECT columnar_relation_storageid(oid) AS storageid
|
||||||
FROM pg_class WHERE relname='t_view' \gset
|
FROM pg_class WHERE relname='t_view' \gset
|
||||||
SELECT count(*) FROM columnar.columnar_stripes WHERE storageid=:storageid;
|
SELECT count(*) FROM columnar.stripe WHERE storageid=:storageid;
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT count(*) FROM columnar.columnar_skipnodes WHERE storageid=:storageid;
|
SELECT count(*) FROM columnar.chunk WHERE storageid=:storageid;
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
3
|
3
|
||||||
|
@ -83,13 +83,13 @@ SELECT count(*) FROM columnar.columnar_skipnodes WHERE storageid=:storageid;
|
||||||
DROP TABLE t CASCADE;
|
DROP TABLE t CASCADE;
|
||||||
NOTICE: drop cascades to materialized view t_view
|
NOTICE: drop cascades to materialized view t_view
|
||||||
-- dropping must remove metadata
|
-- dropping must remove metadata
|
||||||
SELECT count(*) FROM columnar.columnar_stripes WHERE storageid=:storageid;
|
SELECT count(*) FROM columnar.stripe WHERE storageid=:storageid;
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0
|
0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT count(*) FROM columnar.columnar_skipnodes WHERE storageid=:storageid;
|
SELECT count(*) FROM columnar.chunk WHERE storageid=:storageid;
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0
|
0
|
||||||
|
|
|
@ -11,7 +11,7 @@ $$ LANGUAGE SQL;
|
||||||
INSERT INTO t2 SELECT i, f(i) FROM generate_series(1, 5) i;
|
INSERT INTO t2 SELECT i, f(i) FROM generate_series(1, 5) i;
|
||||||
-- there are no subtransactions, so above statement should batch
|
-- there are no subtransactions, so above statement should batch
|
||||||
-- INSERTs inside the UDF and create on stripe per table.
|
-- INSERTs inside the UDF and create on stripe per table.
|
||||||
SELECT relname, count(*) FROM columnar.columnar_stripes a, pg_class b
|
SELECT relname, count(*) FROM columnar.stripe a, pg_class b
|
||||||
WHERE columnar_relation_storageid(b.oid)=a.storageid AND relname IN ('t1', 't2')
|
WHERE columnar_relation_storageid(b.oid)=a.storageid AND relname IN ('t1', 't2')
|
||||||
GROUP BY relname
|
GROUP BY relname
|
||||||
ORDER BY relname;
|
ORDER BY relname;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
--
|
--
|
||||||
CREATE TABLE t(a int, b int) USING columnar;
|
CREATE TABLE t(a int, b int) USING columnar;
|
||||||
CREATE VIEW t_stripes AS
|
CREATE VIEW t_stripes AS
|
||||||
SELECT * FROM columnar.columnar_stripes a, pg_class b
|
SELECT * FROM columnar.stripe a, pg_class b
|
||||||
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname = 't';
|
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname = 't';
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
||||||
|
|
|
@ -15,7 +15,7 @@ CREATE TABLE columnar_truncate_test_second (a int, b int) USING columnar;
|
||||||
-- COMPRESSED
|
-- COMPRESSED
|
||||||
CREATE TABLE columnar_truncate_test_compressed (a int, b int) USING columnar;
|
CREATE TABLE columnar_truncate_test_compressed (a int, b int) USING columnar;
|
||||||
CREATE TABLE columnar_truncate_test_regular (a int, b int);
|
CREATE TABLE columnar_truncate_test_regular (a int, b int);
|
||||||
SELECT count(distinct storageid) AS columnar_data_files_before_truncate FROM columnar.columnar_stripes \gset
|
SELECT count(distinct storageid) AS columnar_data_files_before_truncate FROM columnar.stripe \gset
|
||||||
INSERT INTO columnar_truncate_test select a, a from generate_series(1, 10) a;
|
INSERT INTO columnar_truncate_test select a, a from generate_series(1, 10) a;
|
||||||
set columnar.compression = 'pglz';
|
set columnar.compression = 'pglz';
|
||||||
INSERT INTO columnar_truncate_test_compressed select a, a from generate_series(1, 10) a;
|
INSERT INTO columnar_truncate_test_compressed select a, a from generate_series(1, 10) a;
|
||||||
|
@ -147,7 +147,7 @@ SELECT * from columnar_truncate_test;
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- make sure TRUNATE deletes metadata for old relfilenode
|
-- make sure TRUNATE deletes metadata for old relfilenode
|
||||||
SELECT :columnar_data_files_before_truncate - count(distinct storageid) FROM columnar.columnar_stripes;
|
SELECT :columnar_data_files_before_truncate - count(distinct storageid) FROM columnar.stripe;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0
|
0
|
||||||
|
@ -161,7 +161,7 @@ TRUNCATE columnar_same_transaction_truncate;
|
||||||
INSERT INTO columnar_same_transaction_truncate SELECT * FROM generate_series(20, 23);
|
INSERT INTO columnar_same_transaction_truncate SELECT * FROM generate_series(20, 23);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
-- should output "1" for the newly created relation
|
-- should output "1" for the newly created relation
|
||||||
SELECT count(distinct storageid) - :columnar_data_files_before_truncate FROM columnar.columnar_stripes;
|
SELECT count(distinct storageid) - :columnar_data_files_before_truncate FROM columnar.stripe;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
SET columnar.compression TO 'none';
|
SET columnar.compression TO 'none';
|
||||||
SELECT count(distinct storageid) AS columnar_table_count FROM columnar.columnar_stripes \gset
|
SELECT count(distinct storageid) AS columnar_table_count FROM columnar.stripe \gset
|
||||||
CREATE TABLE t(a int, b int) USING columnar;
|
CREATE TABLE t(a int, b int) USING columnar;
|
||||||
CREATE VIEW t_stripes AS
|
CREATE VIEW t_stripes AS
|
||||||
SELECT * FROM columnar.columnar_stripes a, pg_class b
|
SELECT * FROM columnar.stripe a, pg_class b
|
||||||
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t';
|
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t';
|
||||||
SELECT count(*) FROM t_stripes;
|
SELECT count(*) FROM t_stripes;
|
||||||
count
|
count
|
||||||
|
@ -74,10 +74,10 @@ SELECT count(*) FROM t_stripes;
|
||||||
|
|
||||||
-- VACUUM FULL doesn't reclaim dropped columns, but converts them to NULLs
|
-- VACUUM FULL doesn't reclaim dropped columns, but converts them to NULLs
|
||||||
ALTER TABLE t DROP COLUMN a;
|
ALTER TABLE t DROP COLUMN a;
|
||||||
SELECT stripe, attr, chunk, minimum_value IS NULL, maximum_value IS NULL
|
SELECT stripeid, attnum, chunkid, minimum_value IS NULL, maximum_value IS NULL
|
||||||
FROM columnar.columnar_skipnodes a, pg_class b
|
FROM columnar.chunk a, pg_class b
|
||||||
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t' ORDER BY 1, 2, 3;
|
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t' ORDER BY 1, 2, 3;
|
||||||
stripe | attr | chunk | ?column? | ?column?
|
stripeid | attnum | chunkid | ?column? | ?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | 1 | 0 | f | f
|
1 | 1 | 0 | f | f
|
||||||
1 | 2 | 0 | f | f
|
1 | 2 | 0 | f | f
|
||||||
|
@ -88,10 +88,10 @@ WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t' ORDER B
|
||||||
(6 rows)
|
(6 rows)
|
||||||
|
|
||||||
VACUUM FULL t;
|
VACUUM FULL t;
|
||||||
SELECT stripe, attr, chunk, minimum_value IS NULL, maximum_value IS NULL
|
SELECT stripeid, attnum, chunkid, minimum_value IS NULL, maximum_value IS NULL
|
||||||
FROM columnar.columnar_skipnodes a, pg_class b
|
FROM columnar.chunk a, pg_class b
|
||||||
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t' ORDER BY 1, 2, 3;
|
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t' ORDER BY 1, 2, 3;
|
||||||
stripe | attr | chunk | ?column? | ?column?
|
stripeid | attnum | chunkid | ?column? | ?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | 1 | 0 | t | t
|
1 | 1 | 0 | t | t
|
||||||
1 | 2 | 0 | f | f
|
1 | 2 | 0 | f | f
|
||||||
|
@ -102,7 +102,7 @@ WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t' ORDER B
|
||||||
(6 rows)
|
(6 rows)
|
||||||
|
|
||||||
-- Make sure we cleaned-up the transient table metadata after VACUUM FULL commands
|
-- Make sure we cleaned-up the transient table metadata after VACUUM FULL commands
|
||||||
SELECT count(distinct storageid) - :columnar_table_count FROM columnar.columnar_stripes;
|
SELECT count(distinct storageid) - :columnar_table_count FROM columnar.stripe;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
|
@ -242,7 +242,7 @@ chunk count: 8, containing data for dropped columns: 0, none compressed: 2, pglz
|
||||||
DROP TABLE t;
|
DROP TABLE t;
|
||||||
DROP VIEW t_stripes;
|
DROP VIEW t_stripes;
|
||||||
-- Make sure we cleaned the metadata for t too
|
-- Make sure we cleaned the metadata for t too
|
||||||
SELECT count(distinct storageid) - :columnar_table_count FROM columnar.columnar_stripes;
|
SELECT count(distinct storageid) - :columnar_table_count FROM columnar.stripe;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0
|
0
|
||||||
|
|
|
@ -14,13 +14,20 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
CREATE TABLE citus_local_table (value int);
|
CREATE TABLE dummy_reference_table(a int unique, b int);
|
||||||
SELECT create_citus_local_table('citus_local_table');
|
INSERT INTO dummy_reference_table SELECT i FROM generate_series(-1, 5) i;
|
||||||
create_citus_local_table
|
INSERT INTO dummy_reference_table VALUES (99),(100),(599),(600);
|
||||||
|
SELECT create_reference_table('dummy_reference_table');
|
||||||
|
NOTICE: Copying data from local table...
|
||||||
|
NOTICE: copying the data has completed
|
||||||
|
create_reference_table
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TABLE citus_local_table (value int);
|
||||||
|
ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);
|
||||||
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507001, 'citus_local_table_triggers', 1507000, 'citus_local_table_triggers', 'ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);')
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
-- DELETE trigger --
|
-- DELETE trigger --
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -41,13 +48,13 @@ BEGIN;
|
||||||
CREATE TRIGGER insert_42_trigger
|
CREATE TRIGGER insert_42_trigger
|
||||||
AFTER DELETE ON citus_local_table
|
AFTER DELETE ON citus_local_table
|
||||||
FOR EACH ROW EXECUTE FUNCTION insert_42();
|
FOR EACH ROW EXECUTE FUNCTION insert_42();
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507000, 'citus_local_table_triggers', 'CREATE TRIGGER insert_42_trigger
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507001, 'citus_local_table_triggers', 'CREATE TRIGGER insert_42_trigger
|
||||||
AFTER DELETE ON citus_local_table
|
AFTER DELETE ON citus_local_table
|
||||||
FOR EACH ROW EXECUTE FUNCTION insert_42();')
|
FOR EACH ROW EXECUTE FUNCTION insert_42();')
|
||||||
-- select should print two rows with "42" as delete from citus_local_table will
|
-- select should print two rows with "42" as delete from citus_local_table will
|
||||||
-- insert 42 per deleted row
|
-- insert 42 per deleted row
|
||||||
DELETE FROM citus_local_table;
|
DELETE FROM citus_local_table;
|
||||||
NOTICE: executing the command locally: DELETE FROM citus_local_table_triggers.citus_local_table_1507000 citus_local_table
|
NOTICE: executing the command locally: DELETE FROM citus_local_table_triggers.citus_local_table_1507001 citus_local_table
|
||||||
SELECT * FROM distributed_table;
|
SELECT * FROM distributed_table;
|
||||||
value
|
value
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -60,7 +67,7 @@ ROLLBACK;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE reference_table(value int);
|
CREATE TABLE reference_table(value int);
|
||||||
SELECT create_reference_table('reference_table');
|
SELECT create_reference_table('reference_table');
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507005, 'citus_local_table_triggers', 'CREATE TABLE citus_local_table_triggers.reference_table (value integer)');SELECT worker_apply_shard_ddl_command (1507005, 'citus_local_table_triggers', 'ALTER TABLE citus_local_table_triggers.reference_table OWNER TO postgres')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507006, 'citus_local_table_triggers', 'CREATE TABLE citus_local_table_triggers.reference_table (value integer) ');SELECT worker_apply_shard_ddl_command (1507006, 'citus_local_table_triggers', 'ALTER TABLE citus_local_table_triggers.reference_table OWNER TO postgres')
|
||||||
create_reference_table
|
create_reference_table
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -79,10 +86,10 @@ NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1
|
||||||
-- are executed only for once.
|
-- are executed only for once.
|
||||||
-- select should print a row with "100" as truncate from citus_local_table will insert 100
|
-- select should print a row with "100" as truncate from citus_local_table will insert 100
|
||||||
TRUNCATE citus_local_table;
|
TRUNCATE citus_local_table;
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507005 (value) VALUES (100)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507006 (value) VALUES (100)
|
||||||
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_triggers.citus_local_table_xxxxx CASCADE
|
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_triggers.citus_local_table_xxxxx CASCADE
|
||||||
SELECT * FROM reference_table;
|
SELECT * FROM reference_table;
|
||||||
NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507005 reference_table
|
NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507006 reference_table
|
||||||
value
|
value
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
100
|
100
|
||||||
|
@ -103,7 +110,7 @@ BEGIN;
|
||||||
CREATE TRIGGER increment_value_trigger
|
CREATE TRIGGER increment_value_trigger
|
||||||
AFTER INSERT ON citus_local_table
|
AFTER INSERT ON citus_local_table
|
||||||
FOR EACH ROW EXECUTE FUNCTION increment_value();
|
FOR EACH ROW EXECUTE FUNCTION increment_value();
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507000, 'citus_local_table_triggers', 'CREATE TRIGGER increment_value_trigger
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507001, 'citus_local_table_triggers', 'CREATE TRIGGER increment_value_trigger
|
||||||
AFTER INSERT ON citus_local_table
|
AFTER INSERT ON citus_local_table
|
||||||
FOR EACH ROW EXECUTE FUNCTION increment_value();')
|
FOR EACH ROW EXECUTE FUNCTION increment_value();')
|
||||||
-- insert initial data to the table that increment_value_trigger will execute for
|
-- insert initial data to the table that increment_value_trigger will execute for
|
||||||
|
@ -111,7 +118,7 @@ NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1
|
||||||
-- select should print a row with "2" as insert into citus_local_table will
|
-- select should print a row with "2" as insert into citus_local_table will
|
||||||
-- increment all rows per inserted row
|
-- increment all rows per inserted row
|
||||||
INSERT INTO citus_local_table VALUES(0), (1);
|
INSERT INTO citus_local_table VALUES(0), (1);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507000 AS citus_table_alias (value) VALUES (0), (1)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507001 AS citus_table_alias (value) VALUES (0), (1)
|
||||||
SELECT * FROM local_table;
|
SELECT * FROM local_table;
|
||||||
value
|
value
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -133,14 +140,14 @@ BEGIN;
|
||||||
CREATE TRIGGER error_for_5_trigger
|
CREATE TRIGGER error_for_5_trigger
|
||||||
BEFORE UPDATE OF value ON citus_local_table
|
BEFORE UPDATE OF value ON citus_local_table
|
||||||
FOR EACH ROW EXECUTE FUNCTION error_for_5();
|
FOR EACH ROW EXECUTE FUNCTION error_for_5();
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507000, 'citus_local_table_triggers', 'CREATE TRIGGER error_for_5_trigger
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507001, 'citus_local_table_triggers', 'CREATE TRIGGER error_for_5_trigger
|
||||||
BEFORE UPDATE OF value ON citus_local_table
|
BEFORE UPDATE OF value ON citus_local_table
|
||||||
FOR EACH ROW EXECUTE FUNCTION error_for_5();')
|
FOR EACH ROW EXECUTE FUNCTION error_for_5();')
|
||||||
-- below update will error out as trigger raises exception
|
-- below update will error out as trigger raises exception
|
||||||
INSERT INTO citus_local_table VALUES (5);
|
INSERT INTO citus_local_table VALUES (5);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507000 (value) VALUES (5)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507001 (value) VALUES (5)
|
||||||
UPDATE citus_local_table SET value=value*2 WHERE value=5;
|
UPDATE citus_local_table SET value=value*2 WHERE value=5;
|
||||||
NOTICE: executing the command locally: UPDATE citus_local_table_triggers.citus_local_table_1507000 citus_local_table SET value = (value OPERATOR(pg_catalog.*) 2) WHERE (value OPERATOR(pg_catalog.=) 5)
|
NOTICE: executing the command locally: UPDATE citus_local_table_triggers.citus_local_table_1507001 citus_local_table SET value = (value OPERATOR(pg_catalog.*) 2) WHERE (value OPERATOR(pg_catalog.=) 5)
|
||||||
ERROR: cannot update update for value=5
|
ERROR: cannot update update for value=5
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -165,14 +172,11 @@ BEGIN;
|
||||||
CREATE TRIGGER initial_truncate_trigger
|
CREATE TRIGGER initial_truncate_trigger
|
||||||
AFTER TRUNCATE ON "interesting!schema"."citus_local!_table"
|
AFTER TRUNCATE ON "interesting!schema"."citus_local!_table"
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
||||||
SELECT create_citus_local_table('"interesting!schema"."citus_local!_table"');
|
ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);
|
||||||
create_citus_local_table
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507007, 'interesting!schema', 1507000, 'citus_local_table_triggers', 'ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);')
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- we shouldn't see truncate trigger on shard relation as we drop it
|
-- we shouldn't see truncate trigger on shard relation as we drop it
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
initial_truncate_trigger | "interesting!schema"."citus_local!_table" | O
|
initial_truncate_trigger | "interesting!schema"."citus_local!_table" | O
|
||||||
|
@ -181,23 +185,19 @@ BEGIN;
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
CREATE TABLE "interesting!schema"."citus_local!_table"(value int);
|
CREATE TABLE "interesting!schema"."citus_local!_table"(value int);
|
||||||
SELECT create_citus_local_table('"interesting!schema"."citus_local!_table"');
|
ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);
|
||||||
create_citus_local_table
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507008, 'interesting!schema', 1507000, 'citus_local_table_triggers', 'ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);')
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE TRIGGER "trigger\'name"
|
CREATE TRIGGER "trigger\'name"
|
||||||
BEFORE INSERT ON "interesting!schema"."citus_local!_table"
|
BEFORE INSERT ON "interesting!schema"."citus_local!_table"
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'CREATE TRIGGER "trigger\\''name"
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'CREATE TRIGGER "trigger\\''name"
|
||||||
BEFORE INSERT ON "interesting!schema"."citus_local!_table"
|
BEFORE INSERT ON "interesting!schema"."citus_local!_table"
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();')
|
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();')
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE EXTENSION seg;
|
CREATE EXTENSION seg;
|
||||||
-- ALTER TRIGGER DEPENDS ON
|
-- ALTER TRIGGER DEPENDS ON
|
||||||
ALTER TRIGGER "trigger\'name" ON "interesting!schema"."citus_local!_table" DEPENDS ON EXTENSION seg;
|
ALTER TRIGGER "trigger\'name" ON "interesting!schema"."citus_local!_table" DEPENDS ON EXTENSION seg;
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'ALTER TRIGGER "trigger\\''name" ON "interesting!schema"."citus_local!_table" DEPENDS ON EXTENSION seg;')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'ALTER TRIGGER "trigger\\''name" ON "interesting!schema"."citus_local!_table" DEPENDS ON EXTENSION seg;')
|
||||||
-- show that triggers on both shell relation and shard relation are depending on seg
|
-- show that triggers on both shell relation and shard relation are depending on seg
|
||||||
SELECT tgname FROM pg_depend, pg_trigger, pg_extension
|
SELECT tgname FROM pg_depend, pg_trigger, pg_extension
|
||||||
WHERE deptype = 'x' and classid='pg_trigger'::regclass and
|
WHERE deptype = 'x' and classid='pg_trigger'::regclass and
|
||||||
|
@ -206,12 +206,13 @@ NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1
|
||||||
tgname
|
tgname
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
trigger\'name
|
trigger\'name
|
||||||
trigger\'name_1507007
|
trigger\'name_1507008
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
DROP EXTENSION seg;
|
DROP EXTENSION seg;
|
||||||
-- show that dropping extension drops the triggers automatically
|
-- show that dropping extension drops the triggers automatically
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
||||||
|
@ -220,102 +221,110 @@ NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- ALTER TRIGGER RENAME
|
-- ALTER TRIGGER RENAME
|
||||||
ALTER TRIGGER "trigger\'name" ON "interesting!schema"."citus_local!_table" RENAME TO "trigger\'name22";
|
ALTER TRIGGER "trigger\'name" ON "interesting!schema"."citus_local!_table" RENAME TO "trigger\'name22";
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'ALTER TRIGGER "trigger\\''name" ON "interesting!schema"."citus_local!_table" RENAME TO "trigger\\''name22";')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'ALTER TRIGGER "trigger\\''name" ON "interesting!schema"."citus_local!_table" RENAME TO "trigger\\''name22";')
|
||||||
-- show that triggers on both shell relation and shard relation are renamed
|
-- show that triggers on both shell relation and shard relation are renamed
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
trigger\'name22 | "interesting!schema"."citus_local!_table" | O
|
trigger\'name22 | "interesting!schema"."citus_local!_table" | O
|
||||||
trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | O
|
trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | O
|
||||||
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
-- ALTER TABLE DISABLE trigger
|
-- ALTER TABLE DISABLE trigger
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "trigger\'name22";
|
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "trigger\'name22";
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "trigger\\''name22";')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "trigger\\''name22";')
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
trigger\'name22 | "interesting!schema"."citus_local!_table" | D
|
trigger\'name22 | "interesting!schema"."citus_local!_table" | D
|
||||||
trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | D
|
trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | D
|
||||||
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
-- ALTER TABLE ENABLE trigger
|
-- ALTER TABLE ENABLE trigger
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER "trigger\'name22";
|
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER "trigger\'name22";
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER "trigger\\''name22";')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER "trigger\\''name22";')
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
trigger\'name22 | "interesting!schema"."citus_local!_table" | O
|
trigger\'name22 | "interesting!schema"."citus_local!_table" | O
|
||||||
trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | O
|
trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | O
|
||||||
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
CREATE TRIGGER another_trigger
|
CREATE TRIGGER another_trigger
|
||||||
AFTER DELETE ON "interesting!schema"."citus_local!_table"
|
AFTER DELETE ON "interesting!schema"."citus_local!_table"
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'CREATE TRIGGER another_trigger
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'CREATE TRIGGER another_trigger
|
||||||
AFTER DELETE ON "interesting!schema"."citus_local!_table"
|
AFTER DELETE ON "interesting!schema"."citus_local!_table"
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();')
|
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();')
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER USER;
|
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER USER;
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER USER;')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER USER;')
|
||||||
-- show that all triggers except the internal ones are disabled
|
-- show that all triggers except the internal ones are disabled
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
another_trigger | "interesting!schema"."citus_local!_table" | D
|
another_trigger | "interesting!schema"."citus_local!_table" | D
|
||||||
another_trigger_1507007 | "interesting!schema"."citus_local!_table_1507007" | D
|
another_trigger_1507008 | "interesting!schema"."citus_local!_table_1507008" | D
|
||||||
trigger\'name22 | "interesting!schema"."citus_local!_table" | D
|
trigger\'name22 | "interesting!schema"."citus_local!_table" | D
|
||||||
trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | D
|
trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | D
|
||||||
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER USER;
|
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER USER;
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER USER;')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER USER;')
|
||||||
-- show that all triggers except the internal ones are enabled again
|
-- show that all triggers except the internal ones are enabled again
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
another_trigger | "interesting!schema"."citus_local!_table" | O
|
another_trigger | "interesting!schema"."citus_local!_table" | O
|
||||||
another_trigger_1507007 | "interesting!schema"."citus_local!_table_1507007" | O
|
another_trigger_1507008 | "interesting!schema"."citus_local!_table_1507008" | O
|
||||||
trigger\'name22 | "interesting!schema"."citus_local!_table" | O
|
trigger\'name22 | "interesting!schema"."citus_local!_table" | O
|
||||||
trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | O
|
trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | O
|
||||||
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER ALL;
|
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER ALL;
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER ALL;')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER ALL;')
|
||||||
-- show that all triggers including internal triggers are disabled
|
-- show that all triggers including internal triggers are disabled
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
another_trigger | "interesting!schema"."citus_local!_table" | D
|
another_trigger | "interesting!schema"."citus_local!_table" | D
|
||||||
another_trigger_1507007 | "interesting!schema"."citus_local!_table_1507007" | D
|
another_trigger_1507008 | "interesting!schema"."citus_local!_table_1507008" | D
|
||||||
trigger\'name22 | "interesting!schema"."citus_local!_table" | D
|
trigger\'name22 | "interesting!schema"."citus_local!_table" | D
|
||||||
trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | D
|
trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | D
|
||||||
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | D
|
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | D
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;
|
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;')
|
||||||
-- show that all triggers including internal triggers are enabled again
|
-- show that all triggers including internal triggers are enabled again
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
another_trigger | "interesting!schema"."citus_local!_table" | O
|
another_trigger | "interesting!schema"."citus_local!_table" | O
|
||||||
another_trigger_1507007 | "interesting!schema"."citus_local!_table_1507007" | O
|
another_trigger_1507008 | "interesting!schema"."citus_local!_table_1507008" | O
|
||||||
trigger\'name22 | "interesting!schema"."citus_local!_table" | O
|
trigger\'name22 | "interesting!schema"."citus_local!_table" | O
|
||||||
trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | O
|
trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | O
|
||||||
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
DROP TRIGGER another_trigger ON "interesting!schema"."citus_local!_table";
|
DROP TRIGGER another_trigger ON "interesting!schema"."citus_local!_table";
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'DROP TRIGGER another_trigger ON "interesting!schema"."citus_local!_table";')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'DROP TRIGGER another_trigger ON "interesting!schema"."citus_local!_table";')
|
||||||
DROP TRIGGER "trigger\'name22" ON "interesting!schema"."citus_local!_table";
|
DROP TRIGGER "trigger\'name22" ON "interesting!schema"."citus_local!_table";
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'DROP TRIGGER "trigger\\''name22" ON "interesting!schema"."citus_local!_table";')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'DROP TRIGGER "trigger\\''name22" ON "interesting!schema"."citus_local!_table";')
|
||||||
-- show that drop trigger works as expected
|
-- show that drop trigger works as expected
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O
|
||||||
|
@ -327,7 +336,8 @@ BEGIN;
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "another_trigger\'name";
|
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "another_trigger\'name";
|
||||||
-- show that our truncate trigger is disabled ..
|
-- show that our truncate trigger is disabled ..
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
another_trigger\'name | "interesting!schema"."citus_local!_table" | D
|
another_trigger\'name | "interesting!schema"."citus_local!_table" | D
|
||||||
|
@ -335,9 +345,10 @@ BEGIN;
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;
|
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;')
|
||||||
-- .. and now it is enabled back
|
-- .. and now it is enabled back
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
tgname | tgrelid | tgenabled
|
tgname | tgrelid | tgenabled
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
another_trigger\'name | "interesting!schema"."citus_local!_table" | O
|
another_trigger\'name | "interesting!schema"."citus_local!_table" | O
|
||||||
|
@ -365,9 +376,9 @@ SELECT create_citus_local_table('another_citus_local_table');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
ALTER TABLE another_citus_local_table ADD CONSTRAINT fkey_self FOREIGN KEY(value) REFERENCES another_citus_local_table(value);
|
ALTER TABLE another_citus_local_table ADD CONSTRAINT fkey_self FOREIGN KEY(value) REFERENCES another_citus_local_table(value);
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507008, 'citus_local_table_triggers', 1507008, 'citus_local_table_triggers', 'ALTER TABLE another_citus_local_table ADD CONSTRAINT fkey_self FOREIGN KEY(value) REFERENCES another_citus_local_table(value);')
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507009, 'citus_local_table_triggers', 1507009, 'citus_local_table_triggers', 'ALTER TABLE another_citus_local_table ADD CONSTRAINT fkey_self FOREIGN KEY(value) REFERENCES another_citus_local_table(value);')
|
||||||
ALTER TABLE citus_local_table ADD CONSTRAINT fkey_c_to_c FOREIGN KEY(value) REFERENCES another_citus_local_table(value) ON UPDATE CASCADE;
|
ALTER TABLE citus_local_table ADD CONSTRAINT fkey_c_to_c FOREIGN KEY(value) REFERENCES another_citus_local_table(value) ON UPDATE CASCADE;
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507000, 'citus_local_table_triggers', 1507008, 'citus_local_table_triggers', 'ALTER TABLE citus_local_table ADD CONSTRAINT fkey_c_to_c FOREIGN KEY(value) REFERENCES another_citus_local_table(value) ON UPDATE CASCADE;')
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507001, 'citus_local_table_triggers', 1507009, 'citus_local_table_triggers', 'ALTER TABLE citus_local_table ADD CONSTRAINT fkey_c_to_c FOREIGN KEY(value) REFERENCES another_citus_local_table(value) ON UPDATE CASCADE;')
|
||||||
CREATE TABLE reference_table(value int);
|
CREATE TABLE reference_table(value int);
|
||||||
SELECT create_reference_table('reference_table');
|
SELECT create_reference_table('reference_table');
|
||||||
create_reference_table
|
create_reference_table
|
||||||
|
@ -390,14 +401,14 @@ BEGIN;
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION insert_100();
|
FOR EACH STATEMENT EXECUTE FUNCTION insert_100();
|
||||||
TRUNCATE another_citus_local_table CASCADE;
|
TRUNCATE another_citus_local_table CASCADE;
|
||||||
NOTICE: truncate cascades to table "citus_local_table"
|
NOTICE: truncate cascades to table "citus_local_table"
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507009 (value) VALUES (100)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507010 (value) VALUES (100)
|
||||||
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_triggers.another_citus_local_table_xxxxx CASCADE
|
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_triggers.another_citus_local_table_xxxxx CASCADE
|
||||||
NOTICE: truncate cascades to table "citus_local_table_xxxxx"
|
NOTICE: truncate cascades to table "citus_local_table_xxxxx"
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507009 (value) VALUES (100)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507010 (value) VALUES (100)
|
||||||
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_triggers.citus_local_table_xxxxx CASCADE
|
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_triggers.citus_local_table_xxxxx CASCADE
|
||||||
-- we should see two rows with "100"
|
-- we should see two rows with "100"
|
||||||
SELECT * FROM reference_table;
|
SELECT * FROM reference_table;
|
||||||
NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507009 reference_table
|
NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507010 reference_table
|
||||||
value
|
value
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
100
|
100
|
||||||
|
@ -408,28 +419,28 @@ ROLLBACK;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
-- update should actually update something to test ON UPDATE CASCADE logic
|
-- update should actually update something to test ON UPDATE CASCADE logic
|
||||||
INSERT INTO another_citus_local_table VALUES (600);
|
INSERT INTO another_citus_local_table VALUES (600);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.another_citus_local_table_1507008 (value) VALUES (600)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.another_citus_local_table_1507009 (value) VALUES (600)
|
||||||
INSERT INTO citus_local_table VALUES (600);
|
INSERT INTO citus_local_table VALUES (600);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507000 (value) VALUES (600)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507001 (value) VALUES (600)
|
||||||
CREATE TRIGGER insert_100_trigger
|
CREATE TRIGGER insert_100_trigger
|
||||||
AFTER UPDATE ON another_citus_local_table
|
AFTER UPDATE ON another_citus_local_table
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION insert_100();
|
FOR EACH STATEMENT EXECUTE FUNCTION insert_100();
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'citus_local_table_triggers', 'CREATE TRIGGER insert_100_trigger
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507009, 'citus_local_table_triggers', 'CREATE TRIGGER insert_100_trigger
|
||||||
AFTER UPDATE ON another_citus_local_table
|
AFTER UPDATE ON another_citus_local_table
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION insert_100();')
|
FOR EACH STATEMENT EXECUTE FUNCTION insert_100();')
|
||||||
CREATE TRIGGER insert_100_trigger
|
CREATE TRIGGER insert_100_trigger
|
||||||
AFTER UPDATE ON citus_local_table
|
AFTER UPDATE ON citus_local_table
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION insert_100();
|
FOR EACH STATEMENT EXECUTE FUNCTION insert_100();
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507000, 'citus_local_table_triggers', 'CREATE TRIGGER insert_100_trigger
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507001, 'citus_local_table_triggers', 'CREATE TRIGGER insert_100_trigger
|
||||||
AFTER UPDATE ON citus_local_table
|
AFTER UPDATE ON citus_local_table
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION insert_100();')
|
FOR EACH STATEMENT EXECUTE FUNCTION insert_100();')
|
||||||
UPDATE another_citus_local_table SET value=value-1;;
|
UPDATE another_citus_local_table SET value=value-1;;
|
||||||
NOTICE: executing the command locally: UPDATE citus_local_table_triggers.another_citus_local_table_1507008 another_citus_local_table SET value = (value OPERATOR(pg_catalog.-) 1)
|
NOTICE: executing the command locally: UPDATE citus_local_table_triggers.another_citus_local_table_1507009 another_citus_local_table SET value = (value OPERATOR(pg_catalog.-) 1)
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507009 (value) VALUES (100)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507010 (value) VALUES (100)
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507009 (value) VALUES (100)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507010 (value) VALUES (100)
|
||||||
-- we should see two rows with "100"
|
-- we should see two rows with "100"
|
||||||
SELECT * FROM reference_table;
|
SELECT * FROM reference_table;
|
||||||
NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507009 reference_table
|
NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507010 reference_table
|
||||||
value
|
value
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
100
|
100
|
||||||
|
@ -439,4 +450,4 @@ NOTICE: executing the command locally: SELECT value FROM citus_local_table_trig
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- cleanup at exit
|
-- cleanup at exit
|
||||||
DROP SCHEMA citus_local_table_triggers, "interesting!schema" CASCADE;
|
DROP SCHEMA citus_local_table_triggers, "interesting!schema" CASCADE;
|
||||||
NOTICE: drop cascades to 11 other objects
|
NOTICE: drop cascades to 13 other objects
|
||||||
|
|
|
@ -14,20 +14,19 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
|
CREATE TABLE dummy_reference_table(a int unique, b int);
|
||||||
|
SELECT create_reference_table('dummy_reference_table');
|
||||||
|
create_reference_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
CREATE TABLE citus_local_table(a int, b int);
|
CREATE TABLE citus_local_table(a int, b int);
|
||||||
SELECT create_citus_local_table('citus_local_table');
|
ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);
|
||||||
create_citus_local_table
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509001, 'citus_local_table_queries', 1509000, 'citus_local_table_queries', 'ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);')
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE TABLE citus_local_table_2(a int, b int);
|
CREATE TABLE citus_local_table_2(a int, b int);
|
||||||
SELECT create_citus_local_table('citus_local_table_2');
|
ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);
|
||||||
create_citus_local_table
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509002, 'citus_local_table_queries', 1509000, 'citus_local_table_queries', 'ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);')
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE TABLE reference_table(a int, b int);
|
CREATE TABLE reference_table(a int, b int);
|
||||||
SELECT create_reference_table('reference_table');
|
SELECT create_reference_table('reference_table');
|
||||||
create_reference_table
|
create_reference_table
|
||||||
|
@ -53,8 +52,9 @@ CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
SET client_min_messages to ERROR;
|
SET client_min_messages to ERROR;
|
||||||
|
|
||||||
TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table;
|
TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table, dummy_reference_table, citus_local_table_2;
|
||||||
|
|
||||||
|
INSERT INTO dummy_reference_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
|
@ -75,14 +75,14 @@ SELECT clear_and_init_test_tables();
|
||||||
|
|
||||||
-- join between citus local tables and reference tables would succeed
|
-- join between citus local tables and reference tables would succeed
|
||||||
SELECT count(*) FROM citus_local_table, reference_table WHERE citus_local_table.a = reference_table.a;
|
SELECT count(*) FROM citus_local_table, reference_table WHERE citus_local_table.a = reference_table.a;
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.reference_table_1509002 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a)
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.reference_table_1509003 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT * FROM citus_local_table, reference_table WHERE citus_local_table.a = reference_table.a ORDER BY 1,2,3,4 FOR UPDATE;
|
SELECT * FROM citus_local_table, reference_table WHERE citus_local_table.a = reference_table.a ORDER BY 1,2,3,4 FOR UPDATE;
|
||||||
NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.reference_table_1509002 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) ORDER BY citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FOR UPDATE OF citus_local_table FOR UPDATE OF reference_table
|
NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.reference_table_1509003 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) ORDER BY citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FOR UPDATE OF citus_local_table FOR UPDATE OF reference_table
|
||||||
a | b | a | b
|
a | b | a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0 | 0 | 0 | 0
|
0 | 0 | 0 | 0
|
||||||
|
@ -97,7 +97,7 @@ NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_
|
||||||
WITH cte_1 AS
|
WITH cte_1 AS
|
||||||
(SELECT * FROM citus_local_table, reference_table WHERE citus_local_table.a = reference_table.a ORDER BY 1,2,3,4 FOR UPDATE)
|
(SELECT * FROM citus_local_table, reference_table WHERE citus_local_table.a = reference_table.a ORDER BY 1,2,3,4 FOR UPDATE)
|
||||||
SELECT count(*) FROM cte_1;
|
SELECT count(*) FROM cte_1;
|
||||||
NOTICE: executing the command locally: WITH cte_1 AS (SELECT citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.reference_table_1509002 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) ORDER BY citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FOR UPDATE OF citus_local_table FOR UPDATE OF reference_table) SELECT count(*) AS count FROM cte_1 cte_1(a, b, a_1, b_1)
|
NOTICE: executing the command locally: WITH cte_1 AS (SELECT citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.reference_table_1509003 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) ORDER BY citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FOR UPDATE OF citus_local_table FOR UPDATE OF reference_table) SELECT count(*) AS count FROM cte_1 cte_1(a, b, a_1, b_1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
|
@ -112,7 +112,7 @@ cte_distributed_table AS
|
||||||
(SELECT * FROM distributed_table)
|
(SELECT * FROM distributed_table)
|
||||||
SELECT count(*) FROM cte_distributed_table, cte_citus_local_table, cte_postgres_local_table
|
SELECT count(*) FROM cte_distributed_table, cte_citus_local_table, cte_postgres_local_table
|
||||||
WHERE cte_citus_local_table.a = 1 AND cte_distributed_table.a = 1;
|
WHERE cte_citus_local_table.a = 1 AND cte_distributed_table.a = 1;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
|
@ -126,7 +126,7 @@ SELECT count(*) FROM
|
||||||
(
|
(
|
||||||
SELECT * FROM (SELECT * FROM citus_local_table) as subquery_inner
|
SELECT * FROM (SELECT * FROM citus_local_table) as subquery_inner
|
||||||
) as subquery_top;
|
) as subquery_top;
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.a, subquery_inner.b FROM (SELECT citus_local_table.a, citus_local_table.b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table) subquery_inner) subquery_top
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.a, subquery_inner.b FROM (SELECT citus_local_table.a, citus_local_table.b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table) subquery_inner) subquery_top
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
|
@ -143,7 +143,7 @@ SELECT count(*) FROM
|
||||||
(
|
(
|
||||||
SELECT * FROM (SELECT count(*) FROM citus_local_table, postgres_local_table) as subquery_inner
|
SELECT * FROM (SELECT count(*) FROM citus_local_table, postgres_local_table) as subquery_inner
|
||||||
) as subquery_top;
|
) as subquery_top;
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.count FROM (SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.postgres_local_table) subquery_inner) subquery_top
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.count FROM (SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.postgres_local_table) subquery_inner) subquery_top
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
|
@ -154,7 +154,7 @@ SELECT count(*) FROM
|
||||||
(
|
(
|
||||||
SELECT *, random() FROM (SELECT *, random() FROM citus_local_table, distributed_table) as subquery_inner
|
SELECT *, random() FROM (SELECT *, random() FROM citus_local_table, distributed_table) as subquery_inner
|
||||||
) as subquery_top;
|
) as subquery_top;
|
||||||
NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true
|
NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
36
|
36
|
||||||
|
@ -167,7 +167,7 @@ SELECT count(*) FROM
|
||||||
FROM (
|
FROM (
|
||||||
WITH cte_1 AS (SELECT *, random() FROM citus_local_table, distributed_table) SELECT * FROM cte_1) as subquery_inner
|
WITH cte_1 AS (SELECT *, random() FROM citus_local_table, distributed_table) SELECT * FROM cte_1) as subquery_inner
|
||||||
) as subquery_top;
|
) as subquery_top;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.a, subquery_inner.b, subquery_inner.a_1 AS a, subquery_inner.b_1 AS b, subquery_inner.random, random() AS random FROM (SELECT cte_1.a, cte_1.b, cte_1.a_1 AS a, cte_1.b_1 AS b, cte_1.random FROM (SELECT intermediate_result.a, intermediate_result.b, intermediate_result.a_1 AS a, intermediate_result.b_1 AS b, intermediate_result.random FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer, a_1 integer, b_1 integer, random double precision)) cte_1(a, b, a_1, b_1, random)) subquery_inner(a, b, a_1, b_1, random)) subquery_top(a, b, a_1, b_1, random, random_1)
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.a, subquery_inner.b, subquery_inner.a_1 AS a, subquery_inner.b_1 AS b, subquery_inner.random, random() AS random FROM (SELECT cte_1.a, cte_1.b, cte_1.a_1 AS a, cte_1.b_1 AS b, cte_1.random FROM (SELECT intermediate_result.a, intermediate_result.b, intermediate_result.a_1 AS a, intermediate_result.b_1 AS b, intermediate_result.random FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer, a_1 integer, b_1 integer, random double precision)) cte_1(a, b, a_1, b_1, random)) subquery_inner(a, b, a_1, b_1, random)) subquery_top(a, b, a_1, b_1, random, random_1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -182,7 +182,7 @@ SELECT count(*) FROM
|
||||||
WITH cte_1 AS (SELECT *, random() FROM citus_local_table), cte_2 AS (SELECT * FROM distributed_table) SELECT count(*) FROM cte_1, cte_2
|
WITH cte_1 AS (SELECT *, random() FROM citus_local_table), cte_2 AS (SELECT * FROM distributed_table) SELECT count(*) FROM cte_1, cte_2
|
||||||
) as subquery_inner
|
) as subquery_inner
|
||||||
) as subquery_top;
|
) as subquery_top;
|
||||||
NOTICE: executing the command locally: SELECT a, b, random() AS random FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT a, b, random() AS random FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.count, random() AS random FROM (SELECT intermediate_result.count FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(count bigint)) subquery_inner) subquery_top
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.count, random() AS random FROM (SELECT intermediate_result.count FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(count bigint)) subquery_inner) subquery_top
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -199,42 +199,42 @@ SELECT clear_and_init_test_tables();
|
||||||
PREPARE citus_local_only AS SELECT count(*) FROM citus_local_table;
|
PREPARE citus_local_only AS SELECT count(*) FROM citus_local_table;
|
||||||
-- execute 6 times, local tables without params
|
-- execute 6 times, local tables without params
|
||||||
EXECUTE citus_local_only;
|
EXECUTE citus_local_only;
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only;
|
EXECUTE citus_local_only;
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only;
|
EXECUTE citus_local_only;
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only;
|
EXECUTE citus_local_only;
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only;
|
EXECUTE citus_local_only;
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only;
|
EXECUTE citus_local_only;
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
|
@ -243,42 +243,42 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_loca
|
||||||
-- execute 6 times, with param
|
-- execute 6 times, with param
|
||||||
PREPARE citus_local_only_p(int) AS SELECT count(*) FROM citus_local_table WHERE a = $1;
|
PREPARE citus_local_only_p(int) AS SELECT count(*) FROM citus_local_table WHERE a = $1;
|
||||||
EXECUTE citus_local_only_p(1);
|
EXECUTE citus_local_only_p(1);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only_p(1);
|
EXECUTE citus_local_only_p(1);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only_p(1);
|
EXECUTE citus_local_only_p(1);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only_p(1);
|
EXECUTE citus_local_only_p(1);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only_p(1);
|
EXECUTE citus_local_only_p(1);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only_p(1);
|
EXECUTE citus_local_only_p(1);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
|
@ -287,14 +287,14 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_loca
|
||||||
-- do not evalute the function
|
-- do not evalute the function
|
||||||
-- show the logs
|
-- show the logs
|
||||||
EXECUTE citus_local_only_p(random());
|
EXECUTE citus_local_only_p(random());
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE citus_local_only_p(random());
|
EXECUTE citus_local_only_p(random());
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
|
@ -310,49 +310,49 @@ PREPARE mixed_query(int, int, int) AS
|
||||||
cte_mixes AS (SELECT * FROM cte_distributed_table, cte_citus_local_table, cte_postgres_local_table)
|
cte_mixes AS (SELECT * FROM cte_distributed_table, cte_citus_local_table, cte_postgres_local_table)
|
||||||
SELECT count(*) FROM cte_mixes;
|
SELECT count(*) FROM cte_mixes;
|
||||||
EXECUTE mixed_query(1,2,3);
|
EXECUTE mixed_query(1,2,3);
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE mixed_query(1,2,3);
|
EXECUTE mixed_query(1,2,3);
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE mixed_query(1,2,3);
|
EXECUTE mixed_query(1,2,3);
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE mixed_query(1,2,3);
|
EXECUTE mixed_query(1,2,3);
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE mixed_query(1,2,3);
|
EXECUTE mixed_query(1,2,3);
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE mixed_query(1,2,3);
|
EXECUTE mixed_query(1,2,3);
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
EXECUTE mixed_query(1,2,3);
|
EXECUTE mixed_query(1,2,3);
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
|
@ -366,7 +366,7 @@ SELECT clear_and_init_test_tables();
|
||||||
|
|
||||||
-- anonymous columns
|
-- anonymous columns
|
||||||
WITH a AS (SELECT a, '' FROM citus_local_table GROUP BY a) SELECT a.a FROM a ORDER BY 1 LIMIT 5;
|
WITH a AS (SELECT a, '' FROM citus_local_table GROUP BY a) SELECT a.a FROM a ORDER BY 1 LIMIT 5;
|
||||||
NOTICE: executing the command locally: SELECT a FROM (SELECT citus_local_table.a, ''::text FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table GROUP BY citus_local_table.a) a(a, "?column?") ORDER BY a LIMIT 5
|
NOTICE: executing the command locally: SELECT a FROM (SELECT citus_local_table.a, ''::text FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table GROUP BY citus_local_table.a) a(a, "?column?") ORDER BY a LIMIT 5
|
||||||
a
|
a
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0
|
0
|
||||||
|
@ -377,7 +377,7 @@ NOTICE: executing the command locally: SELECT a FROM (SELECT citus_local_table.
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
WITH a AS (SELECT b, '' FROM citus_local_table WHERE a = 1) SELECT * FROM a, a b ORDER BY 1 LIMIT 5;
|
WITH a AS (SELECT b, '' FROM citus_local_table WHERE a = 1) SELECT * FROM a, a b ORDER BY 1 LIMIT 5;
|
||||||
NOTICE: executing the command locally: WITH a AS (SELECT citus_local_table.b, ''::text FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) 1)) SELECT a.b, a."?column?", b.b, b."?column?" FROM a a(b, "?column?"), a b(b, "?column?") ORDER BY a.b LIMIT 5
|
NOTICE: executing the command locally: WITH a AS (SELECT citus_local_table.b, ''::text FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) 1)) SELECT a.b, a."?column?", b.b, b."?column?" FROM a a(b, "?column?"), a b(b, "?column?") ORDER BY a.b LIMIT 5
|
||||||
b | ?column? | b | ?column?
|
b | ?column? | b | ?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | | 1 |
|
1 | | 1 |
|
||||||
|
@ -388,7 +388,7 @@ SELECT * FROM citus_local_table, postgres_local_table
|
||||||
WHERE citus_local_table.a - postgres_local_table.a = 0
|
WHERE citus_local_table.a - postgres_local_table.a = 0
|
||||||
ORDER BY 1,2,3,4
|
ORDER BY 1,2,3,4
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_table.b, postgres_local_table.a, postgres_local_table.b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.postgres_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.-) postgres_local_table.a) OPERATOR(pg_catalog.=) 0) ORDER BY citus_local_table.a, citus_local_table.b, postgres_local_table.a, postgres_local_table.b LIMIT 10
|
NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_table.b, postgres_local_table.a, postgres_local_table.b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.postgres_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.-) postgres_local_table.a) OPERATOR(pg_catalog.=) 0) ORDER BY citus_local_table.a, citus_local_table.b, postgres_local_table.a, postgres_local_table.b LIMIT 10
|
||||||
a | b | a | b
|
a | b | a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0 | 0 | 0 | 0
|
0 | 0 | 0 | 0
|
||||||
|
@ -401,7 +401,7 @@ NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_
|
||||||
|
|
||||||
-- set operations should just work
|
-- set operations should just work
|
||||||
SELECT * FROM citus_local_table UNION SELECT * FROM postgres_local_table UNION SELECT * FROM distributed_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table UNION SELECT * FROM postgres_local_table UNION SELECT * FROM distributed_table ORDER BY 1,2;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
NOTICE: executing the command locally: SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer) UNION SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer) UNION SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer) ORDER BY 1, 2
|
NOTICE: executing the command locally: SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer) UNION SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer) UNION SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer) ORDER BY 1, 2
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -414,7 +414,7 @@ NOTICE: executing the command locally: SELECT intermediate_result.a, intermedia
|
||||||
(6 rows)
|
(6 rows)
|
||||||
|
|
||||||
(SELECT * FROM citus_local_table ORDER BY 1,2 LIMIT 5) INTERSECT (SELECT i, i FROM generate_series(0, 100) i) ORDER BY 1, 2;
|
(SELECT * FROM citus_local_table ORDER BY 1,2 LIMIT 5) INTERSECT (SELECT i, i FROM generate_series(0, 100) i) ORDER BY 1, 2;
|
||||||
NOTICE: executing the command locally: (SELECT citus_local_table.a, citus_local_table.b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table ORDER BY citus_local_table.a, citus_local_table.b LIMIT 5) INTERSECT SELECT i.i, i.i FROM generate_series(0, 100) i(i) ORDER BY 1, 2
|
NOTICE: executing the command locally: (SELECT citus_local_table.a, citus_local_table.b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table ORDER BY citus_local_table.a, citus_local_table.b LIMIT 5) INTERSECT SELECT i.i, i.i FROM generate_series(0, 100) i(i) ORDER BY 1, 2
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0 | 0
|
0 | 0
|
||||||
|
@ -426,28 +426,28 @@ NOTICE: executing the command locally: (SELECT citus_local_table.a, citus_local
|
||||||
|
|
||||||
-- should just work as recursive planner kicks in
|
-- should just work as recursive planner kicks in
|
||||||
SELECT count(*) FROM distributed_table WHERE a IN (SELECT a FROM citus_local_table);
|
SELECT count(*) FROM distributed_table WHERE a IN (SELECT a FROM citus_local_table);
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT count(*) FROM citus_local_table WHERE a IN (SELECT a FROM distributed_table);
|
SELECT count(*) FROM citus_local_table WHERE a IN (SELECT a FROM distributed_table);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)))
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)))
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT count(*) FROM reference_table WHERE a IN (SELECT a FROM citus_local_table);
|
SELECT count(*) FROM reference_table WHERE a IN (SELECT a FROM citus_local_table);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.reference_table_1509002 reference_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT citus_local_table.a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table))
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.reference_table_1509003 reference_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT citus_local_table.a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table))
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT count(*) FROM citus_local_table WHERE a IN (SELECT a FROM reference_table);
|
SELECT count(*) FROM citus_local_table WHERE a IN (SELECT a FROM reference_table);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT reference_table.a FROM citus_local_table_queries.reference_table_1509002 reference_table))
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT reference_table.a FROM citus_local_table_queries.reference_table_1509003 reference_table))
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
|
@ -458,8 +458,8 @@ SELECT count(*) FROM citus_local_table
|
||||||
WHERE a IN
|
WHERE a IN
|
||||||
(SELECT a FROM distributed_table WHERE a IN
|
(SELECT a FROM distributed_table WHERE a IN
|
||||||
(SELECT b FROM citus_local_table WHERE b IN (SELECT b FROM postgres_local_table)));
|
(SELECT b FROM citus_local_table WHERE b IN (SELECT b FROM postgres_local_table)));
|
||||||
NOTICE: executing the command locally: SELECT b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (b OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(b integer)))
|
NOTICE: executing the command locally: SELECT b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (b OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(b integer)))
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(a integer)))
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(a integer)))
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
|
@ -467,7 +467,7 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_loca
|
||||||
|
|
||||||
-- local outer joins
|
-- local outer joins
|
||||||
SELECT count(*) FROM citus_local_table LEFT JOIN reference_table ON (true);
|
SELECT count(*) FROM citus_local_table LEFT JOIN reference_table ON (true);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_1509000 citus_local_table LEFT JOIN citus_local_table_queries.reference_table_1509002 reference_table ON (true))
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_1509001 citus_local_table LEFT JOIN citus_local_table_queries.reference_table_1509003 reference_table ON (true))
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
36
|
36
|
||||||
|
@ -477,7 +477,7 @@ SELECT count(*) FROM reference_table
|
||||||
LEFT JOIN citus_local_table ON (true)
|
LEFT JOIN citus_local_table ON (true)
|
||||||
LEFT JOIN postgres_local_table ON (true)
|
LEFT JOIN postgres_local_table ON (true)
|
||||||
LEFT JOIN reference_table r2 ON (true);
|
LEFT JOIN reference_table r2 ON (true);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM (((citus_local_table_queries.reference_table_1509002 reference_table LEFT JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true)) LEFT JOIN citus_local_table_queries.postgres_local_table ON (true)) LEFT JOIN citus_local_table_queries.reference_table_1509002 r2 ON (true))
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM (((citus_local_table_queries.reference_table_1509003 reference_table LEFT JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true)) LEFT JOIN citus_local_table_queries.postgres_local_table ON (true)) LEFT JOIN citus_local_table_queries.reference_table_1509003 r2 ON (true))
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1296
|
1296
|
||||||
|
@ -500,7 +500,7 @@ ORDER BY
|
||||||
1, 2
|
1, 2
|
||||||
LIMIT
|
LIMIT
|
||||||
1;
|
1;
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (b OPERATOR(pg_catalog.=) 1)
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (b OPERATOR(pg_catalog.=) 1)
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | 1
|
1 | 1
|
||||||
|
@ -519,7 +519,7 @@ ORDER BY
|
||||||
1 ,2
|
1 ,2
|
||||||
LIMIT
|
LIMIT
|
||||||
1;
|
1;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (b OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) ORDER BY a, b LIMIT 1
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (b OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) ORDER BY a, b LIMIT 1
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | 1
|
1 | 1
|
||||||
|
@ -527,7 +527,7 @@ NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queri
|
||||||
|
|
||||||
-- join between citus local tables and distributed tables would fail
|
-- join between citus local tables and distributed tables would fail
|
||||||
SELECT count(*) FROM citus_local_table, distributed_table;
|
SELECT count(*) FROM citus_local_table, distributed_table;
|
||||||
NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true
|
NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
36
|
36
|
||||||
|
@ -539,7 +539,7 @@ ERROR: could not run distributed query with FOR UPDATE/SHARE commands
|
||||||
SELECT count(citus_local_table.b), count(postgres_local_table.a)
|
SELECT count(citus_local_table.b), count(postgres_local_table.a)
|
||||||
FROM citus_local_table, postgres_local_table
|
FROM citus_local_table, postgres_local_table
|
||||||
WHERE citus_local_table.a = postgres_local_table.b;
|
WHERE citus_local_table.a = postgres_local_table.b;
|
||||||
NOTICE: executing the command locally: SELECT count(citus_local_table.b) AS count, count(postgres_local_table.a) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.postgres_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) postgres_local_table.b)
|
NOTICE: executing the command locally: SELECT count(citus_local_table.b) AS count, count(postgres_local_table.a) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.postgres_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) postgres_local_table.b)
|
||||||
count | count
|
count | count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6 | 6
|
6 | 6
|
||||||
|
@ -547,7 +547,7 @@ NOTICE: executing the command locally: SELECT count(citus_local_table.b) AS cou
|
||||||
|
|
||||||
-- select for update is just OK
|
-- select for update is just OK
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2 FOR UPDATE;
|
SELECT * FROM citus_local_table ORDER BY 1,2 FOR UPDATE;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table ORDER BY a, b FOR UPDATE OF citus_local_table
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table ORDER BY a, b FOR UPDATE OF citus_local_table
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0 | 0
|
0 | 0
|
||||||
|
@ -570,32 +570,32 @@ SELECT clear_and_init_test_tables();
|
||||||
|
|
||||||
INSERT INTO citus_local_table
|
INSERT INTO citus_local_table
|
||||||
SELECT * from reference_table;
|
SELECT * from reference_table;
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a, b) SELECT a, b FROM citus_local_table_queries.reference_table_1509002 reference_table
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a, b) SELECT a, b FROM citus_local_table_queries.reference_table_1509003 reference_table
|
||||||
INSERT INTO reference_table
|
INSERT INTO reference_table
|
||||||
SELECT * from citus_local_table;
|
SELECT * from citus_local_table;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
NOTICE: executing the copy locally for shard xxxxx
|
NOTICE: executing the copy locally for shard xxxxx
|
||||||
INSERT INTO citus_local_table
|
INSERT INTO citus_local_table
|
||||||
SELECT * from distributed_table;
|
SELECT * from distributed_table;
|
||||||
NOTICE: executing the copy locally for shard xxxxx
|
NOTICE: executing the copy locally for shard xxxxx
|
||||||
INSERT INTO distributed_table
|
INSERT INTO distributed_table
|
||||||
SELECT * from citus_local_table;
|
SELECT * from citus_local_table;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
INSERT INTO citus_local_table
|
INSERT INTO citus_local_table
|
||||||
SELECT * from citus_local_table_2;
|
SELECT * from citus_local_table_2;
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a, b) SELECT a, b FROM citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a, b) SELECT a, b FROM citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2
|
||||||
INSERT INTO citus_local_table
|
INSERT INTO citus_local_table
|
||||||
SELECT * from citus_local_table_2
|
SELECT * from citus_local_table_2
|
||||||
ORDER BY 1,2
|
ORDER BY 1,2
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2 ORDER BY a, b LIMIT 10
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2 ORDER BY a, b LIMIT 10
|
||||||
NOTICE: executing the copy locally for shard xxxxx
|
NOTICE: executing the copy locally for shard xxxxx
|
||||||
INSERT INTO citus_local_table
|
INSERT INTO citus_local_table
|
||||||
SELECT * from postgres_local_table;
|
SELECT * from postgres_local_table;
|
||||||
NOTICE: executing the copy locally for shard xxxxx
|
NOTICE: executing the copy locally for shard xxxxx
|
||||||
INSERT INTO postgres_local_table
|
INSERT INTO postgres_local_table
|
||||||
SELECT * from citus_local_table;
|
SELECT * from citus_local_table;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
-- INSERT SELECT with local joins are OK
|
-- INSERT SELECT with local joins are OK
|
||||||
SELECT clear_and_init_test_tables();
|
SELECT clear_and_init_test_tables();
|
||||||
clear_and_init_test_tables
|
clear_and_init_test_tables
|
||||||
|
@ -606,16 +606,16 @@ SELECT clear_and_init_test_tables();
|
||||||
INSERT INTO citus_local_table
|
INSERT INTO citus_local_table
|
||||||
SELECT reference_table.* FROM reference_table
|
SELECT reference_table.* FROM reference_table
|
||||||
JOIN citus_local_table ON (true);
|
JOIN citus_local_table ON (true);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a, b) SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509002 reference_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true))
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a, b) SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509003 reference_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true))
|
||||||
INSERT INTO reference_table
|
INSERT INTO reference_table
|
||||||
SELECT reference_table.* FROM reference_table
|
SELECT reference_table.* FROM reference_table
|
||||||
JOIN citus_local_table ON (true);
|
JOIN citus_local_table ON (true);
|
||||||
NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509002 reference_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true))
|
NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509003 reference_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true))
|
||||||
NOTICE: executing the copy locally for shard xxxxx
|
NOTICE: executing the copy locally for shard xxxxx
|
||||||
INSERT INTO reference_table
|
INSERT INTO reference_table
|
||||||
SELECT reference_table.* FROM reference_table, postgres_local_table
|
SELECT reference_table.* FROM reference_table, postgres_local_table
|
||||||
JOIN citus_local_table ON (true);
|
JOIN citus_local_table ON (true);
|
||||||
NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM citus_local_table_queries.reference_table_1509002 reference_table, (citus_local_table_queries.postgres_local_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true))
|
NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM citus_local_table_queries.reference_table_1509003 reference_table, (citus_local_table_queries.postgres_local_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true))
|
||||||
NOTICE: executing the copy locally for shard xxxxx
|
NOTICE: executing the copy locally for shard xxxxx
|
||||||
SELECT clear_and_init_test_tables();
|
SELECT clear_and_init_test_tables();
|
||||||
clear_and_init_test_tables
|
clear_and_init_test_tables
|
||||||
|
@ -626,15 +626,15 @@ SELECT clear_and_init_test_tables();
|
||||||
INSERT INTO distributed_table
|
INSERT INTO distributed_table
|
||||||
SELECT reference_table.* FROM reference_table
|
SELECT reference_table.* FROM reference_table
|
||||||
JOIN citus_local_table ON (true);
|
JOIN citus_local_table ON (true);
|
||||||
NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509002 reference_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true))
|
NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509003 reference_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true))
|
||||||
INSERT INTO distributed_table
|
INSERT INTO distributed_table
|
||||||
SELECT reference_table.* FROM reference_table, postgres_local_table
|
SELECT reference_table.* FROM reference_table, postgres_local_table
|
||||||
JOIN citus_local_table ON (true);
|
JOIN citus_local_table ON (true);
|
||||||
NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM citus_local_table_queries.reference_table_1509002 reference_table, (citus_local_table_queries.postgres_local_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true))
|
NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM citus_local_table_queries.reference_table_1509003 reference_table, (citus_local_table_queries.postgres_local_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true))
|
||||||
INSERT INTO postgres_local_table
|
INSERT INTO postgres_local_table
|
||||||
SELECT reference_table.* FROM reference_table
|
SELECT reference_table.* FROM reference_table
|
||||||
JOIN citus_local_table ON (true);
|
JOIN citus_local_table ON (true);
|
||||||
NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509002 reference_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true))
|
NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509003 reference_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true))
|
||||||
-- INSERT SELECT that joins reference and distributed tables is also OK
|
-- INSERT SELECT that joins reference and distributed tables is also OK
|
||||||
SELECT clear_and_init_test_tables();
|
SELECT clear_and_init_test_tables();
|
||||||
clear_and_init_test_tables
|
clear_and_init_test_tables
|
||||||
|
@ -654,17 +654,17 @@ NOTICE: executing the copy locally for shard xxxxx
|
||||||
INSERT INTO citus_local_table
|
INSERT INTO citus_local_table
|
||||||
SELECT distributed_table.* FROM distributed_table
|
SELECT distributed_table.* FROM distributed_table
|
||||||
JOIN citus_local_table ON (true);
|
JOIN citus_local_table ON (true);
|
||||||
NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true
|
NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true
|
||||||
NOTICE: executing the copy locally for shard xxxxx
|
NOTICE: executing the copy locally for shard xxxxx
|
||||||
-- .. but when wrapped into a CTE, join works fine
|
-- .. but when wrapped into a CTE, join works fine
|
||||||
INSERT INTO citus_local_table
|
INSERT INTO citus_local_table
|
||||||
SELECT distributed_table.* FROM distributed_table
|
SELECT distributed_table.* FROM distributed_table
|
||||||
JOIN (WITH cte AS (SELECT * FROM citus_local_table) SELECT * FROM cte) as foo ON (true);
|
JOIN (WITH cte AS (SELECT * FROM citus_local_table) SELECT * FROM cte) as foo ON (true);
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
NOTICE: executing the copy locally for shard xxxxx
|
NOTICE: executing the copy locally for shard xxxxx
|
||||||
-- multi row insert is OK
|
-- multi row insert is OK
|
||||||
INSERT INTO citus_local_table VALUES (1, 2), (3, 4);
|
INSERT INTO citus_local_table VALUES (1, 2), (3, 4);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a, b) VALUES (1,2), (3,4)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a, b) VALUES (1,2), (3,4)
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
----- DELETE / UPDATE -----
|
----- DELETE / UPDATE -----
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -679,83 +679,83 @@ SELECT clear_and_init_test_tables();
|
||||||
DELETE FROM citus_local_table
|
DELETE FROM citus_local_table
|
||||||
USING postgres_local_table
|
USING postgres_local_table
|
||||||
WHERE citus_local_table.b = postgres_local_table.b;
|
WHERE citus_local_table.b = postgres_local_table.b;
|
||||||
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table USING citus_local_table_queries.postgres_local_table WHERE (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b)
|
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table USING citus_local_table_queries.postgres_local_table WHERE (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b)
|
||||||
UPDATE citus_local_table
|
UPDATE citus_local_table
|
||||||
SET b = 5
|
SET b = 5
|
||||||
FROM postgres_local_table
|
FROM postgres_local_table
|
||||||
WHERE citus_local_table.a = 3 AND citus_local_table.b = postgres_local_table.b;
|
WHERE citus_local_table.a = 3 AND citus_local_table.b = postgres_local_table.b;
|
||||||
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 citus_local_table SET b = 5 FROM citus_local_table_queries.postgres_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.=) 3) AND (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b))
|
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 citus_local_table SET b = 5 FROM citus_local_table_queries.postgres_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.=) 3) AND (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b))
|
||||||
DELETE FROM postgres_local_table
|
DELETE FROM postgres_local_table
|
||||||
USING citus_local_table
|
USING citus_local_table
|
||||||
WHERE citus_local_table.b = postgres_local_table.b;
|
WHERE citus_local_table.b = postgres_local_table.b;
|
||||||
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.postgres_local_table USING citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b)
|
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.postgres_local_table USING citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b)
|
||||||
UPDATE postgres_local_table
|
UPDATE postgres_local_table
|
||||||
SET b = 5
|
SET b = 5
|
||||||
FROM citus_local_table
|
FROM citus_local_table
|
||||||
WHERE citus_local_table.a = 3 AND citus_local_table.b = postgres_local_table.b;
|
WHERE citus_local_table.a = 3 AND citus_local_table.b = postgres_local_table.b;
|
||||||
NOTICE: executing the command locally: UPDATE citus_local_table_queries.postgres_local_table SET b = 5 FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.=) 3) AND (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b))
|
NOTICE: executing the command locally: UPDATE citus_local_table_queries.postgres_local_table SET b = 5 FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.=) 3) AND (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b))
|
||||||
-- no direct joins supported
|
-- no direct joins supported
|
||||||
UPDATE distributed_table
|
UPDATE distributed_table
|
||||||
SET b = 6
|
SET b = 6
|
||||||
FROM citus_local_table
|
FROM citus_local_table
|
||||||
WHERE citus_local_table.a = distributed_table.a;
|
WHERE citus_local_table.a = distributed_table.a;
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true
|
||||||
UPDATE reference_table
|
UPDATE reference_table
|
||||||
SET b = 6
|
SET b = 6
|
||||||
FROM citus_local_table
|
FROM citus_local_table
|
||||||
WHERE citus_local_table.a = reference_table.a;
|
WHERE citus_local_table.a = reference_table.a;
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true
|
||||||
NOTICE: executing the command locally: UPDATE citus_local_table_queries.reference_table_1509002 reference_table SET b = 6 FROM (SELECT citus_local_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_1) citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a)
|
NOTICE: executing the command locally: UPDATE citus_local_table_queries.reference_table_1509003 reference_table SET b = 6 FROM (SELECT citus_local_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_1) citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a)
|
||||||
-- should not work, add HINT use CTEs
|
-- should not work, add HINT use CTEs
|
||||||
UPDATE citus_local_table
|
UPDATE citus_local_table
|
||||||
SET b = 6
|
SET b = 6
|
||||||
FROM distributed_table
|
FROM distributed_table
|
||||||
WHERE citus_local_table.a = distributed_table.a;
|
WHERE citus_local_table.a = distributed_table.a;
|
||||||
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 citus_local_table SET b = 6 FROM (SELECT distributed_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) distributed_table_1) distributed_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table.a)
|
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 citus_local_table SET b = 6 FROM (SELECT distributed_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) distributed_table_1) distributed_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table.a)
|
||||||
-- should work, add HINT use CTEs
|
-- should work, add HINT use CTEs
|
||||||
UPDATE citus_local_table
|
UPDATE citus_local_table
|
||||||
SET b = 6
|
SET b = 6
|
||||||
FROM reference_table
|
FROM reference_table
|
||||||
WHERE citus_local_table.a = reference_table.a;
|
WHERE citus_local_table.a = reference_table.a;
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509002 reference_table WHERE true
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509003 reference_table WHERE true
|
||||||
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 citus_local_table SET b = 6 FROM (SELECT reference_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) reference_table_1) reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a)
|
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 citus_local_table SET b = 6 FROM (SELECT reference_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) reference_table_1) reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a)
|
||||||
-- should not work, add HINT use CTEs
|
-- should not work, add HINT use CTEs
|
||||||
DELETE FROM distributed_table
|
DELETE FROM distributed_table
|
||||||
USING citus_local_table
|
USING citus_local_table
|
||||||
WHERE citus_local_table.a = distributed_table.a;
|
WHERE citus_local_table.a = distributed_table.a;
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true
|
||||||
-- should not work, add HINT use CTEs
|
-- should not work, add HINT use CTEs
|
||||||
DELETE FROM citus_local_table
|
DELETE FROM citus_local_table
|
||||||
USING distributed_table
|
USING distributed_table
|
||||||
WHERE citus_local_table.a = distributed_table.a;
|
WHERE citus_local_table.a = distributed_table.a;
|
||||||
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table USING (SELECT distributed_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) distributed_table_1) distributed_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table.a)
|
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table USING (SELECT distributed_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) distributed_table_1) distributed_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table.a)
|
||||||
DELETE FROM reference_table
|
DELETE FROM reference_table
|
||||||
USING citus_local_table
|
USING citus_local_table
|
||||||
WHERE citus_local_table.a = reference_table.a;
|
WHERE citus_local_table.a = reference_table.a;
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true
|
||||||
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.reference_table_1509002 reference_table USING (SELECT citus_local_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_1) citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a)
|
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.reference_table_1509003 reference_table USING (SELECT citus_local_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_1) citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a)
|
||||||
-- should work, add HINT use CTEs
|
-- should work, add HINT use CTEs
|
||||||
DELETE FROM citus_local_table
|
DELETE FROM citus_local_table
|
||||||
USING reference_table
|
USING reference_table
|
||||||
WHERE citus_local_table.a = reference_table.a;
|
WHERE citus_local_table.a = reference_table.a;
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509002 reference_table WHERE true
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509003 reference_table WHERE true
|
||||||
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table USING (SELECT reference_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) reference_table_1) reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a)
|
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table USING (SELECT reference_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) reference_table_1) reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a)
|
||||||
-- just works
|
-- just works
|
||||||
DELETE FROM citus_local_table
|
DELETE FROM citus_local_table
|
||||||
WHERE citus_local_table.a IN (SELECT a FROM distributed_table);
|
WHERE citus_local_table.a IN (SELECT a FROM distributed_table);
|
||||||
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)))
|
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)))
|
||||||
-- just works
|
-- just works
|
||||||
DELETE FROM citus_local_table
|
DELETE FROM citus_local_table
|
||||||
WHERE citus_local_table.a IN (SELECT a FROM reference_table);
|
WHERE citus_local_table.a IN (SELECT a FROM reference_table);
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509002 reference_table
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509003 reference_table
|
||||||
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)))
|
NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)))
|
||||||
-- just works
|
-- just works
|
||||||
WITH distributed_table_cte AS (SELECT * FROM distributed_table)
|
WITH distributed_table_cte AS (SELECT * FROM distributed_table)
|
||||||
UPDATE citus_local_table
|
UPDATE citus_local_table
|
||||||
SET b = 6
|
SET b = 6
|
||||||
FROM distributed_table_cte
|
FROM distributed_table_cte
|
||||||
WHERE citus_local_table.a = distributed_table_cte.a;
|
WHERE citus_local_table.a = distributed_table_cte.a;
|
||||||
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 citus_local_table SET b = 6 FROM (SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer)) distributed_table_cte WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table_cte.a)
|
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 citus_local_table SET b = 6 FROM (SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer)) distributed_table_cte WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table_cte.a)
|
||||||
SET citus.log_local_commands to off;
|
SET citus.log_local_commands to off;
|
||||||
-- just works
|
-- just works
|
||||||
WITH reference_table_cte AS (SELECT * FROM reference_table)
|
WITH reference_table_cte AS (SELECT * FROM reference_table)
|
||||||
|
@ -772,7 +772,7 @@ SELECT count(*)
|
||||||
FROM citus_local_table
|
FROM citus_local_table
|
||||||
JOIN reference_table
|
JOIN reference_table
|
||||||
USING (a);
|
USING (a);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_1509000 citus_local_table(a, b) JOIN citus_local_table_queries.reference_table_1509002 reference_table(a, b) USING (a))
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_1509001 citus_local_table(a, b) JOIN citus_local_table_queries.reference_table_1509003 reference_table(a, b) USING (a))
|
||||||
-- ok
|
-- ok
|
||||||
SELECT count(*) FROM mat_view_4;
|
SELECT count(*) FROM mat_view_4;
|
||||||
count
|
count
|
||||||
|
@ -795,8 +795,8 @@ JOIN citus_local_table_2 USING (a)
|
||||||
JOIN distributed_table USING (a);
|
JOIN distributed_table USING (a);
|
||||||
-- should fail as view contains direct local dist join
|
-- should fail as view contains direct local dist join
|
||||||
SELECT count(*) FROM view_2;
|
SELECT count(*) FROM view_2;
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2 WHERE true
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2 WHERE true
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT intermediate_result.count FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(count bigint)) view_2
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT intermediate_result.count FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(count bigint)) view_2
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -810,7 +810,7 @@ JOIN reference_table
|
||||||
USING (a);
|
USING (a);
|
||||||
-- ok
|
-- ok
|
||||||
SELECT count(*) FROM view_3;
|
SELECT count(*) FROM view_3;
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2(a, b) JOIN citus_local_table_queries.reference_table_1509002 reference_table(a, b) USING (a))) view_3
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2(a, b) JOIN citus_local_table_queries.reference_table_1509003 reference_table(a, b) USING (a))) view_3
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1
|
1
|
||||||
|
@ -818,8 +818,8 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT co
|
||||||
|
|
||||||
-- view treated as subquery, so should work
|
-- view treated as subquery, so should work
|
||||||
SELECT count(*) FROM view_3, distributed_table;
|
SELECT count(*) FROM view_3, distributed_table;
|
||||||
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2 WHERE true
|
NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2 WHERE true
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM ((SELECT citus_local_table_2_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_2_1) citus_local_table_2 JOIN citus_local_table_queries.reference_table_1509002 reference_table(a, b) USING (a))
|
NOTICE: executing the command locally: SELECT count(*) AS count FROM ((SELECT citus_local_table_2_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_2_1) citus_local_table_2 JOIN citus_local_table_queries.reference_table_1509003 reference_table(a, b) USING (a))
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
6
|
6
|
||||||
|
@ -845,10 +845,10 @@ JOIN (SELECT count(*) as a, count(*) as b
|
||||||
USING (a)) subquery7132
|
USING (a)) subquery7132
|
||||||
USING (b)) subquery7294
|
USING (b)) subquery7294
|
||||||
USING (a);
|
USING (a);
|
||||||
NOTICE: executing the command locally: SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.reference_table_1509002 reference_table(a, b) JOIN (SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2(a, b) JOIN (SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.postgres_local_table JOIN (SELECT count(*) AS a, count(*) AS b FROM citus_local_table_queries.reference_table_1509002 table_4677) subquery5108 USING (a))) subquery7132 USING (b))) subquery7294 USING (a))
|
NOTICE: executing the command locally: SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.reference_table_1509003 reference_table(a, b) JOIN (SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2(a, b) JOIN (SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.postgres_local_table JOIN (SELECT count(*) AS a, count(*) AS b FROM citus_local_table_queries.reference_table_1509003 table_4677) subquery5108 USING (a))) subquery7132 USING (b))) subquery7294 USING (a))
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0 | 0
|
1 | 1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- direct join inside CTE not supported
|
-- direct join inside CTE not supported
|
||||||
|
@ -857,7 +857,7 @@ UPDATE citus_local_table lt SET a = mt.a
|
||||||
FROM distributed_table mt WHERE mt.b = lt.b
|
FROM distributed_table mt WHERE mt.b = lt.b
|
||||||
RETURNING lt.b, lt.a
|
RETURNING lt.b, lt.a
|
||||||
) SELECT * FROM cte JOIN distributed_table mt ON mt.b = cte.b ORDER BY 1,2,3,4;
|
) SELECT * FROM cte JOIN distributed_table mt ON mt.b = cte.b ORDER BY 1,2,3,4;
|
||||||
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 lt SET a = mt.a FROM (SELECT mt_1.a, mt_1.b FROM (SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer)) mt_1) mt WHERE (mt.b OPERATOR(pg_catalog.=) lt.b) RETURNING lt.b, lt.a
|
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 lt SET a = mt.a FROM (SELECT mt_1.a, mt_1.b FROM (SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer)) mt_1) mt WHERE (mt.b OPERATOR(pg_catalog.=) lt.b) RETURNING lt.b, lt.a
|
||||||
b | a | a | b
|
b | a | a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0 | 0 | 0 | 0
|
0 | 0 | 0 | 0
|
||||||
|
@ -875,14 +875,14 @@ FROM (SELECT avg(distributed_table.b) as avg_b
|
||||||
FROM distributed_table) as foo
|
FROM distributed_table) as foo
|
||||||
WHERE
|
WHERE
|
||||||
foo.avg_b = citus_local_table.b;
|
foo.avg_b = citus_local_table.b;
|
||||||
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 citus_local_table SET a = 5 FROM (SELECT intermediate_result.avg_b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(avg_b numeric)) foo WHERE (foo.avg_b OPERATOR(pg_catalog.=) (citus_local_table.b)::numeric)
|
NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 citus_local_table SET a = 5 FROM (SELECT intermediate_result.avg_b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(avg_b numeric)) foo WHERE (foo.avg_b OPERATOR(pg_catalog.=) (citus_local_table.b)::numeric)
|
||||||
-- should work
|
-- should work
|
||||||
UPDATE distributed_table
|
UPDATE distributed_table
|
||||||
SET b = avg_a
|
SET b = avg_a
|
||||||
FROM (SELECT avg(citus_local_table.a) as avg_a FROM citus_local_table) as foo
|
FROM (SELECT avg(citus_local_table.a) as avg_a FROM citus_local_table) as foo
|
||||||
WHERE foo.avg_a = distributed_table.a
|
WHERE foo.avg_a = distributed_table.a
|
||||||
RETURNING distributed_table.*;
|
RETURNING distributed_table.*;
|
||||||
NOTICE: executing the command locally: SELECT avg(a) AS avg_a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT avg(a) AS avg_a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
@ -918,7 +918,7 @@ LIMIT 10;
|
||||||
-> Limit
|
-> Limit
|
||||||
-> Sort
|
-> Sort
|
||||||
Sort Key: distributed_table.*
|
Sort Key: distributed_table.*
|
||||||
-> Seq Scan on distributed_table_1509003 distributed_table
|
-> Seq Scan on distributed_table_1509004 distributed_table
|
||||||
(14 rows)
|
(14 rows)
|
||||||
|
|
||||||
-- show that we do not pull to coordinator
|
-- show that we do not pull to coordinator
|
||||||
|
@ -932,8 +932,8 @@ SELECT * FROM citus_local_table;
|
||||||
Tasks Shown: All
|
Tasks Shown: All
|
||||||
-> Task
|
-> Task
|
||||||
Node: host=localhost port=xxxxx dbname=regression
|
Node: host=localhost port=xxxxx dbname=regression
|
||||||
-> Insert on citus_local_table_1509000 citus_table_alias
|
-> Insert on citus_local_table_1509001 citus_table_alias
|
||||||
-> Seq Scan on citus_local_table_1509000 citus_local_table
|
-> Seq Scan on citus_local_table_1509001 citus_local_table
|
||||||
(7 rows)
|
(7 rows)
|
||||||
|
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -946,8 +946,8 @@ SELECT reference_table.* FROM reference_table;
|
||||||
Tasks Shown: All
|
Tasks Shown: All
|
||||||
-> Task
|
-> Task
|
||||||
Node: host=localhost port=xxxxx dbname=regression
|
Node: host=localhost port=xxxxx dbname=regression
|
||||||
-> Insert on citus_local_table_1509000 citus_table_alias
|
-> Insert on citus_local_table_1509001 citus_table_alias
|
||||||
-> Seq Scan on reference_table_1509002 reference_table
|
-> Seq Scan on reference_table_1509003 reference_table
|
||||||
(7 rows)
|
(7 rows)
|
||||||
|
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -963,7 +963,7 @@ SELECT reference_table.* FROM reference_table, postgres_local_table;
|
||||||
-> Task
|
-> Task
|
||||||
Node: host=localhost port=xxxxx dbname=regression
|
Node: host=localhost port=xxxxx dbname=regression
|
||||||
-> Nested Loop
|
-> Nested Loop
|
||||||
-> Seq Scan on reference_table_1509002 reference_table
|
-> Seq Scan on reference_table_1509003 reference_table
|
||||||
-> Materialize
|
-> Materialize
|
||||||
-> Seq Scan on postgres_local_table
|
-> Seq Scan on postgres_local_table
|
||||||
(11 rows)
|
(11 rows)
|
||||||
|
@ -982,9 +982,9 @@ SELECT reference_table.* FROM reference_table, distributed_table;
|
||||||
-> Task
|
-> Task
|
||||||
Node: host=localhost port=xxxxx dbname=regression
|
Node: host=localhost port=xxxxx dbname=regression
|
||||||
-> Nested Loop
|
-> Nested Loop
|
||||||
-> Seq Scan on distributed_table_1509003 distributed_table
|
-> Seq Scan on distributed_table_1509004 distributed_table
|
||||||
-> Materialize
|
-> Materialize
|
||||||
-> Seq Scan on reference_table_1509002 reference_table
|
-> Seq Scan on reference_table_1509003 reference_table
|
||||||
(11 rows)
|
(11 rows)
|
||||||
|
|
||||||
-- truncate tables & add unique constraints to be able to define foreign keys
|
-- truncate tables & add unique constraints to be able to define foreign keys
|
||||||
|
@ -992,21 +992,21 @@ TRUNCATE reference_table, citus_local_table, distributed_table;
|
||||||
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries.reference_table_xxxxx CASCADE
|
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries.reference_table_xxxxx CASCADE
|
||||||
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries.citus_local_table_xxxxx CASCADE
|
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries.citus_local_table_xxxxx CASCADE
|
||||||
ALTER TABLE reference_table ADD CONSTRAINT pkey_ref PRIMARY KEY (a);
|
ALTER TABLE reference_table ADD CONSTRAINT pkey_ref PRIMARY KEY (a);
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509002, 'citus_local_table_queries', 'ALTER TABLE reference_table ADD CONSTRAINT pkey_ref PRIMARY KEY (a);')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509003, 'citus_local_table_queries', 'ALTER TABLE reference_table ADD CONSTRAINT pkey_ref PRIMARY KEY (a);')
|
||||||
ALTER TABLE citus_local_table ADD CONSTRAINT pkey_c PRIMARY KEY (a);
|
ALTER TABLE citus_local_table ADD CONSTRAINT pkey_c PRIMARY KEY (a);
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509000, 'citus_local_table_queries', 'ALTER TABLE citus_local_table ADD CONSTRAINT pkey_c PRIMARY KEY (a);')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509001, 'citus_local_table_queries', 'ALTER TABLE citus_local_table ADD CONSTRAINT pkey_c PRIMARY KEY (a);')
|
||||||
-- define a foreign key chain distributed table -> reference table -> citus local table
|
-- define a foreign key chain distributed table -> reference table -> citus local table
|
||||||
-- to test sequential execution
|
-- to test sequential execution
|
||||||
ALTER TABLE distributed_table ADD CONSTRAINT fkey_dist_to_ref FOREIGN KEY(a) REFERENCES reference_table(a) ON DELETE RESTRICT;
|
ALTER TABLE distributed_table ADD CONSTRAINT fkey_dist_to_ref FOREIGN KEY(a) REFERENCES reference_table(a) ON DELETE RESTRICT;
|
||||||
ALTER TABLE reference_table ADD CONSTRAINT fkey_ref_to_local FOREIGN KEY(a) REFERENCES citus_local_table(a) ON DELETE RESTRICT;
|
ALTER TABLE reference_table ADD CONSTRAINT fkey_ref_to_local FOREIGN KEY(a) REFERENCES citus_local_table(a) ON DELETE RESTRICT;
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509002, 'citus_local_table_queries', 1509000, 'citus_local_table_queries', 'ALTER TABLE reference_table ADD CONSTRAINT fkey_ref_to_local FOREIGN KEY(a) REFERENCES citus_local_table(a) ON DELETE RESTRICT;')
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509003, 'citus_local_table_queries', 1509001, 'citus_local_table_queries', 'ALTER TABLE reference_table ADD CONSTRAINT fkey_ref_to_local FOREIGN KEY(a) REFERENCES citus_local_table(a) ON DELETE RESTRICT;')
|
||||||
INSERT INTO citus_local_table VALUES (1);
|
INSERT INTO citus_local_table VALUES (1);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 (a) VALUES (1)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 (a) VALUES (1)
|
||||||
INSERT INTO reference_table VALUES (1);
|
INSERT INTO reference_table VALUES (1);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.reference_table_1509002 (a) VALUES (1)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.reference_table_1509003 (a) VALUES (1)
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO citus_local_table VALUES (1) ON CONFLICT (a) DO NOTHING;
|
INSERT INTO citus_local_table VALUES (1) ON CONFLICT (a) DO NOTHING;
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (1) ON CONFLICT(a) DO NOTHING
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (1) ON CONFLICT(a) DO NOTHING
|
||||||
INSERT INTO distributed_table VALUES (1);
|
INSERT INTO distributed_table VALUES (1);
|
||||||
-- should show sequential as first inserting into citus local table
|
-- should show sequential as first inserting into citus local table
|
||||||
-- would force the xact block to use sequential execution
|
-- would force the xact block to use sequential execution
|
||||||
|
@ -1042,7 +1042,7 @@ ROLLBACK;
|
||||||
ALTER TABLE distributed_table DROP CONSTRAINT fkey_dist_to_ref;
|
ALTER TABLE distributed_table DROP CONSTRAINT fkey_dist_to_ref;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO citus_local_table VALUES (1) ON CONFLICT (a) DO NOTHING;
|
INSERT INTO citus_local_table VALUES (1) ON CONFLICT (a) DO NOTHING;
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (1) ON CONFLICT(a) DO NOTHING
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (1) ON CONFLICT(a) DO NOTHING
|
||||||
show citus.multi_shard_modify_mode;
|
show citus.multi_shard_modify_mode;
|
||||||
citus.multi_shard_modify_mode
|
citus.multi_shard_modify_mode
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -1052,9 +1052,9 @@ NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.ci
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- remove uniqueness constraint and dependent foreign key constraint for next tests
|
-- remove uniqueness constraint and dependent foreign key constraint for next tests
|
||||||
ALTER TABLE reference_table DROP CONSTRAINT fkey_ref_to_local;
|
ALTER TABLE reference_table DROP CONSTRAINT fkey_ref_to_local;
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509002, 'citus_local_table_queries', 1509000, 'citus_local_table_queries', 'ALTER TABLE reference_table DROP CONSTRAINT fkey_ref_to_local;')
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509003, 'citus_local_table_queries', 1509001, 'citus_local_table_queries', 'ALTER TABLE reference_table DROP CONSTRAINT fkey_ref_to_local;')
|
||||||
ALTER TABLE citus_local_table DROP CONSTRAINT pkey_c;
|
ALTER TABLE citus_local_table DROP CONSTRAINT pkey_c;
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509000, 'citus_local_table_queries', 'ALTER TABLE citus_local_table DROP CONSTRAINT pkey_c;')
|
NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509001, 'citus_local_table_queries', 'ALTER TABLE citus_local_table DROP CONSTRAINT pkey_c;')
|
||||||
COPY citus_local_table(a) FROM PROGRAM 'seq 1';
|
COPY citus_local_table(a) FROM PROGRAM 'seq 1';
|
||||||
-- should use local execution
|
-- should use local execution
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -1069,7 +1069,7 @@ COPY citus_local_table TO STDOUT;
|
||||||
1 \N
|
1 \N
|
||||||
1 \N
|
1 \N
|
||||||
COPY (SELECT * FROM citus_local_table) TO STDOUT;
|
COPY (SELECT * FROM citus_local_table) TO STDOUT;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
1 \N
|
1 \N
|
||||||
1 \N
|
1 \N
|
||||||
1 \N
|
1 \N
|
||||||
|
@ -1083,7 +1083,7 @@ BEGIN;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
COPY (SELECT * FROM citus_local_table) TO STDOUT;
|
COPY (SELECT * FROM citus_local_table) TO STDOUT;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table
|
||||||
1 \N
|
1 \N
|
||||||
1 \N
|
1 \N
|
||||||
1 \N
|
1 \N
|
||||||
|
@ -1095,13 +1095,13 @@ NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries
|
||||||
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries.reference_table_xxxxx CASCADE
|
NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries.reference_table_xxxxx CASCADE
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO citus_local_table VALUES (1), (2);
|
INSERT INTO citus_local_table VALUES (1), (2);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (1), (2)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (1), (2)
|
||||||
SAVEPOINT sp1;
|
SAVEPOINT sp1;
|
||||||
INSERT INTO citus_local_table VALUES (3), (4);
|
INSERT INTO citus_local_table VALUES (3), (4);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (3), (4)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (3), (4)
|
||||||
ROLLBACK TO SAVEPOINT sp1;
|
ROLLBACK TO SAVEPOINT sp1;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table ORDER BY a, b
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table ORDER BY a, b
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 |
|
1 |
|
||||||
|
@ -1109,12 +1109,12 @@ NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queri
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
SAVEPOINT sp2;
|
SAVEPOINT sp2;
|
||||||
INSERT INTO citus_local_table VALUES (5), (6);
|
INSERT INTO citus_local_table VALUES (3), (4);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (5), (6)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (3), (4)
|
||||||
INSERT INTO distributed_table VALUES (5), (6);
|
INSERT INTO distributed_table VALUES (3), (4);
|
||||||
ROLLBACK TO SAVEPOINT sp2;
|
ROLLBACK TO SAVEPOINT sp2;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table ORDER BY a, b
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table ORDER BY a, b
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 |
|
1 |
|
||||||
|
@ -1127,13 +1127,13 @@ NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queri
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
SAVEPOINT sp3;
|
SAVEPOINT sp3;
|
||||||
INSERT INTO citus_local_table VALUES (7), (8);
|
INSERT INTO citus_local_table VALUES (3), (2);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (7), (8)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (3), (2)
|
||||||
INSERT INTO reference_table VALUES (7), (8);
|
INSERT INTO reference_table VALUES (3), (2);
|
||||||
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.reference_table_1509002 AS citus_table_alias (a) VALUES (7), (8)
|
NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.reference_table_1509003 AS citus_table_alias (a) VALUES (3), (2)
|
||||||
ROLLBACK TO SAVEPOINT sp3;
|
ROLLBACK TO SAVEPOINT sp3;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table ORDER BY a, b
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table ORDER BY a, b
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 |
|
1 |
|
||||||
|
@ -1141,7 +1141,7 @@ NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queri
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
SELECT * FROM reference_table ORDER BY 1,2;
|
SELECT * FROM reference_table ORDER BY 1,2;
|
||||||
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.reference_table_1509002 reference_table ORDER BY a, b
|
NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.reference_table_1509003 reference_table ORDER BY a, b
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
@ -1149,4 +1149,4 @@ NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queri
|
||||||
COMMIT;
|
COMMIT;
|
||||||
-- cleanup at exit
|
-- cleanup at exit
|
||||||
DROP SCHEMA citus_local_table_queries CASCADE;
|
DROP SCHEMA citus_local_table_queries CASCADE;
|
||||||
NOTICE: drop cascades to 12 other objects
|
NOTICE: drop cascades to 14 other objects
|
||||||
|
|
|
@ -22,20 +22,19 @@ SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SET citus.replication_model TO streaming;
|
SET citus.replication_model TO streaming;
|
||||||
|
CREATE TABLE dummy_reference_table(a int unique, b int);
|
||||||
|
SELECT create_reference_table('dummy_reference_table');
|
||||||
|
create_reference_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
CREATE TABLE citus_local_table(a int, b int);
|
CREATE TABLE citus_local_table(a int, b int);
|
||||||
SELECT create_citus_local_table('citus_local_table');
|
ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);
|
||||||
create_citus_local_table
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1510001, 'citus_local_table_queries_mx', 1510000, 'citus_local_table_queries_mx', 'ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);')
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE TABLE citus_local_table_2(a int, b int);
|
CREATE TABLE citus_local_table_2(a int, b int);
|
||||||
SELECT create_citus_local_table('citus_local_table_2');
|
ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);
|
||||||
create_citus_local_table
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1510002, 'citus_local_table_queries_mx', 1510000, 'citus_local_table_queries_mx', 'ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);')
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE TABLE reference_table(a int, b int);
|
CREATE TABLE reference_table(a int, b int);
|
||||||
SELECT create_reference_table('reference_table');
|
SELECT create_reference_table('reference_table');
|
||||||
create_reference_table
|
create_reference_table
|
||||||
|
@ -63,8 +62,9 @@ CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
SET client_min_messages to ERROR;
|
SET client_min_messages to ERROR;
|
||||||
|
|
||||||
TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table;
|
TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table, dummy_reference_table, citus_local_table_2;
|
||||||
|
|
||||||
|
INSERT INTO dummy_reference_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
|
@ -734,7 +734,7 @@ JOIN (SELECT count(*) as a, count(*) as b
|
||||||
USING (a);
|
USING (a);
|
||||||
a | b
|
a | b
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
0 | 0
|
1 | 1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- direct join inside CTE not supported
|
-- direct join inside CTE not supported
|
||||||
|
@ -801,7 +801,7 @@ LIMIT 10;
|
||||||
-> Limit
|
-> Limit
|
||||||
-> Sort
|
-> Sort
|
||||||
Sort Key: distributed_table.*
|
Sort Key: distributed_table.*
|
||||||
-> Seq Scan on distributed_table_1510003 distributed_table
|
-> Seq Scan on distributed_table_1510004 distributed_table
|
||||||
(14 rows)
|
(14 rows)
|
||||||
|
|
||||||
-- show that we do not pull to coordinator
|
-- show that we do not pull to coordinator
|
||||||
|
@ -815,8 +815,8 @@ SELECT * FROM citus_local_table;
|
||||||
Tasks Shown: All
|
Tasks Shown: All
|
||||||
-> Task
|
-> Task
|
||||||
Node: host=localhost port=xxxxx dbname=regression
|
Node: host=localhost port=xxxxx dbname=regression
|
||||||
-> Insert on citus_local_table_1510000 citus_table_alias
|
-> Insert on citus_local_table_1510001 citus_table_alias
|
||||||
-> Seq Scan on citus_local_table_1510000 citus_local_table
|
-> Seq Scan on citus_local_table_1510001 citus_local_table
|
||||||
(7 rows)
|
(7 rows)
|
||||||
|
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -829,8 +829,8 @@ SELECT reference_table.* FROM reference_table;
|
||||||
Tasks Shown: All
|
Tasks Shown: All
|
||||||
-> Task
|
-> Task
|
||||||
Node: host=localhost port=xxxxx dbname=regression
|
Node: host=localhost port=xxxxx dbname=regression
|
||||||
-> Insert on citus_local_table_1510000 citus_table_alias
|
-> Insert on citus_local_table_1510001 citus_table_alias
|
||||||
-> Seq Scan on reference_table_1510002 reference_table
|
-> Seq Scan on reference_table_1510003 reference_table
|
||||||
(7 rows)
|
(7 rows)
|
||||||
|
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -846,7 +846,7 @@ SELECT reference_table.* FROM reference_table, postgres_local_table;
|
||||||
-> Task
|
-> Task
|
||||||
Node: host=localhost port=xxxxx dbname=regression
|
Node: host=localhost port=xxxxx dbname=regression
|
||||||
-> Nested Loop
|
-> Nested Loop
|
||||||
-> Seq Scan on reference_table_1510002 reference_table
|
-> Seq Scan on reference_table_1510003 reference_table
|
||||||
-> Materialize
|
-> Materialize
|
||||||
-> Seq Scan on postgres_local_table
|
-> Seq Scan on postgres_local_table
|
||||||
(11 rows)
|
(11 rows)
|
||||||
|
@ -865,9 +865,9 @@ SELECT reference_table.* FROM reference_table, distributed_table;
|
||||||
-> Task
|
-> Task
|
||||||
Node: host=localhost port=xxxxx dbname=regression
|
Node: host=localhost port=xxxxx dbname=regression
|
||||||
-> Nested Loop
|
-> Nested Loop
|
||||||
-> Seq Scan on distributed_table_1510003 distributed_table
|
-> Seq Scan on distributed_table_1510004 distributed_table
|
||||||
-> Materialize
|
-> Materialize
|
||||||
-> Seq Scan on reference_table_1510002 reference_table
|
-> Seq Scan on reference_table_1510003 reference_table
|
||||||
(11 rows)
|
(11 rows)
|
||||||
|
|
||||||
-- truncate tables & add unique constraints to be able to define foreign keys
|
-- truncate tables & add unique constraints to be able to define foreign keys
|
||||||
|
@ -983,8 +983,8 @@ BEGIN;
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
SAVEPOINT sp2;
|
SAVEPOINT sp2;
|
||||||
INSERT INTO citus_local_table VALUES (5), (6);
|
INSERT INTO citus_local_table VALUES (3), (4);
|
||||||
INSERT INTO distributed_table VALUES (5), (6);
|
INSERT INTO distributed_table VALUES (3), (4);
|
||||||
ROLLBACK TO SAVEPOINT sp2;
|
ROLLBACK TO SAVEPOINT sp2;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
a | b
|
a | b
|
||||||
|
@ -999,8 +999,8 @@ BEGIN;
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
SAVEPOINT sp3;
|
SAVEPOINT sp3;
|
||||||
INSERT INTO citus_local_table VALUES (7), (8);
|
INSERT INTO citus_local_table VALUES (3), (2);
|
||||||
INSERT INTO reference_table VALUES (7), (8);
|
INSERT INTO reference_table VALUES (3), (2);
|
||||||
ROLLBACK TO SAVEPOINT sp3;
|
ROLLBACK TO SAVEPOINT sp3;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
a | b
|
a | b
|
||||||
|
@ -1018,4 +1018,4 @@ COMMIT;
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
-- cleanup at exit
|
-- cleanup at exit
|
||||||
DROP SCHEMA citus_local_table_queries_mx CASCADE;
|
DROP SCHEMA citus_local_table_queries_mx CASCADE;
|
||||||
NOTICE: drop cascades to 7 other objects
|
NOTICE: drop cascades to 9 other objects
|
||||||
|
|
|
@ -499,9 +499,9 @@ SELECT * FROM print_extension_changes();
|
||||||
| function worker_change_sequence_dependency(regclass,regclass,regclass)
|
| function worker_change_sequence_dependency(regclass,regclass,regclass)
|
||||||
| schema columnar
|
| schema columnar
|
||||||
| sequence columnar.storageid_seq
|
| sequence columnar.storageid_seq
|
||||||
| table columnar.columnar_skipnodes
|
| table columnar.chunk
|
||||||
| table columnar.columnar_stripes
|
|
||||||
| table columnar.options
|
| table columnar.options
|
||||||
|
| table columnar.stripe
|
||||||
| view citus_shards
|
| view citus_shards
|
||||||
| view citus_tables
|
| view citus_tables
|
||||||
| view time_partitions
|
| view time_partitions
|
||||||
|
|
|
@ -495,9 +495,9 @@ SELECT * FROM print_extension_changes();
|
||||||
| function worker_change_sequence_dependency(regclass,regclass,regclass)
|
| function worker_change_sequence_dependency(regclass,regclass,regclass)
|
||||||
| schema columnar
|
| schema columnar
|
||||||
| sequence columnar.storageid_seq
|
| sequence columnar.storageid_seq
|
||||||
| table columnar.columnar_skipnodes
|
| table columnar.chunk
|
||||||
| table columnar.columnar_stripes
|
|
||||||
| table columnar.options
|
| table columnar.options
|
||||||
|
| table columnar.stripe
|
||||||
| view citus_shards
|
| view citus_shards
|
||||||
| view citus_tables
|
| view citus_tables
|
||||||
| view time_partitions
|
| view time_partitions
|
||||||
|
|
|
@ -221,6 +221,19 @@ BEGIN;
|
||||||
ALTER TABLE citus_local_table_1 ADD CONSTRAINT multi_fkey FOREIGN KEY (a, b) REFERENCES citus_local_table_2(a, b);
|
ALTER TABLE citus_local_table_1 ADD CONSTRAINT multi_fkey FOREIGN KEY (a, b) REFERENCES citus_local_table_2(a, b);
|
||||||
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1506004, 'ref_citus_local_fkeys', 1506005, 'ref_citus_local_fkeys', 'ALTER TABLE citus_local_table_1 ADD CONSTRAINT multi_fkey FOREIGN KEY (a, b) REFERENCES citus_local_table_2(a, b);')
|
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1506004, 'ref_citus_local_fkeys', 1506005, 'ref_citus_local_fkeys', 'ALTER TABLE citus_local_table_1 ADD CONSTRAINT multi_fkey FOREIGN KEY (a, b) REFERENCES citus_local_table_2(a, b);')
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
-- when local execution is disabled, citus local table cannot be created
|
||||||
|
BEGIN;
|
||||||
|
SET citus.enable_local_execution TO false;
|
||||||
|
CREATE TABLE referenced_table(id int primary key);
|
||||||
|
SELECT create_reference_table('referenced_table');
|
||||||
|
create_reference_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TABLE referencing_table(id int, ref_id int, FOREIGN KEY(ref_id) REFERENCES referenced_table(id) ON DELETE SET DEFAULT);
|
||||||
|
ERROR: cannot switch local execution status from local execution disabled to local execution enabled since it can cause visibility problems in the current transaction
|
||||||
|
ROLLBACK;
|
||||||
-- cleanup at exit
|
-- cleanup at exit
|
||||||
DROP SCHEMA ref_citus_local_fkeys CASCADE;
|
DROP SCHEMA ref_citus_local_fkeys CASCADE;
|
||||||
NOTICE: drop cascades to 6 other objects
|
NOTICE: drop cascades to 6 other objects
|
||||||
|
|
|
@ -527,10 +527,11 @@ BEGIN;
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
ALTER TABLE reference_table_2 DROP CONSTRAINT fkey_5;
|
||||||
ALTER TABLE reference_table_2 DROP CONSTRAINT fkey_7;
|
ALTER TABLE reference_table_2 DROP CONSTRAINT fkey_7;
|
||||||
-- since now citus_local_table_2 has no foreign keys, show that
|
-- since now reference_table_2 has no foreign keys, show that
|
||||||
-- cascade_via_foreign_keys option still works fine
|
-- cascade_via_foreign_keys option still works fine
|
||||||
SELECT undistribute_table('citus_local_table_2', cascade_via_foreign_keys=>true);
|
SELECT undistribute_table('reference_table_2', cascade_via_foreign_keys=>true);
|
||||||
undistribute_table
|
undistribute_table
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -539,7 +540,7 @@ BEGIN;
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_partition, pg_tables
|
SELECT COUNT(*)=0 FROM pg_dist_partition, pg_tables
|
||||||
WHERE tablename=logicalrelid::regclass::text AND
|
WHERE tablename=logicalrelid::regclass::text AND
|
||||||
schemaname='undistribute_table_cascade' AND
|
schemaname='undistribute_table_cascade' AND
|
||||||
tablename='citus_local_table_2';
|
tablename='reference_table_2';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
|
|
@ -209,9 +209,9 @@ ORDER BY 1;
|
||||||
sequence pg_dist_placement_placementid_seq
|
sequence pg_dist_placement_placementid_seq
|
||||||
sequence pg_dist_shardid_seq
|
sequence pg_dist_shardid_seq
|
||||||
table citus.pg_dist_object
|
table citus.pg_dist_object
|
||||||
table columnar.columnar_skipnodes
|
table columnar.chunk
|
||||||
table columnar.columnar_stripes
|
|
||||||
table columnar.options
|
table columnar.options
|
||||||
|
table columnar.stripe
|
||||||
table pg_dist_authinfo
|
table pg_dist_authinfo
|
||||||
table pg_dist_colocation
|
table pg_dist_colocation
|
||||||
table pg_dist_local_group
|
table pg_dist_local_group
|
||||||
|
|
|
@ -205,9 +205,9 @@ ORDER BY 1;
|
||||||
sequence pg_dist_placement_placementid_seq
|
sequence pg_dist_placement_placementid_seq
|
||||||
sequence pg_dist_shardid_seq
|
sequence pg_dist_shardid_seq
|
||||||
table citus.pg_dist_object
|
table citus.pg_dist_object
|
||||||
table columnar.columnar_skipnodes
|
table columnar.chunk
|
||||||
table columnar.columnar_stripes
|
|
||||||
table columnar.options
|
table columnar.options
|
||||||
|
table columnar.stripe
|
||||||
table pg_dist_authinfo
|
table pg_dist_authinfo
|
||||||
table pg_dist_colocation
|
table pg_dist_colocation
|
||||||
table pg_dist_local_group
|
table pg_dist_local_group
|
||||||
|
|
|
@ -71,3 +71,9 @@ B
|
||||||
\.
|
\.
|
||||||
|
|
||||||
SELECT * FROM collation_chunk_filtering_test WHERE A > 'B';
|
SELECT * FROM collation_chunk_filtering_test WHERE A > 'B';
|
||||||
|
|
||||||
|
CREATE TABLE simple_chunk_filtering(i int) USING COLUMNAR;
|
||||||
|
INSERT INTO simple_chunk_filtering SELECT generate_series(0,234567);
|
||||||
|
EXPLAIN (analyze on, costs off, timing off, summary off)
|
||||||
|
SELECT * FROM simple_chunk_filtering WHERE i > 123456;
|
||||||
|
DROP TABLE simple_chunk_filtering;
|
||||||
|
|
|
@ -66,3 +66,8 @@ CREATE TABLE test_null_values (a int, b int[], c composite_type)
|
||||||
COPY test_null_values FROM '@abs_srcdir@/data/null_values.csv' WITH CSV;
|
COPY test_null_values FROM '@abs_srcdir@/data/null_values.csv' WITH CSV;
|
||||||
|
|
||||||
SELECT * FROM test_null_values;
|
SELECT * FROM test_null_values;
|
||||||
|
|
||||||
|
CREATE TABLE test_json(j json) USING columnar;
|
||||||
|
INSERT INTO test_json SELECT ('{"att": ' || g::text || '}')::json from generate_series(1,1000000) g;
|
||||||
|
SELECT * FROM test_json WHERE (j->'att')::text::int8 > 999990;
|
||||||
|
DROP TABLE test_json;
|
||||||
|
|
|
@ -118,3 +118,16 @@ SELECT * FROM collation_chunk_filtering_test WHERE A > 'B';
|
||||||
Å
|
Å
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TABLE simple_chunk_filtering(i int) USING COLUMNAR;
|
||||||
|
INSERT INTO simple_chunk_filtering SELECT generate_series(0,234567);
|
||||||
|
EXPLAIN (analyze on, costs off, timing off, summary off)
|
||||||
|
SELECT * FROM simple_chunk_filtering WHERE i > 123456;
|
||||||
|
QUERY PLAN
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
Custom Scan (ColumnarScan) on simple_chunk_filtering (actual rows=111111 loops=1)
|
||||||
|
Filter: (i > 123456)
|
||||||
|
Rows Removed by Filter: 3457
|
||||||
|
Columnar Chunks Removed by Filter: 12
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
DROP TABLE simple_chunk_filtering;
|
||||||
|
|
|
@ -76,3 +76,21 @@ SELECT * FROM test_null_values;
|
||||||
| |
|
| |
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
|
CREATE TABLE test_json(j json) USING columnar;
|
||||||
|
INSERT INTO test_json SELECT ('{"att": ' || g::text || '}')::json from generate_series(1,1000000) g;
|
||||||
|
SELECT * FROM test_json WHERE (j->'att')::text::int8 > 999990;
|
||||||
|
j
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
{"att": 999991}
|
||||||
|
{"att": 999992}
|
||||||
|
{"att": 999993}
|
||||||
|
{"att": 999994}
|
||||||
|
{"att": 999995}
|
||||||
|
{"att": 999996}
|
||||||
|
{"att": 999997}
|
||||||
|
{"att": 999998}
|
||||||
|
{"att": 999999}
|
||||||
|
{"att": 1000000}
|
||||||
|
(10 rows)
|
||||||
|
|
||||||
|
DROP TABLE test_json;
|
||||||
|
|
|
@ -15,23 +15,23 @@
|
||||||
-- store postgres database oid
|
-- store postgres database oid
|
||||||
SELECT oid postgres_oid FROM pg_database WHERE datname = 'postgres' \gset
|
SELECT oid postgres_oid FROM pg_database WHERE datname = 'postgres' \gset
|
||||||
|
|
||||||
SELECT count(distinct storageid) AS columnar_stripes_before_drop FROM columnar.columnar_stripes \gset
|
SELECT count(distinct storageid) AS columnar_stripes_before_drop FROM columnar.stripe \gset
|
||||||
|
|
||||||
-- DROP columnar tables
|
-- DROP columnar tables
|
||||||
DROP TABLE contestant;
|
DROP TABLE contestant;
|
||||||
DROP TABLE contestant_compressed;
|
DROP TABLE contestant_compressed;
|
||||||
|
|
||||||
-- make sure DROP deletes metadata
|
-- make sure DROP deletes metadata
|
||||||
SELECT :columnar_stripes_before_drop - count(distinct storageid) FROM columnar.columnar_stripes;
|
SELECT :columnar_stripes_before_drop - count(distinct storageid) FROM columnar.stripe;
|
||||||
|
|
||||||
-- Create a columnar table under a schema and drop it.
|
-- Create a columnar table under a schema and drop it.
|
||||||
CREATE SCHEMA test_schema;
|
CREATE SCHEMA test_schema;
|
||||||
CREATE TABLE test_schema.test_table(data int) USING columnar;
|
CREATE TABLE test_schema.test_table(data int) USING columnar;
|
||||||
INSERT INTO test_schema.test_table VALUES (1);
|
INSERT INTO test_schema.test_table VALUES (1);
|
||||||
|
|
||||||
SELECT count(*) AS columnar_stripes_before_drop FROM columnar.columnar_stripes \gset
|
SELECT count(*) AS columnar_stripes_before_drop FROM columnar.stripe \gset
|
||||||
DROP SCHEMA test_schema CASCADE;
|
DROP SCHEMA test_schema CASCADE;
|
||||||
SELECT :columnar_stripes_before_drop - count(distinct storageid) FROM columnar.columnar_stripes;
|
SELECT :columnar_stripes_before_drop - count(distinct storageid) FROM columnar.stripe;
|
||||||
|
|
||||||
SELECT current_database() datname \gset
|
SELECT current_database() datname \gset
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,11 @@ SELECT * FROM t_view a ORDER BY a;
|
||||||
SELECT columnar_relation_storageid(oid) AS storageid
|
SELECT columnar_relation_storageid(oid) AS storageid
|
||||||
FROM pg_class WHERE relname='t_view' \gset
|
FROM pg_class WHERE relname='t_view' \gset
|
||||||
|
|
||||||
SELECT count(*) FROM columnar.columnar_stripes WHERE storageid=:storageid;
|
SELECT count(*) FROM columnar.stripe WHERE storageid=:storageid;
|
||||||
SELECT count(*) FROM columnar.columnar_skipnodes WHERE storageid=:storageid;
|
SELECT count(*) FROM columnar.chunk WHERE storageid=:storageid;
|
||||||
|
|
||||||
DROP TABLE t CASCADE;
|
DROP TABLE t CASCADE;
|
||||||
|
|
||||||
-- dropping must remove metadata
|
-- dropping must remove metadata
|
||||||
SELECT count(*) FROM columnar.columnar_stripes WHERE storageid=:storageid;
|
SELECT count(*) FROM columnar.stripe WHERE storageid=:storageid;
|
||||||
SELECT count(*) FROM columnar.columnar_skipnodes WHERE storageid=:storageid;
|
SELECT count(*) FROM columnar.chunk WHERE storageid=:storageid;
|
||||||
|
|
|
@ -15,7 +15,7 @@ INSERT INTO t2 SELECT i, f(i) FROM generate_series(1, 5) i;
|
||||||
|
|
||||||
-- there are no subtransactions, so above statement should batch
|
-- there are no subtransactions, so above statement should batch
|
||||||
-- INSERTs inside the UDF and create on stripe per table.
|
-- INSERTs inside the UDF and create on stripe per table.
|
||||||
SELECT relname, count(*) FROM columnar.columnar_stripes a, pg_class b
|
SELECT relname, count(*) FROM columnar.stripe a, pg_class b
|
||||||
WHERE columnar_relation_storageid(b.oid)=a.storageid AND relname IN ('t1', 't2')
|
WHERE columnar_relation_storageid(b.oid)=a.storageid AND relname IN ('t1', 't2')
|
||||||
GROUP BY relname
|
GROUP BY relname
|
||||||
ORDER BY relname;
|
ORDER BY relname;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
CREATE TABLE t(a int, b int) USING columnar;
|
CREATE TABLE t(a int, b int) USING columnar;
|
||||||
|
|
||||||
CREATE VIEW t_stripes AS
|
CREATE VIEW t_stripes AS
|
||||||
SELECT * FROM columnar.columnar_stripes a, pg_class b
|
SELECT * FROM columnar.stripe a, pg_class b
|
||||||
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname = 't';
|
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname = 't';
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
|
@ -13,7 +13,7 @@ CREATE TABLE columnar_truncate_test_second (a int, b int) USING columnar;
|
||||||
CREATE TABLE columnar_truncate_test_compressed (a int, b int) USING columnar;
|
CREATE TABLE columnar_truncate_test_compressed (a int, b int) USING columnar;
|
||||||
CREATE TABLE columnar_truncate_test_regular (a int, b int);
|
CREATE TABLE columnar_truncate_test_regular (a int, b int);
|
||||||
|
|
||||||
SELECT count(distinct storageid) AS columnar_data_files_before_truncate FROM columnar.columnar_stripes \gset
|
SELECT count(distinct storageid) AS columnar_data_files_before_truncate FROM columnar.stripe \gset
|
||||||
|
|
||||||
INSERT INTO columnar_truncate_test select a, a from generate_series(1, 10) a;
|
INSERT INTO columnar_truncate_test select a, a from generate_series(1, 10) a;
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ TRUNCATE TABLE columnar_truncate_test;
|
||||||
SELECT * from columnar_truncate_test;
|
SELECT * from columnar_truncate_test;
|
||||||
|
|
||||||
-- make sure TRUNATE deletes metadata for old relfilenode
|
-- make sure TRUNATE deletes metadata for old relfilenode
|
||||||
SELECT :columnar_data_files_before_truncate - count(distinct storageid) FROM columnar.columnar_stripes;
|
SELECT :columnar_data_files_before_truncate - count(distinct storageid) FROM columnar.stripe;
|
||||||
|
|
||||||
-- test if truncation in the same transaction that created the table works properly
|
-- test if truncation in the same transaction that created the table works properly
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -74,7 +74,7 @@ INSERT INTO columnar_same_transaction_truncate SELECT * FROM generate_series(20,
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
-- should output "1" for the newly created relation
|
-- should output "1" for the newly created relation
|
||||||
SELECT count(distinct storageid) - :columnar_data_files_before_truncate FROM columnar.columnar_stripes;
|
SELECT count(distinct storageid) - :columnar_data_files_before_truncate FROM columnar.stripe;
|
||||||
SELECT * FROM columnar_same_transaction_truncate;
|
SELECT * FROM columnar_same_transaction_truncate;
|
||||||
|
|
||||||
DROP TABLE columnar_same_transaction_truncate;
|
DROP TABLE columnar_same_transaction_truncate;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
SET columnar.compression TO 'none';
|
SET columnar.compression TO 'none';
|
||||||
|
|
||||||
SELECT count(distinct storageid) AS columnar_table_count FROM columnar.columnar_stripes \gset
|
SELECT count(distinct storageid) AS columnar_table_count FROM columnar.stripe \gset
|
||||||
|
|
||||||
CREATE TABLE t(a int, b int) USING columnar;
|
CREATE TABLE t(a int, b int) USING columnar;
|
||||||
|
|
||||||
CREATE VIEW t_stripes AS
|
CREATE VIEW t_stripes AS
|
||||||
SELECT * FROM columnar.columnar_stripes a, pg_class b
|
SELECT * FROM columnar.stripe a, pg_class b
|
||||||
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t';
|
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t';
|
||||||
|
|
||||||
SELECT count(*) FROM t_stripes;
|
SELECT count(*) FROM t_stripes;
|
||||||
|
@ -38,18 +38,18 @@ SELECT count(*) FROM t_stripes;
|
||||||
-- VACUUM FULL doesn't reclaim dropped columns, but converts them to NULLs
|
-- VACUUM FULL doesn't reclaim dropped columns, but converts them to NULLs
|
||||||
ALTER TABLE t DROP COLUMN a;
|
ALTER TABLE t DROP COLUMN a;
|
||||||
|
|
||||||
SELECT stripe, attr, chunk, minimum_value IS NULL, maximum_value IS NULL
|
SELECT stripeid, attnum, chunkid, minimum_value IS NULL, maximum_value IS NULL
|
||||||
FROM columnar.columnar_skipnodes a, pg_class b
|
FROM columnar.chunk a, pg_class b
|
||||||
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t' ORDER BY 1, 2, 3;
|
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t' ORDER BY 1, 2, 3;
|
||||||
|
|
||||||
VACUUM FULL t;
|
VACUUM FULL t;
|
||||||
|
|
||||||
SELECT stripe, attr, chunk, minimum_value IS NULL, maximum_value IS NULL
|
SELECT stripeid, attnum, chunkid, minimum_value IS NULL, maximum_value IS NULL
|
||||||
FROM columnar.columnar_skipnodes a, pg_class b
|
FROM columnar.chunk a, pg_class b
|
||||||
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t' ORDER BY 1, 2, 3;
|
WHERE a.storageid = columnar_relation_storageid(b.oid) AND b.relname='t' ORDER BY 1, 2, 3;
|
||||||
|
|
||||||
-- Make sure we cleaned-up the transient table metadata after VACUUM FULL commands
|
-- Make sure we cleaned-up the transient table metadata after VACUUM FULL commands
|
||||||
SELECT count(distinct storageid) - :columnar_table_count FROM columnar.columnar_stripes;
|
SELECT count(distinct storageid) - :columnar_table_count FROM columnar.stripe;
|
||||||
|
|
||||||
-- do this in a transaction so concurrent autovacuum doesn't interfere with results
|
-- do this in a transaction so concurrent autovacuum doesn't interfere with results
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -112,7 +112,7 @@ DROP TABLE t;
|
||||||
DROP VIEW t_stripes;
|
DROP VIEW t_stripes;
|
||||||
|
|
||||||
-- Make sure we cleaned the metadata for t too
|
-- Make sure we cleaned the metadata for t too
|
||||||
SELECT count(distinct storageid) - :columnar_table_count FROM columnar.columnar_stripes;
|
SELECT count(distinct storageid) - :columnar_table_count FROM columnar.stripe;
|
||||||
|
|
||||||
-- A table with high compression ratio
|
-- A table with high compression ratio
|
||||||
SET columnar.compression TO 'pglz';
|
SET columnar.compression TO 'pglz';
|
||||||
|
|
|
@ -13,8 +13,13 @@ SET client_min_messages to ERROR;
|
||||||
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
|
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
|
|
||||||
|
CREATE TABLE dummy_reference_table(a int unique, b int);
|
||||||
|
INSERT INTO dummy_reference_table SELECT i FROM generate_series(-1, 5) i;
|
||||||
|
INSERT INTO dummy_reference_table VALUES (99),(100),(599),(600);
|
||||||
|
SELECT create_reference_table('dummy_reference_table');
|
||||||
|
|
||||||
CREATE TABLE citus_local_table (value int);
|
CREATE TABLE citus_local_table (value int);
|
||||||
SELECT create_citus_local_table('citus_local_table');
|
ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
-- DELETE trigger --
|
-- DELETE trigger --
|
||||||
|
@ -141,14 +146,15 @@ BEGIN;
|
||||||
AFTER TRUNCATE ON "interesting!schema"."citus_local!_table"
|
AFTER TRUNCATE ON "interesting!schema"."citus_local!_table"
|
||||||
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
||||||
|
|
||||||
SELECT create_citus_local_table('"interesting!schema"."citus_local!_table"');
|
ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);
|
||||||
|
|
||||||
-- we shouldn't see truncate trigger on shard relation as we drop it
|
-- we shouldn't see truncate trigger on shard relation as we drop it
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
CREATE TABLE "interesting!schema"."citus_local!_table"(value int);
|
CREATE TABLE "interesting!schema"."citus_local!_table"(value int);
|
||||||
SELECT create_citus_local_table('"interesting!schema"."citus_local!_table"');
|
ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);
|
||||||
|
|
||||||
CREATE TRIGGER "trigger\'name"
|
CREATE TRIGGER "trigger\'name"
|
||||||
BEFORE INSERT ON "interesting!schema"."citus_local!_table"
|
BEFORE INSERT ON "interesting!schema"."citus_local!_table"
|
||||||
|
@ -168,21 +174,25 @@ BEGIN;
|
||||||
DROP EXTENSION seg;
|
DROP EXTENSION seg;
|
||||||
|
|
||||||
-- show that dropping extension drops the triggers automatically
|
-- show that dropping extension drops the triggers automatically
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
-- ALTER TRIGGER RENAME
|
-- ALTER TRIGGER RENAME
|
||||||
ALTER TRIGGER "trigger\'name" ON "interesting!schema"."citus_local!_table" RENAME TO "trigger\'name22";
|
ALTER TRIGGER "trigger\'name" ON "interesting!schema"."citus_local!_table" RENAME TO "trigger\'name22";
|
||||||
-- show that triggers on both shell relation and shard relation are renamed
|
-- show that triggers on both shell relation and shard relation are renamed
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
|
|
||||||
-- ALTER TABLE DISABLE trigger
|
-- ALTER TABLE DISABLE trigger
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "trigger\'name22";
|
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "trigger\'name22";
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
|
|
||||||
-- ALTER TABLE ENABLE trigger
|
-- ALTER TABLE ENABLE trigger
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER "trigger\'name22";
|
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER "trigger\'name22";
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
|
|
||||||
CREATE TRIGGER another_trigger
|
CREATE TRIGGER another_trigger
|
||||||
AFTER DELETE ON "interesting!schema"."citus_local!_table"
|
AFTER DELETE ON "interesting!schema"."citus_local!_table"
|
||||||
|
@ -190,24 +200,29 @@ FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();
|
||||||
|
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER USER;
|
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER USER;
|
||||||
-- show that all triggers except the internal ones are disabled
|
-- show that all triggers except the internal ones are disabled
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
|
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER USER;
|
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER USER;
|
||||||
-- show that all triggers except the internal ones are enabled again
|
-- show that all triggers except the internal ones are enabled again
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
|
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER ALL;
|
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER ALL;
|
||||||
-- show that all triggers including internal triggers are disabled
|
-- show that all triggers including internal triggers are disabled
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
|
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;
|
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;
|
||||||
-- show that all triggers including internal triggers are enabled again
|
-- show that all triggers including internal triggers are enabled again
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
|
|
||||||
DROP TRIGGER another_trigger ON "interesting!schema"."citus_local!_table";
|
DROP TRIGGER another_trigger ON "interesting!schema"."citus_local!_table";
|
||||||
DROP TRIGGER "trigger\'name22" ON "interesting!schema"."citus_local!_table";
|
DROP TRIGGER "trigger\'name22" ON "interesting!schema"."citus_local!_table";
|
||||||
-- show that drop trigger works as expected
|
-- show that drop trigger works as expected
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TRIGGER "another_trigger\'name"
|
CREATE TRIGGER "another_trigger\'name"
|
||||||
|
@ -216,11 +231,13 @@ BEGIN;
|
||||||
|
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "another_trigger\'name";
|
ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "another_trigger\'name";
|
||||||
-- show that our truncate trigger is disabled ..
|
-- show that our truncate trigger is disabled ..
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
|
|
||||||
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;
|
ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;
|
||||||
-- .. and now it is enabled back
|
-- .. and now it is enabled back
|
||||||
SELECT * FROM citus_local_table_triggers;
|
SELECT * FROM citus_local_table_triggers
|
||||||
|
WHERE tgname NOT LIKE 'RI_ConstraintTrigger%';
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
-- as we create ddl jobs for DROP TRIGGER before standard process utility,
|
-- as we create ddl jobs for DROP TRIGGER before standard process utility,
|
||||||
|
|
|
@ -13,11 +13,14 @@ SET client_min_messages to ERROR;
|
||||||
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
|
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
|
|
||||||
|
CREATE TABLE dummy_reference_table(a int unique, b int);
|
||||||
|
SELECT create_reference_table('dummy_reference_table');
|
||||||
|
|
||||||
CREATE TABLE citus_local_table(a int, b int);
|
CREATE TABLE citus_local_table(a int, b int);
|
||||||
SELECT create_citus_local_table('citus_local_table');
|
ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);
|
||||||
|
|
||||||
CREATE TABLE citus_local_table_2(a int, b int);
|
CREATE TABLE citus_local_table_2(a int, b int);
|
||||||
SELECT create_citus_local_table('citus_local_table_2');
|
ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);
|
||||||
|
|
||||||
CREATE TABLE reference_table(a int, b int);
|
CREATE TABLE reference_table(a int, b int);
|
||||||
SELECT create_reference_table('reference_table');
|
SELECT create_reference_table('reference_table');
|
||||||
|
@ -37,8 +40,9 @@ CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
SET client_min_messages to ERROR;
|
SET client_min_messages to ERROR;
|
||||||
|
|
||||||
TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table;
|
TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table, dummy_reference_table, citus_local_table_2;
|
||||||
|
|
||||||
|
INSERT INTO dummy_reference_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
|
@ -616,16 +620,16 @@ BEGIN;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
|
|
||||||
SAVEPOINT sp2;
|
SAVEPOINT sp2;
|
||||||
INSERT INTO citus_local_table VALUES (5), (6);
|
INSERT INTO citus_local_table VALUES (3), (4);
|
||||||
INSERT INTO distributed_table VALUES (5), (6);
|
INSERT INTO distributed_table VALUES (3), (4);
|
||||||
|
|
||||||
ROLLBACK TO SAVEPOINT sp2;
|
ROLLBACK TO SAVEPOINT sp2;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
SELECT * FROM distributed_table ORDER BY 1,2;
|
SELECT * FROM distributed_table ORDER BY 1,2;
|
||||||
|
|
||||||
SAVEPOINT sp3;
|
SAVEPOINT sp3;
|
||||||
INSERT INTO citus_local_table VALUES (7), (8);
|
INSERT INTO citus_local_table VALUES (3), (2);
|
||||||
INSERT INTO reference_table VALUES (7), (8);
|
INSERT INTO reference_table VALUES (3), (2);
|
||||||
|
|
||||||
ROLLBACK TO SAVEPOINT sp3;
|
ROLLBACK TO SAVEPOINT sp3;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
|
|
|
@ -17,11 +17,14 @@ RESET client_min_messages;
|
||||||
SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
|
SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
|
||||||
SET citus.replication_model TO streaming;
|
SET citus.replication_model TO streaming;
|
||||||
|
|
||||||
|
CREATE TABLE dummy_reference_table(a int unique, b int);
|
||||||
|
SELECT create_reference_table('dummy_reference_table');
|
||||||
|
|
||||||
CREATE TABLE citus_local_table(a int, b int);
|
CREATE TABLE citus_local_table(a int, b int);
|
||||||
SELECT create_citus_local_table('citus_local_table');
|
ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);
|
||||||
|
|
||||||
CREATE TABLE citus_local_table_2(a int, b int);
|
CREATE TABLE citus_local_table_2(a int, b int);
|
||||||
SELECT create_citus_local_table('citus_local_table_2');
|
ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);
|
||||||
|
|
||||||
CREATE TABLE reference_table(a int, b int);
|
CREATE TABLE reference_table(a int, b int);
|
||||||
SELECT create_reference_table('reference_table');
|
SELECT create_reference_table('reference_table');
|
||||||
|
@ -44,8 +47,9 @@ CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
SET client_min_messages to ERROR;
|
SET client_min_messages to ERROR;
|
||||||
|
|
||||||
TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table;
|
TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table, dummy_reference_table, citus_local_table_2;
|
||||||
|
|
||||||
|
INSERT INTO dummy_reference_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i;
|
||||||
INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i;
|
INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i;
|
||||||
|
@ -638,16 +642,16 @@ BEGIN;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
|
|
||||||
SAVEPOINT sp2;
|
SAVEPOINT sp2;
|
||||||
INSERT INTO citus_local_table VALUES (5), (6);
|
INSERT INTO citus_local_table VALUES (3), (4);
|
||||||
INSERT INTO distributed_table VALUES (5), (6);
|
INSERT INTO distributed_table VALUES (3), (4);
|
||||||
|
|
||||||
ROLLBACK TO SAVEPOINT sp2;
|
ROLLBACK TO SAVEPOINT sp2;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
SELECT * FROM distributed_table ORDER BY 1,2;
|
SELECT * FROM distributed_table ORDER BY 1,2;
|
||||||
|
|
||||||
SAVEPOINT sp3;
|
SAVEPOINT sp3;
|
||||||
INSERT INTO citus_local_table VALUES (7), (8);
|
INSERT INTO citus_local_table VALUES (3), (2);
|
||||||
INSERT INTO reference_table VALUES (7), (8);
|
INSERT INTO reference_table VALUES (3), (2);
|
||||||
|
|
||||||
ROLLBACK TO SAVEPOINT sp3;
|
ROLLBACK TO SAVEPOINT sp3;
|
||||||
SELECT * FROM citus_local_table ORDER BY 1,2;
|
SELECT * FROM citus_local_table ORDER BY 1,2;
|
||||||
|
|
|
@ -148,5 +148,13 @@ BEGIN;
|
||||||
ALTER TABLE citus_local_table_1 ADD CONSTRAINT multi_fkey FOREIGN KEY (a, b) REFERENCES citus_local_table_2(a, b);
|
ALTER TABLE citus_local_table_1 ADD CONSTRAINT multi_fkey FOREIGN KEY (a, b) REFERENCES citus_local_table_2(a, b);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
-- when local execution is disabled, citus local table cannot be created
|
||||||
|
BEGIN;
|
||||||
|
SET citus.enable_local_execution TO false;
|
||||||
|
CREATE TABLE referenced_table(id int primary key);
|
||||||
|
SELECT create_reference_table('referenced_table');
|
||||||
|
CREATE TABLE referencing_table(id int, ref_id int, FOREIGN KEY(ref_id) REFERENCES referenced_table(id) ON DELETE SET DEFAULT);
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
-- cleanup at exit
|
-- cleanup at exit
|
||||||
DROP SCHEMA ref_citus_local_fkeys CASCADE;
|
DROP SCHEMA ref_citus_local_fkeys CASCADE;
|
||||||
|
|
|
@ -354,16 +354,17 @@ BEGIN;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
ALTER TABLE reference_table_2 DROP CONSTRAINT fkey_5;
|
||||||
ALTER TABLE reference_table_2 DROP CONSTRAINT fkey_7;
|
ALTER TABLE reference_table_2 DROP CONSTRAINT fkey_7;
|
||||||
|
|
||||||
-- since now citus_local_table_2 has no foreign keys, show that
|
-- since now reference_table_2 has no foreign keys, show that
|
||||||
-- cascade_via_foreign_keys option still works fine
|
-- cascade_via_foreign_keys option still works fine
|
||||||
SELECT undistribute_table('citus_local_table_2', cascade_via_foreign_keys=>true);
|
SELECT undistribute_table('reference_table_2', cascade_via_foreign_keys=>true);
|
||||||
|
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_partition, pg_tables
|
SELECT COUNT(*)=0 FROM pg_dist_partition, pg_tables
|
||||||
WHERE tablename=logicalrelid::regclass::text AND
|
WHERE tablename=logicalrelid::regclass::text AND
|
||||||
schemaname='undistribute_table_cascade' AND
|
schemaname='undistribute_table_cascade' AND
|
||||||
tablename='citus_local_table_2';
|
tablename='reference_table_2';
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
CREATE SCHEMA "bad!schemaName";
|
CREATE SCHEMA "bad!schemaName";
|
||||||
|
|
Loading…
Reference in New Issue