postgres.h MACRO issues - Mailing list pgsql-bugs

From David Busby
Subject postgres.h MACRO issues
Date
Msg-id 3D2E0144.4070902@pnts.com
Whole thread Raw
Responses Re: postgres.h MACRO issues
List pgsql-bugs
Elephant Developers,

    I've got a bit of an issue with using your macros while building my own C
function for PostgreSQL (btw: C functions are a wayyyy cool feature).
So I'm returning a char(32) from my function and I'm using the text*
structure to work with my data.  Here's where I've got trouble.

// Put my 32 bytes into the buffer, this works perfect
memcpy(VARDATA(out_text), pbuf, 32);
// Tell it the buffer size
// I don't like that I've got to add the header size myself
// could/should VARATT_SIZEP handle that for me?
VARATT_SIZEP(out_text) = VARHDRSZ + 32;

// This doesn't work right, but I assumed that it would
// I thought that VARATT_SIZEP would automagically take into
// account the VARHDSZ so I only say "my data size is X"
// not have to say "my data size is X + your header"
// Seems a little odd to me.
VARATT_SIZEP(out_text) = 32

So...I just wanted to share that with you folks, should also mention
that I really apperciate (sp?) the work you've done so far and look
forward to future versions.

Thanks for the cycles
/B

pgsql-bugs by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: 7.2.1 backend crash (convert_string_datum, locale)
Next
From: "praveen vejandla"
Date:
Subject: problem with query in postgres 6.5