Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fAmdf-00043p-8k for pgsql-committers@arkaria.postgresql.org; Tue, 24 Apr 2018 01:20:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fAmde-0004L6-2e for pgsql-committers@arkaria.postgresql.org; Tue, 24 Apr 2018 01:20:58 +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.89) (envelope-from ) id 1fAmdc-0004Kx-F8 for pgsql-committers@lists.postgresql.org; Tue, 24 Apr 2018 01:20:57 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fAmdU-0006hm-W0 for pgsql-committers@lists.postgresql.org; Tue, 24 Apr 2018 01:20:53 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id A0E8521D11; Mon, 23 Apr 2018 21:20:46 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 23 Apr 2018 21:20:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=i6vWSBZN9SNiaMYfcWa3ICO9tL+YmfxiAwtnJ5SgPko=; b=BPAwH9Zj UbLUh7W9ocFBn1WJOlUfyhSHCza0kU8iD/rGryieHvUfufHPRxbjdlIKGxHCe0BU iHs8MUt1J9nRpqSXp0qIwxax+2Srfr/OtMKgKXNt3hhZ/rwrzMi4Kn0rXgi2/VH/ nvKblfCmO2zHFRWPFGj/BYmoHit+aLHworeRNZDNkekgik0M4gGoy7xFI4BaVnlx 8Cc4+sfymQs0QXmXC4X7flMSvywKbAf+KOGMD/l+U8v5gkXkwXLHIOwY1hmqivKs jXuGqtfnxxOiRvgR00Lnkbt6Wgxz2f2KrxXJ+Xp5zym4nOASBbJGe+oBB3XpU/wo DrysDuXMz0nafA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=i6vWSBZN9SNiaMYfcWa3ICO9tL+Ym fxiAwtnJ5SgPko=; b=m5NsVaATUeDv5pb/Cs/hKbAYsB8UEp7fGH0ONz199jOyX ij5Zx9dqRXYM2+iU04xuvvupuuMZ5UMDZwJ8XoUC0RguGXdkKFfyTfaqxyhzchZ0 0CrLFq+vFnN18vEwr+n4gOckBUJ2BsXg9f9NQZbszf/gNfkf99J9Kgyv6DjHEmCX QbU/MzMcHDSrno+Qrfg69QkD+gRTVNqPybmQMF17Uni1U3MZ+4KWm+M1ig+zS7qK 8RqSnNR8n8v1Oi2VHViW/R1QxUbMV/O0whD9t/uC+r6CjNQNEUFi7rOacuJy3QPz wF6rQp2MANXMolAQkVQThJhYPn4s9BmvbRSzIZXSQ== X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 0C32010288; Mon, 23 Apr 2018 21:20:44 -0400 (EDT) Date: Tue, 24 Apr 2018 10:20:42 +0900 From: Michael Paquier To: David Rowley Cc: Alvaro Herrera , pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Remove useless default clause in switch Message-ID: <20180424012042.GD1570@paquier.xyz> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="GV0iVqYguTV4Q9ER" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --GV0iVqYguTV4Q9ER Content-Type: multipart/mixed; boundary="idY8LE8SD6/8DnRI" Content-Disposition: inline --idY8LE8SD6/8DnRI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 24, 2018 at 12:27:27PM +1200, David Rowley wrote: > I always thought that when all options were covered that we generally > kept a default just in case someone added another enum and forgot to > update the code. >=20 > I know generally those are with elog ERRORs but both would be designed > to alert a programmer, just at different times. The advantage with what Alvaro has done is that you get warning at compilation time, so it is much more helpful for developers when adding an option because they need to think about code paths where the warning comes from. > There are other examples in that file with the switch > (part_scheme->strategy), these are not using enums. I'd have to assume > that these must be different because of that. Those apply to PARTITION_STRATEGY_LIST and such, which are not defined based on an enumeration but using their catalog interpretation, so this assumption cannot apply. The same applies for BTLessEqualStrategyNumber & friends which have their own definition. You are right for what's in perform_pruning_combine_step though, so the attached could also be applied. -- Michael --idY8LE8SD6/8DnRI Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="partprune-useless-default.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitionin= g/partprune.c index f8844ef2eb..cbbb4c1827 100644 --- a/src/backend/partitioning/partprune.c +++ b/src/backend/partitioning/partprune.c @@ -2950,10 +2950,6 @@ perform_pruning_combine_step(PartitionPruneContext *= context, } } break; - - default: - elog(ERROR, "invalid pruning combine op: %d", - (int) cstep->combineOp); } =20 return result; --idY8LE8SD6/8DnRI-- --GV0iVqYguTV4Q9ER Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlrehmoACgkQnvQgOdby QH170hAAonu9FHDdCIzy3UENNBhChdXPeBHhkFvFRIp7BDZUBbT4CoQoVV4E+mIw RoX/iYqxBZI4XMIJ4CgR9LaCWvuIRSkpIlfcvyzF9acouzwORxhf9PlVk19eiUsp rkm3H6iRGe6wreGWElAHjj6gAPbYwIIDa1i3BtiseHOtHPg1lX0DufKx6YJGkIPM /yaE1PY9iwK2ReuObrIOo97uDZU26fkrM9MTsMI59dHUnh1TMO8P1tdWnVyo06KD SCKtIxz2L/sBe81C13j4I2VBequimgq1B522mjHzZIUnyvlLUIyN2nVeGqf3NSFS SZqz2xEMFcc1Me4dk4HCH8Q459X5GEhSe9ns9Ugoh9IFrpAk66QuZuEfZvioXFXg /mL4w3k/U9CTpMVrToxDD45011zCBJ3nsLkT627ma9ltXyz2c817UkdGz2ZO+18I qYulLdPNFRYUeGEbLWs1UvKUh0fnh3oESKKHGyW1gbrHPq/e9ksE9m/twuuSZUhQ IT7Yc3a23t7/OWWFqwhUZICOB723ozWSZwbD72OeL9wqejpMt5MhFR8rSXpBHE6x BmMNHiWb6oZyH3OM6WO3yGGQF843+3dYZHJ+zOTUUHL4+f+d8MAV07NndRTnbfb8 b4ECmQEqGTEQhHjYUD/FbtvhpHlAm5QIZwGWTMJgolNSo47mJ3Q= =oYtl -----END PGP SIGNATURE----- --GV0iVqYguTV4Q9ER--