Go to file
David Rowley 8f4ee96269 Fix Assert failure in WITH RECURSIVE UNION queries
If the non-recursive part of a recursive CTE ended up using
TTSOpsBufferHeapTuple as the table slot type, then a duplicate value
could cause an Assert failure in CheckOpSlotCompatibility() when
checking the hash table for the duplicate value.  The expected slot type
for the deform step was TTSOpsMinimalTuple so the Assert failed when the
TTSOpsBufferHeapTuple slot was used.

This is a long-standing bug which we likely didn't notice because it
seems much more likely that the non-recursive term would have required
projection and used a TTSOpsVirtual slot, which CheckOpSlotCompatibility
is ok with.

There doesn't seem to be any harm done here other than the Assert
failure.  Both TTSOpsMinimalTuple and TTSOpsBufferHeapTuple slot types
require tuple deformation, so the EEOP_*_FETCHSOME ExprState step would
have properly existed in the ExprState.

The solution is to pass NULL for the ExecBuildGroupingEqual's 'lops'
parameter.  This means the ExprState's EEOP_*_FETCHSOME step won't
expect a fixed slot type.  This makes CheckOpSlotCompatibility() happy as
no checking is performed when the ExprEvalStep is not expecting a fixed
slot type.

Reported-by: Richard Guo
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/CAMbWs4-8U9q2LAtf8+ghV11zeUReA3AmrYkxzBEv0vKnDxwkKA@mail.gmail.com
Backpatch-through: 13, all supported versions
2024-12-19 13:11:39 +13:00
.github Add CODE_OF_CONDUCT.md, CONTRIBUTING.md, and SECURITY.md. 2024-07-02 13:03:58 -05:00
config Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
contrib seg: pure parser and reentrant scanner 2024-12-18 08:47:53 +01:00
doc psql: Add more information about service name 2024-12-18 15:16:12 +09:00
src Fix Assert failure in WITH RECURSIVE UNION queries 2024-12-19 13:11:39 +13:00
.cirrus.star
.cirrus.tasks.yml ci: Fix cached MacPorts installation management 2024-11-27 11:51:54 -05:00
.cirrus.yml
.dir-locals.el
.editorconfig Add .editorconfig 2019-12-18 09:13:13 +01:00
.git-blame-ignore-revs Add a couple of recent commits to .git-blame-ignore-revs. 2024-11-22 12:17:35 -06:00
.gitattributes gitattributes: Add .cpp files to whitespace checks 2024-11-27 11:20:46 +01:00
.gitignore Update top-level .gitignore. 2022-12-04 15:23:00 -05:00
.mailmap Add a Git .mailmap file 2024-11-05 13:56:02 +01:00
aclocal.m4
configure Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
configure.ac Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
COPYRIGHT
GNUmakefile.in Allow selecting the git revision to be packaged by "make dist". 2024-05-03 11:08:50 -04:00
HISTORY
Makefile Remove AIX support 2024-02-28 15:17:23 +04:00
meson_options.txt Make PG_TEST_EXTRA env var override the "meson setup" option 2024-11-04 14:09:25 +02:00
meson.build Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
README.md

PostgreSQL Database Management System

This directory contains the source code distribution of the PostgreSQL database management system.

PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.

Copyright and license information can be found in the file COPYRIGHT.

General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/devel/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/devel/installation.html.

The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.