Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qSwHN-007qHL-Ky for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Aug 2023 09:11:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qSwGO-008Bxh-4o for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Aug 2023 09:10:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qSwGN-008BxK-9U for pgsql-hackers@lists.postgresql.org; Mon, 07 Aug 2023 09:10:56 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qSwGJ-00143i-T3 for pgsql-hackers@lists.postgresql.org; Mon, 07 Aug 2023 09:10:55 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id BF622320091E; Mon, 7 Aug 2023 05:10:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 07 Aug 2023 05:10:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1691399446; x= 1691485846; bh=/T7hyM1miw8u06qlrk/cwNiglTWTugsS0peiShAioAk=; b=r /FTKY+59PWZP6FlOG7zvtl7LGJzuap7igRLzHRXH8PL9FBjf5hn+Rc1T3eB5GnI9 Vc08RhWGHAP7MWpUWX8R5zxwOQuUQCmrLhdwU7fnyDBYw1qK3Rh0gI65n65Y+bMo dbMbx1z6shc3KdnXX+jQc9u3QCTKEz1182oXne2H/CSJeIkf615/p3cEHi7Rho5d pGyRkeFZ5c/ECvkH1/9KVs4dTCZw1251enBnAPTGnXR/fjshV4zWRozBualRq3MU Ijvm9frQAlNFQL0cJ9NwjrtCBvLu+bMNmKZMvw+3iugaQqHVp4aIBUfQGBfWEwcm lyTVq1BDwFlDKxfePZcwA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrledtgddutdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeff gfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 7 Aug 2023 05:10:45 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 3064AAF; Mon, 7 Aug 2023 11:10:44 +0200 (CEST) Date: Mon, 7 Aug 2023 11:10:44 +0200 From: Alvaro Herrera To: Peter Smith Cc: Dave Cramer , Tatsuo Ishii , pgsql-hackers@lists.postgresql.org, nathandbossart@gmail.com Subject: Re: Using defines for protocol characters Message-ID: <20230807091044.jjgsl2rgheazaung@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Aug-07, Peter Smith wrote: > I guess, your patch would not be much different; you can still have > all the nice names and assign the appropriate values to the enum > values same as now, but using an enum you might also gain > type-checking in the code and also get warnings for the "switch" > statements if there are any cases accidentally omitted. Hmm, I think omitting a 'default' clause (which is needed when you want warnings for missing clauses) in a switch that handles protocol traffic is not great, because the switch would misbehave when the network counterpart sends a broken message. I'm not sure we want to do that. It could become a serious security problem if confronted with a malicious libpq. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/