~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Stewart Smith
  • Date: 2010-02-15 03:55:09 UTC
  • mto: (1273.13.96 build)
  • mto: This revision was merged to the branch mainline in revision 1308.
  • Revision ID: stewart@flamingspork.com-20100215035509-y6sry4q4yymph2by
move SUBSTR, SUBSTRING and SUBSTR_INDEX to plugins. add parser hooks for substr being a plugin now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#include "config.h"
21
21
 
22
 
#include "quote.h"
 
22
#include <drizzled/function/str/quote.h>
23
23
 
24
24
namespace drizzled
25
25
{
26
26
 
27
 
inline
28
 
static uint32_t get_esc_bit(unsigned char *mask, unsigned char num)
29
 
{
30
 
  return (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7));
31
 
}
 
27
#define get_esc_bit(mask, num) (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7))
32
28
 
33
29
/**
34
 
 * @brief
35
 
 *   Returns the argument string in single quotes suitable for using in a SQL statement.
36
 
 * 
37
 
 * @detail
38
 
 *   Adds a \\ before all characters that needs to be escaped in a SQL string.
39
 
 *   We also escape '^Z' (END-OF-FILE in windows) to avoid problems when
40
 
 *   running commands from a file in windows.
41
 
 * 
42
 
 *   This function is very useful when you want to generate SQL statements.
43
 
 *
44
 
 * @note
45
 
 *   val_str(NULL) returns the string 'NULL' (4 letters, without quotes).
46
 
 *
47
 
 * @retval str Quoted string
48
 
 * @retval NULL Out of memory.
49
 
 */
 
30
  QUOTE() function returns argument string in single quotes suitable for
 
31
  using in a SQL statement.
 
32
 
 
33
  Adds a \\ before all characters that needs to be escaped in a SQL string.
 
34
  We also escape '^Z' (END-OF-FILE in windows) to avoid probelms when
 
35
  running commands from a file in windows.
 
36
 
 
37
  This function is very useful when you want to generate SQL statements.
 
38
 
 
39
  @note
 
40
    QUOTE(NULL) returns the string 'NULL' (4 letters, without quotes).
 
41
 
 
42
  @retval
 
43
    str    Quoted string
 
44
  @retval
 
45
    NULL           Out of memory.
 
46
*/
 
47
 
50
48
String *Item_func_quote::val_str(String *str)
51
49
{
52
50
  assert(fixed == 1);