pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: rsto@paranoia.at
To: pgsql-docs@postgresql.org
Subject: Int32 type unclear about signedness
Date: Wed, 23 Aug 2017 18:45:23 +0000
Message-ID: <20170823184523.8152.35782@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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&#39;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&#39;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


view thread (2+ messages)  latest in thread

Message-ID: <20170823184523.8152.35782@wrigleys.postgresql.org>
Permalink:  ../20170823184523.8152.35782@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20170823184523.8152.35782@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: rsto@paranoia.at
  Subject: Re: Int32 type unclear about signedness
  In-Reply-To: <20170823184523.8152.35782@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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