summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2002-10-16 13:11:25 +0300
committerunknown <monty@hundin.mysql.fi>2002-10-16 13:11:25 +0300
commit7013d8ef0ae0a21fadfcc0a159ee1d83fdad8a9d (patch)
treed165b4baadac24102545d94c8f9fe180537a64f5 /sql/sql_select.cc
parente1d7b8414f14de681127f4e19340e4f7737d5bdb (diff)
parent74b73109c1304e62430faa85d2a63a6f2ffa626d (diff)
downloadmariadb-git-7013d8ef0ae0a21fadfcc0a159ee1d83fdad8a9d.tar.gz
Merge with 3.23.54
BitKeeper/etc/logging_ok: auto-union BitKeeper/deleted/.del-LICENSE~4cfaff8de837acb8: Auto merged BitKeeper/deleted/.del-MySQLEULA.txt: Delete: Docs/MySQLEULA.txt BitKeeper/deleted/.del-global.h~e80d28157acfdcb5: Auto merged Build-tools/mysql-copyright-2: Auto merged Build-tools/mysql-copyright: Auto merged heap/heapdef.h: Auto merged heap/hp_open.c: Auto merged innobase/btr/btr0cur.c: Auto merged innobase/lock/lock0lock.c: Auto merged innobase/os/os0file.c: Auto merged innobase/os/os0thread.c: Auto merged myisam/mi_open.c: Auto merged mysql-test/Makefile.am: Auto merged mysql-test/t/null_key.test: Auto merged mysys/safemalloc.c: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysqld_safe.sh: Auto merged scripts/mysqlhotcopy.sh: Auto merged sql/field.h: Auto merged sql/field_conv.cc: Auto merged sql/ha_innodb.h: Auto merged sql/item.cc: Auto merged sql/sql_db.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/table.cc: Auto merged tests/grant.res: Auto merged Build-tools/Do-compile: merge Docs/manual.texi: merge configure.in: merge mysql-test/r/distinct.result: merge mysql-test/r/null_key.result: merge sql/ha_innodb.cc: merge sql/item.h: merge sql/log.cc: merge sql/mysqld.cc: merge support-files/mysql.spec.sh: merge
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc30
1 files changed, 25 insertions, 5 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 042fb779ec2..fc5fe33288f 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -3527,7 +3527,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
char *tmpname,path[FN_REFLEN];
byte *pos,*group_buff;
uchar *null_flags;
- Field **reg_field,**from_field;
+ Field **reg_field, **from_field, **blob_field;
Copy_field *copy=0;
KEY *keyinfo;
KEY_PART_INFO *key_part_info;
@@ -3572,8 +3572,9 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
hidden_field_count=param->hidden_field_count;
if (!my_multi_malloc(MYF(MY_WME),
&table,sizeof(*table),
- &reg_field,sizeof(Field*)*(field_count+1),
- &from_field,sizeof(Field*)*field_count,
+ &reg_field, sizeof(Field*)*(field_count+1),
+ &blob_field, sizeof(Field*)*(field_count+1),
+ &from_field, sizeof(Field*)*field_count,
&copy_func,sizeof(*copy_func)*(param->func_count+1),
&param->keyinfo,sizeof(*param->keyinfo),
&key_part_info,
@@ -3602,8 +3603,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
bzero((char*) reg_field,sizeof(Field*)*(field_count+1));
bzero((char*) from_field,sizeof(Field*)*field_count);
table->field=reg_field;
+ table->blob_field= (Field_blob**) blob_field;
table->real_name=table->path=tmpname;
- table->table_name=base_name(tmpname);
+ /*
+ This must be "" as field may refer to it after tempory table is dropped
+ */
+ table->table_name= (char*) "";
table->reginfo.lock_type=TL_WRITE; /* Will be updated */
table->db_stat=HA_OPEN_KEYFILE+HA_OPEN_RNDFILE;
table->blob_ptr_size=mi_portable_sizeof_char_ptr;
@@ -3611,7 +3616,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
table->tmp_table= TMP_TABLE;
table->db_low_byte_first=1; // True for HEAP and MyISAM
table->temp_pool_slot = temp_pool_slot;
-
+ table->copy_blobs= 1;
/* Calculate which type of fields we will store in the temporary table */
@@ -3658,7 +3663,10 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
if (!(new_field->flags & NOT_NULL_FLAG))
null_count++;
if (new_field->flags & BLOB_FLAG)
+ {
+ *blob_field++= new_field;
blob_count++;
+ }
((Item_sum*) item)->args[i]= new Item_field(new_field);
}
}
@@ -3681,7 +3689,10 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
if (!(new_field->flags & NOT_NULL_FLAG))
null_count++;
if (new_field->flags & BLOB_FLAG)
+ {
+ *blob_field++= new_field;
blob_count++;
+ }
if (item->marker == 4 && item->maybe_null)
{
group_null_items++;
@@ -3694,6 +3705,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
}
DBUG_ASSERT(field_count >= (uint) (reg_field - table->field));
field_count= (uint) (reg_field - table->field);
+ *blob_field= 0; // End marker
/* If result table is small; use a heap */
if (blob_count || using_unique_constraint || group_null_items ||
@@ -3951,10 +3963,17 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
if (create_myisam_tmp_table(table,param,select_options))
goto err;
}
+ /* Set table_name for easier debugging */
+ table->table_name= base_name(tmpname);
if (!open_tmp_table(table))
DBUG_RETURN(table);
err:
+ /*
+ Hack to ensure that free_blobs() doesn't fail if blob_field is not yet
+ complete
+ */
+ *table->blob_field= 0;
free_tmp_table(thd,table); /* purecov: inspected */
bitmap_clear_bit(&temp_pool, temp_pool_slot);
DBUG_RETURN(NULL); /* purecov: inspected */
@@ -4096,6 +4115,7 @@ free_tmp_table(THD *thd, TABLE *entry)
save_proc_info=thd->proc_info;
thd->proc_info="removing tmp table";
+ free_blobs(entry);
if (entry->db_stat && entry->file)
{
(void) entry->file->close();