From 7ad10b48efe23a7aa1dc593e70058c3796d883b8 Mon Sep 17 00:00:00 2001 From: Adam Guo Date: Tue, 4 Mar 2025 22:25:49 +0000 Subject: [PATCH] Move warning --- pg_ivm.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pg_ivm.c b/pg_ivm.c index 569e920..9603ea8 100644 --- a/pg_ivm.c +++ b/pg_ivm.c @@ -273,19 +273,20 @@ IVM_prevent_immv_change(PG_FUNCTION_ARGS) TriggerData *trigdata = (TriggerData *) fcinfo->context; Relation rel = trigdata->tg_relation; - if (ImmvIncrementalMaintenanceIsEnabled()) - return PointerGetDatum(NULL); - /* - * If we are maintaining an IMMV, this warning would have been emitted by - * the IVM_immediate_* triggers, so there is no need to emit it again. + * This warning is shown regardless of whether the user is manually + * modifying the materialized view, or the extension is performing + * incremental maintenance. */ warnIfPgIvmNotPreloaded(); - ereport(ERROR, - (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("cannot change materialized view \"%s\"", - RelationGetRelationName(rel)))); + if (!ImmvIncrementalMaintenanceIsEnabled()) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot change materialized view \"%s\"", + RelationGetRelationName(rel)))); + + return PointerGetDatum(NULL); } /*