~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/stored_key.cc

  • Committer: Stewart Smith
  • Date: 2010-02-22 07:44:37 UTC
  • mfrom: (1283.17.4)
  • mto: (1283.19.1)
  • mto: This revision was merged to the branch mainline in revision 1449.
  • Revision ID: stewart@flamingspork.com-20100222074437-1a9x1n030tbtv1qv
Merged embeddded-innodb-store-table-proto into embedded-innodb-write-row.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#include <config.h>
21
 
 
22
 
#include <drizzled/field/varstring.h>
23
 
#include <drizzled/session.h>
24
 
#include <drizzled/stored_key.h>
25
 
#include <drizzled/table.h>
26
 
 
27
 
namespace drizzled {
28
 
 
29
 
StoredKey::StoredKey(Session *session,
30
 
                     Field *field_arg, 
31
 
                     unsigned char *ptr,
32
 
                     unsigned char *null, 
33
 
                     uint32_t length) :
34
 
  null_key(0), 
35
 
  null_ptr(null), 
36
 
  err(0)
37
 
  {
38
 
    if (field_arg->type() == DRIZZLE_TYPE_BLOB)
39
 
    {
40
 
      /*
41
 
        Key segments are always packed with a 2 byte length prefix.
42
 
        See mi_rkey for details.
43
 
      */
44
 
      to_field= new Field_varstring(ptr,
45
 
                                    length,
46
 
                                    2,
47
 
                                    null,
48
 
                                    1,
49
 
                                    field_arg->field_name,
50
 
                                    field_arg->charset());
51
 
      to_field->init(field_arg->getTable());
52
 
    }
53
 
    else
54
 
    {
55
 
      to_field= field_arg->new_key_field(session->mem_root, field_arg->getTable(),
56
 
                                         ptr, null, 1);
57
 
    }
58
 
 
59
 
    to_field->setWriteSet();
60
 
  }
61
 
 
62
 
StoredKey::store_key_result StoredKey::copy()
63
 
{
64
 
  store_key_result result;
65
 
  Session *session= to_field->getTable()->in_use;
66
 
  enum_check_fields saved_count_cuted_fields= session->count_cuted_fields;
67
 
  session->count_cuted_fields= CHECK_FIELD_IGNORE;
68
 
  result= copy_inner();
69
 
  session->count_cuted_fields= saved_count_cuted_fields;
70
 
 
71
 
  return result;
72
 
}
73
 
 
74
 
} /* namespace drizzled */