pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix pl/tcl's handling of errors from Tcl_ListObjGetElements().
Date: Tue, 04 Jun 2024 22:02:36 +0000
Message-ID: <E1sEcEl-0000uf-GI@gemulon.postgresql.org> (raw)

Fix pl/tcl's handling of errors from Tcl_ListObjGetElements().

In a procedure or function returning tuple, we use that function to
parse the Tcl script's result, which is supposed to be a Tcl list.
If it isn't, you get an error.  Commit 26abb50c4 incautiously
supposed that we could use throw_tcl_error() to report such an error.
That doesn't actually work, because low-level functions like
Tcl_ListObjGetElements() don't fill Tcl's errorInfo variable.
The result is either a null-pointer-dereference crash or emission
of misleading context information describing the previous Tcl error.

Back off to just reporting the interpreter's result string, and
improve throw_tcl_error()'s comment to explain when to use it.

Also, although the similar code in pltcl_trigger_handler() avoided
this mistake, it was using a fairly confusing wording of the
error message.  Improve that while we're here.

Per report from A. Kozhemyakin.  Back-patch to all supported
branches.

Erik Wienhold and Tom Lane

Discussion: https://postgr.es/m/6a2a1c40-2b2c-4a33-8b72-243c0766fcda@postgrespro.ru

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1488dee08c4aa5b92a4cde66eb69b3e78e80a6d8

Modified Files
--------------
src/pl/tcl/expected/pltcl_call.out |  8 ++++++++
src/pl/tcl/pltcl.c                 | 11 +++++++++--
src/pl/tcl/sql/pltcl_call.sql      | 11 +++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1sEcEl-0000uf-GI@gemulon.postgresql.org>
Permalink:  ../E1sEcEl-0000uf-GI@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sEcEl-0000uf-GI@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix pl/tcl's handling of errors from Tcl_ListObjGetElements().
  In-Reply-To: <E1sEcEl-0000uf-GI@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox