diff options
| author | Tom Lane | 2008-07-30 17:05:05 +0000 |
|---|---|---|
| committer | Tom Lane | 2008-07-30 17:05:05 +0000 |
| commit | bac3e83622b588eb449eb4e26c4b1e62e7cca3d5 (patch) | |
| tree | 419f9079e41450aaaaa5ed0b8c8fa849a46d5bf9 /src/include/parser | |
| parent | ab9907f5e5eba6e4e17a279d07a1a9df21ec5b19 (diff) | |
Replace the hard-wired type knowledge in TypeCategory() and IsPreferredType()
with system catalog lookups, as was foreseen to be necessary almost since
their creation. Instead put the information into two new pg_type columns,
typcategory and typispreferred. Add support for setting these when
creating a user-defined base type.
The category column is just a "char" (i.e. a poor man's enum), allowing
a crude form of user extensibility of the category list: just use an
otherwise-unused character. This seems sufficient for foreseen uses,
but we could upgrade to having an actual category catalog someday, if
there proves to be a huge demand for custom type categories.
In this patch I have attempted to hew exactly to the behavior of the
previous hardwired logic, except for introducing new type categories for
arrays, composites, and enums. In particular the default preferred state
for user-defined types remains TRUE. That seems worth revisiting, but it
should be done as a separate patch from introducing the infrastructure.
Likewise, any adjustment of the standard set of categories should be done
separately.
Diffstat (limited to 'src/include/parser')
| -rw-r--r-- | src/include/parser/parse_coerce.h | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/src/include/parser/parse_coerce.h b/src/include/parser/parse_coerce.h index ab36a0c1969..68d5173378a 100644 --- a/src/include/parser/parse_coerce.h +++ b/src/include/parser/parse_coerce.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/parse_coerce.h,v 1.75 2008/01/11 18:39:41 tgl Exp $ + * $PostgreSQL: pgsql/src/include/parser/parse_coerce.h,v 1.76 2008/07/30 17:05:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,22 +17,8 @@ #include "parser/parse_node.h" -/* Type categories (kluge ... ought to be extensible) */ -typedef enum CATEGORY -{ - INVALID_TYPE, - UNKNOWN_TYPE, - GENERIC_TYPE, - BOOLEAN_TYPE, - STRING_TYPE, - BITSTRING_TYPE, - NUMERIC_TYPE, - DATETIME_TYPE, - TIMESPAN_TYPE, - GEOMETRIC_TYPE, - NETWORK_TYPE, - USER_TYPE -} CATEGORY; +/* Type categories (see TYPCATEGORY_xxx symbols in catalog/pg_type.h) */ +typedef char TYPCATEGORY; /* Result codes for find_coercion_pathway */ typedef enum CoercionPathType @@ -46,8 +32,8 @@ typedef enum CoercionPathType extern bool IsBinaryCoercible(Oid srctype, Oid targettype); -extern bool IsPreferredType(CATEGORY category, Oid type); -extern CATEGORY TypeCategory(Oid type); +extern bool IsPreferredType(TYPCATEGORY category, Oid type); +extern TYPCATEGORY TypeCategory(Oid type); extern Node *coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, |
