Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow REFRESH MATERIALIZED VIEW to refresh caggs #2391

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 5 additions & 19 deletions src/process_utility.c
Expand Up @@ -3330,8 +3330,7 @@ process_refresh_mat_view_start(ProcessUtilityArgs *args)
ScanIterator continuous_aggregate_iter;
NameData view_name;
NameData view_schema;
bool cagg_fullrange;
ContinuousAggMatOptions mat_options;
LOCAL_FCINFO(fcinfo, 3);

if (!OidIsValid(view_relid))
return DDL_CONTINUE;
Expand Down Expand Up @@ -3369,24 +3368,11 @@ process_refresh_mat_view_start(ProcessUtilityArgs *args)

PreventInTransactionBlock(args->context == PROCESS_UTILITY_TOPLEVEL, "REFRESH");

PopActiveSnapshot();
CommitTransactionCommand();
FC_SET_ARG(fcinfo, 0, ObjectIdGetDatum(view_relid));
FC_SET_NULL(fcinfo, 1);
FC_SET_NULL(fcinfo, 2);
ts_cm_functions->continuous_agg_refresh(fcinfo);

mat_options = (ContinuousAggMatOptions){
.verbose = true,
.within_single_transaction = false,
.process_only_invalidation = false,
.invalidate_prior_to_time = PG_INT64_MAX,
};
cagg_fullrange = ts_cm_functions->continuous_agg_materialize(materialization_id, &mat_options);
if (!cagg_fullrange)
{
elog(WARNING,
"REFRESH did not materialize the entire range since it was limited by the "
"max_interval_per_job setting");
}

StartTransactionCommand();
return DDL_DONE;
}

Expand Down
4 changes: 3 additions & 1 deletion tsl/test/expected/continuous_aggs_refresh.out
Expand Up @@ -409,7 +409,9 @@ SELECT * FROM weekly_temp_with_data;
Sun May 03 17:00:00 2020 PDT | 3 | 19
(8 rows)

CALL refresh_continuous_aggregate('weekly_temp_without_data', NULL, NULL);
-- Test that REFRESH MATERIALIZED VIEW works as an alternative to
-- refresh_continuous_aggregate()
REFRESH MATERIALIZED VIEW weekly_temp_without_data;
SELECT * FROM weekly_temp_without_data;
day | device | avg_temp
------------------------------+--------+------------------
Expand Down
4 changes: 3 additions & 1 deletion tsl/test/sql/continuous_aggs_refresh.sql
Expand Up @@ -237,7 +237,9 @@ GROUP BY 1,2 WITH DATA;
SELECT * FROM weekly_temp_without_data;
SELECT * FROM weekly_temp_with_data;

CALL refresh_continuous_aggregate('weekly_temp_without_data', NULL, NULL);
-- Test that REFRESH MATERIALIZED VIEW works as an alternative to
-- refresh_continuous_aggregate()
REFRESH MATERIALIZED VIEW weekly_temp_without_data;

SELECT * FROM weekly_temp_without_data;

Expand Down