~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sj_tmp_table.cc

  • Committer: Brian Aker
  • Date: 2008-10-20 04:28:21 UTC
  • mto: (492.3.21 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: brian@tangent.org-20081020042821-rqqdrccuu8195k3y
Second pass of thd cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
  SYNOPSIS
26
26
 
27
27
  create_duplicate_weedout_tmp_table()
28
 
  thd
 
28
  session
29
29
  uniq_tuple_length_arg
30
30
  SJ_TMP_TABLE
31
31
 
52
52
  NULL on error
53
53
*/
54
54
 
55
 
Table *create_duplicate_weedout_tmp_table(Session *thd,
 
55
Table *create_duplicate_weedout_tmp_table(Session *session,
56
56
                                          uint32_t uniq_tuple_length_arg,
57
57
                                          SJ_TMP_TABLE *sjtbl)
58
58
{
77
77
  /*
78
78
    STEP 1: Get temporary table name
79
79
  */
80
 
  statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
 
80
  statistic_increment(session->status_var.created_tmp_tables, &LOCK_status);
81
81
  if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
82
82
    temp_pool_slot = bitmap_lock_set_next(&temp_pool);
83
83
 
88
88
  {
89
89
    /* if we run out of slots or we are not using tempool */
90
90
    sprintf(path,"%s%lx_%lx_%x", tmp_file_prefix,current_pid,
91
 
            thd->thread_id, thd->tmp_table++);
 
91
            session->thread_id, session->tmp_table++);
92
92
  }
93
93
  fn_format(path, path, mysql_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME);
94
94
 
124
124
  memset(reg_field, 0, sizeof(Field*)*2);
125
125
 
126
126
  table->mem_root= own_root;
127
 
  mem_root_save= thd->mem_root;
128
 
  thd->mem_root= &table->mem_root;
 
127
  mem_root_save= session->mem_root;
 
128
  session->mem_root= &table->mem_root;
129
129
 
130
130
  table->field=reg_field;
131
131
  table->alias= "weedout-tmp";
134
134
  table->map=1;
135
135
  table->temp_pool_slot = temp_pool_slot;
136
136
  table->copy_blobs= 1;
137
 
  table->in_use= thd;
 
137
  table->in_use= session;
138
138
  table->quick_keys.init();
139
139
  table->covering_keys.init();
140
140
  table->keys_in_use_for_query.init();
141
141
 
142
142
  table->s= share;
143
 
  init_tmp_table_share(thd, share, "", 0, tmpname, tmpname);
 
143
  init_tmp_table_share(session, share, "", 0, tmpname, tmpname);
144
144
  share->blob_field= blob_field;
145
145
  share->blob_ptr_size= portable_sizeof_char_ptr;
146
146
  share->db_low_byte_first=1;                // True for HEAP and MyISAM
261
261
  //param->recinfo=recinfo;
262
262
  //store_record(table,s->default_values);        // Make empty default record
263
263
 
264
 
  if (thd->variables.tmp_table_size == ~ (uint64_t) 0)    // No limit
 
264
  if (session->variables.tmp_table_size == ~ (uint64_t) 0)    // No limit
265
265
    share->max_rows= ~(ha_rows) 0;
266
266
  else
267
267
    share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
268
 
                                 cmin(thd->variables.tmp_table_size,
269
 
                                      thd->variables.max_heap_table_size) :
270
 
                                 thd->variables.tmp_table_size) /
 
268
                                 cmin(session->variables.tmp_table_size,
 
269
                                      session->variables.max_heap_table_size) :
 
270
                                 session->variables.tmp_table_size) /
271
271
                                share->reclength);
272
272
  set_if_bigger(share->max_rows,1);    // For dummy start options
273
273
 
294
294
      key_part_info->key_type = FIELDFLAG_BINARY;
295
295
      if (!using_unique_constraint)
296
296
      {
297
 
        if (!(key_field= field->new_key_field(thd->mem_root, table,
 
297
        if (!(key_field= field->new_key_field(session->mem_root, table,
298
298
                                              group_buff,
299
299
                                              field->null_ptr,
300
300
                                              field->null_bit)))
305
305
    }
306
306
  }
307
307
 
308
 
  if (thd->is_fatal_error)        // If end of memory
 
308
  if (session->is_fatal_error)        // If end of memory
309
309
    goto err;
310
310
  share->db_record_offset= 1;
311
311
  if (share->db_type() == myisam_hton)
319
319
  if (table->open_tmp_table())
320
320
    goto err;
321
321
 
322
 
  thd->mem_root= mem_root_save;
 
322
  session->mem_root= mem_root_save;
323
323
  return(table);
324
324
 
325
325
err:
326
 
  thd->mem_root= mem_root_save;
327
 
  table->free_tmp_table(thd);                    /* purecov: inspected */
 
326
  session->mem_root= mem_root_save;
 
327
  table->free_tmp_table(session);                    /* purecov: inspected */
328
328
  if (temp_pool_slot != MY_BIT_NONE)
329
329
    bitmap_lock_clear_bit(&temp_pool, temp_pool_slot);
330
330
  return(NULL);        /* purecov: inspected */