|
14 | 14 | */
|
15 | 15 | #include "postgres.h"
|
16 | 16 |
|
17 |
| -#include "access/htup_details.h" |
18 | 17 | #include "catalog/pg_cast.h"
|
19 | 18 | #include "catalog/pg_class.h"
|
20 | 19 | #include "catalog/pg_inherits.h"
|
|
26 | 25 | #include "parser/parse_relation.h"
|
27 | 26 | #include "parser/parse_type.h"
|
28 | 27 | #include "utils/builtins.h"
|
29 |
| -#include "utils/datum.h" |
30 | 28 | #include "utils/lsyscache.h"
|
31 | 29 | #include "utils/syscache.h"
|
32 | 30 | #include "utils/typcache.h"
|
@@ -1968,108 +1966,6 @@ enforce_generic_type_consistency(const Oid *actual_arg_types,
|
1968 | 1966 | return rettype;
|
1969 | 1967 | }
|
1970 | 1968 |
|
1971 |
| -/* |
1972 |
| - * resolve_generic_type() |
1973 |
| - * Deduce an individual actual datatype on the assumption that |
1974 |
| - * the rules for polymorphic types are being followed. |
1975 |
| - * |
1976 |
| - * declared_type is the declared datatype we want to resolve. |
1977 |
| - * context_actual_type is the actual input datatype to some argument |
1978 |
| - * that has declared datatype context_declared_type. |
1979 |
| - * |
1980 |
| - * If declared_type isn't polymorphic, we just return it. Otherwise, |
1981 |
| - * context_declared_type must be polymorphic, and we deduce the correct |
1982 |
| - * return type based on the relationship of the two polymorphic types. |
1983 |
| - */ |
1984 |
| -Oid |
1985 |
| -resolve_generic_type(Oid declared_type, |
1986 |
| - Oid context_actual_type, |
1987 |
| - Oid context_declared_type) |
1988 |
| -{ |
1989 |
| - if (declared_type == ANYARRAYOID) |
1990 |
| - { |
1991 |
| - if (context_declared_type == ANYARRAYOID) |
1992 |
| - { |
1993 |
| - /* |
1994 |
| - * Use actual type, but it must be an array; or if it's a domain |
1995 |
| - * over array, use the base array type. |
1996 |
| - */ |
1997 |
| - Oid context_base_type = getBaseType(context_actual_type); |
1998 |
| - Oid array_typelem = get_element_type(context_base_type); |
1999 |
| - |
2000 |
| - if (!OidIsValid(array_typelem)) |
2001 |
| - ereport(ERROR, |
2002 |
| - (errcode(ERRCODE_DATATYPE_MISMATCH), |
2003 |
| - errmsg("argument declared %s is not an array but type %s", |
2004 |
| - "anyarray", format_type_be(context_base_type)))); |
2005 |
| - return context_base_type; |
2006 |
| - } |
2007 |
| - else if (context_declared_type == ANYELEMENTOID || |
2008 |
| - context_declared_type == ANYNONARRAYOID || |
2009 |
| - context_declared_type == ANYENUMOID || |
2010 |
| - context_declared_type == ANYRANGEOID) |
2011 |
| - { |
2012 |
| - /* Use the array type corresponding to actual type */ |
2013 |
| - Oid array_typeid = get_array_type(context_actual_type); |
2014 |
| - |
2015 |
| - if (!OidIsValid(array_typeid)) |
2016 |
| - ereport(ERROR, |
2017 |
| - (errcode(ERRCODE_UNDEFINED_OBJECT), |
2018 |
| - errmsg("could not find array type for data type %s", |
2019 |
| - format_type_be(context_actual_type)))); |
2020 |
| - return array_typeid; |
2021 |
| - } |
2022 |
| - } |
2023 |
| - else if (declared_type == ANYELEMENTOID || |
2024 |
| - declared_type == ANYNONARRAYOID || |
2025 |
| - declared_type == ANYENUMOID || |
2026 |
| - declared_type == ANYRANGEOID) |
2027 |
| - { |
2028 |
| - if (context_declared_type == ANYARRAYOID) |
2029 |
| - { |
2030 |
| - /* Use the element type corresponding to actual type */ |
2031 |
| - Oid context_base_type = getBaseType(context_actual_type); |
2032 |
| - Oid array_typelem = get_element_type(context_base_type); |
2033 |
| - |
2034 |
| - if (!OidIsValid(array_typelem)) |
2035 |
| - ereport(ERROR, |
2036 |
| - (errcode(ERRCODE_DATATYPE_MISMATCH), |
2037 |
| - errmsg("argument declared %s is not an array but type %s", |
2038 |
| - "anyarray", format_type_be(context_base_type)))); |
2039 |
| - return array_typelem; |
2040 |
| - } |
2041 |
| - else if (context_declared_type == ANYRANGEOID) |
2042 |
| - { |
2043 |
| - /* Use the element type corresponding to actual type */ |
2044 |
| - Oid context_base_type = getBaseType(context_actual_type); |
2045 |
| - Oid range_typelem = get_range_subtype(context_base_type); |
2046 |
| - |
2047 |
| - if (!OidIsValid(range_typelem)) |
2048 |
| - ereport(ERROR, |
2049 |
| - (errcode(ERRCODE_DATATYPE_MISMATCH), |
2050 |
| - errmsg("argument declared %s is not a range type but type %s", |
2051 |
| - "anyrange", format_type_be(context_base_type)))); |
2052 |
| - return range_typelem; |
2053 |
| - } |
2054 |
| - else if (context_declared_type == ANYELEMENTOID || |
2055 |
| - context_declared_type == ANYNONARRAYOID || |
2056 |
| - context_declared_type == ANYENUMOID) |
2057 |
| - { |
2058 |
| - /* Use the actual type; it doesn't matter if array or not */ |
2059 |
| - return context_actual_type; |
2060 |
| - } |
2061 |
| - } |
2062 |
| - else |
2063 |
| - { |
2064 |
| - /* declared_type isn't polymorphic, so return it as-is */ |
2065 |
| - return declared_type; |
2066 |
| - } |
2067 |
| - /* If we get here, declared_type is polymorphic and context isn't */ |
2068 |
| - /* NB: this is a calling-code logic error, not a user error */ |
2069 |
| - elog(ERROR, "could not determine polymorphic type because context isn't polymorphic"); |
2070 |
| - return InvalidOid; /* keep compiler quiet */ |
2071 |
| -} |
2072 |
| - |
2073 | 1969 |
|
2074 | 1970 | /* TypeCategory()
|
2075 | 1971 | * Assign a category to the specified type OID.
|
|
0 commit comments