20
20
#include <drizzled/server_includes.h>
21
22
#include <drizzled/session.h>
22
23
#include <drizzled/item/uint.h>
23
24
#include <drizzled/item/null.h>
24
25
#include <drizzled/item/float.h>
25
26
#include <drizzled/item/param.h>
26
#include <drizzled/sql_string.h>
27
#include <mystrings/utf8.h>
29
29
Item *Item_param::safe_charset_converter(const CHARSET_INFO * const tocs)
131
str2my_decimal((uint32_t)E_DEC_FATAL_ERROR, str, &decimal_value, &end);
131
str2my_decimal((uint)E_DEC_FATAL_ERROR, str, &decimal_value, &end);
132
132
state= DECIMAL_VALUE;
133
133
decimals= decimal_value.frac;
134
134
max_length= my_decimal_precision_to_length(decimal_value.precision(),
519
/* TODO: fact next two functions out */
521
Transforms a string into "" or its expression in 0x... form.
524
static char *str_to_hex(char *to, const char *from, uint32_t len)
530
to= drizzleclient_drizzleclient_octet2hex(to, from, len);
533
to= strcpy(to, "\"\"")+2;
534
return to; // pointer to end 0 of 'to'
540
Add escape characters to a string (blob?) to make it suitable for a insert
541
to should at least have place for length*2+1 chars
542
Returns the length of the to string
546
drizzleclient_escape_string(char *to,const char *from, uint32_t length)
548
const char *to_start= to;
549
const char *end, *to_end=to_start + 2*length;
550
bool overflow= false;
551
for (end= from + length; from < end; from++)
555
if (!U8_IS_SINGLE(*from))
557
tmp_length= U8_LENGTH(*(uint32_t*)from);
558
if (to + tmp_length > to_end)
569
case 0: /* Must be escaped for 'mysql' */
572
case '\n': /* Must be escaped for logs */
584
case '"': /* Better safe than sorry */
587
case '\032': /* This gives problems on Win32 */
612
return overflow ? (size_t) -1 : (size_t) (to - to_start);
616
Append a version of the 'from' string suitable for use in a query to
617
the 'to' string. To generate a correct escaping, the character set
618
information in 'csinfo' is used.
622
append_query_string(const CHARSET_INFO * const csinfo,
623
String const *from, String *to)
626
uint32_t const orig_len= to->length();
627
if (to->reserve(orig_len + from->length()*2+3))
630
beg= to->c_ptr_quick() + to->length();
632
if (csinfo->escape_with_backslash_is_dangerous)
633
ptr= str_to_hex(ptr, from->ptr(), from->length());
637
ptr+= drizzleclient_escape_string(ptr, from->ptr(), from->length());
640
to->length(orig_len + ptr - beg);
646
520
Return Param item values in string format, for generating the dynamic
647
521
query used in update/binary logs.