Fix error-cleanup mistakes in exec_stmt_call().
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 10 Nov 2018 03:04:14 +0000 (22:04 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 10 Nov 2018 03:04:14 +0000 (22:04 -0500)
commitf26c06a4046b62c04ab4a8ef8632a5f705b6dd2d
tree7c833238d5df93aa3582f6e9bb4b0d8639e7f9c7
parentfa2952d8eb0423a02fde7b36f748f8de11aec8db
Fix error-cleanup mistakes in exec_stmt_call().

Commit 15c729347 was a couple bricks shy of a load: we need to
ensure that expr->plan gets reset to NULL on any error exit,
if it's not supposed to be saved.  Also ensure that the
stmt->target calculation gets redone if needed.

The easy way to exhibit a problem is to set up code that
violates the writable-argument restriction and then execute
it twice.  But error exits out of, eg, setup_param_list()
could also break it.  Make the existing PG_TRY block cover
all of that code to be sure.

Per report from Pavel Stehule.

Discussion: https://postgr.es/m/CAFj8pRAeXNTO43W2Y0Cn0YOVFPv1WpYyOqQrrzUiN6s=dn7gCg@mail.gmail.com
src/pl/plpgsql/src/pl_exec.c