mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Many files:
Coercibility, initial stage item_func.h: Coercibility, initial stage sql/item_func.h: Coercibility, initial stage sql/item.cc: Coercibility, initial stage sql/item_create.cc: Coercibility, initial stage sql/item_create.h: Coercibility, initial stage sql/item.h: Coercibility, initial stage sql/item_func.cc: Coercibility, initial stage sql/lex.h: Coercibility, initial stage sql/sql_yacc.yy: Coercibility, initial stage
This commit is contained in:
parent
d9965d3174
commit
1a2c7c18a1
8 changed files with 43 additions and 6 deletions
|
@ -39,6 +39,7 @@ Item::Item():
|
|||
{
|
||||
marker= 0;
|
||||
maybe_null=null_value=with_sum_func=unsigned_flag=0;
|
||||
coercibility=COER_NOCOLL;
|
||||
name= 0;
|
||||
decimals= 0; max_length= 0;
|
||||
THD *thd= current_thd;
|
||||
|
@ -63,7 +64,8 @@ Item::Item(THD *thd, Item &item):
|
|||
null_value(item.null_value),
|
||||
unsigned_flag(item.unsigned_flag),
|
||||
with_sum_func(item.with_sum_func),
|
||||
fixed(item.fixed)
|
||||
fixed(item.fixed),
|
||||
coercibility(item.coercibility)
|
||||
{
|
||||
next=thd->free_list; // Put in free list
|
||||
thd->free_list= this;
|
||||
|
@ -169,6 +171,7 @@ CHARSET_INFO * Item::thd_charset() const
|
|||
Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name)
|
||||
{
|
||||
set_field(f);
|
||||
coercibility= COER_IMPLICIT;
|
||||
fixed= 1; // This item is not needed in fix_fields
|
||||
}
|
||||
|
||||
|
@ -177,7 +180,7 @@ Item_field::Item_field(THD *thd, Item_field &item):
|
|||
Item_ident(thd, item),
|
||||
field(item.field),
|
||||
result_field(item.result_field)
|
||||
{}
|
||||
{ coercibility= COER_IMPLICIT; }
|
||||
|
||||
void Item_field::set_field(Field *field_par)
|
||||
{
|
||||
|
@ -189,6 +192,7 @@ void Item_field::set_field(Field *field_par)
|
|||
field_name=field_par->field_name;
|
||||
unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
|
||||
set_charset(field_par->charset());
|
||||
coercibility= COER_IMPLICIT;
|
||||
}
|
||||
|
||||
const char *Item_ident::full_name() const
|
||||
|
|
12
sql/item.h
12
sql/item.h
|
@ -39,6 +39,8 @@ public:
|
|||
SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM};
|
||||
|
||||
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
|
||||
enum coercion { COER_NOCOLL=0, COER_COERCIBLE=1,
|
||||
COER_IMPLICIT=2, COER_EXPLICIT=3 };
|
||||
|
||||
String str_value; /* used to store value */
|
||||
my_string name; /* Name from select */
|
||||
|
@ -50,6 +52,7 @@ public:
|
|||
my_bool unsigned_flag;
|
||||
my_bool with_sum_func;
|
||||
my_bool fixed; /* If item fixed with fix_fields */
|
||||
enum coercion coercibility; /* Precedence order of collation */
|
||||
|
||||
// alloc & destruct is done as start of select using sql_alloc
|
||||
Item();
|
||||
|
@ -155,7 +158,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; }
|
||||
// Constructor need to process subselect with temporary tables (see Item)
|
||||
Item_field(THD *thd, Item_field &item);
|
||||
Item_field(Field *field);
|
||||
|
@ -350,17 +353,20 @@ public:
|
|||
class Item_string :public Item
|
||||
{
|
||||
public:
|
||||
Item_string(const char *str,uint length,CHARSET_INFO *cs)
|
||||
Item_string(const char *str,uint length,
|
||||
CHARSET_INFO *cs, enum coercion coer= COER_COERCIBLE)
|
||||
{
|
||||
str_value.set(str,length,cs);
|
||||
coercibility= coer;
|
||||
max_length=length;
|
||||
name=(char*) str_value.ptr();
|
||||
decimals=NOT_FIXED_DEC;
|
||||
}
|
||||
Item_string(const char *name_par, const char *str, uint length,
|
||||
CHARSET_INFO *cs)
|
||||
CHARSET_INFO *cs, enum coercion coer= COER_COERCIBLE)
|
||||
{
|
||||
str_value.set(str,length,cs);
|
||||
coercibility= coer;
|
||||
max_length=length;
|
||||
name=(char*) name_par;
|
||||
decimals=NOT_FIXED_DEC;
|
||||
|
|
|
@ -230,6 +230,11 @@ Item *create_func_bit_length(Item* a)
|
|||
return new Item_func_bit_length(a);
|
||||
}
|
||||
|
||||
Item *create_func_coercibility(Item* a)
|
||||
{
|
||||
return new Item_func_coercibility(a);
|
||||
}
|
||||
|
||||
Item *create_func_char_length(Item* a)
|
||||
{
|
||||
return new Item_func_char_length(a);
|
||||
|
|
|
@ -25,6 +25,7 @@ Item *create_func_asin(Item* a);
|
|||
Item *create_func_bin(Item* a);
|
||||
Item *create_func_bit_count(Item* a);
|
||||
Item *create_func_bit_length(Item* a);
|
||||
Item *create_func_coercibility(Item* a);
|
||||
Item *create_func_ceiling(Item* a);
|
||||
Item *create_func_char_length(Item* a);
|
||||
Item *create_func_cast(Item *a, Item_cast cast_type);
|
||||
|
|
|
@ -107,6 +107,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
|||
return 0; // Fatal error if flag is set!
|
||||
if (arg_count)
|
||||
{ // Print purify happy
|
||||
coercibility= COER_NOCOLL;
|
||||
for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
|
||||
{
|
||||
if ((*arg)->fix_fields(thd, tables, arg) ||
|
||||
|
@ -1004,6 +1005,16 @@ longlong Item_func_char_length::val_int()
|
|||
return (longlong) (!args[0]->binary()) ? res->numchars() : res->length();
|
||||
}
|
||||
|
||||
longlong Item_func_coercibility::val_int()
|
||||
{
|
||||
if (args[0]->null_value)
|
||||
{
|
||||
null_value= 1;
|
||||
return 0;
|
||||
}
|
||||
null_value= 0;
|
||||
return (longlong) args[0]->coercibility;
|
||||
}
|
||||
|
||||
longlong Item_func_locate::val_int()
|
||||
{
|
||||
|
|
|
@ -590,6 +590,15 @@ public:
|
|||
void fix_length_and_dec() { max_length=10; }
|
||||
};
|
||||
|
||||
class Item_func_coercibility :public Item_int_func
|
||||
{
|
||||
public:
|
||||
Item_func_coercibility(Item *a) :Item_int_func(a) {}
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "coercibility"; }
|
||||
void fix_length_and_dec() { max_length=10; }
|
||||
};
|
||||
|
||||
class Item_func_locate :public Item_int_func
|
||||
{
|
||||
String value1,value2;
|
||||
|
|
|
@ -441,6 +441,7 @@ static SYMBOL sql_functions[] = {
|
|||
{ "CHAR_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_char_length)},
|
||||
{ "CHARACTER_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_char_length)},
|
||||
{ "COALESCE", SYM(COALESCE),0,0},
|
||||
{ "COERCIBILITY", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_coercibility)},
|
||||
{ "CONCAT", SYM(CONCAT),0,0},
|
||||
{ "CONCAT_WS", SYM(CONCAT_WS),0,0},
|
||||
{ "CONNECTION_ID", SYM(FUNC_ARG0),0,CREATE_FUNC(create_func_connection_id)},
|
||||
|
|
|
@ -3778,7 +3778,7 @@ text_literal:
|
|||
{ $$ = new Item_string($1.str,$1.length,
|
||||
YYTHD->variables.thd_charset); }
|
||||
| UNDERSCORE_CHARSET TEXT_STRING
|
||||
{ $$ = new Item_string($2.str,$2.length,Lex->charset); }
|
||||
{ $$ = new Item_string($2.str,$2.length,Lex->charset,Item::COER_EXPLICIT); }
|
||||
| text_literal TEXT_STRING
|
||||
{ ((Item_string*) $1)->append($2.str,$2.length); };
|
||||
|
||||
|
|
Loading…
Reference in a new issue