@@ -264,16 +264,18 @@ static Datum ExecEvalGroupingFuncExpr(GroupingFuncExprState *gstate,
264264
265265static Datum
266266ExecEvalSubscriptionRef (SubscriptionRefExprState * sbstate ,
267- ExprContext * econtext ,
268- bool * isNull ,
269- ExprDoneCond * isDone )
267+ ExprContext * econtext ,
268+ bool * isNull ,
269+ ExprDoneCond * isDone )
270270{
271- SubscriptionRef * sbsRef = (SubscriptionRef * ) sbstate -> xprstate .expr ;
272- Oid containerType , typsubscription ;
271+ SubscriptionRef * sbsRef = (SubscriptionRef * ) sbstate -> xprstate .expr ;
272+ Oid containerType ,
273+ typsubscription ;
273274 bool isAssignment = (sbsRef -> refassgnexpr != NULL );
274275 bool eisnull ;
275- Datum * upper , * lower ;
276- ListCell * l ;
276+ Datum * upper ,
277+ * lower ;
278+ ListCell * l ;
277279 int i = 0 ,
278280 j = 0 ;
279281 SubscriptionExecData sbsdata ;
@@ -288,10 +290,8 @@ ExecEvalSubscriptionRef(SubscriptionRefExprState *sbstate,
288290
289291 sbsdata .xprcontext = econtext ;
290292 sbsdata .isNull = isNull ;
291- sbsdata .containerSource = ExecEvalExpr (sbstate -> refexpr ,
292- econtext ,
293- isNull ,
294- isDone );
293+ sbsdata .containerSource = ExecEvalExpr (sbstate -> refexpr , econtext ,
294+ isNull , isDone );
295295
296296 /*
297297 * If refexpr yields NULL, and it's a fetch, then result is NULL. In the
@@ -322,12 +322,10 @@ ExecEvalSubscriptionRef(SubscriptionRefExprState *sbstate,
322322 upperProvided [i ++ ] = false;
323323 continue ;
324324 }
325+
325326 upperProvided [i ] = true;
327+ upper [i ++ ] = ExecEvalExpr (eltstate , econtext , & eisnull , NULL );
326328
327- upper [i ++ ] = ExecEvalExpr (eltstate ,
328- econtext ,
329- & eisnull ,
330- NULL );
331329 /* If any index expr yields NULL, result is NULL or error */
332330 if (eisnull )
333331 {
@@ -358,12 +356,10 @@ ExecEvalSubscriptionRef(SubscriptionRefExprState *sbstate,
358356 lowerProvided [j ++ ] = false;
359357 continue ;
360358 }
359+
361360 lowerProvided [j ] = true;
361+ lower [j ++ ] = ExecEvalExpr (eltstate , econtext , & eisnull , NULL );
362362
363- lower [j ++ ] = ExecEvalExpr (eltstate ,
364- econtext ,
365- & eisnull ,
366- NULL );
367363 /* If any index expr yields NULL, result is NULL or error */
368364 if (eisnull )
369365 {
@@ -375,6 +371,7 @@ ExecEvalSubscriptionRef(SubscriptionRefExprState *sbstate,
375371 return (Datum ) NULL ;
376372 }
377373 }
374+
378375 /* this can't happen unless parser messed up */
379376 if (i != j )
380377 elog (ERROR , "upper and lower index lists are not same length" );
@@ -389,19 +386,15 @@ ExecEvalSubscriptionRef(SubscriptionRefExprState *sbstate,
389386 containerType = getBaseTypeAndTypmod (sbsRef -> refcontainertype , & sbsRef -> reftypmod );
390387 typsubscription = get_subscription (containerType );
391388
392- if (OidIsValid (typsubscription ))
393- {
394- return OidFunctionCall3 (typsubscription ,
395- Int32GetDatum (SBS_EXEC ),
396- PointerGetDatum (sbstate ),
397- PointerGetDatum (& sbsdata ));
398- }
399- else
400- {
389+ if (!OidIsValid (typsubscription ))
401390 /* this can't happen */
402391 elog (ERROR , "can not find subscription procedure for type %s" ,
403392 format_type_be (containerType ));
404- }
393+
394+ return OidFunctionCall3 (typsubscription ,
395+ Int32GetDatum (SBS_EXEC ),
396+ PointerGetDatum (sbstate ),
397+ PointerGetDatum (& sbsdata ));
405398}
406399
407400/* ----------------------------------------------------------------
0 commit comments