postgresql/src/backend
Richard Guo 77d0e82e58 Fix estimate_array_length error with set-operation array coercions
When a nested set operation's output type doesn't match the parent's
expected type, recurse_set_operations builds a projection target list
using generate_setop_tlist with varno 0.  If the required type
coercion involves an ArrayCoerceExpr, estimate_array_length could be
called on such a Var, and would pass it to examine_variable, which
errors in find_base_rel because varno 0 has no valid relation entry.

Fix by skipping the statistics lookup for Vars with varno 0.

Bug introduced by commit 9391f7152.  Back-patch to v17, where
estimate_array_length was taught to use statistics.

Reported-by: Justin Pryzby <pryzby@telsasoft.com>
Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/adjW8rfPDkplC7lF@pryzbyj2023
Backpatch-through: 17
2026-04-11 16:38:47 +09:00
..
access Add EXPLAIN (IO) infrastructure with BitmapHeapScan support 2026-04-07 22:33:34 +02:00
archive Don't include wait_event.h in pgstat.h 2026-03-06 16:24:58 +01:00
backup Online enabling and disabling of data checksums 2026-04-03 22:58:51 +02:00
bootstrap Use PG_DATA_CHECKSUM_OFF instead of hardcoded value 2026-04-06 22:11:53 +02:00
catalog Reduce presence of syscache.h in src/include/ 2026-04-09 08:49:36 +09:00
commands Move afterTriggerFiringDepth into AfterTriggersData 2026-04-10 16:17:58 +09:00
executor Fix integer overflow in nodeWindowAgg.c 2026-04-09 19:28:33 +09:00
foreign Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
jit jit: No backport::SectionMemoryManager for LLVM 22. 2026-04-03 14:55:11 +13:00
lib dshash: Make it possible to suppress out of memory errors 2026-03-19 11:51:17 -04:00
libpq Remove RADIUS support. 2026-04-08 22:38:43 +12:00
main Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodes Mark JumbleState as a const in the post_parse_analyze hook 2026-04-07 15:22:49 +09:00
optimizer Fix var_is_nonnullable() to account for varreturningtype 2026-04-10 15:51:00 +09:00
parser Fix WITHOUT OVERLAPS' interaction with domains. 2026-04-07 14:45:37 -04:00
partitioning Strip PlaceHolderVars from partition pruning operands 2026-04-09 16:41:31 +09:00
po Update copyright for 2026 2026-01-01 13:24:10 -05:00
port Use the new shmem allocation functions in a few core subsystems 2026-04-06 02:12:59 +03:00
postmaster Fix double-free in pg_stat_autovacuum_scores. 2026-04-09 13:07:06 -05:00
regex Use fallthrough attribute instead of comment 2026-02-19 08:51:12 +01:00
replication Adjust log level of logical decoding messages by context 2026-04-10 22:59:34 +09:00
rewrite Add UPDATE/DELETE FOR PORTION OF 2026-04-01 19:06:03 +02:00
snowball Fix meson build of snowball code. 2026-01-05 16:51:36 -05:00
statistics Add support for importing statistics from remote servers. 2026-04-08 19:15:00 +09:00
storage read_stream: Remove obsolete comment. 2026-04-11 11:25:25 +12:00
tcop instrumentation: Allocate query level instrumentation in ExecutorStart 2026-04-08 00:06:45 -04:00
tsearch Require superuser to install a non-built-in selectivity estimator. 2026-02-09 10:07:31 -05:00
utils Fix estimate_array_length error with set-operation array coercions 2026-04-11 16:38:47 +09:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile ssl: Serverside SNI support for libpq 2026-03-18 12:37:11 +01:00
meson.build Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
nls.mk Create a separate file listing backend types 2025-09-26 15:21:49 +02:00