Search Postgresql Archives

Getting char * from timestamp in a composite type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I need to extract a text string representation of a timestamp from a user-defined row type; e.g., from the composite type ('1980-01-01 12:00:00', 'Random Comment'), I'd like to extract the C string 1980-01-01 12:00:00 in my user-defined C function.

As I understand it, I should be able to do something like (assuming "time" is the attribute name):

   bool isNull;
   HeapTupleHeader t = DatumGetHeapTupleHeader(row);
   Datum var = GetAttributeByName( row, "time", & isNull );
   // Check for null
   char * ret = DatumGetCString( DirectFunctionCall1(textout, var ) );

However, the code above (and every other variant I've tried) invariable segmentation faults the postmaster. so obviously I am doing something wrong. Can someone explain (or point to an example that works) of how to do this?

Regards,

Michael A.
begin:vcard
fn:Michael Akinde
n:Akinde;Michael
org:Meteorologisk Institutt, Norge;IT
adr;quoted-printable:;;Gaustadall=C3=A9en 30D;Oslo;;0313;Norge
email;internet:michael.akinde@xxxxxx
tel;work:22963379
tel;cell:45885379
x-mozilla-html:FALSE
url:http://www.met.no
version:2.1
end:vcard

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux