Re: Portability concerns over pq_sendbyte?

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Portability concerns over pq_sendbyte?
Дата
Msg-id 20180613185011.zua7iaxyeg4xqwll@alap3.anarazel.de
обсуждение исходный текст
Ответ на Portability concerns over pq_sendbyte?  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Ответы Re: Portability concerns over pq_sendbyte?  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список pgsql-hackers
Hi,

On 2018-05-24 18:13:23 +0100, Andrew Gierth wrote:
> In PG11, pq_sendbyte got changed from taking an int parameter to taking
> an int8.
> 
> 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.

It's not implementation defined in postgres' dialect of C - we rely on
accurate signed->unsigned conversions in a number of places.  But I
doin't think we should increase that reliance, so I think you're right
we should do something about this.


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

Hm, which case were you thinking of here?  The calls usually are exactly
the types that the wire protocol expects, no?


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

I wonder if we should just take 'int' out of the name. Say,
pg_send{8,16,32,64}(unsigned ...).

Greetings,

Andres Freund


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

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Re: Index maintenance function for BRIN doesn't check RecoveryInProgress()
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Portability concerns over pq_sendbyte?