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 1f1ACj-0004m3-7I for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Mar 2018 12:29:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f1ACh-0000oS-6G for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Mar 2018 12:29:23 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f1ACg-0000oH-Ok for pgsql-hackers@lists.postgresql.org; Wed, 28 Mar 2018 12:29:23 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f1ACc-0004L6-C3 for pgsql-hackers@postgresql.org; Wed, 28 Mar 2018 12:29:21 +0000 Received: by mail-wm0-x230.google.com with SMTP id f125so4904971wme.4 for ; Wed, 28 Mar 2018 05:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=sEGZxd1FaEiFJVTneiSWR29t0drnvAw0iywfzW/cbuU=; b=KaHx9lEOLu20eFr1e9YJULMeRa/U47W1SX0MG4Nu9rI+PiWPmQpSsQYnMKresE6YoV 3FcXdGEBbW1j9N6fDU2Tn77Skd/HZp3p7fOB7cF5pkKjpnoeC9ldQgEwxau+sSVdltAc X1Hjjx1hCnQ0hFbDy7sM9gjXwVhX9afWrEgLMK+6uboToPxYO9TCt1RGDJb+N0Psn50Z pD5IBw6n4u0+aLnOgvP37bqjqUcjHtyx/pSUoghPCJTbbikgWTjXnM82IJMQkzc4ADCG nRb8g5gB8CV+YHyCZgy7HRQ9mU1CNj/nRwpDC6IEVZqk3KnYohU6i/rGlDl0W/GlOmZG mrvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sEGZxd1FaEiFJVTneiSWR29t0drnvAw0iywfzW/cbuU=; b=Mm1dFIX6MSLR3y+8v3NZ+69VIiZ4jhhS9/AoFkmUbnYMw1JFZJvJRi6Kg8oSXVF0tJ dng8HRYaBBpyVrGeg4d1OUlASzH58y8oPxe1sV8AjArP9Iu23eBcAPT0jxG/wR2yJ98K g5f49gTANXhJfL8JNfnaaUJ+pEBmpwVGF4+YGN4LCmIPe/7vxKyQQwuqtLbx7vVuUkd6 jwtTHQW/BDw7IQ1FjY3ol3lvErG7WgF4ZachbtAXSDJBymTneCLgCP7Bg3jQ7Vw4K/TN Vj+qsZMvaRIA4GlI6ZzjtjHyykqxo/UW8I8FHo6rh8qup8nSIrHTYrdRJ1mug1iHPFa2 ZeJw== X-Gm-Message-State: AElRT7H25BIz8ryg6gMtrpuMj3cR/4CgYxDyyk3wBMJn8MYmtInWkC76 nbX/fvJOWZciF4YpjjtmUjY+sChwodIyY02pedmnsv+dhObH9oC2DCr23hzXUrG3lpH/8QmJk4o jBUo1ftg8FfUJ4X+xLwV2xRQ8bc0tvnnFfJZuP9QdowZ1p4mpB5YVgDe6o1sne0k8uvo+OYogJA FrfWZtKz7WwhU= X-Google-Smtp-Source: AIpwx4/QuX/LTrv2jo63aVqWVoyALMZPySeYwXVmiCSxTzA0kES+mj/QP0OuTaCn2BsjvEHAsrKQDQ== X-Received: by 10.28.108.5 with SMTP id h5mr2348099wmc.35.1522240155147; Wed, 28 Mar 2018 05:29:15 -0700 (PDT) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id d8sm4394902wrf.8.2018.03.28.05.29.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Mar 2018 05:29:14 -0700 (PDT) Subject: Re: Parallel Aggregates for string_agg and array_agg To: Tom Lane Cc: David Rowley , Stephen Frost , Andres Freund , PostgreSQL-development References: <24abe018-b3c6-2117-b5b9-39e660db00bd@2ndquadrant.com> <1b6ee15c-c218-761e-0120-c1ed438e2db2@2ndquadrant.com> <657be73a-a21d-0ae1-5c62-870afbdfddd4@2ndquadrant.com> <20180326022647.GL24540@tamriel.snowman.net> <20180326132009.GN24540@tamriel.snowman.net> <6538.1522096067@sss.pgh.pa.us> <25812.1522108164@sss.pgh.pa.us> <452e8b7f-418b-4e61-c212-c0e4410b94ad@2ndquadrant.! com> <19216.1522207699@sss.pgh.pa.us> From: Tomas Vondra Message-ID: Date: Wed, 28 Mar 2018 14:29:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <19216.1522207699@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/28/2018 05:28 AM, Tom Lane wrote: > Tomas Vondra writes: >> On 03/27/2018 04:51 AM, David Rowley wrote: >>> Seems I didn't mean "trans types". I should have said aggregate >>> function argument types. > >> I'm not sure that's better than the check proposed by Tom. An argument >> type without send/receive function does not necessarily mean we can't >> serialize/deserialize the trans value. Because who says the argument >> value will be embedded in the trans value? > > In general we would not know that, but *for these specific serial/ > deserial functions*, we know exactly what they will do. Also, IIRC, > the trans type is declared as INTERNAL, so we don't really have any > hope of identifying the behavior by inspecting that type declaration. > Sure, which is why I thought your solution was better, as it was targeted at those particular functions. > Getting a solution that would work for other polymorphic serialization > functions seems like a bit of a research project to me. In the meantime, > I think David's right that what we need to look at is the actual input > type of the aggregate, and then assume that what's to be serialized is > an array of that. Conceivably an aggregate could be built that uses > these serial/deserial functions and yet its input type is something else > than what it constructs an array of ... but I find it a bit hard to > wrap my brain around what that would be exactly. > But David's fix doesn't check the aggregate to produce an array of the input type (or anyarray). It could easily be an aggregate computing a bloom filter or something like that, which has no such issues in the serial/deserial functions. Also, if it's checking aggref->aggargtypes, it'll reject anyelement parameters, no? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services