When creating materialized views, use REFRESH to load data.
authorJeff Davis <[email protected]>
Tue, 16 Jul 2024 22:41:22 +0000 (15:41 -0700)
committerJeff Davis <[email protected]>
Tue, 16 Jul 2024 22:41:22 +0000 (15:41 -0700)
commitb4da732fd64e936970f38c792f8b32c4bdf2bcd5
tree288677abf59991a5a7086a4b14d6c1eb3ba541d7
parentb6ed3cf4b07bfff1f166a239b34a75d818458006
When creating materialized views, use REFRESH to load data.

Previously, CREATE MATERIALIZED VIEW ... WITH DATA populated the MV
the same way as CREATE TABLE ... AS.

Instead, reuse the REFRESH logic, which locks down security-restricted
operations and restricts the search_path. This reduces the chance that
a subsequent refresh will fail.

Reported-by: Noah Misch
Backpatch-through: 17
Discussion: https://postgr.es/m/20240630222344[email protected]
src/backend/commands/createas.c
src/backend/commands/matview.c
src/include/commands/matview.h
src/test/regress/expected/namespace.out