Re: SPI/backend equivalent of extended-query Describe(statement)?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Chapman Flack <chap(at)anastigmatix(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SPI/backend equivalent of extended-query Describe(statement)?
Date: 2018-05-14 17:15:48
Message-ID: CAFj8pRDG1V3DPAS-iURnOEQP_51M-WvHNJutXT-SnERcCYkdKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2018-05-14 17:29 GMT+02:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> Chapman Flack <chap(at)anastigmatix(dot)net> writes:
> > The longer version of $subject is: how would one go about, in the
> > backend using SPI (or SPI and maybe other server APIs as needed),
> > obtaining the same inferred parameter information that a front-end
> > client can get with the Describe (statement variant) extended-query
> > message?
>
> If you're talking about the plan's input parameters, don't SPI_getargcount
> and SPI_getargtypeid do what you need?
>
> If you want to know about the output column types, SPI doesn't seem to
> have a nice way of getting that in advance of execution, but you could
> emulate what Describe does:
>
> * Use SPI_plan_get_plan_sources to get a list of CachedPlanSources
> (up to you to decide what to do if there's more or less than one CPS)
>
> * For each/selected CPS, look at the resultDesc and/or targetlist
> similarly to SendRowDescriptionMessage.
>

plpgsql_check does this work more times

see source code https://github.com/okbob/plpgsql_check

Regards

Pavel

>
> regards, tom lane
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2018-05-14 17:29:10 Re: Indexes on partitioned tables and foreign partitions
Previous Message Magnus Hagander 2018-05-14 17:00:53 Re: Incorrect path in header comment identification