0001-Check-for-duplicate-rows-with-NULLs.patch

application/octet-stream

Filename: 0001-Check-for-duplicate-rows-with-NULLs.patch
Type: application/octet-stream
Part: 0
Message: Re: Two issues with REFRESH MATERIALIZED VIEW CONCURRENTLY

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0001
Subject: Check for duplicate rows with NULLs
File+
src/backend/commands/matview.c 3 3
From 0ca4b1214c86f1b959e4339cc9b8e0a1c6aa0fd3 Mon Sep 17 00:00:00 2001
From: Rafia Sabih <rafia.sabih@cybertec.at>
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)