Re: [PATCHES] parse_expr.c:typecast_expression:return immediate on NULL input

2007-11-23 Thread Hannes Eder
Tom Lane [EMAIL PROTECTED] writes:
 Hannes Eder [EMAIL PROTECTED] writes:
  in parse_expr.c:typecast_expression: return immediate on NULL
 input, i.e. do not lookup target type Oid as it is not required.
 
 I think the existing ordering is intentional, to detect and error
 out if the given typename is bogus.

Ups, yes, you are right. typecast_expression calls typenameTypeId and
this calls typenameType, which will ereport an error if the typename
cannot be found.

-Hannes


---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


[PATCHES] parse_expr.c:typecast_expression:return immediate on NULL input

2007-11-23 Thread Hannes Eder
in parse_expr.c:typecast_expression: return immediate on NULL input, 
i.e. do not lookup target type Oid as it is not required.


-Hannes
Index: src/backend/parser/parse_expr.c
===
--- src/backend/parser/parse_expr.c (revision 377)
+++ src/backend/parser/parse_expr.c (working copy)
@@ -2226,11 +2226,11 @@
Oid targetType;
int32   targetTypmod;
 
-   targetType = typenameTypeId(pstate, typename, targetTypmod);
-
if (inputType == InvalidOid)
return expr;/* do nothing if NULL input */
 
+   targetType = typenameTypeId(pstate, typename, targetTypmod);
+
expr = coerce_to_target_type(pstate, expr, inputType,
 targetType, 
targetTypmod,
 
COERCION_EXPLICIT,

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [PATCHES] parse_expr.c:typecast_expression:return immediate on NULL input

2007-11-23 Thread Tom Lane
Hannes Eder [EMAIL PROTECTED] writes:
 in parse_expr.c:typecast_expression: return immediate on NULL input, 
 i.e. do not lookup target type Oid as it is not required.

I think the existing ordering is intentional, to detect and error out
if the given typename is bogus.

It's fairly likely that the test for InvalidOid is dead code anyway,
but it's cheap enough that I'm not in a hurry to take it out.

regards, tom lane

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match