mirror of https://github.com/citusdata/citus.git
Avoid invalid array accesses to partitionFileArray
parent
519dc8329b
commit
9777f22e1e
|
@ -917,8 +917,13 @@ FilterAndPartitionTable(const char *filterQuery,
|
||||||
if (SPI_processed > 0)
|
if (SPI_processed > 0)
|
||||||
{
|
{
|
||||||
TupleDesc rowDescriptor = SPI_tuptable->tupdesc;
|
TupleDesc rowDescriptor = SPI_tuptable->tupdesc;
|
||||||
partitionColumnIndex = ColumnIndex(rowDescriptor, partitionColumnName);
|
|
||||||
|
|
||||||
|
if (fileCount == 0)
|
||||||
|
{
|
||||||
|
ereport(ERROR, (errmsg("no partition to read into")));
|
||||||
|
}
|
||||||
|
|
||||||
|
partitionColumnIndex = ColumnIndex(rowDescriptor, partitionColumnName);
|
||||||
partitionColumnTypeId = SPI_gettypeid(rowDescriptor, partitionColumnIndex);
|
partitionColumnTypeId = SPI_gettypeid(rowDescriptor, partitionColumnIndex);
|
||||||
if (partitionColumnType != partitionColumnTypeId)
|
if (partitionColumnType != partitionColumnTypeId)
|
||||||
{
|
{
|
||||||
|
@ -942,6 +947,7 @@ FilterAndPartitionTable(const char *filterQuery,
|
||||||
while (SPI_processed > 0)
|
while (SPI_processed > 0)
|
||||||
{
|
{
|
||||||
int rowIndex = 0;
|
int rowIndex = 0;
|
||||||
|
|
||||||
for (rowIndex = 0; rowIndex < SPI_processed; rowIndex++)
|
for (rowIndex = 0; rowIndex < SPI_processed; rowIndex++)
|
||||||
{
|
{
|
||||||
HeapTuple row = SPI_tuptable->vals[rowIndex];
|
HeapTuple row = SPI_tuptable->vals[rowIndex];
|
||||||
|
@ -964,6 +970,10 @@ FilterAndPartitionTable(const char *filterQuery,
|
||||||
if (!partitionKeyNull)
|
if (!partitionKeyNull)
|
||||||
{
|
{
|
||||||
partitionId = (*PartitionIdFunction)(partitionKey, partitionIdContext);
|
partitionId = (*PartitionIdFunction)(partitionKey, partitionIdContext);
|
||||||
|
if (partitionId == INVALID_SHARD_INDEX)
|
||||||
|
{
|
||||||
|
ereport(ERROR, (errmsg("invalid distribution column value")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -256,6 +256,9 @@ SELECT * FROM squares ORDER BY x;
|
||||||
5 | 25
|
5 | 25
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
-- empty shard interval array should raise error
|
||||||
|
SELECT worker_hash_partition_table(42,1,'SELECT a FROM generate_series(1,100) AS a', 'a', 23, ARRAY[0]);
|
||||||
|
ERROR: invalid distribution column value
|
||||||
DROP SCHEMA intermediate_results CASCADE;
|
DROP SCHEMA intermediate_results CASCADE;
|
||||||
NOTICE: drop cascades to 5 other objects
|
NOTICE: drop cascades to 5 other objects
|
||||||
DETAIL: drop cascades to table interesting_squares
|
DETAIL: drop cascades to table interesting_squares
|
||||||
|
|
|
@ -141,4 +141,7 @@ WITH (FORMAT text);
|
||||||
|
|
||||||
SELECT * FROM squares ORDER BY x;
|
SELECT * FROM squares ORDER BY x;
|
||||||
|
|
||||||
|
-- empty shard interval array should raise error
|
||||||
|
SELECT worker_hash_partition_table(42,1,'SELECT a FROM generate_series(1,100) AS a', 'a', 23, ARRAY[0]);
|
||||||
|
|
||||||
DROP SCHEMA intermediate_results CASCADE;
|
DROP SCHEMA intermediate_results CASCADE;
|
||||||
|
|
Loading…
Reference in New Issue