From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Ed Behn <ed(at)behn(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Get Columns from Plan |
Date: | 2018-07-23 03:45:18 |
Message-ID: | 19585.1532317518@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Ed Behn <ed(at)behn(dot)us> writes:
> I'm tinkering with the idea of creating a Procedural Language plugin for
> Haskell. As such I'm reading up on the SPI and prepared statements. The
> idea is that a statement will be prepared at compile time and executed at
> run-time. Therefore, I want to be able to determine the columns (names and
> types) that are returned by a plan without executing it. It seems like this
> should be a straight-forward task, but there doesn't seem to be a mechanism
> to do this.
Sure: SPI_plan_get_plan_sources(), iterate through that list of
CachedPlanSources, inspect the resultDesc tupledescs. The reasons this
isn't terribly well documented include:
* You'll need to decide what your semantics are for cases where there's
more or less than one list entry with a result.
* Consider the possibility that the result tupdesc changes from time to
time, eg the result of "SELECT * FROM foo" can mutate due to ALTER TABLE.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-07-23 03:58:58 | Re: Tips on committing |
Previous Message | Thomas Munro | 2018-07-23 03:40:13 | Re: Possible performance regression in version 10.1 with pgbench read-write tests. |