~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Brian Aker
  • Date: 2009-08-18 07:20:29 UTC
  • mfrom: (1117.1.9 merge)
  • Revision ID: brian@gaz-20090818072029-s9ch5lcmltxwidn7
Merge of Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
281
281
  int error= 0;
282
282
  handler *handler_file= NULL;
283
283
 
284
 
  {
285
 
    share->storage_engine= ha_resolve_by_name(session, table.engine().name());
286
 
  }
 
284
  share->setTableProto(new(std::nothrow) drizzled::message::Table(table));
 
285
 
 
286
  share->storage_engine= ha_resolve_by_name(session, table.engine().name());
287
287
 
288
288
  drizzled::message::Table::TableOptions table_options;
289
289
 
290
290
  if (table.has_options())
291
291
    table_options= table.options();
292
292
 
293
 
  uint32_t db_create_options= HA_OPTION_LONG_BLOB_PTR;
 
293
  uint32_t db_create_options= 0;
294
294
 
295
295
  if (table_options.has_pack_keys())
296
296
  {
303
303
  if (table_options.pack_record())
304
304
    db_create_options|= HA_OPTION_PACK_RECORD;
305
305
 
306
 
  if (table_options.has_checksum())
307
 
  {
308
 
    if (table_options.checksum())
309
 
      db_create_options|= HA_OPTION_CHECKSUM;
310
 
    else
311
 
      db_create_options|= HA_OPTION_NO_CHECKSUM;
312
 
  }
313
 
 
314
 
  if (table_options.has_delay_key_write())
315
 
  {
316
 
    if (table_options.delay_key_write())
317
 
      db_create_options|= HA_OPTION_DELAY_KEY_WRITE;
318
 
    else
319
 
      db_create_options|= HA_OPTION_NO_DELAY_KEY_WRITE;
320
 
  }
321
 
 
322
306
  /* db_create_options was stored as 2 bytes in FRM
323
307
     Any HA_OPTION_ that doesn't fit into 2 bytes was silently truncated away.
324
308
   */
325
309
  share->db_create_options= (db_create_options & 0x0000FFFF);
326
310
  share->db_options_in_use= share->db_create_options;
327
311
 
328
 
 
329
 
  share->avg_row_length= table_options.has_avg_row_length() ?
330
 
    table_options.avg_row_length() : 0;
331
 
 
332
312
  share->page_checksum= table_options.has_page_checksum() ?
333
313
    (table_options.page_checksum()?HA_CHOICE_YES:HA_CHOICE_NO)
334
314
    : HA_CHOICE_UNDEF;
363
343
 
364
344
  share->db_low_byte_first= true;
365
345
 
366
 
  share->max_rows= table_options.has_max_rows() ?
367
 
    table_options.max_rows() : 0;
368
 
 
369
 
  share->min_rows= table_options.has_min_rows() ?
370
 
    table_options.min_rows() : 0;
371
 
 
372
346
  share->keys= table.indexes_size();
373
347
 
374
348
  share->key_parts= 0;
536
510
    share->connect_string.str= strmake_root(&share->mem_root, str, len);
537
511
  }
538
512
 
539
 
  if (table_options.has_comment())
540
 
  {
541
 
    size_t len= table_options.comment().length();
542
 
    const char* str= table_options.comment().c_str();
543
 
 
544
 
    share->comment.length= len;
545
 
    share->comment.str= strmake_root(&share->mem_root, str, len);
546
 
  }
547
 
 
548
513
  share->key_block_size= table_options.has_key_block_size() ?
549
514
    table_options.key_block_size() : 0;
550
515
 
1785
1750
 
1786
1751
 
1787
1752
 
1788
 
void Table::updateCreateInfo(HA_CREATE_INFO *create_info)
 
1753
void Table::updateCreateInfo(HA_CREATE_INFO *create_info,
 
1754
                             drizzled::message::Table *table_proto)
1789
1755
{
1790
 
  create_info->max_rows= s->max_rows;
1791
 
  create_info->min_rows= s->min_rows;
 
1756
  drizzled::message::Table::TableOptions *table_options= table_proto->mutable_options();
1792
1757
  create_info->table_options= s->db_create_options;
1793
 
  create_info->avg_row_length= s->avg_row_length;
1794
1758
  create_info->block_size= s->block_size;
1795
1759
  create_info->row_type= s->row_type;
1796
1760
  create_info->default_table_charset= s->table_charset;
1797
1761
  create_info->table_charset= 0;
1798
 
  create_info->comment= s->comment;
1799
 
 
1800
 
  return;
 
1762
  table_options->set_comment(s->getComment());
1801
1763
}
1802
1764
 
1803
1765
int rename_file_ext(const char * from,const char * to,const char * ext)
2337
2299
  MI_COLUMNDEF *recinfo;
2338
2300
  uint32_t total_uneven_bit_length= 0;
2339
2301
  bool force_copy_fields= param->force_copy_fields;
 
2302
  uint64_t max_rows= 0;
2340
2303
 
2341
2304
  status_var_increment(session->status_var.created_tmp_tables);
2342
2305
 
2769
2732
  table->storeRecordAsDefault();        // Make empty default record
2770
2733
 
2771
2734
  if (session->variables.tmp_table_size == ~ (uint64_t) 0)              // No limit
2772
 
    share->max_rows= ~(ha_rows) 0;
 
2735
    max_rows= ~(uint64_t) 0;
2773
2736
  else
2774
 
    share->max_rows= (ha_rows) (((share->db_type() == heap_engine) ?
2775
 
                                 min(session->variables.tmp_table_size,
2776
 
                                     session->variables.max_heap_table_size) :
2777
 
                                 session->variables.tmp_table_size) /
2778
 
                                 share->reclength);
 
2737
    max_rows= (uint64_t) (((share->db_type() == heap_engine) ?
 
2738
                          min(session->variables.tmp_table_size,
 
2739
                              session->variables.max_heap_table_size) :
 
2740
                          session->variables.tmp_table_size) /
 
2741
                         share->reclength);
2779
2742
 
2780
 
  set_if_bigger(share->max_rows,(ha_rows)1);    // For dummy start options
 
2743
  set_if_bigger(max_rows, (uint64_t)1); // For dummy start options
2781
2744
  /*
2782
2745
    Push the LIMIT clause to the temporary table creation, so that we
2783
2746
    materialize only up to 'rows_limit' records instead of all result records.
2784
2747
  */
2785
 
  set_if_smaller(share->max_rows, rows_limit);
 
2748
  set_if_smaller(max_rows, rows_limit);
 
2749
 
 
2750
  share->setMaxRows(max_rows);
 
2751
 
2786
2752
  param->end_write_records= rows_limit;
2787
2753
 
2788
2754
  keyinfo= param->keyinfo;