Commit 9c8f9652 authored by calvin's avatar calvin

branches/zip: row_raw_format_str_convert(): Rename to

innobase_raw_format(), move the definition from row0row.c to 
ha_innodb.cc. After this change, row0row.c no longer references 
system_charset_info (Mantis issue #17). Patch prepared by Vasil, 
tested by Calvin, and reviewed by Marko.
parent 66312acc
...@@ -64,6 +64,7 @@ extern "C" { ...@@ -64,6 +64,7 @@ extern "C" {
#include "../storage/innobase/include/thr0loc.h" #include "../storage/innobase/include/thr0loc.h"
#include "../storage/innobase/include/dict0boot.h" #include "../storage/innobase/include/dict0boot.h"
#include "../storage/innobase/include/ha_prototypes.h" #include "../storage/innobase/include/ha_prototypes.h"
#include "../storage/innobase/include/ut0mem.h"
} }
#include "ha_innodb.h" #include "ha_innodb.h"
...@@ -906,6 +907,45 @@ innobase_convert_string( ...@@ -906,6 +907,45 @@ innobase_convert_string(
errors)); errors));
} }
/***********************************************************************
Formats the raw data in "data" (in InnoDB on-disk format) that is of
type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "charset_coll" and writes
the result to "buf". The result is converted to "system_charset_info".
Not more than "buf_size" bytes are written to "buf".
The result is always '\0'-terminated (provided buf_size > 0) and the
number of bytes that were written to "buf" is returned (including the
terminating '\0'). */
extern "C" UNIV_INTERN
ulint
innobase_raw_format(
/*================*/
/* out: number of bytes
that were written */
const char* data, /* in: raw data */
ulint data_len, /* in: raw data length
in bytes */
ulint charset_coll, /* in: charset collation */
char* buf, /* out: output buffer */
ulint buf_size) /* in: output buffer size
in bytes */
{
/* XXX we use a hard limit instead of allocating
but_size bytes from the heap */
CHARSET_INFO* data_cs;
char buf_tmp[8192];
ulint buf_tmp_used;
uint num_errors;
data_cs = all_charsets[charset_coll];
buf_tmp_used = innobase_convert_string(buf_tmp, sizeof(buf_tmp),
system_charset_info,
data, data_len, data_cs,
&num_errors);
return(ut_str_sql_format(buf_tmp, buf_tmp_used, buf, buf_size));
}
/************************************************************************* /*************************************************************************
Gets the InnoDB transaction handle for a MySQL handler object, creates Gets the InnoDB transaction handle for a MySQL handler object, creates
an InnoDB transaction struct if the corresponding MySQL thread struct still an InnoDB transaction struct if the corresponding MySQL thread struct still
......
...@@ -24,6 +24,28 @@ innobase_convert_string( ...@@ -24,6 +24,28 @@ innobase_convert_string(
CHARSET_INFO* from_cs, CHARSET_INFO* from_cs,
uint* errors); uint* errors);
/***********************************************************************
Formats the raw data in "data" (in InnoDB on-disk format) that is of
type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "charset_coll" and writes
the result to "buf". The result is converted to "system_charset_info".
Not more than "buf_size" bytes are written to "buf".
The result is always '\0'-terminated (provided buf_size > 0) and the
number of bytes that were written to "buf" is returned (including the
terminating '\0'). */
UNIV_INTERN
ulint
innobase_raw_format(
/*================*/
/* out: number of bytes
that were written */
const char* data, /* in: raw data */
ulint data_len, /* in: raw data length
in bytes */
ulint charset_coll, /* in: charset collation */
char* buf, /* out: output buffer */
ulint buf_size); /* in: output buffer size
in bytes */
/********************************************************************* /*********************************************************************
Convert a table or index name to the MySQL system_charset_info (UTF-8) Convert a table or index name to the MySQL system_charset_info (UTF-8)
and quote it if needed. */ and quote it if needed. */
......
...@@ -871,47 +871,6 @@ row_raw_format_int( ...@@ -871,47 +871,6 @@ row_raw_format_int(
return(ut_min(ret, buf_size)); return(ut_min(ret, buf_size));
} }
extern CHARSET_INFO* system_charset_info;
/***********************************************************************
Formats the raw data in "data" (in InnoDB on-disk format) that is of
type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "charset_coll" and writes
the result to "buf". The result is converted to "system_charset_info".
Not more than "buf_size" bytes are written to "buf".
The result is always '\0'-terminated (provided buf_size > 0) and the
number of bytes that were written to "buf" is returned (including the
terminating '\0'). */
static
ulint
row_raw_format_str_convert(
/*=======================*/
/* out: number of bytes
that were written */
const char* data, /* in: raw data */
ulint data_len, /* in: raw data length
in bytes */
ulint charset_coll, /* in: charset collation */
char* buf, /* out: output buffer */
ulint buf_size) /* in: output buffer size
in bytes */
{
/* XXX we use a hard limit instead of allocating
but_size bytes from the heap */
CHARSET_INFO* data_cs;
char buf_tmp[8192];
ulint buf_tmp_used;
uint num_errors;
data_cs = all_charsets[charset_coll];
buf_tmp_used = innobase_convert_string(buf_tmp, sizeof(buf_tmp),
system_charset_info,
data, data_len, data_cs,
&num_errors);
return(ut_str_sql_format(buf_tmp, buf_tmp_used, buf, buf_size));
}
/*********************************************************************** /***********************************************************************
Formats the raw data in "data" (in InnoDB on-disk format) that is of Formats the raw data in "data" (in InnoDB on-disk format) that is of
type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "prtype" and writes the type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "prtype" and writes the
...@@ -963,7 +922,7 @@ row_raw_format_str( ...@@ -963,7 +922,7 @@ row_raw_format_str(
} }
/* else */ /* else */
return(row_raw_format_str_convert(data, data_len, charset_coll, return(innobase_raw_format(data, data_len, charset_coll,
buf, buf_size)); buf, buf_size));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment