~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/str.h

  • Committer: Stewart Smith
  • Date: 2009-01-12 05:43:13 UTC
  • mto: (784.1.4 for-brian)
  • mto: This revision was merged to the branch mainline in revision 785.
  • Revision ID: stewart@flamingspork.com-20090112054313-edk6kpf4l6kpz4j7
fix archive_basic for drizzle

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 MySQL
 
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; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#ifndef DRIZZLE_SERVER_FIELD_STR
 
22
#define DRIZZLE_SERVER_FIELD_STR
 
23
 
 
24
#include <drizzled/field.h>
 
25
 
 
26
typedef struct charset_info_st CHARSET_INFO;
 
27
 
 
28
/* base class for all string related classes */
 
29
 
 
30
class Field_str :public Field {
 
31
protected:
 
32
  const CHARSET_INFO *field_charset;
 
33
  enum Derivation field_derivation;
 
34
public:
 
35
  Field_str(unsigned char *ptr_arg,uint32_t len_arg,
 
36
            unsigned char *null_ptr_arg,
 
37
            unsigned char null_bit_arg, utype unireg_check_arg,
 
38
            const char *field_name_arg, const CHARSET_INFO * const charset);
 
39
  Item_result result_type () const { return STRING_RESULT; }
 
40
  uint32_t decimals() const { return NOT_FIXED_DEC; }
 
41
  int  store(double nr);
 
42
  int  store(int64_t nr, bool unsigned_val)=0;
 
43
  int  store_decimal(const my_decimal *);
 
44
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const cs)=0;
 
45
  uint32_t size_of() const { return sizeof(*this); }
 
46
  const CHARSET_INFO *charset(void) const { return field_charset; }
 
47
  void set_charset(const CHARSET_INFO * const charset_arg)
 
48
  { field_charset= charset_arg; }
 
49
  enum Derivation derivation(void) const { return field_derivation; }
 
50
  virtual void set_derivation(enum Derivation derivation_arg)
 
51
  { field_derivation= derivation_arg; }
 
52
  bool binary() const { return field_charset == &my_charset_bin; }
 
53
  uint32_t max_display_length() { return field_length; }
 
54
  friend class Create_field;
 
55
  my_decimal *val_decimal(my_decimal *);
 
56
  virtual bool str_needs_quotes() { return true; }
 
57
  bool compare_str_field_flags(Create_field *new_field, uint32_t flags);
 
58
  uint32_t is_equal(Create_field *new_field);
 
59
};
 
60
 
 
61
/*
 
62
  Report "not well formed" or "cannot convert" error
 
63
  after storing a character string info a field.
 
64
 
 
65
  SYNOPSIS
 
66
    check_string_copy_error()
 
67
    field                    - Field
 
68
    well_formed_error_pos    - where not well formed data was first met
 
69
    cannot_convert_error_pos - where a not-convertable character was first met
 
70
    end                      - end of the string
 
71
    cs                       - character set of the string
 
72
 
 
73
  NOTES
 
74
    As of version 5.0 both cases return the same error:
 
75
 
 
76
      "Invalid string value: 'xxx' for column 't' at row 1"
 
77
 
 
78
  Future versions will possibly introduce a new error message:
 
79
 
 
80
      "Cannot convert character string: 'xxx' for column 't' at row 1"
 
81
 
 
82
  RETURN
 
83
    false - If errors didn't happen
 
84
    true  - If an error happened
 
85
*/
 
86
 
 
87
bool check_string_copy_error(Field_str *field,
 
88
                             const char *well_formed_error_pos,
 
89
                             const char *cannot_convert_error_pos,
 
90
                             const char *end,
 
91
                             const CHARSET_INFO * const cs);
 
92
 
 
93
 
 
94
#endif