~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/select_export.h

  • Committer: Monty Taylor
  • Date: 2009-08-12 06:25:19 UTC
  • mto: (1114.1.1 innodb-plugin-merge)
  • mto: This revision was merged to the branch mainline in revision 1183.
  • Revision ID: mordred@inaugust.com-20090812062519-cij02mrrunvnxblt
Tags: innodb-plugin-1.0.4
InnoDB Plugin 1.0.4

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
 
 
21
 
#ifndef DRIZZLED_SELECT_EXPORT_H
22
 
#define DRIZZLED_SELECT_EXPORT_H
23
 
 
24
 
/*
25
 
 List of all possible characters of a numeric value text representation.
26
 
*/
27
 
#define NUMERIC_CHARS ".0123456789e+-"
28
 
 
29
 
namespace drizzled
30
 
{
31
 
 
32
 
class select_export :
33
 
  public select_to_file
34
 
{
35
 
  uint32_t field_term_length;
36
 
  int field_sep_char,escape_char,line_sep_char;
37
 
  int field_term_char; // first char of FIELDS TERMINATED BY or MAX_INT
38
 
  /*
39
 
    The is_ambiguous_field_sep field is true if a value of the field_sep_char
40
 
    field is one of the 'n', 't', 'r' etc characters
41
 
    (see the READ_INFO::unescape method and the ESCAPE_CHARS constant value).
42
 
  */
43
 
  bool is_ambiguous_field_sep;
44
 
  /*
45
 
     The is_ambiguous_field_term is true if field_sep_char contains the first
46
 
     char of the FIELDS TERMINATED BY (ENCLOSED BY is empty), and items can
47
 
     contain this character.
48
 
  */
49
 
  bool is_ambiguous_field_term;
50
 
  /*
51
 
    The is_unsafe_field_sep field is true if a value of the field_sep_char
52
 
    field is one of the '0'..'9', '+', '-', '.' and 'e' characters
53
 
    (see the NUMERIC_CHARS constant value).
54
 
  */
55
 
  bool is_unsafe_field_sep;
56
 
  bool fixed_row_size;
57
 
public:
58
 
  select_export(file_exchange *ex) :
59
 
    select_to_file(ex),
60
 
    field_term_length(0),
61
 
    field_sep_char(0),
62
 
    escape_char(0),
63
 
    line_sep_char(0),
64
 
    field_term_char(0),
65
 
    is_ambiguous_field_sep(0),
66
 
    is_ambiguous_field_term(0),
67
 
    is_unsafe_field_sep(0),
68
 
    fixed_row_size(0)
69
 
  {}
70
 
  ~select_export();
71
 
  int prepare(List<Item> &list, Select_Lex_Unit *u);
72
 
  bool send_data(List<Item> &items);
73
 
private:
74
 
  inline bool needs_escaping(char character, bool enclosed)
75
 
  {
76
 
    if ((character == escape_char) ||
77
 
        (enclosed ? character == field_sep_char : character == field_term_char) ||
78
 
        character == line_sep_char  ||
79
 
        (character == 0))
80
 
      return true;
81
 
 
82
 
    return false;
83
 
 
84
 
  }
85
 
};
86
 
 
87
 
} /* namespace drizzled */
88
 
 
89
 
#endif /* DRIZZLED_SELECT_EXPORT_H */