Materialized views and unique indexes - Mailing list pgsql-hackers

From Michael Paquier
Subject Materialized views and unique indexes
Date
Msg-id CAB7nPqT1GhYNWA1Cbv5LAm+baD9mYi31WzZ_aQ6CXWS+G1v4jA@mail.gmail.com
Whole thread Raw
Responses Re: Materialized views and unique indexes
List pgsql-hackers
Hi all,<br /><br />While testing materialized views, I found the following behavior with unique indexes:<br
/>postgres=#create table aa as select generate_series(1,3) as a;<br />SELECT 3<br />postgres=# create materialized view
aamas select * from aa;<br /> SELECT 3<br />postgres=# create unique index aam_ind on aam(a);<br />CREATE INDEX<br
/>postgres=#insert into aa values (4);<br />INSERT 0 1<br />postgres=# insert into aa values (1);<br />INSERT 0 1<br
/>postgres=#refresh materialized view aam;<br /> ERROR:  could not create unique index "aam_ind"<br />DETAIL:  Key
(a)=(1)is duplicated.<br />postgres=# select * from aam;<br /> a <br />---<br /> 1<br /> 2<br /> 3<br />(3 rows)<br
/><br/>As expected, the refresh failed, but the error message is not really user-friendly. <br /> Shouldn't we output
insteadsomething like that?<br />ERROR: could not refresh materialized view because of failure when rebuilding
index"<br/>DETAIL: key is duplicated.<br /><br />Thanks,<br />-- <br />Michael<br /> 

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: REFRESH MATERIALIZED VIEW locklevel
Next
From: Josh Berkus
Date:
Subject: Re: Materialized views and unique indexes