mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
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
This commit is contained in:
36
src/backend/utils/cache/lsyscache.c
vendored
36
src/backend/utils/cache/lsyscache.c
vendored
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user