@@ -264,16 +264,18 @@ static Datum ExecEvalGroupingFuncExpr(GroupingFuncExprState *gstate,
264
264
265
265
static Datum
266
266
ExecEvalSubscriptionRef (SubscriptionRefExprState * sbstate ,
267
- ExprContext * econtext ,
268
- bool * isNull ,
269
- ExprDoneCond * isDone )
267
+ ExprContext * econtext ,
268
+ bool * isNull ,
269
+ ExprDoneCond * isDone )
270
270
{
271
- SubscriptionRef * sbsRef = (SubscriptionRef * ) sbstate -> xprstate .expr ;
272
- Oid containerType , typsubscription ;
271
+ SubscriptionRef * sbsRef = (SubscriptionRef * ) sbstate -> xprstate .expr ;
272
+ Oid containerType ,
273
+ typsubscription ;
273
274
bool isAssignment = (sbsRef -> refassgnexpr != NULL );
274
275
bool eisnull ;
275
- Datum * upper , * lower ;
276
- ListCell * l ;
276
+ Datum * upper ,
277
+ * lower ;
278
+ ListCell * l ;
277
279
int i = 0 ,
278
280
j = 0 ;
279
281
SubscriptionExecData sbsdata ;
@@ -288,10 +290,8 @@ ExecEvalSubscriptionRef(SubscriptionRefExprState *sbstate,
288
290
289
291
sbsdata .xprcontext = econtext ;
290
292
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 );
295
295
296
296
/*
297
297
* If refexpr yields NULL, and it's a fetch, then result is NULL. In the
@@ -322,12 +322,10 @@ ExecEvalSubscriptionRef(SubscriptionRefExprState *sbstate,
322
322
upperProvided [i ++ ] = false;
323
323
continue ;
324
324
}
325
+
325
326
upperProvided [i ] = true;
327
+ upper [i ++ ] = ExecEvalExpr (eltstate , econtext , & eisnull , NULL );
326
328
327
- upper [i ++ ] = ExecEvalExpr (eltstate ,
328
- econtext ,
329
- & eisnull ,
330
- NULL );
331
329
/* If any index expr yields NULL, result is NULL or error */
332
330
if (eisnull )
333
331
{
@@ -358,12 +356,10 @@ ExecEvalSubscriptionRef(SubscriptionRefExprState *sbstate,
358
356
lowerProvided [j ++ ] = false;
359
357
continue ;
360
358
}
359
+
361
360
lowerProvided [j ] = true;
361
+ lower [j ++ ] = ExecEvalExpr (eltstate , econtext , & eisnull , NULL );
362
362
363
- lower [j ++ ] = ExecEvalExpr (eltstate ,
364
- econtext ,
365
- & eisnull ,
366
- NULL );
367
363
/* If any index expr yields NULL, result is NULL or error */
368
364
if (eisnull )
369
365
{
@@ -375,6 +371,7 @@ ExecEvalSubscriptionRef(SubscriptionRefExprState *sbstate,
375
371
return (Datum ) NULL ;
376
372
}
377
373
}
374
+
378
375
/* this can't happen unless parser messed up */
379
376
if (i != j )
380
377
elog (ERROR , "upper and lower index lists are not same length" );
@@ -389,19 +386,15 @@ ExecEvalSubscriptionRef(SubscriptionRefExprState *sbstate,
389
386
containerType = getBaseTypeAndTypmod (sbsRef -> refcontainertype , & sbsRef -> reftypmod );
390
387
typsubscription = get_subscription (containerType );
391
388
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 ))
401
390
/* this can't happen */
402
391
elog (ERROR , "can not find subscription procedure for type %s" ,
403
392
format_type_be (containerType ));
404
- }
393
+
394
+ return OidFunctionCall3 (typsubscription ,
395
+ Int32GetDatum (SBS_EXEC ),
396
+ PointerGetDatum (sbstate ),
397
+ PointerGetDatum (& sbsdata ));
405
398
}
406
399
407
400
/* ----------------------------------------------------------------
0 commit comments