@@ -683,34 +683,44 @@ continuous_agg_refresh(PG_FUNCTION_ARGS)
683683
684684 int32 v = ts_jsonb_get_int32_field (options , POL_REFRESH_CONF_KEY_BUCKETS_PER_BATCH , & found );
685685 if (found )
686+ {
686687 buckets_per_batch = v ;
688+ }
687689
688690 v = ts_jsonb_get_int32_field (options ,
689691 POL_REFRESH_CONF_KEY_MAX_BATCHES_PER_EXECUTION ,
690692 & found );
691693 if (found )
694+ {
692695 max_batches_per_execution = v ;
696+ }
693697
694698 bool b =
695699 ts_jsonb_get_bool_field (options , POL_REFRESH_CONF_KEY_REFRESH_NEWEST_FIRST , & found );
696700 if (found )
701+ {
697702 refresh_newest_first = b ;
703+ }
698704 }
699705
700706 if (buckets_per_batch < 0 )
707+ {
701708 ereport (ERROR ,
702709 (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
703710 errmsg ("invalid buckets per batch" ),
704711 errdetail ("buckets_per_batch: %d" , buckets_per_batch ),
705712 errhint ("The buckets per batch should be greater than or equal to zero." )));
713+ }
706714
707715 if (max_batches_per_execution < 0 )
716+ {
708717 ereport (ERROR ,
709718 (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
710719 errmsg ("invalid max batches per execution" ),
711720 errdetail ("max_batches_per_execution: %d" , max_batches_per_execution ),
712721 errhint (
713722 "The max batches per execution should be greater than or equal to zero." )));
723+ }
714724
715725 ContinuousAggRefreshContext context = {
716726 .callctx = CAGG_REFRESH_WINDOW ,
@@ -1125,8 +1135,7 @@ continuous_agg_refresh_single_window(const ContinuousAgg *cagg_arg,
11251135 * own independent SPI session and commits independently (non-atomic).
11261136 */
11271137void
1128- continuous_agg_refresh_internal (const ContinuousAgg * cagg ,
1129- const InternalTimeRange * refresh_window ,
1138+ continuous_agg_refresh_internal (const ContinuousAgg * cagg , const InternalTimeRange * refresh_window ,
11301139 ContinuousAggRefreshContext context , bool force ,
11311140 bool extend_last_bucket )
11321141{
@@ -1144,12 +1153,11 @@ continuous_agg_refresh_internal(const ContinuousAgg *cagg,
11441153
11451154 if (context .buckets_per_batch > 0 )
11461155 {
1147- refresh_window_list =
1148- continuous_agg_split_refresh_window (cagg ,
1149- refresh_window ,
1150- context .buckets_per_batch ,
1151- context .refresh_newest_first ,
1152- force );
1156+ refresh_window_list = continuous_agg_split_refresh_window (cagg ,
1157+ refresh_window ,
1158+ context .buckets_per_batch ,
1159+ context .refresh_newest_first ,
1160+ force );
11531161 }
11541162
11551163 if (refresh_window_list == NIL )
@@ -1162,7 +1170,9 @@ continuous_agg_refresh_internal(const ContinuousAgg *cagg,
11621170 /* Batched windows are already bucket-aligned by the split function */
11631171 bucketing_refresh_window = false;
11641172 if (context .callctx == CAGG_REFRESH_POLICY )
1173+ {
11651174 context .callctx = CAGG_REFRESH_POLICY_BATCHED ;
1175+ }
11661176 }
11671177
11681178 context .number_of_batches = list_length (refresh_window_list );
@@ -1186,11 +1196,13 @@ continuous_agg_refresh_internal(const ContinuousAgg *cagg,
11861196 processing_batch == context .number_of_batches );
11871197
11881198 if (context .number_of_batches > 1 )
1199+ {
11891200 elog (DEBUG1 ,
11901201 "refreshing continuous aggregate \"%s\" in window [ %s, %s ]" ,
11911202 NameStr (cagg -> data .user_view_name ),
11921203 ts_internal_to_time_string (batch_window -> start , batch_window -> type ),
11931204 ts_internal_to_time_string (batch_window -> end , batch_window -> type ));
1205+ }
11941206
11951207 bool refreshed = continuous_agg_refresh_single_window (cagg ,
11961208 batch_window ,
@@ -1356,14 +1368,12 @@ continuous_agg_split_refresh_window(const ContinuousAgg *cagg,
13561368 * 5. If the batch overlaps with both then it's a valid batch to be processed
13571369 * 6. If the batch overlaps with only one of them then it's not a valid batch to be processed
13581370 * 7. If the batch does not overlap with any of them then it's not a valid batch to be processed
1359- */
1360- /*
1371+ *
13611372 * When force is true, skip the invalidation log filter since forced refresh
13621373 * synthesizes invalidations per-window and there may be no existing log entries.
13631374 * Only filter on dimension slices (chunks with data).
13641375 */
1365- const char * query_str_template = force ?
1366- " \
1376+ const char * query_str_template = force ? " \
13671377 WITH dimension_slices AS ( \
13681378 SELECT \
13691379 range_start AS start, \
@@ -1392,9 +1402,8 @@ continuous_agg_split_refresh_window(const ContinuousAgg *cagg,
13921402 pg_catalog.int8range(dimension_slices.start, dimension_slices.end) \
13931403 ) \
13941404 ORDER BY \
1395- refresh_start %s;"
1396- :
1397- " \
1405+ refresh_start %s;" :
1406+ " \
13981407 WITH dimension_slices AS ( \
13991408 SELECT \
14001409 range_start AS start, \
0 commit comments