Re: Get the name of the target Relation from Query struct?

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Ernst-Georg Schmid <ernst-georg(dot)schmid(at)bayer(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Get the name of the target Relation from Query struct?
Date: 2018-04-06 08:51:46
Message-ID: CAKJS1f8pacTSymTMvT__J_23+KBOfJ_i0=8s+Kb9QMVDfZ0P=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 6 April 2018 at 20:38, Ernst-Georg Schmid
<ernst-georg(dot)schmid(at)bayer(dot)com> wrote:
> I can get the resultRelation and it is 1 (which matches the Documentation that says that it would be 0 for a SELECT but I exclude SELECTs as you suggested).

I didn't quite say exclude SELECT :)

I wrote:
> You'll probably also want to check the query->commandType to ensure
> the command is one that will actually have a valid resultRelation.

> if(parse->commandType != CMD_SELECT) {

Does it perhaps crash on a utility command?

Have a look at parsenodes.h and find the comments for resultRelation,
then find the commandType field and look for the definition of
CmdType. You'll see you need to think a bit harder about which
commandTypes you allow.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ernst-Georg Schmid 2018-04-06 09:06:45 AW: Get the name of the target Relation from Query struct?
Previous Message amul sul 2018-04-06 08:49:02 Re: [HACKERS] Restrict concurrent update/delete with UPDATE of partition key