public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Maxwell Dreytser <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: RowDescription for a function does not include table OID
Date: Fri, 21 Jun 2024 11:51:18 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <LV3PR16MB60014D610A726368182ACC7EE6C92@LV3PR16MB6001.namprd16.prod.outlook.com>
References: <LV3PR16MB6001AF4D05893E9FF4B3C746E6CE2@LV3PR16MB6001.namprd16.prod.outlook.com>
<[email protected]>
<LV3PR16MB6001CD31C5982777BA9BA25EE6CE2@LV3PR16MB6001.namprd16.prod.outlook.com>
<LV3PR16MB6001216CE02B2D908F9D87ECE6C82@LV3PR16MB6001.namprd16.prod.outlook.com>
<LV3PR16MB60014D610A726368182ACC7EE6C92@LV3PR16MB6001.namprd16.prod.outlook.com>
Maxwell Dreytser <[email protected]> writes:
> I am working on a meta-programming use-case where I need to scrape some detailed information about the results of a function that "RETURNS TABLE (LIKE physical_table)", which ends up with prorettype = 'physical_table'::regtype.
> The problem is that for the query "SELECT * FROM my_function()" the RowDescription that is sent back shows 0 for Table OID and Column Index.
Yes, that's expected. You're selecting from a function, not a table.
> I would expect that the Table OID contains the relation OID of this
> table, as it would do for a typical statement like "SELECT * FROM
> my_table".
The PG wire protocol specification [1] defines these fields thus:
If the field can be identified as a column of a specific
table, the object ID of the table; otherwise zero.
If the field can be identified as a column of a specific
table, the attribute number of the column; otherwise zero.
My reading of that is that we should populate these fields only for
the case of direct selection from a table. If you go further than
that, then first off you have a ton of definitional issues (should it
"look through" views, for example?), and second you probably break
applications that are expecting the existing, longstanding definition.
regards, tom lane
[1] https://www.postgresql.org/docs/current/protocol-message-formats.html
view thread (14+ messages) latest in thread
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: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: RowDescription for a function does not include table OID
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox