diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 5de4d19a5b831c7e00bd008082dcc412b1add0a2..2d8d86f103593bcea4500e862bbb0491311b95d7 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.153 2003/08/17 23:43:26 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.154 2003/10/29 18:10:15 tgl Exp $
  *
  * HISTORY
  *	  AUTHOR			DATE			MAJOR EVENT
@@ -2412,6 +2412,16 @@ expression_tree_walker(Node *node,
 					return true;
 			}
 			break;
+		case T_RangeVar:
+			/*
+			 * Give a useful complaint if someone uses a bare relation name
+			 * in an expression (see comments in transformColumnRef()).
+			 */
+			ereport(ERROR,
+					(errcode(ERRCODE_SYNTAX_ERROR),
+					 errmsg("relation reference \"%s\" cannot be used in an expression",
+							((RangeVar *) node)->relname)));
+			break;
 		default:
 			elog(ERROR, "unrecognized node type: %d",
 				 (int) nodeTag(node));
@@ -2879,6 +2889,16 @@ expression_tree_mutator(Node *node,
 				return (Node *) newnode;
 			}
 			break;
+		case T_RangeVar:
+			/*
+			 * Give a useful complaint if someone uses a bare relation name
+			 * in an expression (see comments in transformColumnRef()).
+			 */
+			ereport(ERROR,
+					(errcode(ERRCODE_SYNTAX_ERROR),
+					 errmsg("relation reference \"%s\" cannot be used in an expression",
+							((RangeVar *) node)->relname)));
+			break;
 		default:
 			elog(ERROR, "unrecognized node type: %d",
 				 (int) nodeTag(node));