summaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_utilcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/parser/parse_utilcmd.c')
-rw-r--r--src/backend/parser/parse_utilcmd.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 9fd4a09fe4..b8ebf9b52d 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -1891,13 +1891,16 @@ transformFKConstraints(CreateStmtContext *cxt,
* If not yet set, set it to first column in FK constraint
* if it references a partitioned table
*/
- if (IS_PGXC_COORDINATOR && !cxt->fallback_dist_col)
+ if (IS_PGXC_COORDINATOR &&
+ !cxt->fallback_dist_col &&
+ list_length(constraint->pk_attrs) != 0)
{
Oid pk_rel_id = RangeVarGetRelid(constraint->pktable, NoLock, false);
+ AttrNumber attnum = get_attnum(pk_rel_id,
+ strVal(list_nth(constraint->fk_attrs, 0)));
- /* make sure it is a partitioned column */
- if (list_length(constraint->pk_attrs) != 0
- && IsHashColumnForRelId(pk_rel_id, strVal(list_nth(constraint->pk_attrs,0))))
+ /* Make sure key is done on a partitioned column */
+ if (IsDistribColumn(pk_rel_id, attnum))
{
/* take first column */
char *colstr = strdup(strVal(list_nth(constraint->fk_attrs,0)));