Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2e17-0005NS-1p for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Oct 2017 13:59:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e2e15-0003oK-B2 for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Oct 2017 13:59:15 +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.84_2) (envelope-from ) id 1e2e13-0003o0-Kq for pgsql-bugs@postgresql.org; Thu, 12 Oct 2017 13:59:13 +0000 Received: from mail-lf0-x234.google.com ([2a00:1450:4010:c07::234]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e2e0w-0003f7-D7 for pgsql-bugs@postgresql.org; Thu, 12 Oct 2017 13:59:12 +0000 Received: by mail-lf0-x234.google.com with SMTP id 90so6049242lfs.13 for ; Thu, 12 Oct 2017 06:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=DKyC6NyO42NFx/sN18yDejaZqaEc0l41qT5+1Mjeqr0=; b=bkWVTmuj2GABUeV7uJ6uSrAVjAm6xYLJaz9Qf6a3+XglzFB04+qRPYAZHc8EWpXrd6 /wO40sr9SXevJ6j0QteKel4t1DUNtA+FMUa26rtlO+3T/7tPngScdIpgcCLypiKG+f6V glDqri294DTGHN04FQFouxXdplhaIGwWigW67ZCACkf+w8uqgWXY3a0SXo7OW/Goxj78 v9Z4X8Gv+uP/gljZmYSRx4aNG5tCXTKJ1hFv/4vNBSbRpYKXFy509I0ef/J3CmQze+bN 43coViO2hISTSTK3mLmuC+KAoFrn05o5Z5qM/G2Yk8GXBAcLxwkidDxpQhs58WVtpscj ZgYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=DKyC6NyO42NFx/sN18yDejaZqaEc0l41qT5+1Mjeqr0=; b=sKztE5pFb7b48JOt25o+mvHRPdf9F0pFQLRePyJcB7+7qdG+XqciEWkn/DyBM2bpE8 xvu7nVhvZaahG2QWV4V4L96qJlgvR5Rymsa18dNUasfFqhSt1tI0AkrjBdYKdnWEi4J0 iH+W+oQe2XLeNMIN1vbxyNWqc7PyjHjNbgjuHdnwa5QWzU6AUA2s2XNk53rg8bgxNygc KEcnYjcWL/poN1Qc5dGuK504on7Or1MIwzeNDCuC1t2c7mJ2aKgJMmI/AB976CRpQdNv hkgDTBTJ81jNDYpLo3gNy+To7pro00Oa6Ol9hEakFB63lHViWMHNGYmO485SmFa/78bV rhww== X-Gm-Message-State: AMCzsaVF1a+dIJm6lH02A9cOEuhoQPaUNyysy29Y1Mxx5mHj57MOg7jd M43srOsmC5Y4jGT7V7+VP77hZA== X-Google-Smtp-Source: ABhQp+R3Vk5ccAHsE+c5SvLAz+9wzB+JQUIwGHrT9I9qhvoqwxZLlGtPPuiJx5lxZwYgCVpSXL6ryw== X-Received: by 10.46.89.147 with SMTP id g19mr174090ljf.26.1507816744180; Thu, 12 Oct 2017 06:59:04 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibng32-54fb4e-103.dhcp.inet.fi. [84.251.78.103]) by smtp.gmail.com with ESMTPSA id g78sm2315640lfi.23.2017.10.12.06.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 06:59:02 -0700 (PDT) Subject: Re: Combination of ordered-set aggregate function terminates JDBC connection on PostgreSQL 9.6.5 To: Tom Lane , David Rowley Cc: Lukas Eder , PostgreSQL mailing lists References: <23270.1507751492@sss.pgh.pa.us> <3802.1507775225@sss.pgh.pa.us> From: Heikki Linnakangas Message-ID: Date: Thu, 12 Oct 2017 16:59:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <3802.1507775225@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 10/12/2017 05:27 AM, Tom Lane wrote: >>> This might be a bigger change than we want to push into the back >>> branches. In that case probably a back-patchable fix is to hw ck >>> nodeAgg.c so it will never combine input states for OSAs. > >> I've attached a patch which does this. > > Needs to reject plain OSAs too, not just hypotheticals. Pushed > with that fix and some test cases. Thanks! > Speaking of AggGetAggref, there's another thing that I think 804163bc2 > did wrong for ordered-set aggregates: it can return the wrong Aggref > when two aggregates' intermediate states have been merged. I do not > think it's appropriate to say "well, you shouldn't care which of the > Aggrefs you get". It looks like this accidentally fails to fail > for the current OSAs, because indeed they do only look at the input- > related fields of the Aggref, but surely that's not something to > rely on. It's most certainly not acceptable that the function's > documentation doesn't mention that its result may be a lie. Hmm. All the fields except for aggfnoid, aggtype and aggcollid are related to the inputs or the transition function, so all the other fields would be the same between two shared transition states. But yes, this really should be documented. Perhaps AggGetAggref() should return an Aggref with those fields set to InvalidOid, to make it clear that they should not be looked at? Conceivably we could have another function like AggGetAggref() that returns all of the Aggrefs. But I don't think it's worth the complication. If the transition function needs to do something different depending on the aggregate it's for, well, don't do that. Define a different transition function for both aggregates. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs