mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
date and time fields now have charset arg in constructor
my_charset_latin1 include/m_ctype.h: my_charset_latin1 is now visible all around the program sql/field.cc: date and time fields now have charset arg in constructor sql/field.h: date and time fields now have charset arg in constructor sql/item_timefunc.h: date and time fields now have charset arg in constructor strings/ctype.c: my_charset_latin1 is now visible all around the program
This commit is contained in:
@@ -118,6 +118,7 @@ typedef struct charset_info_st
|
|||||||
|
|
||||||
|
|
||||||
extern CHARSET_INFO *my_charset_bin;
|
extern CHARSET_INFO *my_charset_bin;
|
||||||
|
extern CHARSET_INFO *my_charset_latin1;
|
||||||
extern CHARSET_INFO *default_charset_info;
|
extern CHARSET_INFO *default_charset_info;
|
||||||
extern CHARSET_INFO *system_charset_info;
|
extern CHARSET_INFO *system_charset_info;
|
||||||
extern CHARSET_INFO *all_charsets[256];
|
extern CHARSET_INFO *all_charsets[256];
|
||||||
|
10
sql/field.cc
10
sql/field.cc
@@ -5283,19 +5283,19 @@ Field *make_field(char *ptr, uint32 field_length,
|
|||||||
unireg_check, field_name, table);
|
unireg_check, field_name, table);
|
||||||
case FIELD_TYPE_DATE:
|
case FIELD_TYPE_DATE:
|
||||||
return new Field_date(ptr,null_pos,null_bit,
|
return new Field_date(ptr,null_pos,null_bit,
|
||||||
unireg_check, field_name, table);
|
unireg_check, field_name, table, field_charset);
|
||||||
case FIELD_TYPE_NEWDATE:
|
case FIELD_TYPE_NEWDATE:
|
||||||
return new Field_newdate(ptr,null_pos,null_bit,
|
return new Field_newdate(ptr,null_pos,null_bit,
|
||||||
unireg_check, field_name, table);
|
unireg_check, field_name, table, field_charset);
|
||||||
case FIELD_TYPE_TIME:
|
case FIELD_TYPE_TIME:
|
||||||
return new Field_time(ptr,null_pos,null_bit,
|
return new Field_time(ptr,null_pos,null_bit,
|
||||||
unireg_check, field_name, table);
|
unireg_check, field_name, table, field_charset);
|
||||||
case FIELD_TYPE_DATETIME:
|
case FIELD_TYPE_DATETIME:
|
||||||
return new Field_datetime(ptr,null_pos,null_bit,
|
return new Field_datetime(ptr,null_pos,null_bit,
|
||||||
unireg_check, field_name, table);
|
unireg_check, field_name, table, field_charset);
|
||||||
case FIELD_TYPE_NULL:
|
case FIELD_TYPE_NULL:
|
||||||
default: // Impossible (Wrong version)
|
default: // Impossible (Wrong version)
|
||||||
return new Field_null(ptr,field_length,unireg_check,field_name,table);
|
return new Field_null(ptr,field_length,unireg_check,field_name,table, field_charset);
|
||||||
}
|
}
|
||||||
return 0; // Impossible (Wrong version)
|
return 0; // Impossible (Wrong version)
|
||||||
}
|
}
|
||||||
|
34
sql/field.h
34
sql/field.h
@@ -528,9 +528,9 @@ class Field_null :public Field_str {
|
|||||||
public:
|
public:
|
||||||
Field_null(char *ptr_arg, uint32 len_arg,
|
Field_null(char *ptr_arg, uint32 len_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||||
:Field_str(ptr_arg, len_arg, null, 1,
|
:Field_str(ptr_arg, len_arg, null, 1,
|
||||||
unireg_check_arg, field_name_arg, table_arg, default_charset_info)
|
unireg_check_arg, field_name_arg, table_arg, cs)
|
||||||
{}
|
{}
|
||||||
enum_field_types type() const { return FIELD_TYPE_NULL;}
|
enum_field_types type() const { return FIELD_TYPE_NULL;}
|
||||||
int store(const char *to, uint length, CHARSET_INFO *cs) { null[0]=1; return 0; }
|
int store(const char *to, uint length, CHARSET_INFO *cs) { null[0]=1; return 0; }
|
||||||
@@ -544,7 +544,7 @@ public:
|
|||||||
int cmp(const char *a, const char *b) { return 0;}
|
int cmp(const char *a, const char *b) { return 0;}
|
||||||
void sort_string(char *buff, uint length) {}
|
void sort_string(char *buff, uint length) {}
|
||||||
uint32 pack_length() const { return 0; }
|
uint32 pack_length() const { return 0; }
|
||||||
void sql_type(String &str) const { str.set("null",4,default_charset_info); }
|
void sql_type(String &str) const { str.set("null",4,my_thd_charset); }
|
||||||
uint size_of() const { return sizeof(*this); }
|
uint size_of() const { return sizeof(*this); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -615,14 +615,14 @@ class Field_date :public Field_str {
|
|||||||
public:
|
public:
|
||||||
Field_date(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
Field_date(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||||
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
|
||||||
unireg_check_arg, field_name_arg, table_arg, default_charset_info)
|
unireg_check_arg, field_name_arg, table_arg, cs)
|
||||||
{}
|
{}
|
||||||
Field_date(bool maybe_null_arg, const char *field_name_arg,
|
Field_date(bool maybe_null_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||||
:Field_str((char*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
|
:Field_str((char*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
|
||||||
NONE, field_name_arg, table_arg, default_charset_info) {}
|
NONE, field_name_arg, table_arg, cs) {}
|
||||||
enum_field_types type() const { return FIELD_TYPE_DATE;}
|
enum_field_types type() const { return FIELD_TYPE_DATE;}
|
||||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
|
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
|
||||||
enum Item_result cmp_type () const { return INT_RESULT; }
|
enum Item_result cmp_type () const { return INT_RESULT; }
|
||||||
@@ -645,9 +645,9 @@ class Field_newdate :public Field_str {
|
|||||||
public:
|
public:
|
||||||
Field_newdate(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
Field_newdate(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||||
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
|
||||||
unireg_check_arg, field_name_arg, table_arg, default_charset_info)
|
unireg_check_arg, field_name_arg, table_arg, cs)
|
||||||
{}
|
{}
|
||||||
enum_field_types type() const { return FIELD_TYPE_DATE;}
|
enum_field_types type() const { return FIELD_TYPE_DATE;}
|
||||||
enum_field_types real_type() const { return FIELD_TYPE_NEWDATE; }
|
enum_field_types real_type() const { return FIELD_TYPE_NEWDATE; }
|
||||||
@@ -676,14 +676,14 @@ class Field_time :public Field_str {
|
|||||||
public:
|
public:
|
||||||
Field_time(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
Field_time(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||||
:Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
|
||||||
unireg_check_arg, field_name_arg, table_arg, default_charset_info)
|
unireg_check_arg, field_name_arg, table_arg, cs)
|
||||||
{}
|
{}
|
||||||
Field_time(bool maybe_null_arg, const char *field_name_arg,
|
Field_time(bool maybe_null_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||||
:Field_str((char*) 0,8, maybe_null_arg ? (uchar*) "": 0,0,
|
:Field_str((char*) 0,8, maybe_null_arg ? (uchar*) "": 0,0,
|
||||||
NONE, field_name_arg, table_arg, default_charset_info) {}
|
NONE, field_name_arg, table_arg, cs) {}
|
||||||
enum_field_types type() const { return FIELD_TYPE_TIME;}
|
enum_field_types type() const { return FIELD_TYPE_TIME;}
|
||||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
|
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
|
||||||
enum Item_result cmp_type () const { return INT_RESULT; }
|
enum Item_result cmp_type () const { return INT_RESULT; }
|
||||||
@@ -708,14 +708,14 @@ class Field_datetime :public Field_str {
|
|||||||
public:
|
public:
|
||||||
Field_datetime(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
Field_datetime(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||||
:Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg,
|
||||||
unireg_check_arg, field_name_arg, table_arg, default_charset_info)
|
unireg_check_arg, field_name_arg, table_arg, cs)
|
||||||
{}
|
{}
|
||||||
Field_datetime(bool maybe_null_arg, const char *field_name_arg,
|
Field_datetime(bool maybe_null_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||||
:Field_str((char*) 0,19, maybe_null_arg ? (uchar*) "": 0,0,
|
:Field_str((char*) 0,19, maybe_null_arg ? (uchar*) "": 0,0,
|
||||||
NONE, field_name_arg, table_arg, default_charset_info) {}
|
NONE, field_name_arg, table_arg, cs) {}
|
||||||
enum_field_types type() const { return FIELD_TYPE_DATETIME;}
|
enum_field_types type() const { return FIELD_TYPE_DATETIME;}
|
||||||
#ifdef HAVE_LONG_LONG
|
#ifdef HAVE_LONG_LONG
|
||||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
|
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
|
||||||
|
@@ -243,7 +243,7 @@ public:
|
|||||||
}
|
}
|
||||||
Field *tmp_table_field(TABLE *t_arg)
|
Field *tmp_table_field(TABLE *t_arg)
|
||||||
{
|
{
|
||||||
return (!t_arg) ? result_field : new Field_date(maybe_null, name, t_arg);
|
return (!t_arg) ? result_field : new Field_date(maybe_null, name, t_arg, my_thd_charset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ public:
|
|||||||
Field *tmp_table_field(TABLE *t_arg)
|
Field *tmp_table_field(TABLE *t_arg)
|
||||||
{
|
{
|
||||||
return (!t_arg) ? result_field : new Field_datetime(maybe_null, name,
|
return (!t_arg) ? result_field : new Field_datetime(maybe_null, name,
|
||||||
t_arg);
|
t_arg, my_thd_charset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -287,7 +287,8 @@ public:
|
|||||||
}
|
}
|
||||||
Field *tmp_table_field(TABLE *t_arg)
|
Field *tmp_table_field(TABLE *t_arg)
|
||||||
{
|
{
|
||||||
return (!t_arg) ? result_field : new Field_time(maybe_null, name, t_arg);
|
return (!t_arg) ? result_field :
|
||||||
|
new Field_time(maybe_null, name, t_arg, my_thd_charset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -379,7 +380,8 @@ public:
|
|||||||
}
|
}
|
||||||
Field *tmp_table_field(TABLE *t_arg)
|
Field *tmp_table_field(TABLE *t_arg)
|
||||||
{
|
{
|
||||||
return (!t_arg) ? result_field : new Field_time(maybe_null, name, t_arg);
|
return (!t_arg) ? result_field :
|
||||||
|
new Field_time(maybe_null, name, t_arg, my_thd_charset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -443,7 +445,8 @@ public:
|
|||||||
}
|
}
|
||||||
Field *tmp_table_field(TABLE *t_arg)
|
Field *tmp_table_field(TABLE *t_arg)
|
||||||
{
|
{
|
||||||
return (!t_arg) ? result_field : new Field_date(maybe_null, name, t_arg);
|
return (!t_arg) ? result_field :
|
||||||
|
new Field_date(maybe_null, name, t_arg, my_thd_charset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -458,7 +461,8 @@ public:
|
|||||||
}
|
}
|
||||||
Field *tmp_table_field(TABLE *t_arg)
|
Field *tmp_table_field(TABLE *t_arg)
|
||||||
{
|
{
|
||||||
return (!t_arg) ? result_field : new Field_time(maybe_null, name, t_arg);
|
return (!t_arg) ? result_field :
|
||||||
|
new Field_time(maybe_null, name, t_arg, my_thd_charset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -474,6 +478,6 @@ public:
|
|||||||
Field *tmp_table_field(TABLE *t_arg)
|
Field *tmp_table_field(TABLE *t_arg)
|
||||||
{
|
{
|
||||||
return (!t_arg) ? result_field : new Field_datetime(maybe_null, name,
|
return (!t_arg) ? result_field : new Field_datetime(maybe_null, name,
|
||||||
t_arg);
|
t_arg, my_thd_charset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -20,6 +20,10 @@
|
|||||||
#include <m_string.h>
|
#include <m_string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_CHARSET_latin1
|
||||||
|
#define HAVE_CHARSET_latin1
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_CHARSET_latin1)||defined(HAVE_CHARSET_latin1_de)||\
|
#if defined(HAVE_CHARSET_latin1)||defined(HAVE_CHARSET_latin1_de)||\
|
||||||
defined(HAVE_CHARSET_danish)||defined(HAVE_CHARSET_german1)
|
defined(HAVE_CHARSET_danish)||defined(HAVE_CHARSET_german1)
|
||||||
|
|
||||||
@@ -3651,6 +3655,7 @@ static CHARSET_INFO compiled_charsets[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CHARSET_INFO *my_charset_latin1 = &compiled_charsets[0];
|
||||||
CHARSET_INFO *all_charsets[256];
|
CHARSET_INFO *all_charsets[256];
|
||||||
CHARSET_INFO *default_charset_info = &compiled_charsets[0];
|
CHARSET_INFO *default_charset_info = &compiled_charsets[0];
|
||||||
CHARSET_INFO *system_charset_info = &compiled_charsets[0];
|
CHARSET_INFO *system_charset_info = &compiled_charsets[0];
|
||||||
|
Reference in New Issue
Block a user