pg.ddx.io pgsql-docs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Int32 type unclear about signedness 2+ messages / 2 participants [nested] [flat]
* Int32 type unclear about signedness @ 2017-08-23 18:45 rsto@paranoia.at 0 siblings, 1 reply; 2+ messages in thread From: rsto@paranoia.at @ 2017-08-23 18:45 UTC (permalink / raw) To: pgsql-docs The following documentation comment has been logged on the website: Page: https://www.postgresql.org/docs/9.6/static/protocol-message-types.html Description: The specification of the Int32 Message data type in section 51.4 of the current documentation does to specify signedness (see [1]). Both its C-like name and its use for negative values in several protocol 3 messages make assuming signedness only reasonable. Yet, when used for message lengths, the libpq code seems unclear: The libpq frontend reads message lengths from the backend as 4 bytes into a signed int (see [2]). It checks if the length exceeds 30000 and allows excessive message lengths only for some messages. Yet, the related backend code uses a uint32_t to transmit the length value of a size_t (see [3]). This suggests that UINT32_MAX lengths would theoretically be possible and driver implementations would need to handle it. I'm almost certain that signed ints are meant, but it might not hurt to explicitly state it in section 51.4. Furthermore, the restriction of certain message lengths to 30000 is not documented. Did I oversee something in the docs? Otherwise, I'd be happy to send a patch with a suggested change in the documentation. [1] https://www.postgresql.org/docs/9.6/static/protocol-message-types.html [2] https://github.com/postgres/postgres/blob/master/src/interfaces/libpq/fe-protocol3.c#L1985 [3] https://github.com/postgres/postgres/blob/master/src/backend/libpq/pqcomm.c#L1570 P.S.: Thanks for PostgreSQL, such a great tool! -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Int32 type unclear about signedness @ 2017-09-02 02:12 Peter Eisentraut <peter.eisentraut@2ndquadrant.com> parent: rsto@paranoia.at 0 siblings, 0 replies; 2+ messages in thread From: Peter Eisentraut @ 2017-09-02 02:12 UTC (permalink / raw) To: rsto@paranoia.at; pgsql-docs On 8/23/17 14:45, rsto@paranoia.at wrote: > Both its C-like name and its use for negative values in several protocol 3 > messages make assuming signedness only reasonable. Yet, when used for > message lengths, the libpq code seems unclear: > > The libpq frontend reads message lengths from the backend as 4 bytes into a > signed int (see [2]). It checks if the length exceeds 30000 and allows > excessive message lengths only for some messages. That doesn't contradict anything about the value being signed. > Yet, the related backend code uses a uint32_t to transmit the length value > of a size_t (see [3]). This suggests that UINT32_MAX lengths would > theoretically be possible and driver implementations would need to handle > it. That's because it calls ntonl() on the value, which requires an unsigned argument. It doesn't mean the original value is meant to be unsigned. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2017-09-02 02:12 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2017-08-23 18:45 Int32 type unclear about signedness rsto@paranoia.at 2017-09-02 02:12 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox