mirror of https://github.com/citusdata/citus.git
EnsureRelationCanBeDistributed
parent
5abead7f2c
commit
361acde19d
|
@ -99,7 +99,7 @@ static uint32 ColocationIdForNewTable(Oid relationId, Var *distributionColumn,
|
||||||
int shardCount, bool shardCountIsStrict,
|
int shardCount, bool shardCountIsStrict,
|
||||||
char *colocateWithTableName,
|
char *colocateWithTableName,
|
||||||
bool viaDeprecatedAPI);
|
bool viaDeprecatedAPI);
|
||||||
static void EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
|
static void EnsureRelationCanBeDistributed(Oid relationId, List *distributionColumnList,
|
||||||
char distributionMethod, uint32 colocationId,
|
char distributionMethod, uint32 colocationId,
|
||||||
char replicationModel, bool viaDeprecatedAPI);
|
char replicationModel, bool viaDeprecatedAPI);
|
||||||
static void EnsureTableCanBeColocatedWith(Oid relationId, char replicationModel,
|
static void EnsureTableCanBeColocatedWith(Oid relationId, char replicationModel,
|
||||||
|
@ -525,7 +525,7 @@ CreateDistributedTable(Oid relationId, List *distributionColumnList,
|
||||||
colocateWithTableName,
|
colocateWithTableName,
|
||||||
viaDeprecatedAPI);
|
viaDeprecatedAPI);
|
||||||
|
|
||||||
EnsureRelationCanBeDistributed(relationId, linitial(distributionColumnList),
|
EnsureRelationCanBeDistributed(relationId, distributionColumnList,
|
||||||
distributionMethod,
|
distributionMethod,
|
||||||
colocationId, replicationModel, viaDeprecatedAPI);
|
colocationId, replicationModel, viaDeprecatedAPI);
|
||||||
|
|
||||||
|
@ -1083,7 +1083,7 @@ ColocationIdForNewTable(Oid relationId, Var *distributionColumn,
|
||||||
* there will not be any change in the given relation.
|
* there will not be any change in the given relation.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
|
EnsureRelationCanBeDistributed(Oid relationId, List *distributionColumnList,
|
||||||
char distributionMethod, uint32 colocationId,
|
char distributionMethod, uint32 colocationId,
|
||||||
char replicationModel, bool viaDeprecatedAPI)
|
char replicationModel, bool viaDeprecatedAPI)
|
||||||
{
|
{
|
||||||
|
@ -1109,53 +1109,60 @@ EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
|
||||||
"... AS IDENTITY.")));
|
"... AS IDENTITY.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* verify target relation is not distributed by a generated columns */
|
Var *distributionColumn = NULL;
|
||||||
if (distributionMethod != DISTRIBUTE_BY_NONE &&
|
foreach_ptr(distributionColumn, distributionColumnList)
|
||||||
DistributionColumnUsesGeneratedStoredColumn(relationDesc, distributionColumn))
|
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
/* verify target relation is not distributed by a generated columns */
|
||||||
errmsg("cannot distribute relation: %s", relationName),
|
if (distributionMethod != DISTRIBUTE_BY_NONE &&
|
||||||
errdetail("Distribution column must not use GENERATED ALWAYS "
|
DistributionColumnUsesGeneratedStoredColumn(relationDesc, distributionColumn))
|
||||||
"AS (...) STORED.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check for support function needed by specified partition method */
|
|
||||||
if (distributionMethod == DISTRIBUTE_BY_HASH)
|
|
||||||
{
|
|
||||||
Oid hashSupportFunction = SupportFunctionForColumn(distributionColumn,
|
|
||||||
HASH_AM_OID,
|
|
||||||
HASHSTANDARD_PROC);
|
|
||||||
if (hashSupportFunction == InvalidOid)
|
|
||||||
{
|
|
||||||
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION),
|
|
||||||
errmsg("could not identify a hash function for type %s",
|
|
||||||
format_type_be(distributionColumn->vartype)),
|
|
||||||
errdatatype(distributionColumn->vartype),
|
|
||||||
errdetail("Partition column types must have a hash function "
|
|
||||||
"defined to use hash partitioning.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (distributionColumn->varcollid != InvalidOid &&
|
|
||||||
!get_collation_isdeterministic(distributionColumn->varcollid))
|
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("Hash distributed partition columns may not use "
|
errmsg("cannot distribute relation: %s", relationName),
|
||||||
"a non deterministic collation")));
|
errdetail("Distribution column must not use GENERATED ALWAYS "
|
||||||
|
"AS (...) STORED.")));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (distributionMethod == DISTRIBUTE_BY_RANGE)
|
/* check for support function needed by specified partition method */
|
||||||
{
|
if (distributionMethod == DISTRIBUTE_BY_HASH)
|
||||||
Oid btreeSupportFunction = SupportFunctionForColumn(distributionColumn,
|
|
||||||
BTREE_AM_OID, BTORDER_PROC);
|
|
||||||
if (btreeSupportFunction == InvalidOid)
|
|
||||||
{
|
{
|
||||||
ereport(ERROR,
|
Oid hashSupportFunction = SupportFunctionForColumn(distributionColumn,
|
||||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
HASH_AM_OID,
|
||||||
errmsg("could not identify a comparison function for type %s",
|
HASHSTANDARD_PROC);
|
||||||
format_type_be(distributionColumn->vartype)),
|
if (hashSupportFunction == InvalidOid)
|
||||||
errdatatype(distributionColumn->vartype),
|
{
|
||||||
errdetail("Partition column types must have a comparison function "
|
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||||
"defined to use range partitioning.")));
|
errmsg("could not identify a hash function for type %s",
|
||||||
|
format_type_be(distributionColumn->vartype)),
|
||||||
|
errdatatype(distributionColumn->vartype),
|
||||||
|
errdetail(
|
||||||
|
"Partition column types must have a hash function "
|
||||||
|
"defined to use hash partitioning.")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distributionColumn->varcollid != InvalidOid &&
|
||||||
|
!get_collation_isdeterministic(distributionColumn->varcollid))
|
||||||
|
{
|
||||||
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
|
errmsg("Hash distributed partition columns may not use "
|
||||||
|
"a non deterministic collation")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (distributionMethod == DISTRIBUTE_BY_RANGE)
|
||||||
|
{
|
||||||
|
Oid btreeSupportFunction = SupportFunctionForColumn(distributionColumn,
|
||||||
|
BTREE_AM_OID,
|
||||||
|
BTORDER_PROC);
|
||||||
|
if (btreeSupportFunction == InvalidOid)
|
||||||
|
{
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||||
|
errmsg("could not identify a comparison function for type %s",
|
||||||
|
format_type_be(distributionColumn->vartype)),
|
||||||
|
errdatatype(distributionColumn->vartype),
|
||||||
|
errdetail(
|
||||||
|
"Partition column types must have a comparison function "
|
||||||
|
"defined to use range partitioning.")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1216,7 +1223,7 @@ EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorIfUnsupportedConstraint(relation, distributionMethod, replicationModel,
|
ErrorIfUnsupportedConstraint(relation, distributionMethod, replicationModel,
|
||||||
distributionColumn, colocationId);
|
linitial(distributionColumnList), colocationId);
|
||||||
|
|
||||||
|
|
||||||
ErrorIfUnsupportedPolicy(relation);
|
ErrorIfUnsupportedPolicy(relation);
|
||||||
|
|
Loading…
Reference in New Issue