~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sj_tmp_table.cc

  • Committer: Monty Taylor
  • Date: 2009-05-24 23:54:21 UTC
  • mfrom: (1014.2.12 kill-malloc)
  • mto: This revision was merged to the branch mainline in revision 1039.
  • Revision ID: mordred@inaugust.com-20090524235421-x5vfss90auzbn896
Merged Monty from lp:~mordred/drizzle/kill-malloc

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
  MEM_ROOT *mem_root_save, own_root;
63
63
  Table *table;
64
64
  TableShare *share;
65
 
  uint32_t temp_pool_slot= MY_BIT_NONE;
66
65
  char  *tmpname,path[FN_REFLEN];
67
66
  Field **reg_field;
68
67
  KEY_PART_INFO *key_part_info;
81
80
    STEP 1: Get temporary table name
82
81
  */
83
82
  statistic_increment(session->status_var.created_tmp_tables, &LOCK_status);
84
 
  if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
85
 
    temp_pool_slot = bitmap_lock_set_next(&temp_pool);
86
83
 
87
 
  if (temp_pool_slot != MY_BIT_NONE) // we got a slot
88
 
    sprintf(path, "%s_%lx_%i", TMP_FILE_PREFIX,
89
 
            (unsigned long)current_pid, temp_pool_slot);
90
 
  else
91
 
  {
92
 
    /* if we run out of slots or we are not using tempool */
93
 
    sprintf(path,"%s%lx_%"PRIx64"_%x", TMP_FILE_PREFIX, (unsigned long)current_pid,
94
 
            session->thread_id, session->tmp_table++);
95
 
  }
 
84
  /* if we run out of slots or we are not using tempool */
 
85
  sprintf(path,"%s%lx_%"PRIx64"_%x", TMP_FILE_PREFIX, (unsigned long)current_pid,
 
86
          session->thread_id, session->tmp_table++);
96
87
  fn_format(path, path, drizzle_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME);
97
88
 
98
89
  /* STEP 2: Figure if we'll be using a key or blob+constraint */
116
107
                        &bitmaps, bitmap_buffer_size(1)*2,
117
108
                        NULL))
118
109
  {
119
 
    if (temp_pool_slot != MY_BIT_NONE)
120
 
      bitmap_lock_clear_bit(&temp_pool, temp_pool_slot);
121
110
    return NULL;
122
111
  }
123
112
  strcpy(tmpname,path);
135
124
  table->reginfo.lock_type=TL_WRITE;  /* Will be updated */
136
125
  table->db_stat=HA_OPEN_KEYFILE+HA_OPEN_RNDFILE;
137
126
  table->map=1;
138
 
  table->temp_pool_slot = temp_pool_slot;
139
127
  table->copy_blobs= 1;
140
128
  table->in_use= session;
141
129
  table->quick_keys.reset();
328
316
err:
329
317
  session->mem_root= mem_root_save;
330
318
  table->free_tmp_table(session);                    /* purecov: inspected */
331
 
  if (temp_pool_slot != MY_BIT_NONE)
332
 
    bitmap_lock_clear_bit(&temp_pool, temp_pool_slot);
333
319
  return NULL;        /* purecov: inspected */
334
320
}