@@ -2779,12 +2779,7 @@ static void
2779
2779
ExecInitCoerceToDomain (ExprEvalStep * scratch , CoerceToDomain * ctest ,
2780
2780
ExprState * state , Datum * resv , bool * resnull )
2781
2781
{
2782
- ExprEvalStep scratch2 = {0 };
2783
2782
DomainConstraintRef * constraint_ref ;
2784
- Datum * domainval = NULL ;
2785
- bool * domainnull = NULL ;
2786
- Datum * save_innermost_domainval ;
2787
- bool * save_innermost_domainnull ;
2788
2783
ListCell * l ;
2789
2784
2790
2785
scratch -> d .domaincheck .resulttype = ctest -> resulttype ;
@@ -2831,6 +2826,10 @@ ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest,
2831
2826
foreach (l , constraint_ref -> constraints )
2832
2827
{
2833
2828
DomainConstraintState * con = (DomainConstraintState * ) lfirst (l );
2829
+ Datum * domainval = NULL ;
2830
+ bool * domainnull = NULL ;
2831
+ Datum * save_innermost_domainval ;
2832
+ bool * save_innermost_domainnull ;
2834
2833
2835
2834
scratch -> d .domaincheck .constraintname = con -> name ;
2836
2835
@@ -2862,6 +2861,8 @@ ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest,
2862
2861
*/
2863
2862
if (get_typlen (ctest -> resulttype ) == -1 )
2864
2863
{
2864
+ ExprEvalStep scratch2 = {0 };
2865
+
2865
2866
/* Yes, so make output workspace for MAKE_READONLY */
2866
2867
domainval = (Datum * ) palloc (sizeof (Datum ));
2867
2868
domainnull = (bool * ) palloc (sizeof (bool ));
@@ -2932,8 +2933,6 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
2932
2933
ExprState * state = makeNode (ExprState );
2933
2934
PlanState * parent = & aggstate -> ss .ps ;
2934
2935
ExprEvalStep scratch = {0 };
2935
- int transno = 0 ;
2936
- int setoff = 0 ;
2937
2936
bool isCombine = DO_AGGSPLIT_COMBINE (aggstate -> aggsplit );
2938
2937
LastAttnumInfo deform = {0 , 0 , 0 };
2939
2938
@@ -2947,7 +2946,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
2947
2946
* First figure out which slots, and how many columns from each, we're
2948
2947
* going to need.
2949
2948
*/
2950
- for (transno = 0 ; transno < aggstate -> numtrans ; transno ++ )
2949
+ for (int transno = 0 ; transno < aggstate -> numtrans ; transno ++ )
2951
2950
{
2952
2951
AggStatePerTrans pertrans = & aggstate -> pertrans [transno ];
2953
2952
@@ -2967,17 +2966,15 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
2967
2966
/*
2968
2967
* Emit instructions for each transition value / grouping set combination.
2969
2968
*/
2970
- for (transno = 0 ; transno < aggstate -> numtrans ; transno ++ )
2969
+ for (int transno = 0 ; transno < aggstate -> numtrans ; transno ++ )
2971
2970
{
2972
2971
AggStatePerTrans pertrans = & aggstate -> pertrans [transno ];
2973
- int argno ;
2974
- int setno ;
2975
2972
FunctionCallInfo trans_fcinfo = pertrans -> transfn_fcinfo ;
2976
- ListCell * arg ;
2977
- ListCell * bail ;
2978
2973
List * adjust_bailout = NIL ;
2979
2974
NullableDatum * strictargs = NULL ;
2980
2975
bool * strictnulls = NULL ;
2976
+ int argno ;
2977
+ ListCell * bail ;
2981
2978
2982
2979
/*
2983
2980
* If filter present, emit. Do so before evaluating the input, to
@@ -3071,6 +3068,8 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
3071
3068
}
3072
3069
else if (pertrans -> numSortCols == 0 )
3073
3070
{
3071
+ ListCell * arg ;
3072
+
3074
3073
/*
3075
3074
* Normal transition function without ORDER BY / DISTINCT.
3076
3075
*/
@@ -3113,6 +3112,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
3113
3112
*/
3114
3113
Datum * values = pertrans -> sortslot -> tts_values ;
3115
3114
bool * nulls = pertrans -> sortslot -> tts_isnull ;
3115
+ ListCell * arg ;
3116
3116
3117
3117
strictnulls = nulls ;
3118
3118
@@ -3152,12 +3152,12 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
3152
3152
* grouping set). Do so for both sort and hash based computations, as
3153
3153
* applicable.
3154
3154
*/
3155
- setoff = 0 ;
3156
3155
if (doSort )
3157
3156
{
3158
3157
int processGroupingSets = Max (phase -> numsets , 1 );
3158
+ int setoff = 0 ;
3159
3159
3160
- for (setno = 0 ; setno < processGroupingSets ; setno ++ )
3160
+ for (int setno = 0 ; setno < processGroupingSets ; setno ++ )
3161
3161
{
3162
3162
ExecBuildAggTransCall (state , aggstate , & scratch , trans_fcinfo ,
3163
3163
pertrans , transno , setno , setoff , false);
@@ -3168,14 +3168,15 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
3168
3168
if (doHash )
3169
3169
{
3170
3170
int numHashes = aggstate -> num_hashes ;
3171
+ int setoff ;
3171
3172
3172
3173
/* in MIXED mode, there'll be preceding transition values */
3173
3174
if (aggstate -> aggstrategy != AGG_HASHED )
3174
3175
setoff = aggstate -> maxsets ;
3175
3176
else
3176
3177
setoff = 0 ;
3177
3178
3178
- for (setno = 0 ; setno < numHashes ; setno ++ )
3179
+ for (int setno = 0 ; setno < numHashes ; setno ++ )
3179
3180
{
3180
3181
ExecBuildAggTransCall (state , aggstate , & scratch , trans_fcinfo ,
3181
3182
pertrans , transno , setno , setoff , true);
@@ -3204,6 +3205,8 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
3204
3205
Assert (as -> d .agg_deserialize .jumpnull == -1 );
3205
3206
as -> d .agg_deserialize .jumpnull = state -> steps_len ;
3206
3207
}
3208
+ else
3209
+ Assert (false);
3207
3210
}
3208
3211
}
3209
3212
@@ -3338,7 +3341,6 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
3338
3341
{
3339
3342
ExprState * state = makeNode (ExprState );
3340
3343
ExprEvalStep scratch = {0 };
3341
- int natt ;
3342
3344
int maxatt = -1 ;
3343
3345
List * adjust_jumps = NIL ;
3344
3346
ListCell * lc ;
@@ -3358,7 +3360,7 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
3358
3360
scratch .resnull = & state -> resnull ;
3359
3361
3360
3362
/* compute max needed attribute */
3361
- for (natt = 0 ; natt < numCols ; natt ++ )
3363
+ for (int natt = 0 ; natt < numCols ; natt ++ )
3362
3364
{
3363
3365
int attno = keyColIdx [natt ];
3364
3366
@@ -3388,7 +3390,7 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
3388
3390
* Start comparing at the last field (least significant sort key). That's
3389
3391
* the most likely to be different if we are dealing with sorted input.
3390
3392
*/
3391
- for (natt = numCols ; -- natt >= 0 ;)
3393
+ for (int natt = numCols ; -- natt >= 0 ;)
3392
3394
{
3393
3395
int attno = keyColIdx [natt ];
3394
3396
Form_pg_attribute latt = TupleDescAttr (ldesc , attno - 1 );
0 commit comments