• Tom Lane's avatar
    Avoid fetching from an already-terminated plan. · b7056c0a
    Tom Lane authored
    Some plan node types don't react well to being called again after
    they've already returned NULL.  PortalRunSelect() has long dealt
    with this by calling the executor with NoMovementScanDirection
    if it sees that we've already run the portal to the end.  However,
    commit ba2c6d6c overlooked this point, so that persisting an
    already-fully-fetched cursor would fail if it had such a plan.
    
    Per report from Tomas Barton.  Back-patch to v11, as the faulty
    commit was.  (I've omitted a test case because the type of plan
    that causes a problem isn't all that stable.)
    
    Discussion: https://postgr.es/m/CAPV2KRjd=ErgVGbvO2Ty20tKTEZZr6cYsYLxgN_W3eAo9pf5sw@mail.gmail.com
    b7056c0a
portalcmds.c 12.7 KB