Re: FDW: possible resjunk columns in AddForeignUpdateTargets

From: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, "rdunklau(at)gmail(dot)com" <rdunklau(at)gmail(dot)com>
Subject: Re: FDW: possible resjunk columns in AddForeignUpdateTargets
Date: 2013-12-04 14:47:46
Message-ID: CAB8KJ=ipd-kiqpE6AGhRprSqj6TExm=Rx9+csH7HvuxLA=D8kw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2013/11/8 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> writes:
>> What I would like to do is add a custom resjunk column
>> (e.g. a bytea) in AddForeignUpdateTargets that carries a row identifier
>> from the scan state to the modify state.
>> Would that be possible? Can I have anything else than a Var
>> in a resjunk column?
>
> [ thinks for awhile... ] Hm. In principle you can put any expression
> you want into the tlist during AddForeignUpdateTargets. However, if it's
> not a Var then the planner won't understand that it's something that needs
> to be supplied by the table scan, so things won't work right in any but
> the most trivial cases (maybe not even then :-().
>
> What I'd try is creating a Var that has the attno of ctid
> (ie, SelfItemPointerAttributeNumber) but the datatype you want, ie bytea.
> This won't match what the catalogs say your table's ctid is, but I think
> that nothing will care much about that.

Apologies for reinvigorating this thread, but I'm running into a similar wall
myself and would like to clarify if this approach will work at all.

My foreign data source is returning a fixed-length string as a unique row
identifier; in AddForeignUpdateTargets() I can create a Var like this:

var = makeVar(parsetree->resultRelation,
SelfItemPointerAttributeNumber,
BPCHAROID,
32,
InvalidOid,
0);

but is it possible to store something other than a TIDOID here, and if so how?

Regards

Ian Barwick

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2013-12-04 14:50:03 Re: Extension Templates S03E11
Previous Message MauMau 2013-12-04 14:27:02 [bug fix] pg_ctl fails with config-only directory