If a base table is modified before calling create_immv in a concurrent transaction, create_immv will create an IMMV inconsistent with the latest contents of the table.
Modify a table in a transaction A.
postgres=# begin ;
BEGIN
postgres=*# insert into yyy values (10);
INSERT 0 1
Create an IMMV in a transaction B.
postgres=# begin ;
BEGIN
postgres=*# select create_immv('mvyyy','select * from yyy'); -- blocked
Commit the transaction A.
postgres=*# commit;
COMMIT
postgres=# select * from yyy;
i
----
1
2
10
(3 rows)
4. Commit the transaction B, the IMMV doesn't contain the inserted row.
```sql
(cont.)
NOTICE: could not create an index on immv "mvyyy" automatically
DETAIL: This target list does not have all the primary key columns, or this view does not contain GROUP BY or DISTINCT clause.
HINT: Create an index on the immv for efficient incremental maintenance.
create_immv
-------------
2
(1 row)
postgres=*# end;
COMMIT
postgres=# select * from mvyyy;
i
---
1
2
(2 rows)
If a base table is modified before calling create_immv in a concurrent transaction, create_immv will create an IMMV inconsistent with the latest contents of the table.
Modify a table in a transaction A.
Create an IMMV in a transaction B.
Commit the transaction A.