*** a/src/backend/parser/parse_coerce.c
--- b/src/backend/parser/parse_coerce.c
***************
*** 2214,2226 **** find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
  
  		/*
  		 * If we still haven't found a possibility, consider automatic casting
! 		 * using I/O functions.  We allow assignment casts to string types and
! 		 * explicit casts from string types to be handled this way. (The
! 		 * CoerceViaIO mechanism is a lot more general than that, but this is
! 		 * all we want to allow in the absence of a pg_cast entry.) It would
! 		 * probably be better to insist on explicit casts in both directions,
! 		 * but this is a compromise to preserve something of the pre-8.3
! 		 * behavior that many types had implicit (yipes!) casts to text.
  		 */
  		if (result == COERCION_PATH_NONE)
  		{
--- 2214,2227 ----
  
  		/*
  		 * If we still haven't found a possibility, consider automatic casting
! 		 * using I/O functions.  We allow assignment casts to string types,
! 		 * explicit casts from string types, and any cast from unknown to be
! 		 * handled this way. (The CoerceViaIO mechanism is a lot more general
! 		 * than that, but this is all we want to allow in the absence of a
! 		 * pg_cast entry.) It would probably be better to insist on explicit
! 		 * casts in both directions, but this is a compromise to preserve
! 		 * something of the pre-8.3 behavior that many types had implicit
! 		 * (yipes!) casts to text.
  		 */
  		if (result == COERCION_PATH_NONE)
  		{
***************
*** 2230,2235 **** find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
--- 2231,2238 ----
  			else if (ccontext >= COERCION_EXPLICIT &&
  					 TypeCategory(sourceTypeId) == TYPCATEGORY_STRING)
  				result = COERCION_PATH_COERCEVIAIO;
+ 			else if (sourceTypeId == UNKNOWNOID)
+ 				result = COERCION_PATH_COERCEVIAIO;
  		}
  	}
  
*** a/src/test/regress/expected/strings.out
--- b/src/test/regress/expected/strings.out
***************
*** 1086,1091 **** SELECT 'jack' LIKE '%____%' AS t;
--- 1086,1097 ----
  --
  -- test implicit type conversion
  --
+ SELECT a=b FROM (SELECT ''::text, '  ') x(a,b);
+  ?column? 
+ ----------
+  f
+ (1 row)
+ 
  -- E021-07 character concatenation
  SELECT 'unknown' || ' and unknown' AS "Concat unknown types";
   Concat unknown types 
*** a/src/test/regress/sql/strings.sql
--- b/src/test/regress/sql/strings.sql
***************
*** 324,329 **** SELECT 'jack' LIKE '%____%' AS t;
--- 324,331 ----
  -- test implicit type conversion
  --
  
+ SELECT a=b FROM (SELECT ''::text, '  ') x(a,b);
+ 
  -- E021-07 character concatenation
  SELECT 'unknown' || ' and unknown' AS "Concat unknown types";
  
