mirror of https://github.com/citusdata/citus.git
Only read from pg_dist_partkeys column
parent
3e96d3a736
commit
bb347de6a5
|
@ -1238,59 +1238,43 @@ BuildCitusTableCacheEntry(Oid relationId)
|
||||||
cacheEntry->relationId = relationId;
|
cacheEntry->relationId = relationId;
|
||||||
|
|
||||||
cacheEntry->partitionMethod = datumArray[Anum_pg_dist_partition_partmethod - 1];
|
cacheEntry->partitionMethod = datumArray[Anum_pg_dist_partition_partmethod - 1];
|
||||||
Datum partitionKeyDatum = datumArray[Anum_pg_dist_partition_partkey - 1];
|
|
||||||
bool partitionKeyIsNull = isNullArray[Anum_pg_dist_partition_partkey - 1];
|
|
||||||
Datum partitionKeysDatum = datumArray[Anum_pg_dist_partition_partkeys - 1];
|
Datum partitionKeysDatum = datumArray[Anum_pg_dist_partition_partkeys - 1];
|
||||||
bool partitionKeysIsNull = isNullArray[Anum_pg_dist_partition_partkeys - 1];
|
bool partitionKeysIsNull = isNullArray[Anum_pg_dist_partition_partkeys - 1];
|
||||||
|
|
||||||
/* note that for reference tables partitionKeyIsNull is true */
|
/* note that for reference tables partitionKeyIsNull is true */
|
||||||
if (!partitionKeyIsNull)
|
if (!partitionKeysIsNull)
|
||||||
{
|
{
|
||||||
|
Assert(!isNullArray[Anum_pg_dist_partition_partkey - 1]);
|
||||||
|
|
||||||
oldContext = MemoryContextSwitchTo(MetadataCacheMemoryContext);
|
oldContext = MemoryContextSwitchTo(MetadataCacheMemoryContext);
|
||||||
Assert(!partitionKeysIsNull);
|
|
||||||
if (!partitionKeysIsNull)
|
ArrayType *partitionKeysArray = DatumGetArrayTypeP(partitionKeysDatum);
|
||||||
|
int partitionKeysCount = ArrayObjectCount(partitionKeysArray);
|
||||||
|
Datum *partitionKeysArrayDatum = DeconstructArrayObject(partitionKeysArray);
|
||||||
|
for (int i = 0; i < partitionKeysCount; i++)
|
||||||
{
|
{
|
||||||
ArrayType *partitionKeysArray = DatumGetArrayTypeP(partitionKeysDatum);
|
/* get the string representation of the partition column Var */
|
||||||
int partitionKeysCount = ArrayObjectCount(partitionKeysArray);
|
char *partitionKeyString = TextDatumGetCString(
|
||||||
Datum *partitionKeysArrayDatum = DeconstructArrayObject(partitionKeysArray);
|
partitionKeysArrayDatum[i]);
|
||||||
for (int i = 0; i < partitionKeysCount; i++)
|
|
||||||
{
|
|
||||||
/* get the string representation of the partition column Var */
|
|
||||||
char *partitionKeyString = TextDatumGetCString(
|
|
||||||
partitionKeysArrayDatum[i]);
|
|
||||||
|
|
||||||
/* convert the string to a Node and ensure it is a Var */
|
/* convert the string to a Node and ensure it is a Var */
|
||||||
Node *partitionNode = stringToNode(partitionKeyString);
|
Node *partitionNode = stringToNode(partitionKeyString);
|
||||||
Assert(IsA(partitionNode, Var));
|
Assert(IsA(partitionNode, Var));
|
||||||
|
|
||||||
cacheEntry->partitionKeyStrings =
|
cacheEntry->partitionKeyStrings =
|
||||||
lappend(cacheEntry->partitionKeyStrings, partitionKeyString);
|
lappend(cacheEntry->partitionKeyStrings, partitionKeyString);
|
||||||
cacheEntry->partitionColumns =
|
cacheEntry->partitionColumns =
|
||||||
lappend(cacheEntry->partitionColumns, partitionNode);
|
lappend(cacheEntry->partitionColumns, partitionNode);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: uncomment once fixed
|
|
||||||
* cacheEntry->partitionColumn = linitial(cacheEntry->partitionColumns);
|
|
||||||
* cacheEntry->partitionKeyString = linitial(cacheEntry->partitionKeyStrings);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the string representation of the partition column Var */
|
cacheEntry->partitionColumn = linitial(cacheEntry->partitionColumns);
|
||||||
cacheEntry->partitionKeyString = TextDatumGetCString(partitionKeyDatum);
|
cacheEntry->partitionKeyString = linitial(cacheEntry->partitionKeyStrings);
|
||||||
|
|
||||||
/* convert the string to a Node and ensure it is a Var */
|
|
||||||
Node *partitionNode = stringToNode(cacheEntry->partitionKeyString);
|
|
||||||
Assert(IsA(partitionNode, Var));
|
|
||||||
|
|
||||||
cacheEntry->partitionColumn = (Var *) partitionNode;
|
|
||||||
|
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldContext);
|
MemoryContextSwitchTo(oldContext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Assert(partitionKeysIsNull);
|
Assert(isNullArray[Anum_pg_dist_partition_partkey - 1]);
|
||||||
cacheEntry->partitionKeyString = NULL;
|
cacheEntry->partitionKeyString = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue