Description:
UPDATE a blob column with load_file() or with a long string.
How to repeat:
drop table if exists teste;
create table teste ( id integer auto_increment unique,imagem LONGBLOB not null);
insert into teste (id) values (1);
update teste set imagem=load_file("/mnt/mail/archive/slike/pic1.jpg") where id=1;
select if(imagem is null, "ERRO", "OK") from teste where id = 1;
drop table if exists teste;
Suggested fix:
===== sql/sql_update.cc 1.74 vs edited =====
*** /tmp/sql_update.cc-1.74-30953 Wed Dec 18 18:59:56 2002
--- edited/sql/sql_update.cc Tue Feb 4 19:11:08 2003
***************
*** 116,121 ****
--- 116,122 ----
// Don't count on usage of 'only index' when calculating which key to use
table->used_keys=0;
+ table->copy_blobs=1;
select=make_select(table,0,0,conds,&error);
if (error ||
(select && select->check_quick(safe_update, limit)) || !limit)
***************
*** 474,479 ****
--- 475,481 ----
tl->shared= table_count++;
table->no_keyread=1;
table->used_keys=0;
+ table->copy_blobs=1;
table->pos_in_table_list= tl;
}
}
Description: UPDATE a blob column with load_file() or with a long string. How to repeat: drop table if exists teste; create table teste ( id integer auto_increment unique,imagem LONGBLOB not null); insert into teste (id) values (1); update teste set imagem=load_file("/mnt/mail/archive/slike/pic1.jpg") where id=1; select if(imagem is null, "ERRO", "OK") from teste where id = 1; drop table if exists teste; Suggested fix: ===== sql/sql_update.cc 1.74 vs edited ===== *** /tmp/sql_update.cc-1.74-30953 Wed Dec 18 18:59:56 2002 --- edited/sql/sql_update.cc Tue Feb 4 19:11:08 2003 *************** *** 116,121 **** --- 116,122 ---- // Don't count on usage of 'only index' when calculating which key to use table->used_keys=0; + table->copy_blobs=1; select=make_select(table,0,0,conds,&error); if (error || (select && select->check_quick(safe_update, limit)) || !limit) *************** *** 474,479 **** --- 475,481 ---- tl->shared= table_count++; table->no_keyread=1; table->used_keys=0; + table->copy_blobs=1; table->pos_in_table_list= tl; } }