$OpenBSD: patch-sql_item_strfunc_cc,v 1.1 2003/08/26 15:37:18 brad Exp $
--- sql/item_strfunc.cc.orig	2003-08-24 17:21:25.000000000 -0400
+++ sql/item_strfunc.cc	2003-08-24 17:22:18.000000000 -0400
@@ -1094,7 +1094,8 @@ String *Item_func_database::val_str(Stri
 String *Item_func_user::val_str(String *str)
 {
   THD *thd=current_thd;
-  if (str->copy((const char*) thd->user,(uint) strlen(thd->user)) ||
+  if (!(thd->user) || // for system threads (e.g. replication thread)
+      str->copy((const char*) thd->user,(uint) strlen(thd->user)) ||
       str->append('@') ||
       str->append(thd->host ? thd->host : thd->ip ? thd->ip : ""))
     return &empty_string;
