Skip to content

Commit

Permalink
Reject unknown partition types
Browse files Browse the repository at this point in the history
Surprising that this conditional didn't already have an else clause,
but so it goes. This causes us to reject any partition types we don't
explicitly support (the function used to silently succeed).
  • Loading branch information
jasonmp85 committed May 25, 2015
1 parent f33d3ae commit 5c4f183
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions create_shards.c
Expand Up @@ -130,6 +130,12 @@ master_create_distributed_table(PG_FUNCTION_ARGS)
"defined to use range partitioning.")));
}
}
else
{
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized table partition type: %c",
partitionMethod)));
}

/* insert row into the partition metadata table */
InsertPartitionRow(distributedTableId, partitionMethod, partitionColumnText);
Expand Down
3 changes: 3 additions & 0 deletions expected/create_shards.out.tmpl
Expand Up @@ -52,6 +52,9 @@ ERROR: column "bad_column" of relation "table_to_distribute" does not exist
-- use unsupported partition type
SELECT master_create_distributed_table('table_to_distribute', 'name', 'r');
ERROR: pg_shard only supports hash partitioning
-- use unrecognized partition type
SELECT master_create_distributed_table('table_to_distribute', 'name', 'z');
ERROR: unrecognized table partition type: z
-- use a partition column of a type lacking any default operator class
SELECT master_create_distributed_table('table_to_distribute', 'json_data');
ERROR: data type json has no default operator class for specified partition method
Expand Down
3 changes: 3 additions & 0 deletions sql/create_shards.sql.tmpl
Expand Up @@ -61,6 +61,9 @@ SELECT master_create_distributed_table('table_to_distribute', 'bad_column');
-- use unsupported partition type
SELECT master_create_distributed_table('table_to_distribute', 'name', 'r');

-- use unrecognized partition type
SELECT master_create_distributed_table('table_to_distribute', 'name', 'z');

-- use a partition column of a type lacking any default operator class
SELECT master_create_distributed_table('table_to_distribute', 'json_data');

Expand Down

0 comments on commit 5c4f183

Please sign in to comment.