Re: Portability concerns over pq_sendbyte?

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: Portability concerns over pq_sendbyte?
Дата
Msg-id 20180525020349.GB3078@paquier.xyz
обсуждение исходный текст
Ответ на Portability concerns over pq_sendbyte?  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список pgsql-hackers
On Thu, May 24, 2018 at 06:13:23PM +0100, Andrew Gierth wrote:
> In PG11, pq_sendbyte got changed from taking an int parameter to taking
> an int8.

From 1de09ad8.

> While that seems to work in general, it does mean that there are now
> several places in the code that do the equivalent of:
>
>     unsigned char x = 128;
>     pq_sendbyte(&buf, x);
>
> which I believe is not well-defined since pq_sendbyte takes an int8, and
> conversions of unrepresentable values to _signed_ integer types are
> (iirc) implementation-dependent.

Good point.

> There are also some cases where pq_sendint16 is being called for an
> unsigned value or a value that might exceed 32767.

If kept, some safeguards based on PG_INT*_[MIN|MAX] could be
appropriate.

> Would it be better for these to take unsigned values, or have unsigned
> variants?

It seems to me that it is not too late to change those interfaces so
as they use unsigned values in input so as they are consistent, it would
be dangerous on the contrary to keep those as they are.
--
Michael

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Jonathan S. Katz"
Дата:
Сообщение: Re: Add PostgreSQL 11 to feature matrix page?
Следующее
От: "Higuchi, Daisuke"
Дата:
Сообщение: RE: [Bug Fix]ECPG: cancellation of significant digits on ECPG