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
|
||||
* of the original value if the distribution method is hash.
|
||||
*
|
||||
* Note that, if the searched value can not be found for hash partitioned tables,
|
||||
* we error out. This should only happen if something is terribly wrong, either
|
||||
* metadata tables are corrupted or we have a bug somewhere. Such as a hash
|
||||
* function which returns a value not in the range of [INT32_MIN, INT32_MAX] can
|
||||
* fire this.
|
||||
* Note that, if the searched value can not be found for hash partitioned
|
||||
* tables, we error out (unless there are no shards, in which case
|
||||
* INVALID_SHARD_INDEX is returned). This should only happen if something is
|
||||
* terribly wrong, either metadata tables are corrupted or we have a bug
|
||||
* somewhere. Such as a hash function which returns a value not in the range
|
||||
* of [INT32_MIN, INT32_MAX] can fire this.
|
||||
*/
|
||||
static int
|
||||
FindShardIntervalIndex(Datum searchedValue, DistTableCacheEntry *cacheEntry)
|
||||
|
@ -264,6 +265,11 @@ FindShardIntervalIndex(Datum searchedValue, DistTableCacheEntry *cacheEntry)
|
|||
!cacheEntry->hasUniformHashDistribution);
|
||||
int shardIndex = INVALID_SHARD_INDEX;
|
||||
|
||||
if (shardCount == 0)
|
||||
{
|
||||
return INVALID_SHARD_INDEX;
|
||||
}
|
||||
|
||||
if (partitionMethod == DISTRIBUTE_BY_HASH)
|
||||
{
|
||||
if (useBinarySearch)
|
||||
|
|
Loading…
Reference in New Issue