From 0ca4b1214c86f1b959e4339cc9b8e0a1c6aa0fd3 Mon Sep 17 00:00:00 2001 From: Rafia Sabih Date: Wed, 11 Feb 2026 11:38:07 -0800 Subject: [PATCH] Check for duplicate rows with NULLs In case of concurrent refresh of materialized view, check for columns with NULL values. If there are duplicate entries with NULLS then error out. --- src/backend/commands/matview.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c index 81a55a33ef2..48bb2582a92 100644 --- a/src/backend/commands/matview.c +++ b/src/backend/commands/matview.c @@ -648,9 +648,9 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner, resetStringInfo(&querybuf); appendStringInfo(&querybuf, "SELECT newdata.*::%s FROM %s newdata " - "WHERE newdata.* IS NOT NULL AND EXISTS " - "(SELECT 1 FROM %s newdata2 WHERE newdata2.* IS NOT NULL " - "AND newdata2.* OPERATOR(pg_catalog.*=) newdata.* " + "WHERE EXISTS " + "(SELECT 1 FROM %s newdata2 WHERE " + " newdata2.* OPERATOR(pg_catalog.*=) newdata.* " "AND newdata2.ctid OPERATOR(pg_catalog.<>) " "newdata.ctid)", tempname, tempname, tempname); -- 2.39.5 (Apple Git-154)