summaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_coerce.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-03-19 02:18:25 +0000
committerBruce Momjian <bruce@momjian.us>2002-03-19 02:18:25 +0000
commitd3788c330517af301576a14bdd71f26da3b0e1c0 (patch)
treeaccb7af74b71d962496a250d1eb6cbec71bffd48 /src/backend/parser/parse_coerce.c
parent525b19399c629455bdcd63c9879f7c75f7ae3d25 (diff)
downloadpostgresql-d3788c330517af301576a14bdd71f26da3b0e1c0.tar.gz
Add DOMAIN support. Includes manual pages and regression tests, from
Rod Taylor.
Diffstat (limited to 'src/backend/parser/parse_coerce.c')
-rw-r--r--src/backend/parser/parse_coerce.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 172142e33d..7aaaa65c61 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.66 2002/03/07 16:35:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.67 2002/03/19 02:18:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -605,3 +605,32 @@ PreferredType(CATEGORY category, Oid type)
}
return result;
} /* PreferredType() */
+
+
+/*
+ * If the targetTypeId is a domain, we really want to coerce
+ * the tuple to the domain type -- not the domain itself
+ */
+Oid
+getBaseType(Oid inType)
+{
+ HeapTuple tup;
+ Form_pg_type typTup;
+
+ tup = SearchSysCache(TYPEOID,
+ ObjectIdGetDatum(inType),
+ 0, 0, 0);
+
+ typTup = ((Form_pg_type) GETSTRUCT(tup));
+
+ /*
+ * Assume that typbasetype exists and is a base type, where inType
+ * was a domain
+ */
+ if (typTup->typtype == 'd')
+ inType = typTup->typbasetype;
+
+ ReleaseSysCache(tup);
+
+ return inType;
+}