mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
Allow SET STATISTICS on expression indexes
Index columns are referenced by ordinal number rather than name, e.g. CREATE INDEX coord_idx ON measured (x, y, (z + t)); ALTER INDEX coord_idx ALTER COLUMN 3 SET STATISTICS 1000; Incompatibility note for release notes: \d+ for indexes now also displays Stats Target Authors: Alexander Korotkov, with contribution by Adrien NAYRAT Review: Adrien NAYRAT, Simon Riggs Wordsmith: Simon Riggs
This commit is contained in:
46
src/backend/utils/cache/syscache.c
vendored
46
src/backend/utils/cache/syscache.c
vendored
@ -1256,6 +1256,52 @@ SearchSysCacheExistsAttName(Oid relid, const char *attname)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SearchSysCacheAttNum
|
||||
*
|
||||
* This routine is equivalent to SearchSysCache on the ATTNUM cache,
|
||||
* except that it will return NULL if the found attribute is marked
|
||||
* attisdropped. This is convenient for callers that want to act as
|
||||
* though dropped attributes don't exist.
|
||||
*/
|
||||
HeapTuple
|
||||
SearchSysCacheAttNum(Oid relid, int16 attnum)
|
||||
{
|
||||
HeapTuple tuple;
|
||||
|
||||
tuple = SearchSysCache2(ATTNUM,
|
||||
ObjectIdGetDatum(relid),
|
||||
Int16GetDatum(attnum));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
return NULL;
|
||||
if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
|
||||
{
|
||||
ReleaseSysCache(tuple);
|
||||
return NULL;
|
||||
}
|
||||
return tuple;
|
||||
}
|
||||
|
||||
/*
|
||||
* SearchSysCacheCopyAttNum
|
||||
*
|
||||
* As above, an attisdropped-aware version of SearchSysCacheCopy.
|
||||
*/
|
||||
HeapTuple
|
||||
SearchSysCacheCopyAttNum(Oid relid, int16 attnum)
|
||||
{
|
||||
HeapTuple tuple,
|
||||
newtuple;
|
||||
|
||||
tuple = SearchSysCacheAttNum(relid, attnum);
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
return NULL;
|
||||
newtuple = heap_copytuple(tuple);
|
||||
ReleaseSysCache(tuple);
|
||||
return newtuple;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SysCacheGetAttr
|
||||
*
|
||||
|
Reference in New Issue
Block a user