Re: Portability concerns over pq_sendbyte?

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: Portability concerns over pq_sendbyte?
Дата
Msg-id 87in6ms8tq.fsf@news-spur.riddles.org.uk
обсуждение исходный текст
Ответ на Re: Portability concerns over pq_sendbyte?  (Andres Freund <andres@anarazel.de>)
Ответы Re: Portability concerns over pq_sendbyte?  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
>>>>> "Andres" == Andres Freund <andres@anarazel.de> writes:

 >> 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.

 Andres> It's not implementation defined in postgres' dialect of C - we
 Andres> rely on accurate signed->unsigned conversions in a number of
 Andres> places.

Converting signed integer to unsigned is ok as I understand it - what's
happening here is the reverse, converting an unrepresentable unsigned
value to a signed type.

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

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

There are cases where it's not actually clear what the wire protocol
expects - I'm thinking in particular of the number of entries in a list
of parameter types/formats.

-- 
Andrew (irc:RhodiumToad)


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

Предыдущее
От: "Bossart, Nathan"
Дата:
Сообщение: Add SKIP LOCKED to VACUUM and ANALYZE
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Portability concerns over pq_sendbyte?