postgres.h MACRO issues

From: David Busby <busby(at)pnts(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: postgres.h MACRO issues
Date: 2002-07-11 22:05:56
Message-ID: 3D2E0144.4070902@pnts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2002-07-12 00:58:48 Bug #709: PL/pgSQL Parameter Of Composite Type
Previous Message Bruce Momjian 2002-07-11 16:41:24 Re: Bug #708: PgTransaction class is broken since 7.2