Re: postgres.h MACRO issues - Mailing list pgsql-bugs

From Tom Lane
Subject Re: postgres.h MACRO issues
Date
Msg-id 9833.1026486666@sss.pgh.pa.us
Whole thread Raw
In response to postgres.h MACRO issues  (David Busby <busby@pnts.com>)
List pgsql-bugs
David Busby <busby@pnts.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bug #711: Automatic created indexes can in some cases not be referenced to
Next
From: Tom Lane
Date:
Subject: Re: problem with query in postgres 6.5