1
0
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:
Simon Riggs
2017-09-06 13:46:01 -07:00
parent e09db94c0a
commit 5b6d13eec7
13 changed files with 201 additions and 17 deletions

View File

@ -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
*