diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index 343ab89e6b5836fd539bb0465e06f23a3fae9047..2405c34b9fb545a2e46e1f583fea7d60526f66f8 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -529,3 +529,14 @@ t5	CREATE TABLE `t5` (
   KEY `PRIMARY_2` (`PRIMARY`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1, t2, t3, t4, t5;
+CREATE TABLE t1(id varchar(10) NOT NULL PRIMARY KEY, dsc longtext);
+INSERT INTO t1 VALUES ('5000000001', NULL),('5000000003', 'Test'),('5000000004', NULL);
+CREATE TABLE t2(id varchar(15) NOT NULL, proc varchar(100) NOT NULL, runID varchar(16) NOT NULL, start datetime NOT NULL, PRIMARY KEY  (id,proc,runID,start));
+INSERT INTO t2 VALUES ('5000000001', 'proc01', '20031029090650', '2003-10-29 13:38:40'),('5000000001', 'proc02', '20031029090650', '2003-10-29 13:38:51'),('5000000001', 'proc03', '20031029090650', '2003-10-29 13:38:11'),('5000000002', 'proc09', '20031024013310', '2003-10-24 01:33:11'),('5000000002', 'proc09', '20031024153537', '2003-10-24 15:36:04'),('5000000004', 'proc01', '20031024013641', '2003-10-24 01:37:29'),('5000000004', 'proc02', '20031024013641', '2003-10-24 01:37:39');
+CREATE TABLE t3  SELECT t1.dsc,COUNT(DISTINCT t2.id) AS countOfRuns  FROM t1 LEFT JOIN t2 ON (t1.id=t2.id) GROUP BY t1.id;
+SELECT * FROM t3;
+dsc	countOfRuns
+NULL	1
+Test	0
+NULL	1
+drop table t1, t2, t3;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 253aa1bd8b9d1cabdf52d430fc9afb099e18f1a0..0d9b0ffcb6bca95a3051fb3e1045ad8244fbfc7f 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -410,3 +410,17 @@ alter table t5 add index(`PRIMARY`);
 show create table t5;
 
 drop table t1, t2, t3, t4, t5;
+
+#
+# bug #3266 TEXT in CREATE TABLE SELECT
+#
+
+CREATE TABLE t1(id varchar(10) NOT NULL PRIMARY KEY, dsc longtext);
+INSERT INTO t1 VALUES ('5000000001', NULL),('5000000003', 'Test'),('5000000004', NULL);
+CREATE TABLE t2(id varchar(15) NOT NULL, proc varchar(100) NOT NULL, runID varchar(16) NOT NULL, start datetime NOT NULL, PRIMARY KEY  (id,proc,runID,start));
+
+INSERT INTO t2 VALUES ('5000000001', 'proc01', '20031029090650', '2003-10-29 13:38:40'),('5000000001', 'proc02', '20031029090650', '2003-10-29 13:38:51'),('5000000001', 'proc03', '20031029090650', '2003-10-29 13:38:11'),('5000000002', 'proc09', '20031024013310', '2003-10-24 01:33:11'),('5000000002', 'proc09', '20031024153537', '2003-10-24 15:36:04'),('5000000004', 'proc01', '20031024013641', '2003-10-24 01:37:29'),('5000000004', 'proc02', '20031024013641', '2003-10-24 01:37:39');
+
+CREATE TABLE t3  SELECT t1.dsc,COUNT(DISTINCT t2.id) AS countOfRuns  FROM t1 LEFT JOIN t2 ON (t1.id=t2.id) GROUP BY t1.id;
+SELECT * FROM t3;
+drop table t1, t2, t3;
diff --git a/sql/item.cc b/sql/item.cc
index 124310b68d597a6abd4d9b3e3964e28a7f546fbc..e889bbf19307d8374a1f0c1a6d6b1c3406205afc 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1284,8 +1284,8 @@ int Item::save_in_field(Field *field, bool no_conversions)
     String *result;
     CHARSET_INFO *cs= collation.collation;
     char buff[MAX_FIELD_WIDTH];		// Alloc buffer for small columns
-    str_value.set_quick(buff,sizeof(buff),cs);
-    result=val_str(&str_value);
+    String loc_value(buff, sizeof(buff), cs);
+    result=val_str(&loc_value);
     if (null_value)
       return set_field_to_null_with_conversions(field, no_conversions);
     field->set_notnull();