Re: heaptuple over the network

Lists: pgsql-hackers
From: Mon Nsi <wong(dot)fei(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)surnet(dot)cl>
Subject: heaptuple over the network
Date: 2006-03-02 21:44:39
Message-ID: 20060302214439.5214.qmail@web37401.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello list,

I would like to be able to send the HeapTuple returned
by ExecFetchSlotTuple() over the network (socket) to
another postmaster process that's waiting for it. I
don't need to decode it, just send bytes.

My question, and I am not a DB expert, I just deal
with raw data. What other information do I need to
include from struct HeapTupleData in order for that
data to make sense on the other end (to rebuild a
HeapTuple from it).

I understand that:

data_address = offset(HeapTupleHeaderData,
tuple->t_data->t_hoff);
data_len = tuple->t_len - tuple->t_data->t_hoff;

tuple->t_data->t_ctid and tuple->t_data->t_natts are
needed for this. Is that it?

What do I need to watch for with TOAST'ed tuple?

I will basically create a temp struct that will hold
those necessary information and sent that struct.

Thank you,
tjjr

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Mon Nsi <wong(dot)fei(at)yahoo(dot)com>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: heaptuple over the network
Date: 2006-03-04 21:39:38
Message-ID: 20060304213938.GH13230@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Mon Nsi wrote:

Hi,

> My question, and I am not a DB expert, I just deal
> with raw data. What other information do I need to
> include from struct HeapTupleData in order for that
> data to make sense on the other end (to rebuild a
> HeapTuple from it).
>
> I understand that:
>
> data_address = offset(HeapTupleHeaderData,
> tuple->t_data->t_hoff);
> data_len = tuple->t_len - tuple->t_data->t_hoff;
>
> tuple->t_data->t_ctid and tuple->t_data->t_natts are
> needed for this. Is that it?
>
> What do I need to watch for with TOAST'ed tuple?

You need to detoast any attribute that is stored externally.
A compressed attribute will work fine, but an externally stored
attribute just won't work because it references the toast table by OID,
which will not be available on the remote system.

You also need to send the null bitmap. OTOH I don't think you need to
CTID.

Not sure if anything else.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support