Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnxvU-0000qm-Tt for pgsql-docs@arkaria.postgresql.org; Sat, 02 Sep 2017 02:12:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dnxvU-0003DS-Gm for pgsql-docs@arkaria.postgresql.org; Sat, 02 Sep 2017 02:12:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dnxvT-0003Ai-P0 for pgsql-docs@postgresql.org; Sat, 02 Sep 2017 02:12:47 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dnxvP-0003R5-PA for pgsql-docs@postgresql.org; Sat, 02 Sep 2017 02:12:46 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 5F6D620EB0; Fri, 1 Sep 2017 22:12:42 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Fri, 01 Sep 2017 22:12:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=dsw1znUs0cGkoImlnmwUmGOsvWenAPH16zmq4t3Bb80=; b=miikfa6o ba7xn6f+D8Oo640sFO8IazZCI6nAPOT3TZSScdnpraCeax2HrGjcY/q9RDzfTnxB qg05RGF2KXxyUYES5EJDEW9qOAteR8LMmd5SopDdLRl7FlRYQSfCz9QULojD2HOg dXXzW9WZCpaZTTXcgehxExo9li9anMXngP1BWQGe9W8p/hv2G2zSrnCCeX/prToE EIJAfFbsBreBoUxC6C+NQj7Zh8UbTpeZ0F2cu9F2b3PYvO9rzTgylZzFwlmd02zq Bc1yKGsuWq4FIgBxcCthc/lajAI/jfAACTqS+Lj017Cwe7BPey/ro4LkhI5Lc82g nxnui2+of7MmhQ== X-ME-Sender: X-Sasl-enc: dhJFJEPtAYbC61V8eoQsamgVbaXB9cfCNiueoVN1CBfa 1504318362 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id E7B4A7E193; Fri, 1 Sep 2017 22:12:41 -0400 (EDT) Subject: Re: Int32 type unclear about signedness To: rsto@paranoia.at, pgsql-docs@postgresql.org References: <20170823184523.8152.35782@wrigleys.postgresql.org> From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Fri, 1 Sep 2017 22:12:41 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170823184523.8152.35782@wrigleys.postgresql.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org 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