pgsql: Do not access indclass through Form_pg_index

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Do not access indclass through Form_pg_index
Date: 2012-01-27 18:21:54
Message-ID: E1RqqQs-0005fW-Lc@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Do not access indclass through Form_pg_index

Normally, accessing variable-length members of catalog structures past
the first one doesn't work at all. Here, it happened to work because
indnatts was checked to be 1, and so the defined FormData_pg_index
layout, using int2vector[1] and oidvector[1] for variable-length
arrays, happened to match the actual memory layout. But it's a very
fragile assumption, and it's not in a performance-critical path, so
code it properly using heap_getattr() instead.

bug analysis by Tom Lane

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/8a3f745f160d8334ad978676828d3926ac949f43

Modified Files
--------------
src/backend/utils/cache/relcache.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2012-01-27 19:21:58 pgsql: Disallow ALTER DOMAIN on non-domain type everywhere
Previous Message Robert Haas 2012-01-27 17:42:41 pgsql: Document that COUNT(*) might not need a seq scan any more.