postgresql/src/backend
Robert Haas 570e2fcc04 Prevent spurious "indexes on virtual generated columns are not supported".
Both of the checks in DefineIndex() that can produce this error
message have a guard against negative attribute numbers, but lack a
guard to ensure that attno is non-zero. As a result, we can index
off the beginning of the TupleDesc and read a garbage byte for
attgenerated. If that byte happens to be 'v', we'll incorrectly
produce the error mentioned above.

The first call site is easy to hit: any attempt to create an
expression index does so. The second one is not currently hit in
the regression tests, but can be hit by something like
CREATE INDEX ON some_table ((some_function(some_table))).

Found by study of a test_plan_advice failure on buildfarm member
skink, though this issue has nothing to do with test_plan_advice
and seems to have only been revealed by happenstance.

Backpatch-through: 18
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: http://postgr.es/m/CA+TgmoacixUZVvi00hOjk_d9B4iYKswWP1gNqQ8Vfray-AcOCA@mail.gmail.com
2026-03-24 06:28:33 -04:00
..
access Add fake LSN support to hash index AM. 2026-03-22 17:31:43 -04:00
archive Don't include wait_event.h in pgstat.h 2026-03-06 16:24:58 +01:00
backup Add missing deflateEnd() for server-side gzip base backups 2026-03-23 09:04:44 +09:00
bootstrap Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
catalog Add support for lock statistics in pgstats 2026-03-24 15:32:09 +09:00
commands Prevent spurious "indexes on virtual generated columns are not supported". 2026-03-24 06:28:33 -04:00
executor Make IndexScanInstrumentation a pointer in executor scan nodes. 2026-03-22 13:20:29 -04:00
foreign Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
jit Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
lib dshash: Make it possible to suppress out of memory errors 2026-03-19 11:51:17 -04:00
libpq ssl: Serverside SNI support for libpq 2026-03-18 12:37:11 +01:00
main Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodes Allow IS JSON predicate to work with domain types 2026-03-17 15:20:22 -04:00
optimizer Add some const qualifiers enabled by typeof_unqual change on copyObject 2026-03-19 06:35:54 +01:00
parser json format for COPY TO 2026-03-20 08:40:04 -04:00
partitioning Add some const qualifiers enabled by typeof_unqual change on copyObject 2026-03-19 06:35:54 +01:00
po Update copyright for 2026 2026-01-01 13:24:10 -05:00
port Restore AIX support. 2026-02-23 13:34:22 -05:00
postmaster Add more debugging information for bgworker termination tests of worker_spi 2026-03-19 11:39:31 +09:00
regex Use fallthrough attribute instead of comment 2026-02-19 08:51:12 +01:00
replication Fix WAL flush LSN used by logical walsender during shutdown 2026-03-17 08:10:20 +09:00
rewrite Further improve commentary about ChangeVarNodesWalkExpression() 2026-03-24 09:54:00 +02:00
snowball Fix meson build of snowball code. 2026-01-05 16:51:36 -05:00
statistics Fix inconsistency with HeapTuple freeing in extended_stats_funcs.c 2026-03-06 14:49:00 +09:00
storage Add support for lock statistics in pgstats 2026-03-24 15:32:09 +09:00
tcop Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
tsearch Require superuser to install a non-built-in selectivity estimator. 2026-02-09 10:07:31 -05:00
utils Add support for lock statistics in pgstats 2026-03-24 15:32:09 +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 backtrace support for Windows using DbgHelp API 2026-02-24 17:34:56 +01:00
nls.mk Create a separate file listing backend types 2025-09-26 15:21:49 +02:00