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 1fAn6r-0006LJ-Kb for pgsql-committers@arkaria.postgresql.org; Tue, 24 Apr 2018 01:51:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fAn6p-00042U-Vz for pgsql-committers@arkaria.postgresql.org; Tue, 24 Apr 2018 01:51:07 +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 1fAn6p-00042L-Qh for pgsql-committers@lists.postgresql.org; Tue, 24 Apr 2018 01:51:07 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fAn6m-0007M6-B5 for pgsql-committers@lists.postgresql.org; Tue, 24 Apr 2018 01:51:07 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 145A6FF5; Mon, 23 Apr 2018 21:51:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 23 Apr 2018 21:51:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=oi4kQlDmqT89N+eVK O6zRr7YTlj+NZeoCAoIaQTyY6g=; b=MmFJFUoWxs+PkYYKE9hUyweQ8vgTSDnzD Ohememghe9WpCMHVj5pRP47skxi33I1db2tyQoR5rJP5orjt6oBD1/pRDKtZxd56 ExmeZZZnJ44Aq1dO+bNsFCu5uDHLQhZdQ5E9SDihn6hbDnxIzHRA6VcHwGr0y0py yn91ydQBeiHX5qY6DnPmrvnc/xB1MRQZSQAwEi2iVTxl2K003ugbzxHa8HJwHRrt wkAstMjCFNP2iJcH99BErzkYilD7brWiN6IWdw3DRH50bcGk5/qQss4iNFg1MxEp if9mShfqD6BuqeHt87yor6mWlFUJPgrPoV3On6wBWm+0pezxKGs1g== X-ME-Sender: Received: from alvin.alvh.no-ip.org (unknown [201.186.80.51]) by mail.messagingengine.com (Postfix) with ESMTPA id 5593BE498D; Mon, 23 Apr 2018 21:51:01 -0400 (EDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id BC7A0538; Mon, 23 Apr 2018 22:50:58 -0300 (-03) Date: Mon, 23 Apr 2018 22:50:58 -0300 From: Alvaro Herrera To: David Rowley Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Remove useless default clause in switch Message-ID: <20180424015058.yx7vtksqzjarzkrd@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Rowley wrote: > On 24 April 2018 at 03:12, Alvaro Herrera wrote: > > Remove useless default clause in switch > > > > The switch covers all values of the enum driver variable, so having a > > default: clause is useless, even if it's only to do Assert(false). > > Just for my own understanding: > > 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. The compiler will emit a warning when it sees that not all cases are handled, so it's not necessary to have a default case. > 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. Yeah, operator strategy numbers are a hopeless case, because each index AM defines its own set of valid strategy numbers. Another interesting case is PARTITION_STRATEGY which I wanted to convert to an enum, but got sidetracked. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services