pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: [PATCH] Add result_types column to pg_prepared_statements view
Date: Fri, 01 Jul 2022 13:27:20 +0100
Message-ID: <87v8shj9w7.fsf@wibble.ilmari.org> (raw)
In-Reply-To: <58307e2c-a26c-d438-27f7-5bef9f693943@enterprisedb.com>
References: <871qwpo7te.fsf@wibble.ilmari.org>
	<58307e2c-a26c-d438-27f7-5bef9f693943@enterprisedb.com>

Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:

> On 19.05.22 17:34, Dagfinn Ilmari Mannsåker wrote:
>> Prompted by a question on IRC, here's a patch to add a result_types
>> column to the pg_prepared_statements view, so that one can see the types
>> of the columns returned by a prepared statement, not just the parameter
>> types.
>> I'm not quite sure about the column name, suggestions welcome.
>
> I think this patch is sensible.
>
> I see one issue: When you describe a prepared statement via the
> protocol, if a result field has a domain as its type, the RowDescription 
> message sends the underlying base type, not the domain type directly
> (see SendRowDescriptionMessage()).  But it doesn't do that for the 
> parameters (see exec_describe_statement_message()).  I don't know why
> that is; the protocol documentation doesn't mention it.  Might be worth 
> looking into, and checking whether the analogous information contained
> in this view should be made consistent.

A bit of git archaeology shows that the change was made by Tom (Cc-ed)
in 7.4:

commit d9b679c13a820eb7b464a1eeb1f177c3fea13ece
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date:   2003-05-13 18:39:50 +0000

    In RowDescription messages, report columns of domain datatypes as having
    the type OID and typmod of the underlying base type.  Per discussions
    a few weeks ago with Andreas Pflug and others.  Note that this behavioral
    change affects both old- and new-protocol clients.

I can't find that discussion in the archive, but someone did complain
about it shortly after:

https://www.postgresql.org/message-id/flat/D71A1574-A772-11D7-913D-0030656EE7B2%40icx.net

I think in this case returning the domain type is more useful, since
it's easy to get from that to the base type, but not vice versa.

The arguments about client-side type-specific value handling for
RowDescription don't apply here IMO, since this view is more
user-facing.

- ilmari





view thread (8+ messages)  latest in thread

Message-ID: <87v8shj9w7.fsf@wibble.ilmari.org>
Permalink:  ../87v8shj9w7.fsf@wibble.ilmari.org/
Also on:    postgresql.org/message-id/87v8shj9w7.fsf@wibble.ilmari.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: ilmari@ilmari.org, peter.eisentraut@enterprisedb.com, tgl@sss.pgh.pa.us
  Subject: Re: [PATCH] Add result_types column to pg_prepared_statements view
  In-Reply-To: <87v8shj9w7.fsf@wibble.ilmari.org>
  References: <871qwpo7te.fsf@wibble.ilmari.org> <58307e2c-a26c-d438-27f7-5bef9f693943@enterprisedb.com> <87v8shj9w7.fsf@wibble.ilmari.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