~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/functions/str/quote.cc

  • Committer: Monty Taylor
  • Date: 2008-11-16 05:36:13 UTC
  • mto: (584.1.9 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116053613-bld4rqxhlkb49c02
Split out cache_row and type_holder.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
22
 
#include "quote.h"
23
 
 
24
 
#include <drizzled/lex_string.h>
25
 
 
26
 
namespace drizzled
27
 
{
28
 
 
29
 
inline
30
 
static uint32_t get_esc_bit(unsigned char *mask, unsigned char num)
31
 
{
32
 
  return (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7));
33
 
}
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/functions/str/quote.h>
 
23
 
 
24
 
 
25
#define get_esc_bit(mask, num) (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7))
34
26
 
35
27
/**
36
 
 * @brief
37
 
 *   Returns the argument string in single quotes suitable for using in a SQL statement.
38
 
 * 
39
 
 * @detail
40
 
 *   Adds a \\ before all characters that needs to be escaped in a SQL string.
41
 
 *   We also escape '^Z' (END-OF-FILE in windows) to avoid problems when
42
 
 *   running commands from a file in windows.
43
 
 * 
44
 
 *   This function is very useful when you want to generate SQL statements.
45
 
 *
46
 
 * @note
47
 
 *   val_str(NULL) returns the string 'NULL' (4 letters, without quotes).
48
 
 *
49
 
 * @retval str Quoted string
50
 
 * @retval NULL Out of memory.
51
 
 */
 
28
  QUOTE() function returns argument string in single quotes suitable for
 
29
  using in a SQL statement.
 
30
 
 
31
  Adds a \\ before all characters that needs to be escaped in a SQL string.
 
32
  We also escape '^Z' (END-OF-FILE in windows) to avoid probelms when
 
33
  running commands from a file in windows.
 
34
 
 
35
  This function is very useful when you want to generate SQL statements.
 
36
 
 
37
  @note
 
38
    QUOTE(NULL) returns the string 'NULL' (4 letters, without quotes).
 
39
 
 
40
  @retval
 
41
    str    Quoted string
 
42
  @retval
 
43
    NULL           Out of memory.
 
44
*/
 
45
 
52
46
String *Item_func_quote::val_str(String *str)
53
47
{
54
48
  assert(fixed == 1);
125
119
  null_value= 1;
126
120
  return 0;
127
121
}
128
 
 
129
 
} /* namespace drizzled */