~hartmut-php/drizzle/drizzle-codegen

« back to all changes in this revision

Viewing changes to drizzled/handler.cc

  • Committer: Hartmut Holzgraefe
  • Date: 2009-02-21 11:38:51 UTC
  • mfrom: (884.1.12 drizzle)
  • Revision ID: hartmut@mysql.com-20090221113851-p2n577trxbr8ip7v
mergeĀ fromĀ lp:drizzle

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
  Handler-calling-functions
24
24
*/
25
25
 
26
 
#include <drizzled/server_includes.h>
27
 
#include <libdrizzleclient/libdrizzle.h>
28
 
#include <mysys/hash.h>
29
 
#include <drizzled/error.h>
30
 
#include <drizzled/gettext.h>
31
 
#include <drizzled/data_home.h>
32
 
#include <drizzled/probes.h>
33
 
#include <drizzled/sql_parse.h>
34
 
#include <drizzled/cost_vect.h>
 
26
#include "drizzled/server_includes.h"
 
27
#include "libdrizzleclient/libdrizzle.h"
 
28
#include "mysys/hash.h"
 
29
#include "drizzled/error.h"
 
30
#include "drizzled/gettext.h"
 
31
#include "drizzled/data_home.h"
 
32
#include "drizzled/probes.h"
 
33
#include "drizzled/sql_parse.h"
 
34
#include "drizzled/cost_vect.h"
35
35
#include CMATH_H
36
 
#include <drizzled/session.h>
37
 
#include <drizzled/sql_base.h>
38
 
#include <drizzled/replicator.h>
39
 
#include <drizzled/lock.h>
40
 
#include <drizzled/item/int.h>
41
 
#include <drizzled/item/empty_string.h>
42
 
#include <drizzled/unireg.h> // for mysql_frm_type
43
 
#include <drizzled/serialize/table.pb.h>
 
36
#include "drizzled/session.h"
 
37
#include "drizzled/sql_base.h"
 
38
#include "drizzled/replicator.h"
 
39
#include "drizzled/lock.h"
 
40
#include "drizzled/item/int.h"
 
41
#include "drizzled/item/empty_string.h"
 
42
#include "drizzled/unireg.h" // for mysql_frm_type
 
43
#include "drizzled/field/timestamp.h"
 
44
#include "drizzled/serialize/table.pb.h"
44
45
 
45
46
#if defined(CMATH_NAMESPACE)
46
47
using namespace CMATH_NAMESPACE;
2106
2107
  else
2107
2108
  {
2108
2109
    /* Table is opened and defined at this point */
2109
 
    key_unpack(&str,table,(uint) key_nr);
2110
 
    uint32_t max_length=DRIZZLE_ERRMSG_SIZE-(uint) strlen(msg);
 
2110
    key_unpack(&str,table,(uint32_t) key_nr);
 
2111
    uint32_t max_length=DRIZZLE_ERRMSG_SIZE-(uint32_t) strlen(msg);
2111
2112
    if (str.length() >= max_length)
2112
2113
    {
2113
2114
      str.length(max_length-4);
2170
2171
      char key[MAX_KEY_LENGTH];
2171
2172
      String str(key,sizeof(key),system_charset_info);
2172
2173
      /* Table is opened and defined at this point */
2173
 
      key_unpack(&str,table,(uint) key_nr);
 
2174
      key_unpack(&str,table,(uint32_t) key_nr);
2174
2175
      max_length= (DRIZZLE_ERRMSG_SIZE-
2175
 
                   (uint) strlen(ER(ER_FOREIGN_DUPLICATE_KEY)));
 
2176
                   (uint32_t) strlen(ER(ER_FOREIGN_DUPLICATE_KEY)));
2176
2177
      if (str.length() >= max_length)
2177
2178
      {
2178
2179
        str.length(max_length-4);
2369
2370
*/
2370
2371
uint32_t handler::get_dup_key(int error)
2371
2372
{
2372
 
  table->file->errkey  = (uint) -1;
 
2373
  table->file->errkey  = (uint32_t) -1;
2373
2374
  if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY ||
2374
2375
      error == HA_ERR_FOUND_DUPP_UNIQUE ||
2375
2376
      error == HA_ERR_DROP_INDEX_FK)
2849
2850
 
2850
2851
  init_tmp_table_share(session, &share, db, 0, table_name, path);
2851
2852
  if (open_table_def(session, &share, 0) ||
2852
 
      open_table_from_share(session, &share, "", 0, (uint) READ_ALL, 0, &table,
 
2853
      open_table_from_share(session, &share, "", 0, (uint32_t) READ_ALL, 0, &table,
2853
2854
                            OTM_CREATE))
2854
2855
    goto err;
2855
2856
 
2897
2898
  {
2898
2899
    pthread_mutex_lock(&LOCK_global_system_variables);
2899
2900
    uint32_t tmp_buff_size= (uint32_t) key_cache->param_buff_size;
2900
 
    uint32_t tmp_block_size= (uint) key_cache->param_block_size;
 
2901
    uint32_t tmp_block_size= (uint32_t) key_cache->param_block_size;
2901
2902
    uint32_t division_limit= key_cache->param_division_limit;
2902
2903
    uint32_t age_threshold=  key_cache->param_age_threshold;
2903
2904
    pthread_mutex_unlock(&LOCK_global_system_variables);
3172
3173
    cost->zero();
3173
3174
    cost->avg_io_cost= 1; /* assume random seeks */
3174
3175
    if ((*flags & HA_MRR_INDEX_ONLY) && total_rows > 2)
3175
 
      cost->io_count= index_only_read_time(keyno, (uint)total_rows);
 
3176
      cost->io_count= index_only_read_time(keyno, (uint32_t)total_rows);
3176
3177
    else
3177
3178
      cost->io_count= read_time(keyno, n_ranges, total_rows);
3178
3179
    cost->cpu_cost= (double) total_rows / TIME_FOR_COMPARE + 0.01;
3779
3780
    return true; /* Buffer has not enough space for even 1 rowid */
3780
3781
 
3781
3782
  /* Number of iterations we'll make with full buffer */
3782
 
  n_full_steps= (uint)floor(rows2double(rows) / max_buff_entries);
 
3783
  n_full_steps= (uint32_t)floor(rows2double(rows) / max_buff_entries);
3783
3784
 
3784
3785
  /*
3785
3786
    Get numbers of rows we'll be processing in
3901
3902
  if (table->file->primary_key_is_clustered())
3902
3903
  {
3903
3904
    cost->io_count= table->file->read_time(table->s->primary_key,
3904
 
                                           (uint) nrows, nrows);
 
3905
                                           (uint32_t) nrows, nrows);
3905
3906
  }
3906
3907
  else
3907
3908
  {
4279
4280
  int error;
4280
4281
  DRIZZLE_INSERT_ROW_START();
4281
4282
 
 
4283
  /* 
 
4284
   * If we have a timestamp column, update it to the current time 
 
4285
   * 
 
4286
   * @TODO Technically, the below two lines can be take even further out of the
 
4287
   * handler interface and into the fill_record() method.
 
4288
   */
 
4289
  if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
 
4290
    table->timestamp_field->set_time();
 
4291
 
4282
4292
  mark_trx_read_write();
4283
4293
 
4284
4294
  if (unlikely(error= write_row(buf)))