mirror of https://github.com/citusdata/citus.git
Fix: Make FindShardIntervalIndex robust against 0 shards.
parent
6dbd434f81
commit
5b6dd0812d
|
@ -247,11 +247,12 @@ FindShardInterval(Datum partitionColumnValue, DistTableCacheEntry *cacheEntry)
|
||||||
* the searched value. Note that the searched value must be the hashed value
|
* the searched value. Note that the searched value must be the hashed value
|
||||||
* of the original value if the distribution method is hash.
|
* of the original value if the distribution method is hash.
|
||||||
*
|
*
|
||||||
* Note that, if the searched value can not be found for hash partitioned tables,
|
* Note that, if the searched value can not be found for hash partitioned
|
||||||
* we error out. This should only happen if something is terribly wrong, either
|
* tables, we error out (unless there are no shards, in which case
|
||||||
* metadata tables are corrupted or we have a bug somewhere. Such as a hash
|
* INVALID_SHARD_INDEX is returned). This should only happen if something is
|
||||||
* function which returns a value not in the range of [INT32_MIN, INT32_MAX] can
|
* terribly wrong, either metadata tables are corrupted or we have a bug
|
||||||
* fire this.
|
* somewhere. Such as a hash function which returns a value not in the range
|
||||||
|
* of [INT32_MIN, INT32_MAX] can fire this.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
FindShardIntervalIndex(Datum searchedValue, DistTableCacheEntry *cacheEntry)
|
FindShardIntervalIndex(Datum searchedValue, DistTableCacheEntry *cacheEntry)
|
||||||
|
@ -264,6 +265,11 @@ FindShardIntervalIndex(Datum searchedValue, DistTableCacheEntry *cacheEntry)
|
||||||
!cacheEntry->hasUniformHashDistribution);
|
!cacheEntry->hasUniformHashDistribution);
|
||||||
int shardIndex = INVALID_SHARD_INDEX;
|
int shardIndex = INVALID_SHARD_INDEX;
|
||||||
|
|
||||||
|
if (shardCount == 0)
|
||||||
|
{
|
||||||
|
return INVALID_SHARD_INDEX;
|
||||||
|
}
|
||||||
|
|
||||||
if (partitionMethod == DISTRIBUTE_BY_HASH)
|
if (partitionMethod == DISTRIBUTE_BY_HASH)
|
||||||
{
|
{
|
||||||
if (useBinarySearch)
|
if (useBinarySearch)
|
||||||
|
|
Loading…
Reference in New Issue