Re: postgres.h MACRO issues

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: postgres.h MACRO issues
Дата
Msg-id 9833.1026486666@sss.pgh.pa.us
обсуждение исходный текст
Ответ на postgres.h MACRO issues  (David Busby <busby@pnts.com>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Bug #711: Automatic created indexes can in some cases not be referenced to
Следующее
От: Tom Lane
Дата:
Сообщение: Re: problem with query in postgres 6.5