Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bG8qg-0002Rj-41 for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jun 2016 17:55:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bG8qf-0006Dn-Jg for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jun 2016 17:55:29 +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.84_2) (envelope-from ) id 1bG8qe-0006AV-D4 for pgsql-hackers@postgresql.org; Thu, 23 Jun 2016 17:55:28 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bG8qb-0002Vo-4n for pgsql-hackers@postgresql.org; Thu, 23 Jun 2016 17:55:27 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u5NHtM8K032397; Thu, 23 Jun 2016 13:55:22 -0400 From: Tom Lane To: Alvaro Herrera cc: Robert Haas , David Rowley , "pgsql-hackers@postgresql.org" Subject: Re: Rethinking representation of partial-aggregate steps In-reply-to: <20160623173851.GA203183@alvherre.pgsql> References: <20160623173851.GA203183@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Thu, 23 Jun 2016 13:38:51 -0400" Date: Thu, 23 Jun 2016 13:55:22 -0400 Message-ID: <32396.1466704522@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Alvaro Herrera writes: > Tom Lane wrote: >> Yeah, that's another way we could go. I had been considering a variant >> of that, which was to assign specific code values to the enum constants >> and then invent macros that did bit-anding tests on them. That ends up >> being just about what you propose except that the compiler understands >> the enum-ness of the behavioral alternatives, which seems like a good >> thing. > Isn't that what you said not to do in > https://www.postgresql.org/message-id/13345.1462383078@sss.pgh.pa.us ? No. What I'm imagining is, say, #define AGGOP_COMBINESTATES 0x1 #define AGGOP_SERIALIZESTATES 0x2 #define AGGOP_DESERIALIZESTATES 0x4 #define AGGOP_FINALIZEAGGS 0x8 typedef enum AggPartialMode { AGGPARTIAL_SIMPLE = AGGOP_FINALIZEAGGS, AGGPARTIAL_PARTIAL = AGGOP_SERIALIZESTATES, AGGPARTIAL_FINAL = AGGOP_COMBINESTATES | AGGOP_DESERIALIZESTATES | AGGOP_FINALIZEAGGS } AggPartialMode; #define DO_AGGPARTIAL_COMBINE(apm) (((apm) & AGGOP_COMBINESTATES) != 0) #define DO_AGGPARTIAL_SERIALIZE(apm) (((apm) & AGGOP_SERIALIZESTATES) != 0) #define DO_AGGPARTIAL_DESERIALIZE(apm) (((apm) & AGGOP_DESERIALIZESTATES) != 0) #define DO_AGGPARTIAL_FINALIZE(apm) (((apm) & AGGOP_FINALIZEAGGS) != 0) These enum constants satisfy the properties I mentioned before, but their assigned values are chosen to make the macros cheap. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers