summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/heap.c14
-rw-r--r--src/test/regress/expected/xc_misc.out2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 67a8fcb8a9..4afe2f3523 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -995,9 +995,12 @@ AddRelationDistribution(Oid relid,
switch (distributeby->disttype)
{
case DISTTYPE_HASH:
- /* User specified hash column, validate */
+ /*
+ * Validate user-specified hash column.
+ * System columns cannot be used.
+ */
attnum = get_attnum(relid, distributeby->colname);
- if (!attnum)
+ if (attnum <= 0 && attnum >= -(int) lengthof(SysAtt))
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -1015,9 +1018,12 @@ AddRelationDistribution(Oid relid,
break;
case DISTTYPE_MODULO:
- /* User specified modulo column, validate */
+ /*
+ * Validate user specified modulo column.
+ * System columns cannot be used.
+ */
attnum = get_attnum(relid, distributeby->colname);
- if (!attnum)
+ if (attnum <= 0 && attnum >= -(int) lengthof(SysAtt))
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
diff --git a/src/test/regress/expected/xc_misc.out b/src/test/regress/expected/xc_misc.out
index 4d5ccd30dc..b6af82aa2f 100644
--- a/src/test/regress/expected/xc_misc.out
+++ b/src/test/regress/expected/xc_misc.out
@@ -99,7 +99,7 @@ select get_unified_node_name(xc_node_id),* from t1 order by xc_node_id;
create table t2(a int , xc_node_id int) distribute by modulo(a);
ERROR: column name "xc_node_id" conflicts with a system column name
create table t2(a int , b int) distribute by modulo(xc_node_id);
-ERROR: Column xc_node_id is not modulo distributable data type
+ERROR: Invalid distribution column specified
drop table t1;
-- Test an SQL function with multiple statements in it including a utility statement.
create table my_tab1 (a int);