Re: Properly pathify the union planner

Alexander Law <exclusion@gmail.com>

From: Alexander Lakhin <exclusion@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>, Richard Guo <guofenglinux@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2024-03-26T17:00:00Z
Lists: pgsql-hackers
Hello David,

25.03.2024 04:43, David Rowley wrote:
> I didn't see that as a reason not to push this patch as this occurs
> both with and without this change, so I've now pushed this patch.

Please look at a new assertion failure, that is triggered by the following
query:
SELECT count(*) FROM (
   WITH q1(x) AS (SELECT 1)
   SELECT FROM q1 UNION SELECT FROM q1
) qu;

TRAP: failed Assert("lg != NULL"), File: "planner.c", Line: 7941, PID: 1133017

Best regards,
Alexander



Commits

  1. Don't adjust ressortgroupref in generate_setop_child_grouplist()

  2. Don't zero tuple_fraction when planning UNIONs with ORDER BYs

  3. Fix assert failure when planning setop subqueries with CTEs

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

  5. Simplify PathKey checking code

  6. Clarify the 'rows' parameter in create_append_path