Re: Get the name of the target Relation from Query struct?
От | David Rowley |
---|---|
Тема | Re: Get the name of the target Relation from Query struct? |
Дата | |
Msg-id | CAKJS1f8p9XvMzJ+vghHHVPdq8sUnhRsd1vxJZGRD+BO-78ws+w@mail.gmail.com обсуждение исходный текст |
Ответ на | Get the name of the target Relation from Query struct? (Ernst-Georg Schmid <ernst-georg.schmid@bayer.com>) |
Ответы |
AW: Get the name of the target Relation from Query struct?
AW: Get the name of the target Relation from Query struct? |
Список | pgsql-hackers |
On 5 April 2018 at 22:34, Ernst-Georg Schmid <ernst-georg.schmid@bayer.com> wrote: > I want to get the target Relation name for a UPDATE / INSERT / DELETE in a planner_hook. Do I understand struct Query correctlythat: > > Query->resultRelation will be the index into Query->rtable to give me the target Relation? Yes > And if yes, what would rtable give me as list entry? An OID or a Relation or something else? The list_nth(query->rtable, query->resultRelation) will give you a RangeTblEntry which has a property called relid, which is the Relation's OID as per pg_class.oid. If you want the relation name from the OID then you'll need something like get_rel_name(). You'll probably also want to check the query->commandType to ensure the command is one that will actually have a valid resultRelation. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
В списке pgsql-hackers по дате отправления: