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 1n2bqO-0004fT-3V for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Dec 2021 16:30:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n2bqM-0004WI-SF for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Dec 2021 16:30:26 +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 1n2bqM-0004W9-F9 for pgsql-hackers@lists.postgresql.org; Wed, 29 Dec 2021 16:30:26 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n2bqE-0007e8-MH for pgsql-hackers@lists.postgresql.org; Wed, 29 Dec 2021 16:30:25 +0000 Received: by mail-io1-xd2f.google.com with SMTP id i14so25822090ioj.12 for ; Wed, 29 Dec 2021 08:30:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=j5qE4aQZcB+p9ofVD0gX0A9awj8PKDZWtrbIvw7mRSQ=; b=8PWSOZ5ZnLclDKPCRm2hbzQWmNmBpLt2fjnFHQXjLrh045jjdQqAtScZj3hvDOrUnd tH8edLZMMYjC1/jN5jXjwxrLU6fmP83cEXuz0DdIBH3geA8qX4FoR4jiVLfnk3UzEcVS z9PXC1TdhM4kw7iqrh88rNsWVgIZSrsSu9px8+P0KoUXAWC0dr/1NT6+3baf0+n/p/Dq HAOwX/605DjPB+8Z75Xyfz1rsBBhvrNINUlnMLcvIc2+k0uHOqzT613RhYIZaCBsrIGo olRe98UhDkCQ8gVID42T6BeAupFOatKnjrLF0ZSvu+wxUl35k7OJh32A6NEiqQFcGmKZ 1pwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=j5qE4aQZcB+p9ofVD0gX0A9awj8PKDZWtrbIvw7mRSQ=; b=JPD1IHN0QTbpojIVi8YO6dczFy016oMFcOXACWg0OUg4Ky5IQf6UfqEhH3CjygT/TB gRurzQPoewdg5T/pWMHr9zD//ekMs89U/mJN4Ct95QB8pNjG9M265DBpf4Wlb0z4Kdv0 j3f34088LW0pYQjE6as6Weln3kDzlVhAC/gI/N/YcGQbX1k7up06MwOzW92+sLfSqx+y TYCUKqmYWoIgMWtHdqi622fUyT5X+5PTVgRH18cngNX4Bw5bTcF2sCmBv1dsyS3iJ/Ta PZUXBdVqBo3Cmc5Ak3iR+xpYpJ9+cMG4OJsC9KW8Q4ByM+rstNYwpRGkWPGrfM9ebNJa 8Dpg== X-Gm-Message-State: AOAM532xirouwrmSkf0nSNOhUKAdiKvsct19TH4Ig5F/Af0AleBPcfMD 3K2dUR2r7XrmOAMCkFPRQXcbbQ== X-Google-Smtp-Source: ABdhPJxQfdoKCF7R6N98Gdf+zDw13g0FnDTS6FVpn67cB75OIE/p21yEsltyPiBoaK5qFF2iGP1wwg== X-Received: by 2002:a05:6602:1588:: with SMTP id e8mr12338370iow.181.1640795416648; Wed, 29 Dec 2021 08:30:16 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id p15sm12784713ilo.83.2021.12.29.08.30.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Dec 2021 08:30:16 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 27C6580078F; Wed, 29 Dec 2021 10:30:15 -0600 (CST) Date: Wed, 29 Dec 2021 10:30:15 -0600 From: Justin Pryzby To: Peter Smith Cc: pgsql-hackers@lists.postgresql.org Subject: Re: PublicationActions - use bit flags. Message-ID: <20211229163014.GO24477@telsasoft.com> References: 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 Mon, Dec 20, 2021 at 11:18:41AM +1100, Peter Smith wrote: > For some reason the current HEAD PublicationActions is a struct of > boolean representing combinations of the 4 different "publication > actions". > > I felt it is more natural to implement boolean flag combinations using > a bitmask instead of a struct of bools. IMO using the bitmask also > simplifies assignment and checking of said flags. Peter E made a suggestion to use a similar struct with bools last year for REINDEX. https://www.postgresql.org/message-id/7ec67c56-2377-cd05-51a0-691104404abe@enterprisedb.com Alvaro pointed out that the integer flags are better for ABI compatibility - it would allow adding a new flag in backbranches, if that were needed for a bugfix. But that's not very compelling, since the bools have existed in v10... Also, the booleans directly correspond with the catalog. + if (pubform->pubinsert) pub->pubactions |= PUBACTION_INSERT; This is usually written like: pub->pubactions |= (pubform->pubinsert ? PUBACTION_INSERT : 0) -- Justin