diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 094e99a8acf5762632f99a3b479de758b6fcba1f..e46b63f6d9f0b3228e1bc5b67f7c60c63422181d 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.129 2005/05/29 18:24:13 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.130 2005/05/30 01:20:49 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -168,8 +168,11 @@ coerce_type(ParseState *pstate, Node *node,
 
 		if (!con->constisnull)
 		{
-			char	   *val = DatumGetCString(DirectFunctionCall1(unknownout,
-													   con->constvalue));
+			/*
+			 * We assume here that UNKNOWN's internal representation is the
+			 * same as CSTRING
+			 */
+			char	   *val = DatumGetCString(con->constvalue);
 
 			/*
 			 * We pass typmod -1 to the input routine, primarily because
@@ -183,7 +186,6 @@ coerce_type(ParseState *pstate, Node *node,
 			 * ugly...
 			 */
 			newcon->constvalue = stringTypeDatum(targetType, val, -1);
-			pfree(val);
 		}
 
 		result = (Node *) newcon;
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c
index 921da9a04a53fdc704df74bdbbf4e64c565467e9..20999f81ffe4645c29af7dd01e39c5aff469e2ad 100644
--- a/src/backend/parser/parse_node.c
+++ b/src/backend/parser/parse_node.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.88 2005/04/23 18:35:12 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.89 2005/05/30 01:20:49 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -271,8 +271,8 @@ transformArraySubscripts(ParseState *pstate,
  *	have to guess what type is wanted.
  *
  *	For string literals we produce a constant of type UNKNOWN ---- whose
- *	representation is the same as text, but it indicates to later type
- *	resolution that we're not sure that it should be considered text.
+ *	representation is the same as cstring, but it indicates to later type
+ *	resolution that we're not sure yet what type it should be considered.
  *	Explicit "NULL" constants are also typed as UNKNOWN.
  *
  *	For integers and floats we produce int4, int8, or numeric depending
@@ -341,11 +341,14 @@ make_const(Value *value)
 			break;
 
 		case T_String:
-			val = DirectFunctionCall1(unknownin,
-									  CStringGetDatum(strVal(value)));
+			/*
+			 * We assume here that UNKNOWN's internal representation is the
+			 * same as CSTRING
+			 */
+			val = CStringGetDatum(strVal(value));
 
 			typeid = UNKNOWNOID;	/* will be coerced later */
-			typelen = -1;		/* variable len */
+			typelen = -2;			/* cstring-style varwidth type */
 			typebyval = false;
 			break;
 
@@ -362,7 +365,7 @@ make_const(Value *value)
 		case T_Null:
 			/* return a null const */
 			con = makeConst(UNKNOWNOID,
-							-1,
+							-2,
 							(Datum) 0,
 							true,
 							false);
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index c07f4f8f02cbe92e30fa52c9dae1d61787226cde..5efda61bce47f6fe29cf3f81f223ac411862c0fd 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.122 2005/05/27 00:57:49 neilc Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.123 2005/05/30 01:20:50 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -330,18 +330,10 @@ textsend(PG_FUNCTION_ARGS)
 Datum
 unknownin(PG_FUNCTION_ARGS)
 {
-	char	   *inputStr = PG_GETARG_CSTRING(0);
-	unknown    *result;
-	int			len;
-
-	len = strlen(inputStr) + VARHDRSZ;
-
-	result = (unknown *) palloc(len);
-	VARATT_SIZEP(result) = len;
-
-	memcpy(VARDATA(result), inputStr, len - VARHDRSZ);
+	char	   *str = PG_GETARG_CSTRING(0);
 
-	PG_RETURN_UNKNOWN_P(result);
+	/* representation is same as cstring */
+	PG_RETURN_CSTRING(pstrdup(str));
 }
 
 /*
@@ -350,16 +342,10 @@ unknownin(PG_FUNCTION_ARGS)
 Datum
 unknownout(PG_FUNCTION_ARGS)
 {
-	unknown    *t = PG_GETARG_UNKNOWN_P(0);
-	int			len;
-	char	   *result;
-
-	len = VARSIZE(t) - VARHDRSZ;
-	result = (char *) palloc(len + 1);
-	memcpy(result, VARDATA(t), len);
-	result[len] = '\0';
+	/* representation is same as cstring */
+	char	   *str = PG_GETARG_CSTRING(0);
 
-	PG_RETURN_CSTRING(result);
+	PG_RETURN_CSTRING(pstrdup(str));
 }
 
 /*
@@ -369,28 +355,27 @@ Datum
 unknownrecv(PG_FUNCTION_ARGS)
 {
 	StringInfo	buf = (StringInfo) PG_GETARG_POINTER(0);
-	unknown    *result;
+	char	   *str;
 	int			nbytes;
 
-	nbytes = buf->len - buf->cursor;
-	result = (unknown *) palloc(nbytes + VARHDRSZ);
-	VARATT_SIZEP(result) = nbytes + VARHDRSZ;
-	pq_copymsgbytes(buf, VARDATA(result), nbytes);
-	PG_RETURN_UNKNOWN_P(result);
+	str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);
+	/* representation is same as cstring */
+	PG_RETURN_CSTRING(str);
 }
 
 /*
  *		unknownsend			- converts unknown to binary format
- *
- * This is a special case: just copy the input, since it's
- * effectively the same format as bytea
  */
 Datum
 unknownsend(PG_FUNCTION_ARGS)
 {
-	unknown    *vlena = PG_GETARG_UNKNOWN_P_COPY(0);
+	/* representation is same as cstring */
+	char	   *str = PG_GETARG_CSTRING(0);
+	StringInfoData buf;
 
-	PG_RETURN_UNKNOWN_P(vlena);
+	pq_begintypsend(&buf);
+	pq_sendtext(&buf, str, strlen(str));
+	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
 
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 97817e9229820fd612a1fc7e8e270e8dac63f100..ffab04a85d434876bcbc0498f57fe1c8bf22e949 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.269 2005/05/20 01:29:55 neilc Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.270 2005/05/30 01:20:50 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,6 +53,6 @@
  */
 
 /*							yyyymmddN */
-#define CATALOG_VERSION_NO	200505201
+#define CATALOG_VERSION_NO	200505291
 
 #endif
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 1af651c068e19f4fa4c764853d8973bdc66d70ad..8a4207e9ea6bce9cf7db2b1d45dac15559981a49 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.160 2005/04/14 01:38:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.161 2005/05/30 01:20:50 tgl Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -370,7 +370,7 @@ DESCR("relative, limited-range time interval (Unix delta time)");
 DATA(insert OID = 704 (  tinterval PGNSP PGUID 12 f b t \054 0	 0 tintervalin tintervalout tintervalrecv tintervalsend - i p f 0 -1 0 _null_ _null_ ));
 DESCR("(abstime,abstime), time interval");
 #define TINTERVALOID	704
-DATA(insert OID = 705 (  unknown   PGNSP PGUID -1 f b t \054 0	 0 unknownin unknownout unknownrecv unknownsend - i p f 0 -1 0 _null_ _null_ ));
+DATA(insert OID = 705 (  unknown   PGNSP PGUID -2 f b t \054 0	 0 unknownin unknownout unknownrecv unknownsend - c p f 0 -1 0 _null_ _null_ ));
 DESCR("");
 #define UNKNOWNOID		705