* Display type names "nicely".
*
*
- * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/format_type.c,v 1.51 2009/01/01 17:23:49 momjian Exp $
+ * src/backend/utils/adt/format_type.c
*
*-------------------------------------------------------------------------
*/
if (type_oid == InvalidOid && allow_invalid)
return pstrdup("-");
- tuple = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(type_oid),
- 0, 0, 0);
+ tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_oid));
if (!HeapTupleIsValid(tuple))
{
if (allow_invalid)
typeform = (Form_pg_type) GETSTRUCT(tuple);
/*
- * Check if it's an array (and not a domain --- we don't want to show the
- * substructure of a domain type). Fixed-length array types such as
- * "name" shouldn't get deconstructed either. As of Postgres 8.1, rather
- * than checking typlen we check the toast property, and don't deconstruct
- * "plain storage" array types --- this is because we don't want to show
- * oidvector as oid[].
+ * Check if it's a regular (variable length) array type. Fixed-length
+ * array types such as "name" shouldn't get deconstructed. As of Postgres
+ * 8.1, rather than checking typlen we check the toast property, and don't
+ * deconstruct "plain storage" array types --- this is because we don't
+ * want to show oidvector as oid[].
*/
array_base_type = typeform->typelem;
if (array_base_type != InvalidOid &&
- typeform->typstorage != 'p' &&
- typeform->typtype != TYPTYPE_DOMAIN)
+ typeform->typstorage != 'p')
{
/* Switch our attention to the array element type */
ReleaseSysCache(tuple);
- tuple = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(array_base_type),
- 0, 0, 0);
+ tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(array_base_type));
if (!HeapTupleIsValid(tuple))
{
if (allow_invalid)
+ VARHDRSZ;
case NUMERICOID:
- /* precision (ie, max # of digits) is in upper bits of typmod */
- if (typemod > VARHDRSZ)
- {
- int precision = ((typemod - VARHDRSZ) >> 16) & 0xffff;
-
- /* Numeric stores 2 decimal digits/byte, plus header */
- return (precision + 1) / 2 + NUMERIC_HDRSZ;
- }
- break;
+ return numeric_maximum_size(typemod);
case VARBITOID:
case BITOID: