Dumping variables..A sort of serialize - Mailing list pgsql-hackers

From Gurunandan R. Bhat
Subject Dumping variables..A sort of serialize
Date
Msg-id Pine.LNX.4.33.0110032237050.3819-100000@suman.greenfields.universe
Whole thread Raw
List pgsql-hackers
Hi,
I am currently struggling to write a "serialize"-like function
that would dump a row of a table into a string-like object in a way that
would allow me to reconstruct the original row (or its individual
elements) from this object.
The tentative plan I have is something like this:
1) Write a C-function declared something like so:
  Datum serialise(PG_FUNCTION_ARGS)
2) Inside the function, get the pointer to the row using:  TupleTableSlot *row = PG_GETARGPOINTER(0);
3) Use GetAttributeByName to get the "Datum" value corresponding    to each of the attributes.

This is where I am stuck. What I want to do now is to use this datum value
returned by GetAttributeByName to get at the "glob of memory" occupied by
the attribute and "memmove" it into an area declared as text. I could then
store this text as a row in a table. Is this at all possible or am I
talking through my hat ;) 

I am sorry I dont understand the backend variable storage and 
types too well and would be grateful for some help. 

Regards and Thanks,
Gurunandan





pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Unicode combining characters
Next
From: Tom Lane
Date:
Subject: Rounding issue with current_time