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,8 +136,8 @@ clear_paths(RelOptInfo *rel)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CStoreSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
ColumnarSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
||||||
RangeTblEntry *rte)
|
RangeTblEntry *rte)
|
||||||
{
|
{
|
||||||
/* call into previous hook if assigned */
|
/* call into previous hook if assigned */
|
||||||
if (PreviousSetRelPathlistHook)
|
if (PreviousSetRelPathlistHook)
|
||||||
|
@ -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,16 +354,16 @@ CStoreScanNext(CStoreScanState *cstorescanstate)
|
||||||
{
|
{
|
||||||
/* the cstore access method does not use the flags, they are specific to heap */
|
/* the cstore access method does not use the flags, they are specific to heap */
|
||||||
uint32 flags = 0;
|
uint32 flags = 0;
|
||||||
Bitmapset *attr_needed = CStoreAttrNeeded(&node->ss);
|
Bitmapset *attr_needed = ColumnarAttrNeeded(&node->ss);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We reach here if the scan is not parallel, or if we're serially
|
* We reach here if the scan is not parallel, or if we're serially
|
||||||
* executing a scan that was planned to be parallel.
|
* executing a scan that was planned to be parallel.
|
||||||
*/
|
*/
|
||||||
scandesc = cstore_beginscan_extended(node->ss.ss_currentRelation,
|
scandesc = columnar_beginscan_extended(node->ss.ss_currentRelation,
|
||||||
estate->es_snapshot,
|
estate->es_snapshot,
|
||||||
0, NULL, NULL, flags, attr_needed,
|
0, NULL, NULL, flags, attr_needed,
|
||||||
cstorescanstate->qual);
|
cstorescanstate->qual);
|
||||||
bms_free(attr_needed);
|
bms_free(attr_needed);
|
||||||
|
|
||||||
node->ss.ss_currentScanDesc = scandesc;
|
node->ss.ss_currentScanDesc = scandesc;
|
||||||
|
@ -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,12 +80,12 @@ static Datum ColumnDefaultValue(TupleConstr *tupleConstraints,
|
||||||
Form_pg_attribute attributeForm);
|
Form_pg_attribute attributeForm);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreBeginRead initializes a cstore read operation. This function returns a
|
* ColumnarBeginRead initializes a cstore read operation. This function returns a
|
||||||
* read handle that's used during reading rows and finishing the read operation.
|
* read handle that's used during reading rows and finishing the read operation.
|
||||||
*/
|
*/
|
||||||
TableReadState *
|
TableReadState *
|
||||||
CStoreBeginRead(Relation relation, TupleDesc tupleDescriptor,
|
ColumnarBeginRead(Relation relation, TupleDesc tupleDescriptor,
|
||||||
List *projectedColumnList, List *whereClauseList)
|
List *projectedColumnList, List *whereClauseList)
|
||||||
{
|
{
|
||||||
List *stripeList = StripesForRelfilenode(relation->rd_node);
|
List *stripeList = StripesForRelfilenode(relation->rd_node);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -53,16 +53,16 @@ static Datum DatumCopy(Datum datum, bool datumTypeByValue, int datumTypeLength);
|
||||||
static StringInfo CopyStringInfo(StringInfo sourceString);
|
static StringInfo CopyStringInfo(StringInfo sourceString);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreBeginWrite initializes a cstore data load operation and returns a table
|
* ColumnarBeginWrite initializes a cstore data load operation and returns a table
|
||||||
* handle. This handle should be used for adding the row values and finishing the
|
* handle. This handle should be used for adding the row values and finishing the
|
||||||
* data load operation. If the cstore footer file already exists, we read the
|
* data load operation. If the cstore footer file already exists, we read the
|
||||||
* footer and then seek to right after the last stripe where the new stripes
|
* footer and then seek to right after the last stripe where the new stripes
|
||||||
* will be added.
|
* will be added.
|
||||||
*/
|
*/
|
||||||
TableWriteState *
|
TableWriteState *
|
||||||
CStoreBeginWrite(RelFileNode relfilenode,
|
ColumnarBeginWrite(RelFileNode relfilenode,
|
||||||
ColumnarOptions options,
|
ColumnarOptions options,
|
||||||
TupleDesc tupleDescriptor)
|
TupleDesc tupleDescriptor)
|
||||||
{
|
{
|
||||||
/* get comparison function pointers for each of the columns */
|
/* get comparison function pointers for each of the columns */
|
||||||
uint32 columnCount = tupleDescriptor->natts;
|
uint32 columnCount = tupleDescriptor->natts;
|
||||||
|
@ -110,7 +110,7 @@ CStoreBeginWrite(RelFileNode relfilenode,
|
||||||
writeState->chunkData = chunkData;
|
writeState->chunkData = chunkData;
|
||||||
writeState->compressionBuffer = NULL;
|
writeState->compressionBuffer = NULL;
|
||||||
writeState->perTupleContext = AllocSetContextCreate(CurrentMemoryContext,
|
writeState->perTupleContext = AllocSetContextCreate(CurrentMemoryContext,
|
||||||
"CStore per tuple context",
|
"Columnar per tuple context",
|
||||||
ALLOCSET_DEFAULT_SIZES);
|
ALLOCSET_DEFAULT_SIZES);
|
||||||
|
|
||||||
return writeState;
|
return writeState;
|
||||||
|
@ -118,7 +118,7 @@ CStoreBeginWrite(RelFileNode relfilenode,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreWriteRow adds a row to the cstore file. If the stripe is not initialized,
|
* ColumnarWriteRow adds a row to the cstore file. If the stripe is not initialized,
|
||||||
* we create structures to hold stripe data and skip list. Then, we serialize and
|
* we create structures to hold stripe data and skip list. Then, we serialize and
|
||||||
* append data to serialized value buffer for each of the columns and update
|
* append data to serialized value buffer for each of the columns and update
|
||||||
* corresponding skip nodes. Then, whole chunk data is compressed at every
|
* corresponding skip nodes. Then, whole chunk data is compressed at every
|
||||||
|
@ -126,7 +126,7 @@ CStoreBeginWrite(RelFileNode relfilenode,
|
||||||
* the stripe, and add its metadata to the table footer.
|
* the stripe, and add its metadata to the table footer.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CStoreWriteRow(TableWriteState *writeState, Datum *columnValues, bool *columnNulls)
|
ColumnarWriteRow(TableWriteState *writeState, Datum *columnValues, bool *columnNulls)
|
||||||
{
|
{
|
||||||
uint32 columnIndex = 0;
|
uint32 columnIndex = 0;
|
||||||
StripeBuffers *stripeBuffers = writeState->stripeBuffers;
|
StripeBuffers *stripeBuffers = writeState->stripeBuffers;
|
||||||
|
@ -206,7 +206,7 @@ CStoreWriteRow(TableWriteState *writeState, Datum *columnValues, bool *columnNul
|
||||||
stripeBuffers->rowCount++;
|
stripeBuffers->rowCount++;
|
||||||
if (stripeBuffers->rowCount >= options->stripeRowCount)
|
if (stripeBuffers->rowCount >= options->stripeRowCount)
|
||||||
{
|
{
|
||||||
CStoreFlushPendingWrites(writeState);
|
ColumnarFlushPendingWrites(writeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldContext);
|
MemoryContextSwitchTo(oldContext);
|
||||||
|
@ -214,15 +214,15 @@ CStoreWriteRow(TableWriteState *writeState, Datum *columnValues, bool *columnNul
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CStoreEndWrite finishes a cstore data load operation. If we have an unflushed
|
* ColumnarEndWrite finishes a cstore data load operation. If we have an unflushed
|
||||||
* stripe, we flush it. Then, we sync and close the cstore data file. Last, we
|
* stripe, we flush it. Then, we sync and close the cstore data file. Last, we
|
||||||
* flush the footer to a temporary file, and atomically rename this temporary
|
* flush the footer to a temporary file, and atomically rename this temporary
|
||||||
* file to the original footer file.
|
* file to the original footer file.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CStoreEndWrite(TableWriteState *writeState)
|
ColumnarEndWrite(TableWriteState *writeState)
|
||||||
{
|
{
|
||||||
CStoreFlushPendingWrites(writeState);
|
ColumnarFlushPendingWrites(writeState);
|
||||||
|
|
||||||
MemoryContextDelete(writeState->stripeWriteContext);
|
MemoryContextDelete(writeState->stripeWriteContext);
|
||||||
pfree(writeState->comparisonFunctionArray);
|
pfree(writeState->comparisonFunctionArray);
|
||||||
|
@ -232,7 +232,7 @@ CStoreEndWrite(TableWriteState *writeState)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CStoreFlushPendingWrites(TableWriteState *writeState)
|
ColumnarFlushPendingWrites(TableWriteState *writeState)
|
||||||
{
|
{
|
||||||
StripeBuffers *stripeBuffers = writeState->stripeBuffers;
|
StripeBuffers *stripeBuffers = writeState->stripeBuffers;
|
||||||
if (stripeBuffers != NULL)
|
if (stripeBuffers != NULL)
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
void
|
void
|
||||||
columnar_init(void)
|
columnar_init(void)
|
||||||
{
|
{
|
||||||
cstore_init();
|
columnar_init_gucs();
|
||||||
#ifdef HAS_TABLEAM
|
#ifdef HAS_TABLEAM
|
||||||
cstore_tableam_init();
|
columnar_tableam_init();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,6 @@ void
|
||||||
columnar_fini(void)
|
columnar_fini(void)
|
||||||
{
|
{
|
||||||
#if HAS_TABLEAM
|
#if HAS_TABLEAM
|
||||||
cstore_tableam_finish();
|
columnar_tableam_finish();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,8 +116,8 @@ CleanupWriteStateMap(void *arg)
|
||||||
|
|
||||||
|
|
||||||
TableWriteState *
|
TableWriteState *
|
||||||
cstore_init_write_state(Relation relation, TupleDesc tupdesc,
|
columnar_init_write_state(Relation relation, TupleDesc tupdesc,
|
||||||
SubTransactionId currentSubXid)
|
SubTransactionId currentSubXid)
|
||||||
{
|
{
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
|
@ -182,9 +182,9 @@ cstore_init_write_state(Relation relation, TupleDesc tupdesc,
|
||||||
ReadColumnarOptions(relation->rd_id, &cstoreOptions);
|
ReadColumnarOptions(relation->rd_id, &cstoreOptions);
|
||||||
|
|
||||||
SubXidWriteState *stackEntry = palloc0(sizeof(SubXidWriteState));
|
SubXidWriteState *stackEntry = palloc0(sizeof(SubXidWriteState));
|
||||||
stackEntry->writeState = CStoreBeginWrite(relation->rd_node,
|
stackEntry->writeState = ColumnarBeginWrite(relation->rd_node,
|
||||||
cstoreOptions,
|
cstoreOptions,
|
||||||
tupdesc);
|
tupdesc);
|
||||||
stackEntry->subXid = currentSubXid;
|
stackEntry->subXid = currentSubXid;
|
||||||
stackEntry->next = hashEntry->writeStateStack;
|
stackEntry->next = hashEntry->writeStateStack;
|
||||||
hashEntry->writeStateStack = stackEntry;
|
hashEntry->writeStateStack = stackEntry;
|
||||||
|
@ -215,7 +215,7 @@ FlushWriteStateForRelfilenode(Oid relfilenode, SubTransactionId currentSubXid)
|
||||||
SubXidWriteState *stackEntry = entry->writeStateStack;
|
SubXidWriteState *stackEntry = entry->writeStateStack;
|
||||||
if (stackEntry->subXid == currentSubXid)
|
if (stackEntry->subXid == currentSubXid)
|
||||||
{
|
{
|
||||||
CStoreFlushPendingWrites(stackEntry->writeState);
|
ColumnarFlushPendingWrites(stackEntry->writeState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ PopWriteStateForAllRels(SubTransactionId currentSubXid, SubTransactionId parentS
|
||||||
{
|
{
|
||||||
if (commit)
|
if (commit)
|
||||||
{
|
{
|
||||||
CStoreEndWrite(stackHead->writeState);
|
ColumnarEndWrite(stackHead->writeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->writeStateStack = stackHead->next;
|
entry->writeStateStack = stackHead->next;
|
||||||
|
|
|
@ -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,9 +336,9 @@ extern Datum columnar_relation_storageid(PG_FUNCTION_ARGS);
|
||||||
|
|
||||||
|
|
||||||
/* write_state_management.c */
|
/* write_state_management.c */
|
||||||
extern TableWriteState * cstore_init_write_state(Relation relation, TupleDesc
|
extern TableWriteState * columnar_init_write_state(Relation relation, TupleDesc
|
||||||
tupdesc,
|
tupdesc,
|
||||||
SubTransactionId currentSubXid);
|
SubTransactionId currentSubXid);
|
||||||
extern void FlushWriteStateForRelfilenode(Oid relfilenode, SubTransactionId
|
extern void FlushWriteStateForRelfilenode(Oid relfilenode, SubTransactionId
|
||||||
currentSubXid);
|
currentSubXid);
|
||||||
extern void FlushWriteStateForAllRels(SubTransactionId currentSubXid, SubTransactionId
|
extern void FlushWriteStateForAllRels(SubTransactionId currentSubXid, SubTransactionId
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#ifndef COLUMNAR_CUSTOMSCAN_H
|
#ifndef COLUMNAR_CUSTOMSCAN_H
|
||||||
#define COLUMNAR_CUSTOMSCAN_H
|
#define COLUMNAR_CUSTOMSCAN_H
|
||||||
|
|
||||||
void cstore_customscan_init(void);
|
void columnar_customscan_init(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* COLUMNAR_CUSTOMSCAN_H */
|
#endif /* COLUMNAR_CUSTOMSCAN_H */
|
||||||
|
|
|
@ -10,16 +10,16 @@
|
||||||
#include "distributed/coordinator_protocol.h"
|
#include "distributed/coordinator_protocol.h"
|
||||||
|
|
||||||
const TableAmRoutine * GetColumnarTableAmRoutine(void);
|
const TableAmRoutine * GetColumnarTableAmRoutine(void);
|
||||||
extern void cstore_tableam_init(void);
|
extern void columnar_tableam_init(void);
|
||||||
extern void cstore_tableam_finish(void);
|
extern void columnar_tableam_finish(void);
|
||||||
|
|
||||||
extern TableScanDesc cstore_beginscan_extended(Relation relation, Snapshot snapshot,
|
extern TableScanDesc columnar_beginscan_extended(Relation relation, Snapshot snapshot,
|
||||||
int nkeys, ScanKey key,
|
int nkeys, ScanKey key,
|
||||||
ParallelTableScanDesc parallel_scan,
|
ParallelTableScanDesc parallel_scan,
|
||||||
uint32 flags, Bitmapset *attr_needed,
|
uint32 flags, Bitmapset *attr_needed,
|
||||||
List *scanQual);
|
List *scanQual);
|
||||||
|
extern int64 ColumnarGetChunksFiltered(TableScanDesc scanDesc);
|
||||||
extern 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,35 +74,35 @@ 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
|
||||||
2 | 1 | 0 | f | f
|
2 | 1 | 0 | f | f
|
||||||
2 | 2 | 0 | f | f
|
2 | 2 | 0 | f | f
|
||||||
3 | 1 | 0 | f | f
|
3 | 1 | 0 | f | f
|
||||||
3 | 2 | 0 | f | f
|
3 | 2 | 0 | f | f
|
||||||
(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
|
||||||
2 | 1 | 0 | t | t
|
2 | 1 | 0 | t | t
|
||||||
2 | 2 | 0 | f | f
|
2 | 2 | 0 | f | f
|
||||||
3 | 1 | 0 | t | t
|
3 | 1 | 0 | t | t
|
||||||
3 | 2 | 0 | f | f
|
3 | 2 | 0 | f | f
|
||||||
(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