From ce1210456914bee47c55cec26b0076232000e841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Nordstr=C3=B6m?= Date: Thu, 5 Oct 2017 13:50:30 +0200 Subject: [PATCH] Fix "ON CONFLICT ON CONSTRAINT" on plain PostgreSQL tables In the planner hook, we erroneously blocked "ON CONFLICT ON CONSTRAINT" statements on plain tables. This fixes the issue so that this error only occurs on hypertables. --- src/planner.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/planner.c b/src/planner.c index 0041c67d9c9..a5e58c2f060 100644 --- a/src/planner.c +++ b/src/planner.c @@ -368,13 +368,6 @@ modifytable_plan_walker(Plan **planptr, void *pctx) ListCell *lc_plan, *lc_rel; - if (ctx->parse->onConflict != NULL && - ctx->parse->onConflict->constraint != InvalidOid) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("Hypertables do not support ON CONFLICT statements that reference constraints"), - errhint("Use column names to infer indexes instead."))); - /* * To match up tuple-producing subplans with result relations, we * simultaneously loop over subplans and resultRelations, although @@ -391,6 +384,13 @@ modifytable_plan_walker(Plan **planptr, void *pctx) void **subplan_ptr = &lfirst(lc_plan); Plan *subplan = *subplan_ptr; + if (ctx->parse->onConflict != NULL && + ctx->parse->onConflict->constraint != InvalidOid) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Hypertables do not support ON CONFLICT statements that reference constraints"), + errhint("Use column names to infer indexes instead."))); + /* * We replace the plan with our custom chunk dispatch * plan.