AW: Get the name of the target Relation from Query struct? SOLVED! - Mailing list pgsql-hackers

From Ernst-Georg Schmid
Subject AW: Get the name of the target Relation from Query struct? SOLVED!
Date
Msg-id 9a79484538f64bb0be94beaa327c94bb@BYEX19.de.bayer.cnb
Whole thread Raw
Responses Re: Get the name of the target Relation from Query struct? SOLVED!
List 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


pgsql-hackers by date:

Previous
From: Suhal Vemu
Date:
Subject: ERROR: invalid memory alloc request size 1073741824
Next
From: John Naylor
Date:
Subject: Re: WIP: a way forward on bootstrap data