diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2017-09-06 13:46:01 -0700 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2017-09-06 13:46:01 -0700 |
commit | 5b6d13eec72b960eb0f78542199380e49c8583d4 (patch) | |
tree | 8893caeb77015bb2502f3795954b6f59b5b04305 /src/backend/utils/cache/syscache.c | |
parent | e09db94c0a5f3b440d96c5c9e8e6c1638d1ec39f (diff) | |
download | postgresql-5b6d13eec72b960eb0f78542199380e49c8583d4.tar.gz postgresql-5b6d13eec72b960eb0f78542199380e49c8583d4.zip |
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
Diffstat (limited to 'src/backend/utils/cache/syscache.c')
-rw-r--r-- | src/backend/utils/cache/syscache.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index 607fe9db79b..fcbb683a991 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -1257,6 +1257,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 * * Given a tuple previously fetched by SearchSysCache(), |