Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v2B8k-0015k6-Kp for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Sep 2025 16:17:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v2B8h-003mwC-Eg for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Sep 2025 16:17:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v2B8h-003mw4-4o for pgsql-hackers@lists.postgresql.org; Fri, 26 Sep 2025 16:17:43 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v2B8f-0003c1-1i for pgsql-hackers@postgresql.org; Fri, 26 Sep 2025 16:17:42 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b28e1b87aa7so317105266b.3 for ; Fri, 26 Sep 2025 09:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgguru-net.20230601.gappssmtp.com; s=20230601; t=1758903461; x=1759508261; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LGD18k/6CDHytt0VcFbuZCJrC+qD9CVQeIS5AEs3BGo=; b=BmluBspJimhOQ5nxlJ0NPbL16hMw/gbgkN/xp95hdUoskAeV+PLJ2hB/NQ3Pk+1op/ JVdckvUW2TCPUEh1mN4h1c9QZ1YdYbLKTm57PrKnynwrlC4W+Mx7vT4L/0V+JafQ4Gtm JjcDU4AgwVc3icITQMb5eH7sIy3HPnuY3Moorm6YzctY/G/LJdt90paf8Lsrxf81uo96 l41zSszBioQqM8GQdyBanMYlsg0MdI7XFj53IUCCfg0hZ5tqB8s7kBGDY4sUCs+ZReke s67hZaIToGXBH5Y9RgxdOxMkvKyMnT2LJ5/QMPk4/6TIpqb7fs6M3t5o3+MWolnpLJ2d bk7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758903461; x=1759508261; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LGD18k/6CDHytt0VcFbuZCJrC+qD9CVQeIS5AEs3BGo=; b=GYn2BYc1wFz5/JlqlvE9k8dM5yAH/IY3H9aPx/JnK4JoYbscsURQv8EQapj59Y2jkI Gs0gl26ebumFw9TH4k0OktxVsXwgqPnXGLct2Z2DjDUdSQQ7xLHOyj6QPhSEKnAqDh09 nyLAdsH2+oZYqd6jTSsmkzWRW7Gm0T556maXsQ74YEGhQlKxHbJB1qV4r6GR3/3oCNim S3w8v7iiqA1NXyf+PCUjObUYIWT4FSYQ9OxpB7LYccFw+XXxx7HD5ikgvrHPsJJysXGU msoAv048AuqKw+Ya5++p9slHuKKRM7NoPqz+LNzgm1e0WhsjW6Pp4w+eG9/GRglQ5PIy 8QqA== X-Forwarded-Encrypted: i=1; AJvYcCUeEtJTS1SsGM7xOHgkjmLjoSWmzswE+Qs4h+KxzPqXoetF2L3bFww4pkW/yC360TbFU28XTPwlZd5cZw29@postgresql.org X-Gm-Message-State: AOJu0YylX5YHBq8rFglXlLS0eVuxsCcJn61mfZX+Tpcb9nNWSOoQrR3E gxYHD71klG3ie2tzdmWD2j4qvsLMa28dgM2Hn6lcuTjmAgbt9cn1E99p+YqG+aubgMZDZZn8a// d9knVCSDfn6bMU/lIICU0a3wStaNeiEoLwK33Ultqiw== X-Gm-Gg: ASbGncu36c0hQOKz8+XA0vHvMs7ib8GQlA7nrhl+yqPZ6bGCQS/3eUABDC7qSIs6edP xHCYOqiFgOjObXsvw7g70cL0X0a87PUeOQ3y3rKrW2dzBCfvbxR7GcZP8WUnp0bpZPAqqhBR95Y KiPmqN3EUWUxRs3cKwxIwrbKm6utBQQ/SWWuOIJEzk/0ueHqUryzmOuNo+BGpWs3dF09RE1SZ5r 7cRDHx9jCuy3tJ89ebF7AqZYHw7n1Cpet6FMgIeTznSPkXLTHQa X-Google-Smtp-Source: AGHT+IHOD834+WuQF6wWNV7/9bCW7KRrdofMMOmxjb82mZ8XF4OJiqCboypTIFHRjkuLAlnCItE8CYyn6PAhPCxaAfc= X-Received: by 2002:a17:906:7956:b0:b37:5551:9982 with SMTP id a640c23a62f3a-b375560e78fmr470383266b.50.1758903460865; Fri, 26 Sep 2025 09:17:40 -0700 (PDT) MIME-Version: 1.0 References: <4D2047B0-E8D8-472B-B7E8-61206B1E6AFA@yandex-team.ru> <4083063.1758902694@sss.pgh.pa.us> In-Reply-To: From: David Christensen Date: Fri, 26 Sep 2025 11:17:29 -0500 X-Gm-Features: AS18NWCfxWO2jhAaUAWSv5c4B1cg64MGJ-RoMpwsr50T5PsokJ4m8pYufmy4GZg Message-ID: Subject: Re: [PATCH] GROUP BY ALL To: Tom Lane Cc: Andrey Borodin , Peter Eisentraut , pgsql-hackers , "David G. Johnston" , Jelte Fennema-Nio Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Sep 26, 2025 at 11:13=E2=80=AFAM David Christensen wrote: > > On Fri, Sep 26, 2025 at 11:05=E2=80=AFAM Tom Lane wro= te: > > > > David Christensen writes: > > > Here is a rebased version with a few more tests. I also changed the > > > main check here to using `!contain_agg_clause` instead of > > > `!IsA(Aggref))` directly. (This was defined in `optimizer/clauses.h`= , > > > but we already are pulling in `optimizer.h`, so it felt valid to me.) > > > > contain_agg_clause will blow up on a SubLink, so I doubt this is > > gonna be robust. > > Fair enough, see that Assert now; easy enough to make a new > expression_tree_walker that only looks for Aggref and short-circuits > SubLink (which I assume is the right behavior here, but might have to > add some more tests/play around with subqueries in the GROUP BY ALL > part). Or contain_aggs_of_level(), assuming I can suss out how to get the current level... :D Anyway, will mess with this for a bit. David