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 1tVn7Z-00BTdj-Dg for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Jan 2025 07:38:25 +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 1tVn7Y-00EEaZ-OB for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Jan 2025 07:38:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tVn7Y-00EEZb-FN for pgsql-bugs@lists.postgresql.org; Thu, 09 Jan 2025 07:38:24 +0000 Received: from mail-yb1-xb2d.google.com ([2607:f8b0:4864:20::b2d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tVn7V-000h26-1c for pgsql-bugs@lists.postgresql.org; Thu, 09 Jan 2025 07:38:23 +0000 Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-e53a91756e5so980429276.1 for ; Wed, 08 Jan 2025 23:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736408301; x=1737013101; darn=lists.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=uN/Eqo0fseC3beF7HRVtlu5+MiF9evh7CEmBJQhH7S8=; b=K+ctcdSJ3cfJetua1yrZUpbXEsJLWX/gOXmQl8k67peC1dNwkCTQaeQdWrVQFvGgV6 MzrmqZYQjoGwvi6rP5EbfLztg2rUUuv+rQU3bXlyV+tcIGMhd822IdqgE0VCR2yQKMZe HlobATTYTQVyvFKVvSdG2nkX9flBieHM/VvTo1Inut/9rg2HnCEV3RrO9HIv4trfgeQ6 qYOBeB43p/+XjpKeDZ5XMN+7qGIeLkHngpG7OrDcYIpiPB3NTgEQtrkU3ZRxG1s/9EaP m5DQODjEUsvqOwXpOIdu9Y82CFfVDsU34Qkh/rRgBXBlPZTz9+hS1bF5UtTsVPSnH12n GZWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736408301; x=1737013101; 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=uN/Eqo0fseC3beF7HRVtlu5+MiF9evh7CEmBJQhH7S8=; b=TJAuL51f3xPVpO1y7F2yKmwfhPn3YjrC+rJdVIyHp3p48pyDAJcgLxGbPs6leusFZt shuaJsR/MuCpJsgsAmAXlju5lAz4nVT/F3w6CRJEephC7uOzaxgroD1/YX3OkmTPPuqY xFcnQR1/NobI+pMxPeWkQczHQwVomnMbsFvco/Et/Cd+I0ABtd9Q/D4uiOYsfgj7eeRJ LdSkpimeKwFbX4MrqtffuvZotkrNSBb01lLzv0SlnPdW7DAoKmVeB0O0PPHezCnrbhFL kpqmdL2EzbZcYo6bOAu/c4LnioPLvc133QCcVpS94QX5tG0t+Mtqv8QVUVm5Hx9A4gqk Kahw== X-Forwarded-Encrypted: i=1; AJvYcCWHjpKYHzD5TQ7TgzhN0HyU1VuxdWMtMkGiJchw1PzKw8Xt3zVIKd+y234F/dHXe+W+Sz8ijblljmVC@lists.postgresql.org X-Gm-Message-State: AOJu0YzqvYrfEDZEXWe6Cf3GwbCZ8bowyncYXdR137n4H5FNHDtm79I5 A9Q/viTPk2lmkonDQZVToTmYHiI5RZPWybiz0FLd8UmrEUpvt5bjxNUVKOgd/AZiWUpyqw0PaMX hFyGeLHSK4aJ49+buadxVqWAi0ckosyMX X-Gm-Gg: ASbGnctUMX3S71FGUqgHNdr+XIHzdSVwu2fYXUjPKUkQ1tTEj4e2obMz5HC/5MeGa2d x1SMlOb4STJdvvTfAIFendMyNSwFGLZRrxZEIjW2Pt1fJ/qSfa3Vakh5FPmf4k+dz+LK4cz6B X-Google-Smtp-Source: AGHT+IFFO9oj6MSQ7QkseWpjx/wUQk+JqB2Nssuiq0B4Rg2qbusNc2btZLgYVhg1EPsi5peCKLY//EhsnwhHJdquhzs= X-Received: by 2002:a05:6902:10ce:b0:e4c:ae89:1603 with SMTP id 3f1490d57ef6-e54ee1f4a24mr4741381276.41.1736408300657; Wed, 08 Jan 2025 23:38:20 -0800 (PST) MIME-Version: 1.0 References: <18764-63ad667ea26e877a@postgresql.org> <446342.1735923417@sss.pgh.pa.us> <468120.1735927103@sss.pgh.pa.us> In-Reply-To: From: Richard Guo Date: Thu, 9 Jan 2025 16:38:09 +0900 X-Gm-Features: AbW1kvYsgVPeYrT1rFmAi90k8hDsE9JW_q3dUZLoGx4UOB32RVN4c9vrMFQ_0yM Message-ID: Subject: Re: BUG #18764: server closed the connection unexpectedly To: David Rowley Cc: Tom Lane , dqetool@126.com, pgsql-bugs@lists.postgresql.org 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 Thu, Jan 9, 2025 at 12:44=E2=80=AFPM David Rowley = wrote: > On Tue, 7 Jan 2025 at 02:14, Richard Guo wrote: > > --- a/src/backend/optimizer/plan/planner.c > > +++ b/src/backend/optimizer/plan/planner.c > > @@ -8091,6 +8091,9 @@ generate_setop_child_grouplist(SetOperationStmt > > *op, List *targetlist) > > { > > TargetEntry *tle =3D (TargetEntry *) lfirst(lt); > > SortGroupClause *sgc; > > + Oid opfamily, > > + opcintype; > > + int16 strategy; > > > > /* resjunk columns could have sortgrouprefs. Leave these alone= */ > > if (tle->resjunk) > > @@ -8101,6 +8104,18 @@ generate_setop_child_grouplist(SetOperationStmt > > *op, List *targetlist) > > sgc =3D (SortGroupClause *) lfirst(lg); > > lg =3D lnext(grouplist, lg); > > > > + if (!OidIsValid(sgc->sortop)) > > + return NIL; > > + > > + /* Find the operator in pg_amop --- failure shouldn't happen */ > > + if (!get_ordering_op_properties(sgc->sortop, > > + &opfamily, &opcintype, &strateg= y)) > > + elog(ERROR, "operator %u is not a valid ordering operator", > > + sgc->sortop); > > + > > + if (exprType((Node *) tle->expr) !=3D opcintype) > > + return NIL; > > + > > /* assign a tleSortGroupRef, or reuse the existing one */ > > sgc->tleSortGroupRef =3D assignSortGroupRef(tle, targetlist); > > } > > Can't you just look up the setop's type from op->colTypes instead of > looking the type up via the sortop? i.e. the attached? Yeah, right. Using SetOperationStmt.colTypes is more convenient here. Thanks Richard