Re: BUG #18764: server closed the connection unexpectedly

dqetool <dqetool@126.com>

From: dqetool <dqetool@126.com>
To: "David Rowley" <dgrowleyml@gmail.com>
Cc: "Richard Guo" <guofenglinux@gmail.com>, "Tom Lane" <tgl@sss.pgh.pa.us>, "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Date: 2025-01-10T02:41:05Z
Lists: pgsql-bugs

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix UNION planner datatype issue

  2. Allow planner to use Merge Append to efficiently implement UNION

Thanks for the quick fix and detailed explanation.


Jason
---- Replied Message ----
| From | David Rowley<dgrowleyml@gmail.com> |
| Date | 1/10/2025 09:36 |
| To | Richard Guo<guofenglinux@gmail.com> |
| Cc | Tom Lane<tgl@sss.pgh.pa.us>,
<dqetool@126.com>,
<pgsql-bugs@lists.postgresql.org> |
| Subject | Re: BUG #18764: server closed the connection unexpectedly |
On Thu, 9 Jan 2025 at 20:38, Richard Guo <guofenglinux@gmail.com> wrote:

On Thu, Jan 9, 2025 at 12:44 PM David Rowley <dgrowleyml@gmail.com> wrote:
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.

I pushed a revised patch. I removed the check for the sortop. I first
also thought I'd overlooked that, but it turned out that's fine as it
was as standard_qp_callback() handles checking for un-sortable
SortGroupClauses.

Jason, you can expect a fix for this in 17.3. In the meantime, you
could add an explicit cast to numeric in the subquery, e.g:

SELECT c2 AS ca2, c2 AS ca3
FROM t0
UNION
SELECT DISTINCT ca8 AS ca5, ca7::numeric AS ca6
FROM (
SELECT c1 AS ca7, c2 AS ca8 FROM t0
) AS ta1 JOIN (
SELECT c1 AS ca10, c1 AS ca11
FROM t0
) AS ta2 ON TRUE;

Thanks for the report.

David