mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
Code review for DOMAIN patch.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.27 2002/03/19 02:18:21 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.28 2002/03/20 19:44:40 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -123,10 +123,10 @@ format_type_internal(Oid type_oid, int32 typemod,
|
||||
HeapTuple tuple;
|
||||
Oid array_base_type;
|
||||
int16 typlen;
|
||||
char typtype;
|
||||
bool is_array;
|
||||
char *name;
|
||||
char *buf;
|
||||
char typtype;
|
||||
|
||||
if (type_oid == InvalidOid && allow_invalid)
|
||||
return pstrdup("-");
|
||||
@@ -143,34 +143,16 @@ format_type_internal(Oid type_oid, int32 typemod,
|
||||
type_oid);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
array_base_type = ((Form_pg_type) GETSTRUCT(tuple))->typelem;
|
||||
typlen = ((Form_pg_type) GETSTRUCT(tuple))->typlen;
|
||||
typtype = ((Form_pg_type) GETSTRUCT(tuple))->typtype;
|
||||
|
||||
/*
|
||||
* Domains look alot like arrays, so lets process them first, and return
|
||||
* back to avoid the array and 'standard' formatting procedures that are
|
||||
* use for base types.
|
||||
*/
|
||||
if (typtype == 'd') {
|
||||
name = NameStr(((Form_pg_type) GETSTRUCT(tuple))->typname);
|
||||
|
||||
/*
|
||||
* Double-quote the name if it's not a standard identifier.
|
||||
* Note this is *necessary* for ruleutils.c's use.
|
||||
*/
|
||||
if (strspn(name, "abcdefghijklmnopqrstuvwxyz0123456789_") != strlen(name)
|
||||
|| isdigit((unsigned char) name[0]))
|
||||
buf = psnprintf(strlen(name) + 3, "\"%s\"", name);
|
||||
else
|
||||
buf = pstrdup(name);
|
||||
|
||||
ReleaseSysCache(tuple);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
if (array_base_type != InvalidOid && typlen < 0)
|
||||
if (array_base_type != InvalidOid && typlen < 0 && typtype != 'd')
|
||||
{
|
||||
/* Switch our attention to the array element type */
|
||||
ReleaseSysCache(tuple);
|
||||
|
||||
Reference in New Issue
Block a user