From: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> |
---|---|
To: | Walter Cai <wzcai92(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Accessing base table relational names via RelOptInfo |
Date: | 2017-12-06 20:44:56 |
Message-ID: | CAKJS1f999TpXXPZjdyVajjd0PrE3pLDmA+Cz-BNJ8bZkHriOAQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 7 December 2017 at 09:26, Walter Cai <wzcai92(at)gmail(dot)com> wrote:
> I want to be able to programmatically access the relation names inside from
> inside the calc_joinrel_size_estimate method (in costsize.c) using the
> RelOptInfo *outer_rel, RelOptInfo *inner_rel arguments. I'm pretty sure I
> need to use the Relids relids variables in the RelOptInfo struct but I'm not
> sure where to go from there.
If you loop through the RelOptInfo->relids with bms_next_member() and
lookup the RangeTblEntry from root->simple_rte_array[] you can get the
"relid", which is the Oid of the relation. You can then call
get_rel_name() on that Oid. You'll also need to ensure the relid
actually belongs to a relation, for this check that the
RangeTblEntry->rtekind is RTE_RELATION. You might also want to think
about schema names since two relations can share the same name in
different schemas.
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-12-06 21:31:10 | Re: pgsql: When VACUUM or ANALYZE skips a concurrently dropped table, log i |
Previous Message | Bossart, Nathan | 2017-12-06 20:32:38 | Re: pgsql: When VACUUM or ANALYZE skips a concurrently dropped table, log i |