diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-05-09 23:13:37 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-05-09 23:13:37 +0000 |
commit | c23bc6fbb02455ee9c2e0206747a929aa79b7d01 (patch) | |
tree | 798bf1a1cdfa4e5c9d2d5f50e951a8d49f04c74d /src/backend/utils/cache/lsyscache.c | |
parent | e02033572d1a017e481b69c937e6618c4c2af234 (diff) | |
download | postgresql-c23bc6fbb02455ee9c2e0206747a929aa79b7d01.tar.gz postgresql-c23bc6fbb02455ee9c2e0206747a929aa79b7d01.zip |
First cut at making indexscan cost estimates depend on correlation
between index order and table order.
Diffstat (limited to 'src/backend/utils/cache/lsyscache.c')
-rw-r--r-- | src/backend/utils/cache/lsyscache.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index ee15a940cc5..573c21afd8d 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.54 2001/05/09 00:35:09 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.55 2001/05/09 23:13:35 tgl Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -185,6 +185,36 @@ get_atttypmod(Oid relid, AttrNumber attnum) return -1; } +/* + * get_atttypetypmod + * + * A two-fer: given the relation id and the attribute number, + * fetch both type OID and atttypmod in a single cache lookup. + * + * Unlike the otherwise-similar get_atttype/get_atttypmod, this routine + * raises an error if it can't obtain the information. + */ +void +get_atttypetypmod(Oid relid, AttrNumber attnum, + Oid *typid, int32 *typmod) +{ + HeapTuple tp; + Form_pg_attribute att_tup; + + tp = SearchSysCache(ATTNUM, + ObjectIdGetDatum(relid), + Int16GetDatum(attnum), + 0, 0); + if (!HeapTupleIsValid(tp)) + elog(ERROR, "cache lookup failed for relation %u attribute %d", + relid, attnum); + att_tup = (Form_pg_attribute) GETSTRUCT(tp); + + *typid = att_tup->atttypid; + *typmod = att_tup->atttypmod; + ReleaseSysCache(tp); +} + /* ---------- INDEX CACHE ---------- */ /* watch this space... |