diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-05-11 17:57:14 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-05-11 17:57:14 +0000 |
commit | bc8036fc666a8f846b1d4b2f935af7edd90eb5aa (patch) | |
tree | 7915d1a5cce3d9b5acdff19d8f12382ad5299485 /src/backend/utils/cache/lsyscache.c | |
parent | b1110aaa8bc7da6f7ebdc12fb550ed378b72ef6e (diff) |
Support arrays of composite types, including the rowtypes of regular tables
and views (but not system catalogs, nor sequences or toast tables). Get rid
of the hardwired convention that a type's array type is named exactly "_type",
instead using a new column pg_type.typarray to provide the linkage. (It still
will be named "_type", though, except in odd corner cases such as
maximum-length type names.)
Along the way, make tracking of owner and schema dependencies for types more
uniform: a type directly created by the user has these dependencies, while a
table rowtype or auto-generated array type does not have them, but depends on
its parent object instead.
David Fetter, Andrew Dunstan, Tom Lane
Diffstat (limited to 'src/backend/utils/cache/lsyscache.c')
-rw-r--r-- | src/backend/utils/cache/lsyscache.c | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 391870c3a69..d86a70521e3 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 - * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.151 2007/04/02 03:49:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.152 2007/05/11 17:57:12 tgl Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -2203,50 +2203,24 @@ get_element_type(Oid typid) /* * get_array_type * - * Given the type OID, get the corresponding array type. + * Given the type OID, get the corresponding "true" array type. * Returns InvalidOid if no array type can be found. - * - * NB: this only considers varlena arrays to be true arrays. */ Oid get_array_type(Oid typid) { HeapTuple tp; + Oid result = InvalidOid; tp = SearchSysCache(TYPEOID, ObjectIdGetDatum(typid), 0, 0, 0); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); - char *array_typename; - Oid namespaceId; - - array_typename = makeArrayTypeName(NameStr(typtup->typname)); - namespaceId = typtup->typnamespace; + result = ((Form_pg_type) GETSTRUCT(tp))->typarray; ReleaseSysCache(tp); - - tp = SearchSysCache(TYPENAMENSP, - PointerGetDatum(array_typename), - ObjectIdGetDatum(namespaceId), - 0, 0); - - pfree(array_typename); - - if (HeapTupleIsValid(tp)) - { - Oid result; - - typtup = (Form_pg_type) GETSTRUCT(tp); - if (typtup->typlen == -1 && typtup->typelem == typid) - result = HeapTupleGetOid(tp); - else - result = InvalidOid; - ReleaseSysCache(tp); - return result; - } } - return InvalidOid; + return result; } /* |