Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFqEA-0002JB-CZ for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Jan 2023 05:34:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pFqE9-00018W-75 for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Jan 2023 05:34:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFqE8-00018M-UA for pgsql-hackers@lists.postgresql.org; Thu, 12 Jan 2023 05:34:12 +0000 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pFqE6-0007jF-LD for pgsql-hackers@postgresql.org; Thu, 12 Jan 2023 05:34:12 +0000 Received: by mail-qt1-x82b.google.com with SMTP id g9so1074313qtu.2 for ; Wed, 11 Jan 2023 21:34:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=vZMQHSRA/1IzqcArLRoNi94xTc9cDZMpOyfKKUhezlo=; b=BH+HjqNJl3TnM6qaqhA5p7R2tYamg1oSzOi+S63crDxRGODRW9x5N3T3Lkpc4h6Qs8 lSpYsvsbcb3h0FXQ36/1mMnRJRvRVSXavhdbC3Zida7QlIrZGR9sTXqG+bK+DbXzfJCD Bumk79NEb2RHd1zbDZMQ1t1/9a1MzK6laWGXkOOgy5roYOK5lxREjsS/uIQPTirvOmC8 G4cn366meyfZhag7oEjpHuzYb6KEO0exdt8URw4z6LgLGeyFZ8r7WxtGXX7qE/Yk7Pws B2i9baRtdkhQ+/O/hUc+DNbPme6rCGLLxOIbo84pkpxO1Lq/P74ojQBOqQzU2sqr7GZI s6Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vZMQHSRA/1IzqcArLRoNi94xTc9cDZMpOyfKKUhezlo=; b=51zedYvcCP6WHY3YV87HIhKFX5BJG7Wd+Gqtb+oyJckZ/kwRobUIz8mcCLL1imyiVj 3qwnfBIk4JB85HUJr3RlwPWfZ52SASu6slmWKhZJjPPQs5f/EZeHdHZv3E8vOPtfSanr CtvfpQn4LBSp7y91T7qXDLCLm7HZ+kHOvWxYrwZROzUfBRQ+6WkUBD3gLueqtaRQlTQl ZxR8TESaHxeJHf1bxXRAtp4VJkksPaW24zzM8w6aT1r6Zh3IHgeT6m8JSe81IfNqxk5n M+yMi4whRL33eA+cISGASbg0tgfAlgNDGvmxFIY6g6qiqAt+1XkRCJVGVdvecMHyNvcC xeSA== X-Gm-Message-State: AFqh2kpMml5+SfN9bUYFGPYUKFcBFyrkespMr24g4JqqY2LOEPRGfcB1 PuiXbf3V8/wDqvyLSethiAPMhg== X-Google-Smtp-Source: AMrXdXv6OUTAsovfuKpNlpnKIiai64QipmWce6+Flklsklcra+KXcg9jAkqjRl7xxBwXDifMyU8ugg== X-Received: by 2002:ac8:4990:0:b0:3a5:7645:c06c with SMTP id f16-20020ac84990000000b003a57645c06cmr11917838qtq.59.1673501649233; Wed, 11 Jan 2023 21:34:09 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id fu28-20020a05622a5d9c00b003a7f3c4dcdfsm8640385qtb.47.2023.01.11.21.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 21:34:08 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id DF7BA800C8A; Wed, 11 Jan 2023 23:34:07 -0600 (CST) Date: Wed, 11 Jan 2023 23:34:07 -0600 From: Justin Pryzby To: John Naylor Cc: Ranier Vilela , pgsql-hackers@postgresql.org Subject: Re: Small miscellaneus fixes (Part II) Message-ID: <20230112053407.GT9837@telsasoft.com> References: <20221221005134.GJ1153@telsasoft.com> <20221223010818.GP1153@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jan 12, 2023 at 12:15:24PM +0700, John Naylor wrote: > On Fri, Dec 23, 2022 at 8:08 AM Justin Pryzby wrote: > > > Makes sense now (in your first message, you said that the problem was > > with "sign", and the patch didn't address the actual problem in > > IS_PLUS()). > > > > One can look and find that the unreachable code was introduced at > > 7a3e7b64a. > > > > With your proposed change, the unreachable line is hit by regression > > tests, which is an improvment. As is the change to pg_dump.c. > > But that now reachable line just unsets a flag that we previously found > unset, right? Good point. > And if that line was unreachable, then surely the previous flag-clearing > operation is too? > > 5669 994426 : if (IS_MINUS(Np->Num)) // <- also always > false > 5670 0 : Np->Num->flag &= ~NUM_F_MINUS; > 5671 : } > 5672 524 : else if (Np->sign != '+' && IS_PLUS(Np->Num)) > 5673 0 : Np->Num->flag &= ~NUM_F_PLUS; > > https://coverage.postgresql.org/src/backend/utils/adt/formatting.c.gcov.html > > I'm inclined to turn the dead unsets into asserts. To be clear - did you mean like this ? diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index a4b524ea3ac..848956879f5 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -5662,15 +5662,13 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, } else { + Assert(!IS_MINUS(Np->Num)); + Assert(!IS_PLUS(Np->Num)); if (Np->sign != '-') { if (IS_BRACKET(Np->Num) && IS_FILLMODE(Np->Num)) Np->Num->flag &= ~NUM_F_BRACKET; - if (IS_MINUS(Np->Num)) - Np->Num->flag &= ~NUM_F_MINUS; } - else if (Np->sign != '+' && IS_PLUS(Np->Num)) - Np->Num->flag &= ~NUM_F_PLUS; if (Np->sign == '+' && IS_FILLMODE(Np->Num) && IS_LSIGN(Np->Num) == false) Np->sign_wrote = true; /* needn't sign */