aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_coerce.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-03-15 01:13:41 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-03-15 01:13:41 +0000
commit89ab5c4abf48de8156b9284dda869f9ea2b2ad44 (patch)
tree00b04c3c9edb91919fba7969083e71f38f2d12db /src/backend/parser/parse_coerce.c
parent64fe1fd2394cfd14346cef3845529b053a1d5998 (diff)
downloadpostgresql-89ab5c4abf48de8156b9284dda869f9ea2b2ad44.tar.gz
postgresql-89ab5c4abf48de8156b9284dda869f9ea2b2ad44.zip
Remove grotty special-case code in coerce_to_target_type() that
implemented casts to varchar and bpchar using a cast-to-text function. This is a holdover from before we had pg_cast; it now makes more sense to just list these casts in pg_cast. While at it, add pg_cast entries for the other direction (casts from varchar/bpchar) where feasible.
Diffstat (limited to 'src/backend/parser/parse_coerce.c')
-rw-r--r--src/backend/parser/parse_coerce.c46
1 files changed, 1 insertions, 45 deletions
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 7ed028512da..a5bff31c89f 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.113 2003/12/17 19:49:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.114 2004/03/15 01:13:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -63,50 +63,6 @@ coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype,
if (can_coerce_type(1, &exprtype, &targettype, ccontext))
expr = coerce_type(pstate, expr, exprtype, targettype,
ccontext, cformat);
- else if (ccontext >= COERCION_ASSIGNMENT)
- {
- /*
- * String hacks to get transparent conversions for char and
- * varchar: if a coercion to text is available, use it for forced
- * coercions to char(n) or varchar(n) or domains thereof.
- *
- * This is pretty grotty, but seems easier to maintain than providing
- * entries in pg_cast that parallel all the ones for text.
- */
- Oid targetbasetype = getBaseType(targettype);
-
- if (targetbasetype == BPCHAROID || targetbasetype == VARCHAROID)
- {
- Oid text_id = TEXTOID;
-
- if (can_coerce_type(1, &exprtype, &text_id, ccontext))
- {
- expr = coerce_type(pstate, expr, exprtype, text_id,
- ccontext, cformat);
- if (targetbasetype != targettype)
- {
- /* need to coerce to domain over char or varchar */
- expr = coerce_to_domain(expr, targetbasetype, targettype,
- cformat);
- }
- else
- {
- /*
- * need a RelabelType if no typmod coercion will be
- * performed
- */
- if (targettypmod < 0)
- expr = (Node *) makeRelabelType((Expr *) expr,
- targettype, -1,
- cformat);
- }
- }
- else
- expr = NULL;
- }
- else
- expr = NULL;
- }
else
expr = NULL;