summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorunknown <bar@bar.mysql.r18.ru>2003-06-24 15:11:07 +0500
committerunknown <bar@bar.mysql.r18.ru>2003-06-24 15:11:07 +0500
commit64d7734f3827ea28f6463978cde5a97de212dcf9 (patch)
treed10534e6181ac170a28712b39017af615ec3fd3d /sql/item.h
parent4c1766ddee7216a540ec35f691b41825492d55db (diff)
downloadmariadb-git-64d7734f3827ea28f6463978cde5a97de212dcf9.tar.gz
New class DTCollation (SQL:2003 calls it "declared type collation")
It's a combination of collation and its derivation (precedence order)
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h109
1 files changed, 80 insertions, 29 deletions
diff --git a/sql/item.h b/sql/item.h
index df9ada72ce5..ce79e70e5d6 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -23,6 +23,63 @@ class Protocol;
struct st_table_list;
void item_init(void); /* Init item functions */
+
+/*
+ "Declared Type Collation"
+ A combination of collation and its deriviation.
+*/
+
+enum Derivation
+{
+ DERIVATION_COERCIBLE= 3,
+ DERIVATION_IMPLICIT= 2,
+ DERIVATION_NONE= 1,
+ DERIVATION_EXPLICIT= 0
+};
+
+class DTCollation {
+public:
+ CHARSET_INFO *collation;
+ enum Derivation derivation;
+
+ DTCollation()
+ {
+ collation= &my_charset_bin;
+ derivation= DERIVATION_NONE;
+ }
+ DTCollation(CHARSET_INFO *collation_arg, Derivation derivation_arg)
+ {
+ collation= collation_arg;
+ derivation= derivation_arg;
+ }
+ void set(DTCollation *dt)
+ {
+ collation= dt->collation;
+ derivation= dt->derivation;
+ }
+ void set(CHARSET_INFO *collation_arg, Derivation derivation_arg)
+ {
+ collation= collation_arg;
+ derivation= derivation_arg;
+ }
+ void set(CHARSET_INFO *collation_arg)
+ { collation= collation_arg; }
+ void set(Derivation derivation_arg)
+ { derivation= derivation_arg; }
+ bool aggregate(DTCollation *dt);
+ const char *derivation_name() const
+ {
+ switch(derivation)
+ {
+ case DERIVATION_COERCIBLE: return "COERCIBLE";
+ case DERIVATION_IMPLICIT: return "IMPLICIT";
+ case DERIVATION_EXPLICIT: return "EXPLICIT";
+ case DERIVATION_NONE: return "NONE";
+ default: return "UNKNOWN";
+ }
+ }
+};
+
class Item {
uint loop_id; /* Used to find selfrefering loops */
Item(const Item &); /* Prevent use of these */
@@ -41,19 +98,6 @@ public:
SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM};
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
- enum coercion { COER_COERCIBLE=3, COER_IMPLICIT=2,
- COER_NOCOLL=1, COER_EXPLICIT=0 };
- const char *coercion_name(enum coercion coer) const
- {
- switch(coer)
- {
- case COER_COERCIBLE: return "COERCIBLE";
- case COER_IMPLICIT: return "IMPLICIT";
- case COER_EXPLICIT: return "EXPLICIT";
- case COER_NOCOLL: return "NO COLLATION";
- default: return "UNKNOWN";
- }
- }
String str_value; /* used to store value */
my_string name; /* Name from select */
@@ -65,9 +109,8 @@ public:
my_bool unsigned_flag;
my_bool with_sum_func;
my_bool fixed; /* If item fixed with fix_fields */
- CHARSET_INFO *collation; /* character set && collation */
- enum coercion coercibility; /* Precedence order of collation */
-
+ DTCollation collation;
+
// alloc & destruct is done as start of select using sql_alloc
Item();
/*
@@ -125,13 +168,23 @@ public:
virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); }
CHARSET_INFO *default_charset() const;
- CHARSET_INFO *charset() const { return collation; };
+ Derivation derivation() const { return collation.derivation; }
+ CHARSET_INFO *charset() const { return collation.collation; }
void set_charset(CHARSET_INFO *cs)
- { collation= cs; }
- void set_charset(CHARSET_INFO *cs, enum coercion coer)
- { collation= cs; coercibility= coer; }
- bool set_charset(CHARSET_INFO *cs1, enum coercion co1,
- CHARSET_INFO *cs2, enum coercion co2);
+ { collation.collation= cs; }
+ void set_charset(Derivation dv)
+ { collation.derivation= dv; }
+ void set_charset(CHARSET_INFO *cs, Derivation dv)
+ { collation.collation= cs; collation.derivation= dv; }
+ void set_charset(Item &item)
+ { collation= item.collation; }
+ void set_charset(DTCollation *collation_arg)
+ {
+ collation.collation= collation_arg->collation;
+ collation.derivation= collation_arg->derivation;
+ }
+ bool set_charset(CHARSET_INFO *cs1, Derivation dv1,
+ CHARSET_INFO *cs2, Derivation dv2);
bool binary() const
{ return charset()->state & MY_CS_BINSORT ? 1 : 0 ; }
@@ -180,7 +233,7 @@ public:
Item_field(const char *db_par,const char *table_name_par,
const char *field_name_par)
:Item_ident(db_par,table_name_par,field_name_par),field(0),result_field(0)
- { coercibility= COER_IMPLICIT; }
+ { set_charset(DERIVATION_IMPLICIT); }
// Constructor need to process subselect with temporary tables (see Item)
Item_field(THD *thd, Item_field &item);
Item_field(Field *field);
@@ -381,21 +434,19 @@ class Item_string :public Item
{
public:
Item_string(const char *str,uint length,
- CHARSET_INFO *cs, enum coercion coer= COER_COERCIBLE)
+ CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
{
- set_charset(cs);
+ set_charset(cs, dv);
str_value.set(str,length,cs);
- coercibility= coer;
max_length=length;
set_name(str, length, cs);
decimals=NOT_FIXED_DEC;
}
Item_string(const char *name_par, const char *str, uint length,
- CHARSET_INFO *cs, enum coercion coer= COER_COERCIBLE)
+ CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
{
- set_charset(cs);
+ set_charset(cs, dv);
str_value.set(str,length,cs);
- coercibility= coer;
max_length=length;
set_name(name_par,0,cs);
decimals=NOT_FIXED_DEC;