--- a/sql/item.cc	Sat Mar 31 15:58:00 2007
+++ b/sql/item.cc	Sun Apr  8 20:59:06 2007
@@ -1162,12 +1195,21 @@
 
   if (value_item->fix_fields(thd, &value_item) ||
       name_item->fix_fields(thd, &name_item))
-    return TRUE;
+    {
+      my_error(ER_RESERVED_SYNTAX, MYF(0), "NAME_CONST");
+      return TRUE;
+    }
   if (!(value_item->const_item() && name_item->const_item()))
-    return TRUE;
+    {
+      my_error(ER_RESERVED_SYNTAX, MYF(0), "NAME_CONST");
+      return TRUE;
+    }
 
   if (!(item_name= name_item->val_str(&s)))
-    return TRUE; /* Can't have a NULL name */
+    {
+      my_error(ER_RESERVED_SYNTAX, MYF(0), "NAME_CONST");
+      return TRUE; /* Can't have a NULL name */
+    }
 
   set_name(item_name->ptr(), (uint) item_name->length(), system_charset_info);
   max_length= value_item->max_length;
--- mysql-5.0.bk-orig/mysql-test/t/func_misc.test	Fri Mar  2 02:20:46 2007
+++ mysql-5.0.bk-sub-aggr/mysql-test/t/func_misc.test	Sun Apr  8 21:13:15 2007
@@ -190,3 +190,11 @@
 drop function func_26093_b;
 
 --echo End of 5.0 tests
+
+#
+# Bug #27545: name_const errors in subquery, did not return anything to the client.
+#  As a result the client would hang, waiting for a response
+#
+
+--error ER_RESERVED_SYNTAX
+select * from ( select name_const(x,2) from (select 1 x UNION select 2 union select 4) x ) c;
--- mysql-5.0.bk-orig/mysql-test/r/func_misc.result	Fri Mar  2 02:20:46 2007
+++ mysql-5.0.bk-sub-aggr/mysql-test/r/func_misc.result	Sun Apr  8 21:13:33 2007
@@ -186,3 +186,5 @@
 drop function func_26093_a;
 drop function func_26093_b;
 End of 5.0 tests
+select * from ( select name_const(x,2) from (select 1 x UNION select 2 union select 4) x ) c;
+ERROR HY000: The 'NAME_CONST' syntax is reserved for purposes internal to the MySQL server
