summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/field.h1
-rw-r--r--sql/filesort.cc10
-rw-r--r--sql/ha_heap.cc2
-rw-r--r--sql/table.cc21
-rw-r--r--sql/table.h1
5 files changed, 33 insertions, 2 deletions
diff --git a/sql/field.h b/sql/field.h
index baedf9e78e7..91bb39dd338 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -252,6 +252,7 @@ public:
void make_field(Send_field *);
uint size_of() const { return sizeof(*this); }
inline CHARSET_INFO *charset() const { return field_charset; }
+ inline void set_charset(CHARSET_INFO *charset) { field_charset=charset; }
inline int cmp_image(char *buff,uint length)
{
if (binary())
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 3bde4eeae14..c087e65172e 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -77,10 +77,18 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
SORTPARAM param;
DBUG_ENTER("filesort");
DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length,special););
+ CHARSET_INFO *charset=table->table_charset;
+ uint i;
#ifdef SKIP_DBUG_IN_FILESORT
DBUG_PUSH(""); /* No DBUG here */
#endif
+ // BAR TODO: this is not absolutely correct, but OK for now
+ for(i=0;i<table->fields;i++)
+ if (!table->field[i]->binary())
+ charset=((Field_str*)(table->field[i]))->charset();
+ // /BAR TODO
+
outfile= table->io_cache;
my_b_clear(&tempfile);
my_b_clear(&buffpek_pointers);
@@ -129,7 +137,7 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
records=param.max_rows; /* purecov: inspected */
#ifdef USE_STRCOLL
- if (use_strcoll(default_charset_info) &&
+ if (use_strcoll(charset) &&
!(param.tmp_buffer=my_malloc(param.sort_length,MYF(MY_WME))))
goto err;
#endif
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index 43485a97fe3..e18bc877540 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -85,7 +85,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
seg->start= (uint) key_part->offset;
seg->length= (uint) key_part->length;
seg->flag = 0;
- seg->charset= default_charset_info;
+ seg->charset= field->binary() ? NULL : ((Field_str*)field)->charset();
if (field->null_ptr)
{
seg->null_bit= field->null_bit;
diff --git a/sql/table.cc b/sql/table.cc
index 3c217ced03c..eb5f5ecbc9a 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -341,6 +341,15 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
(hash_get_key) get_field_name,0,
HASH_CASE_INSENSITIVE);
+// BAR: dirty hack while waiting for new FRM
+// BAR: take a charset information from table name
+{
+ const char* csname=strstr(alias,"_cs_");
+ if(!csname ||
+ !(outparam->table_charset=get_charset_by_name(csname+4,MYF(MY_WME))))
+ outparam->table_charset=default_charset_info;
+}
+
for (i=0 ; i < outparam->fields; i++, strpos+= 11, field_ptr++)
{
uint pack_flag= uint2korr(strpos+6);
@@ -357,6 +366,18 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
(TYPELIB*) 0),
outparam->fieldnames.type_names[i],
outparam);
+ if (!reg_field->binary())
+ {
+ // BAR: dirty hack while waiting for new FRM
+ // BAR: take a charset information from field name
+
+ Field_str* str_field=(Field_str*)reg_field;
+ const char* csname=strstr(str_field->field_name,"_cs_");
+ CHARSET_INFO *fcs;
+ if (!csname || (!(fcs=get_charset_by_name(csname+4,MYF(MY_WME)))))
+ fcs=outparam->table_charset;
+ str_field->set_charset(fcs);
+ }
if (!(reg_field->flags & NOT_NULL_FLAG))
{
if ((null_bit<<=1) == 256)
diff --git a/sql/table.h b/sql/table.h
index 59cb28038bf..183e1b2a38f 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -104,6 +104,7 @@ struct st_table {
*rowid_field;
Field_timestamp *timestamp_field;
my_string comment; /* Comment about table */
+ CHARSET_INFO *table_charset; /* Default charset of string fields */
REGINFO reginfo; /* field connections */
MEM_ROOT mem_root;
GRANT_INFO grant;