From 89ab5c4abf48de8156b9284dda869f9ea2b2ad44 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 15 Mar 2004 01:13:41 +0000 Subject: 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. --- src/backend/parser/parse_coerce.c | 46 +-------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) (limited to 'src/backend/parser') 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; -- cgit v1.2.3