Re: postgres.h MACRO issues

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: busby(at)pnts(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: postgres.h MACRO issues
Date: 2002-07-12 15:11:06
Message-ID: 9833.1026486666@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

David Busby <busby(at)pnts(dot)com> writes:
> // 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;

VARATT_SIZEP can't be changed without breaking lots of extant code.
However, there's nothing stopping you from defining your own
convenience macro, along the lines of

#define SET_CHAR_LEN(ptr, len) (VARATT_SIZEP(ptr) = (len) + VARHDRSZ)

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2002-07-12 15:17:41 Re: problem with query in postgres 6.5
Previous Message Tom Lane 2002-07-12 14:57:24 Re: Bug #711: Automatic created indexes can in some cases not be referenced to