Closed thoshiai closed 4 years ago
REFRESH MATERIALIZED VIEW command and CREATE INCREMENTAL MATERIALIZED VIEW .... WITH NO DATA are supported by this pull request.
IF spcify WITH NO DATA option, IMMV don't create immv-triggers. and recreate immv-triggers when REFRESH command execute.
Add new type 'm' in deptye column of pg_depend. it is used by REFRESH immv's triggers.
For example:
test=# CREATE INCREMENTAL MATERIALIZED VIEW immv AS SELECT FROM base_a INNER JOIN base_b USING(i); SELECT 2 test=# SELECT FROM pg_depend WHERE refobjid = 'immv'::regclass; classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptype ---------+-------+----------+------------+----------+-------------+--------- 1247 | 16837 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | n 2620 | 16839 | 0 | 1259 | 16835 | 0 | m 2620 | 16840 | 0 | 1259 | 16835 | 0 | m 2620 | 16841 | 0 | 1259 | 16835 | 0 | m 2620 | 16842 | 0 | 1259 | 16835 | 0 | m 2620 | 16843 | 0 | 1259 | 16835 | 0 | m 2620 | 16844 | 0 | 1259 | 16835 | 0 | m 2620 | 16845 | 0 | 1259 | 16835 | 0 | m 2620 | 16846 | 0 | 1259 | 16835 | 0 | m 2620 | 16847 | 0 | 1259 | 16835 | 0 | m 2620 | 16848 | 0 | 1259 | 16835 | 0 | m 2620 | 16849 | 0 | 1259 | 16835 | 0 | m 2620 | 16850 | 0 | 1259 | 16835 | 0 | m (15 rows)
test=# REFRESH MATERIALIZED VIEW immv; REFRESH MATERIALIZED VIEW test=# SELECT * FROM pg_depend WHERE refobjid = 'immv'::regclass; classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptype ---------+-------+----------+------------+----------+-------------+--------- 1247 | 16837 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | n 2620 | 16854 | 0 | 1259 | 16835 | 0 | m 2620 | 16855 | 0 | 1259 | 16835 | 0 | m 2620 | 16856 | 0 | 1259 | 16835 | 0 | m 2620 | 16857 | 0 | 1259 | 16835 | 0 | m 2620 | 16858 | 0 | 1259 | 16835 | 0 | m 2620 | 16859 | 0 | 1259 | 16835 | 0 | m 2620 | 16860 | 0 | 1259 | 16835 | 0 | m 2620 | 16861 | 0 | 1259 | 16835 | 0 | m 2620 | 16862 | 0 | 1259 | 16835 | 0 | m 2620 | 16863 | 0 | 1259 | 16835 | 0 | m 2620 | 16864 | 0 | 1259 | 16835 | 0 | m 2620 | 16865 | 0 | 1259 | 16835 | 0 | m (15 rows)
test=# REFRESH MATERIALIZED VIEW immv WITH NO DATA; REFRESH MATERIALIZED VIEW test=# SELECT * FROM pg_depend WHERE refobjid = 'immv'::regclass; classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptype ---------+-------+----------+------------+----------+-------------+--------- 1247 | 16837 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | n (3 rows)
test=# SELECT * FROM immv; ERROR: materialized view "immv" has not been populated HINT: Use the REFRESH MATERIALIZED VIEW command.
I recireate new pull request #60 instead of this. so this request close.
REFRESH MATERIALIZED VIEW command and CREATE INCREMENTAL MATERIALIZED VIEW .... WITH NO DATA are supported by this pull request.
IF spcify WITH NO DATA option, IMMV don't create immv-triggers. and recreate immv-triggers when REFRESH command execute.
Add new type 'm' in deptye column of pg_depend. it is used by REFRESH immv's triggers.
For example:
test=# CREATE INCREMENTAL MATERIALIZED VIEW immv AS SELECT FROM base_a INNER JOIN base_b USING(i); SELECT 2 test=# SELECT FROM pg_depend WHERE refobjid = 'immv'::regclass; classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptype ---------+-------+----------+------------+----------+-------------+--------- 1247 | 16837 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | n 2620 | 16839 | 0 | 1259 | 16835 | 0 | m 2620 | 16840 | 0 | 1259 | 16835 | 0 | m 2620 | 16841 | 0 | 1259 | 16835 | 0 | m 2620 | 16842 | 0 | 1259 | 16835 | 0 | m 2620 | 16843 | 0 | 1259 | 16835 | 0 | m 2620 | 16844 | 0 | 1259 | 16835 | 0 | m 2620 | 16845 | 0 | 1259 | 16835 | 0 | m 2620 | 16846 | 0 | 1259 | 16835 | 0 | m 2620 | 16847 | 0 | 1259 | 16835 | 0 | m 2620 | 16848 | 0 | 1259 | 16835 | 0 | m 2620 | 16849 | 0 | 1259 | 16835 | 0 | m 2620 | 16850 | 0 | 1259 | 16835 | 0 | m (15 rows)
test=# REFRESH MATERIALIZED VIEW immv; REFRESH MATERIALIZED VIEW test=# SELECT * FROM pg_depend WHERE refobjid = 'immv'::regclass; classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptype ---------+-------+----------+------------+----------+-------------+--------- 1247 | 16837 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | n 2620 | 16854 | 0 | 1259 | 16835 | 0 | m 2620 | 16855 | 0 | 1259 | 16835 | 0 | m 2620 | 16856 | 0 | 1259 | 16835 | 0 | m 2620 | 16857 | 0 | 1259 | 16835 | 0 | m 2620 | 16858 | 0 | 1259 | 16835 | 0 | m 2620 | 16859 | 0 | 1259 | 16835 | 0 | m 2620 | 16860 | 0 | 1259 | 16835 | 0 | m 2620 | 16861 | 0 | 1259 | 16835 | 0 | m 2620 | 16862 | 0 | 1259 | 16835 | 0 | m 2620 | 16863 | 0 | 1259 | 16835 | 0 | m 2620 | 16864 | 0 | 1259 | 16835 | 0 | m 2620 | 16865 | 0 | 1259 | 16835 | 0 | m (15 rows)
test=# REFRESH MATERIALIZED VIEW immv WITH NO DATA; REFRESH MATERIALIZED VIEW test=# SELECT * FROM pg_depend WHERE refobjid = 'immv'::regclass; classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptype ---------+-------+----------+------------+----------+-------------+--------- 1247 | 16837 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | i 2618 | 16838 | 0 | 1259 | 16835 | 0 | n (3 rows)
test=# SELECT * FROM immv; ERROR: materialized view "immv" has not been populated HINT: Use the REFRESH MATERIALIZED VIEW command.