AW: Get the name of the target Relation from Query struct? SOLVED!

From: Ernst-Georg Schmid <ernst-georg(dot)schmid(at)bayer(dot)com>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: AW: Get the name of the target Relation from Query struct? SOLVED!
Date: 2018-04-06 10:12:05
Message-ID: 9a79484538f64bb0be94beaa327c94bb@BYEX19.de.bayer.cnb
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello David,

actually Query->resultRelation is one based and Query->rtable is zero based.

So the correct call to list_nth is: list_nth(Query->rtable, Query->resultRelation - 1)

The comment "rtable index of target relation for INSERT/UPDATE/DELETE/MERGE; 0 for SELECT" on resultRelation in parsenodes.h, Line 120 is misleading. It is _not_ a direct index into rtable, you have to subtract 1 first!

And now it works...checked against 9.6.8 and 10.3.

Best regards,

Ernst-Georg

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2018-04-06 10:17:51 Re: WIP: a way forward on bootstrap data
Previous Message Suhal Vemu 2018-04-06 10:06:09 ERROR: invalid memory alloc request size 1073741824