Commit b043f066 authored by unknown's avatar unknown

Now several character sets can live in the same table,

However some hacks were used while waiting for new FRM file


sql/field.h:
  Added function to set Field charset
sql/filesort.cc:
  Temporarily workaround, It seems charset should be passed in argument
sql/ha_heap.cc:
  Set correct key charset from Field information
sql/table.cc:
  Dirty hack to distinguish columns charsets while waiting for Monty to rewrite FRM file
sql/table.h:
  New field: table default character set
parent bf872799
......@@ -252,6 +252,7 @@ class Field_str :public Field {
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())
......
......@@ -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
......
......@@ -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;
......
......@@ -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)
......
......@@ -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;
......
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