Below is the list of changes that have just been committed into a local
5.0 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1829 05/04/30 21:37:20 hf@deer.(none) +12 -0
coding
sql/sql_parse.cc
1.444 05/04/30 21:37:14 hf@deer.(none) +2 -2
coding
sql/my_decimal.h
1.11 05/04/30 21:37:14 hf@deer.(none) +6 -5
coding
sql/item_timefunc.h
1.53 05/04/30 21:37:14 hf@deer.(none) +0 -10
coding
sql/item_timefunc.cc
1.82 05/04/30 21:37:14 hf@deer.(none) +0 -8
coding
sql/item_sum.cc
1.141 05/04/30 21:37:14 hf@deer.(none) +21 -25
coding
sql/item_func.h
1.107 05/04/30 21:37:14 hf@deer.(none) +4 -2
coding
sql/item_func.cc
1.183 05/04/30 21:37:14 hf@deer.(none) +51 -56
coding
sql/item_cmpfunc.h
1.98 05/04/30 21:37:14 hf@deer.(none) +9 -0
coding
sql/item_cmpfunc.cc
1.146 05/04/30 21:37:14 hf@deer.(none) +29 -27
coding
sql/item.h
1.116 05/04/30 21:37:14 hf@deer.(none) +9 -9
coding
sql/item.cc
1.113 05/04/30 21:37:14 hf@deer.(none) +35 -51
coding
sql/field.cc
1.259 05/04/30 21:37:14 hf@deer.(none) +2 -2
coding
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: hf
# Host: deer.(none)
# Root: /home/hf/work/mysql-5.0.prec
--- 1.258/sql/field.cc Wed Apr 20 11:01:20 2005
+++ 1.259/sql/field.cc Sat Apr 30 21:37:14 2005
@@ -2242,7 +2242,7 @@
unireg_check_arg, field_name_arg, table_arg,
dec_arg, zero_arg, unsigned_arg)
{
- precision= my_decimal_length2precision(len_arg, dec_arg, unsigned_arg);
+ precision= my_decimal_length_to_precision(len_arg, dec_arg, unsigned_arg);
DBUG_ASSERT((precision <= DECIMAL_MAX_PRECISION) &&
(dec <= DECIMAL_MAX_SCALE));
bin_size= my_decimal_get_binary_size(precision, dec);
@@ -2261,7 +2261,7 @@
dec_arg,
0, unsigned_arg)
{
- precision= my_decimal_length2precision(len_arg, dec_arg, unsigned_arg);
+ precision= my_decimal_length_to_precision(len_arg, dec_arg, unsigned_arg);
DBUG_ASSERT((precision <= DECIMAL_MAX_PRECISION) &&
(dec <= DECIMAL_MAX_SCALE));
bin_size= my_decimal_get_binary_size(precision, dec);
--- 1.112/sql/item.cc Wed Apr 20 11:01:21 2005
+++ 1.113/sql/item.cc Sat Apr 30 21:37:14 2005
@@ -303,7 +303,7 @@
{
marker= 0;
maybe_null=null_value=with_sum_func=unsigned_flag=0;
- decimals= 0; max_length= 0; precision= 0;
+ decimals= 0; max_length= 0;
/* Put item in free list so that we can free all items at end */
THD *thd= current_thd;
@@ -336,7 +336,6 @@
max_length(item->max_length),
marker(item->marker),
decimals(item->decimals),
- precision(item->precision),
maybe_null(item->maybe_null),
null_value(item->null_value),
unsigned_flag(item->unsigned_flag),
@@ -349,6 +348,16 @@
}
+uint Item::decimal_precision() const
+{
+ Item_result restype= result_type();
+
+ if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT))
+ return my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
+ return min(max_length, DECIMAL_MAX_PRECISION);
+}
+
+
void Item::print_item_w_name(String *str)
{
print(str);
@@ -749,7 +758,6 @@
DBUG_ASSERT(it->fixed);
max_length= it->max_length;
decimals= it->decimals;
- precision= it->precision;
fixed= 1;
return FALSE;
}
@@ -939,10 +947,8 @@
return 1;
}
if (collation->state & MY_CS_BINSORT)
- {
return 0;
- }
- else if (dt.collation->state & MY_CS_BINSORT)
+ if (dt.collation->state & MY_CS_BINSORT)
{
set(dt);
return 0;
@@ -1023,15 +1029,11 @@
maybe_null=field->maybe_null();
decimals= field->decimals();
max_length= field_par->field_length;
- precision= (field->type() == FIELD_TYPE_NEWDECIMAL) ?
- ((Field_new_decimal *)field)->precision : max_length;
table_name= *field_par->table_name;
field_name= field_par->field_name;
db_name= field_par->table->s->db;
alias_name_used= field_par->table->alias_name_used;
unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
- if ((field->result_type() == INT_RESULT) && !unsigned_flag)
- max_length++;
collation.set(field_par->charset(), DERIVATION_IMPLICIT);
fixed= 1;
}
@@ -1364,20 +1366,18 @@
str2my_decimal(E_DEC_FATAL_ERROR, str_arg, length, charset, &decimal_value);
name= (char*) str_arg;
decimals= (uint8) decimal_value.frac;
- precision= decimal_value.intg + decimal_value.frac;
fixed= 1;
- unsigned_flag= !decimal_value.sign();
- max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
+ max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
+ decimals, unsigned_flag);
}
Item_decimal::Item_decimal(longlong val, bool unsig)
{
int2my_decimal(E_DEC_FATAL_ERROR, val, unsig, &decimal_value);
decimals= (uint8) decimal_value.frac;
- precision= decimal_value.intg + decimal_value.frac;
- max_length= my_decimal_max_length(&decimal_value);
fixed= 1;
- unsigned_flag= !decimal_value.sign();
+ max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
+ decimals, unsigned_flag);
}
@@ -1385,10 +1385,9 @@
{
double2my_decimal(E_DEC_FATAL_ERROR, val, &decimal_value);
decimals= (uint8) decimal_value.frac;
- precision= decimal_value.intg + decimal_value.frac;
- max_length= my_decimal_max_length(&decimal_value);
fixed= 1;
- unsigned_flag= !decimal_value.sign();
+ max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
+ decimals, unsigned_flag);
}
@@ -1399,8 +1398,6 @@
name= (char*) str;
decimals= (uint8) decimal_par;
max_length= length;
- unsigned_flag= !decimal_value.sign();
- precision= my_decimal_length2precision(length, decimals, unsigned_flag);
fixed= 1;
}
@@ -1409,10 +1406,9 @@
{
my_decimal2decimal(value_par, &decimal_value);
decimals= (uint8) decimal_value.frac;
- precision= decimal_value.intg + decimal_value.frac;
- max_length= my_decimal_max_length(value_par);
fixed= 1;
- unsigned_flag= !decimal_value.sign();
+ max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
+ decimals, !decimal_value.sign());
}
@@ -1421,10 +1417,9 @@
binary2my_decimal(E_DEC_FATAL_ERROR, bin,
&decimal_value, precision_arg, scale);
decimals= (uint8) decimal_value.frac;
- precision= precision_arg;
- max_length= my_decimal_max_length(&decimal_value);
fixed= 1;
- unsigned_flag= !decimal_value.sign();
+ max_length= my_decimal_precision_to_length(precision_arg, decimals,
+ !decimal_value.sign());
}
@@ -1634,7 +1629,6 @@
*/
max_length= 0;
decimals= 0;
- precision= 0;
state= NULL_VALUE;
DBUG_VOID_RETURN;
}
@@ -1646,7 +1640,6 @@
state= INT_VALUE;
max_length= max_length_arg;
decimals= 0;
- precision= max_length_arg;
maybe_null= 0;
DBUG_VOID_RETURN;
}
@@ -1658,7 +1651,6 @@
state= REAL_VALUE;
max_length= DBL_DIG + 8;
decimals= NOT_FIXED_DEC;
- precision= DBL_DIG;
maybe_null= 0;
DBUG_VOID_RETURN;
}
@@ -1687,8 +1679,8 @@
str2my_decimal(E_DEC_FATAL_ERROR, str, &decimal_value, &end);
state= DECIMAL_VALUE;
decimals= decimal_value.frac;
- precision= decimal_value.intg + decimal_value.frac;
- max_length= my_decimal_string_length(&decimal_value);
+ max_length= my_decimal_precision_to_length(decimal_value.precision(),
+ decimals, unsigned_flag);
maybe_null= 0;
DBUG_VOID_RETURN;
}
@@ -1731,7 +1723,6 @@
maybe_null= 0;
max_length= max_length_arg;
decimals= 0;
- precision= max_length_arg;
DBUG_VOID_RETURN;
}
@@ -1840,8 +1831,8 @@
my_decimal2decimal(ent_value, &decimal_value);
state= DECIMAL_VALUE;
decimals= ent_value->frac;
- precision= ent_value->frac + ent_value->intg;
- max_length= my_decimal_string_length(ent_value);
+ max_length= my_decimal_precision_to_length(ent_value->precision(),
+ decimals, unsigned_flag);
break;
}
default:
@@ -2174,7 +2165,6 @@
max_length= str_value.length();
decimals= 0;
- precision= max_length;
/*
str_value_ptr is returned from val_str(). It must be not alloced
to prevent it's modification by val_str() invoker.
@@ -3132,17 +3122,17 @@
Field::NONE, name, table, decimals, 0,
unsigned_flag);
case MYSQL_TYPE_TINY:
- return new Field_tiny((char*) 0, precision, null_ptr, 0, Field::NONE,
+ return new Field_tiny((char*) 0, max_length, null_ptr, 0, Field::NONE,
name, table, 0, unsigned_flag);
case MYSQL_TYPE_SHORT:
- return new Field_short((char*) 0, precision, null_ptr, 0, Field::NONE,
+ return new Field_short((char*) 0, max_length, null_ptr, 0, Field::NONE,
name, table, 0, unsigned_flag);
case MYSQL_TYPE_LONG:
- return new Field_long((char*) 0, precision, null_ptr, 0, Field::NONE,
+ return new Field_long((char*) 0, max_length, null_ptr, 0, Field::NONE,
name, table, 0, unsigned_flag);
#ifdef HAVE_LONG_LONG
case MYSQL_TYPE_LONGLONG:
- return new Field_longlong((char*) 0, precision, null_ptr, 0, Field::NONE,
+ return new Field_longlong((char*) 0, max_length, null_ptr, 0, Field::NONE,
name, table, 0, unsigned_flag);
#endif
case MYSQL_TYPE_FLOAT:
@@ -3155,7 +3145,7 @@
return new Field_null((char*) 0, max_length, Field::NONE,
name, table, &my_charset_bin);
case MYSQL_TYPE_INT24:
- return new Field_medium((char*) 0, precision, null_ptr, 0, Field::NONE,
+ return new Field_medium((char*) 0, max_length, null_ptr, 0, Field::NONE,
name, table, 0, unsigned_flag);
case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_DATE:
@@ -3416,7 +3406,6 @@
presentation= name=(char*) str_arg;
decimals=(uint8) nr_of_decimals(str_arg, str_arg+length);
max_length=length;
- precision= max_length;
fixed= 1;
}
@@ -3952,7 +3941,6 @@
max_length= (*ref)->max_length;
maybe_null= (*ref)->maybe_null;
decimals= (*ref)->decimals;
- precision= (*ref)->precision;
collation.set((*ref)->collation);
/*
We have to remember if we refer to a sum function, to ensure that
@@ -4952,16 +4940,12 @@
}
if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
{
- int item_precision=
- my_decimal_length2precision(display_length(item),
- item->decimals, item->unsigned_flag);
- int intp1= my_decimal_int_part(item_precision, item->decimals);
- int intp2= my_decimal_int_part(precision, decimals);
-
decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
- precision= min(max(intp1, intp2) + decimals, DECIMAL_MAX_PRECISION);
+ int precision= min(max(decimal_int_part(), item->decimal_int_part())
+ + decimals, DECIMAL_MAX_PRECISION);
unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
+ max_length= my_decimal_precision_to_length(precision, decimals,
+ unsigned_flag);
}
else
max_length= max(max_length, display_length(item));
--- 1.115/sql/item.h Wed Apr 20 11:01:21 2005
+++ 1.116/sql/item.h Sat Apr 30 21:37:14 2005
@@ -259,7 +259,6 @@
uint32 max_length;
uint name_length; /* Length of name */
uint8 marker, decimals;
- uint precision;
my_bool maybe_null; /* If item may be null */
my_bool null_value; /* if item is null */
my_bool unsigned_flag;
@@ -442,6 +441,9 @@
virtual cond_result eq_cmp_result() const { return COND_OK; }
inline uint float_length(uint decimals_par) const
{ return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;}
+ virtual uint decimal_precision() const;
+ inline int decimal_int_part() const
+ { return my_decimal_int_part(decimal_precision(), decimals); }
/*
Returns true if this is constant (during query execution, i.e. its value
will not change until next fix_fields) and its value is known.
@@ -930,13 +932,13 @@
public:
longlong value;
Item_int(int32 i,uint length=11) :value((longlong) i)
- { max_length=length; fixed= 1; precision= max_length;}
+ { max_length=length; fixed= 1; }
#ifdef HAVE_LONG_LONG
Item_int(longlong i,uint length=21) :value(i)
- { max_length=length; fixed= 1; precision= max_length;}
+ { max_length=length; fixed= 1; }
#endif
Item_int(const char *str_arg,longlong i,uint length) :value(i)
- { max_length=length; precision=max_length; name=(char*) str_arg; fixed= 1; }
+ { max_length=length; name=(char*) str_arg; fixed= 1; }
Item_int(const char *str_arg, uint length=64);
enum Type type() const { return INT_ITEM; }
enum Item_result result_type () const { return INT_RESULT; }
@@ -952,6 +954,7 @@
void cleanup() {}
void print(String *str);
Item_num *neg() { value= -value; return this; }
+ uint decimal_precision() const { return max_length - (value < 0); }
};
@@ -979,6 +982,7 @@
int save_in_field(Field *field, bool no_conversions);
void print(String *str);
Item_num *neg ();
+ uint decimal_precision() const { return max_length; }
};
@@ -1018,6 +1022,7 @@
unsigned_flag= !decimal_value.sign();
return this;
}
+ uint decimal_precision() const { return decimal_value.precision(); }
};
class Item_float :public Item_num
@@ -1033,7 +1038,6 @@
presentation= name=(char*) str;
decimals=(uint8) decimal_par;
max_length=length;
- precision=max_length;
fixed= 1;
}
Item_float(double value_par) :presentation(0), value(value_par) { fixed= 1; }
@@ -1089,7 +1093,6 @@
max_length= str_value.numchars()*cs->mbmaxlen;
set_name(str, length, cs);
decimals=NOT_FIXED_DEC;
- precision=max_length;
// it is constant => can be used without fix_fields (and frequently used)
fixed= 1;
}
@@ -1101,7 +1104,6 @@
max_length= str_value.numchars()*cs->mbmaxlen;
set_name(name_par,0,cs);
decimals=NOT_FIXED_DEC;
- precision=max_length;
// it is constant => can be used without fix_fields (and frequently used)
fixed= 1;
}
@@ -1405,7 +1407,6 @@
null_value=maybe_null=item->maybe_null;
decimals=item->decimals;
max_length=item->max_length;
- precision=item->precision;
name=item->name;
cached_field_type= item->field_type();
}
@@ -1625,7 +1626,6 @@
example= item;
max_length= item->max_length;
decimals= item->decimals;
- precision= item->precision;
collation.set(item->collation);
return 0;
};
--- 1.145/sql/item_cmpfunc.cc Wed Apr 20 10:52:58 2005
+++ 1.146/sql/item_cmpfunc.cc Sat Apr 30 21:37:14 2005
@@ -201,7 +201,6 @@
void Item_bool_func2::fix_length_and_dec()
{
max_length= 1; // Function returns 0 or 1
- precision= 1;
THD *thd= current_thd;
/*
@@ -875,7 +874,6 @@
}
maybe_null= 0;
max_length= 2;
- precision= max_length;
used_tables_cache|= row->used_tables();
not_null_tables_cache= row->not_null_tables();
with_sum_func= with_sum_func || row->with_sum_func;
@@ -972,7 +970,6 @@
void Item_func_between::fix_length_and_dec()
{
max_length= 1;
- precision= 1;
THD *thd= current_thd;
/*
@@ -1115,14 +1112,13 @@
maybe_null=args[1]->maybe_null;
decimals= max(args[0]->decimals, args[1]->decimals);
max_length= max(args[0]->max_length, args[1]->max_length);
- precision= max(args[0]->precision, args[1]->precision);
+ unsigned_flag= min(args[0]->unsigned_flag, args[1]->unsigned_flag);
agg_result_type(&cached_result_type, args, 2);
switch (cached_result_type) {
case STRING_RESULT:
agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV);
break;
case DECIMAL_RESULT:
- break;
case REAL_RESULT:
break;
case INT_RESULT:
@@ -1137,6 +1133,14 @@
cached_field_type= Item_func::field_type();
}
+
+uint Item_func_ifnull::decimal_precision() const
+{
+ int max_int_part=max(args[0]->decimal_int_part(),args[1]->decimal_int_part());
+ return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
+}
+
+
enum_field_types Item_func_ifnull::field_type() const
{
return cached_field_type;
@@ -1248,21 +1252,14 @@
collation.set(&my_charset_bin); // Number
}
}
- if (cached_result_type == DECIMAL_RESULT)
- {
- precision= (max(args[1]->precision - args[1]->decimals,
- args[2]->precision - args[2]->decimals) +
- decimals);
- set_if_smaller(precision, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
- }
- else
- {
- max_length= (max(args[1]->max_length - args[1]->decimals,
- args[2]->max_length - args[2]->decimals) +
+}
+
+
+uint Item_func_if::decimal_precision() const
+{
+ int precision=(max(args[1]->decimal_int_part(),args[2]->decimal_int_part())+
decimals);
- precision= min(max_length, DECIMAL_MAX_PRECISION);
- }
+ return min(precision, DECIMAL_MAX_PRECISION);
}
@@ -1319,7 +1316,7 @@
{
max_length=args[0]->max_length;
decimals=args[0]->decimals;
- precision=args[0]->precision;
+ unsigned_flag= args[0]->unsigned_flag;
cached_result_type= args[0]->result_type();
if (cached_result_type == STRING_RESULT &&
agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV))
@@ -1619,25 +1616,31 @@
max_length=0;
decimals=0;
- precision=0;
- unsigned_flag= TRUE;
for (uint i=0 ; i < ncases ; i+=2)
{
set_if_bigger(max_length,args[i+1]->max_length);
set_if_bigger(decimals,args[i+1]->decimals);
- set_if_bigger(precision, args[i+1]->precision);
- unsigned_flag&= args[i+1]->unsigned_flag;
}
if (else_expr_num != -1)
{
set_if_bigger(max_length,args[else_expr_num]->max_length);
set_if_bigger(decimals,args[else_expr_num]->decimals);
- set_if_bigger(precision, args[else_expr_num]->precision);
- unsigned_flag&= args[else_expr_num]->unsigned_flag;
}
}
+uint Item_func_case::decimal_precision() const
+{
+ int max_int_part=0;
+ for (uint i=0 ; i < ncases ; i+=2)
+ set_if_bigger(max_int_part, args[i+1]->decimal_int_part());
+
+ if (else_expr_num != -1)
+ set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
+ return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
+}
+
+
/* TODO: Fix this so that it prints the whole CASE expression */
void Item_func_case::print(String *str)
@@ -2811,7 +2814,6 @@
return TRUE; /* purecov: inspected */
with_sum_func=args[0]->with_sum_func || args[1]->with_sum_func;
max_length= 1;
- precision=max_length;
decimals= 0;
if (agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV))
--- 1.97/sql/item_cmpfunc.h Fri Apr 1 14:10:45 2005
+++ 1.98/sql/item_cmpfunc.h Sat Apr 30 21:37:14 2005
@@ -95,6 +95,7 @@
Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {}
bool is_bool_func() { return 1; }
void fix_length_and_dec() { decimals=0; max_length=1; }
+ uint decimal_precision() const { return 1; }
};
class Item_cache;
@@ -208,6 +209,7 @@
bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); }
bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
+ uint decimal_precision() const { return 1; }
friend class Arg_comparator;
};
@@ -411,6 +413,7 @@
void fix_length_and_dec();
void print(String *str);
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
+ uint decimal_precision() const { return 1; }
};
@@ -445,6 +448,7 @@
longlong val_int();
void fix_length_and_dec();
const char *func_name() const { return "interval"; }
+ uint decimal_precision() const { return 2; }
};
@@ -485,6 +489,7 @@
void fix_length_and_dec();
const char *func_name() const { return "ifnull"; }
Field *tmp_table_field(TABLE *table);
+ uint decimal_precision() const;
};
@@ -507,6 +512,7 @@
return Item_func::fix_fields(thd, tlist, ref);
}
void fix_length_and_dec();
+ uint decimal_precision() const;
const char *func_name() const { return "if"; }
table_map not_null_tables() const { return 0; }
};
@@ -525,6 +531,7 @@
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type () const { return cached_result_type; }
void fix_length_and_dec();
+ uint decimal_precision() const { return args[0]->decimal_precision(); }
const char *func_name() const { return "nullif"; }
void print(String *str) { Item_func::print(str); }
table_map not_null_tables() const { return 0; }
@@ -563,6 +570,7 @@
String *val_str(String *);
my_decimal *val_decimal(my_decimal *);
void fix_length_and_dec();
+ uint decimal_precision() const;
table_map not_null_tables() const { return 0; }
enum Item_result result_type () const { return cached_result_type; }
const char *func_name() const { return "case"; }
@@ -825,6 +833,7 @@
}
longlong val_int();
void fix_length_and_dec();
+ uint decimal_precision() const { return 1; }
void cleanup()
{
DBUG_ENTER("Item_func_in::cleanup");
--- 1.182/sql/item_func.cc Wed Apr 20 10:52:58 2005
+++ 1.183/sql/item_func.cc Sat Apr 30 21:37:14 2005
@@ -520,11 +520,11 @@
switch (result_type()) {
case INT_RESULT:
- if (precision > 11)
- res= new Field_longlong(precision, maybe_null, name, t_arg,
+ if (max_length > 11)
+ res= new Field_longlong(max_length, maybe_null, name, t_arg,
unsigned_flag);
else
- res= new Field_long(precision, maybe_null, name, t_arg,
+ res= new Field_long(max_length, maybe_null, name, t_arg,
unsigned_flag);
break;
case REAL_RESULT:
@@ -534,9 +534,9 @@
res= make_string_field(t_arg);
break;
case DECIMAL_RESULT:
- res= new Field_new_decimal(my_decimal_precision2length(precision,
- decimals,
- unsigned_flag),
+ res= new Field_new_decimal(my_decimal_precision_to_length(decimal_precision(),
+ decimals,
+ unsigned_flag),
maybe_null, name, t_arg, decimals, unsigned_flag);
break;
case ROW_RESULT:
@@ -575,7 +575,6 @@
set_if_bigger(decimals, args[i]->decimals);
}
max_length= float_length(decimals);
- precision= max_length;
}
@@ -593,15 +592,18 @@
void Item_func::count_decimal_length()
{
- uint max_int_part= 0;
+ int max_int_part= 0;
decimals= 0;
+ unsigned_flag= 1;
for (uint i=0 ; i < arg_count ; i++)
{
set_if_bigger(decimals, args[i]->decimals);
- set_if_bigger(max_int_part, args[i]->precision - args[i]->decimals);
+ set_if_bigger(max_int_part, args[i]->decimal_int_part());
+ set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
}
- precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
+ int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
+ max_length= my_decimal_precision_to_length(precision, decimals,
+ unsigned_flag);
}
@@ -615,11 +617,11 @@
void Item_func::count_only_length()
{
max_length= 0;
- precision= 0;
+ unsigned_flag= 0;
for (uint i=0 ; i < arg_count ; i++)
{
set_if_bigger(max_length, args[i]->max_length);
- set_if_bigger(precision, args[i]->precision);
+ set_if_bigger(unsigned_flag, args[i]->unsigned_flag);
}
}
@@ -655,7 +657,6 @@
else
max_length= length;
}
- precision= max_length;
}
@@ -723,7 +724,6 @@
{
decimals= 0;
hybrid_type=INT_RESULT;
- unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag;
result_precision();
}
DBUG_PRINT("info", ("Type: %s",
@@ -772,7 +772,6 @@
void Item_func_num1::fix_num_length_and_dec()
{
decimals= args[0]->decimals;
- precision= args[0]->precision;
max_length= args[0]->max_length;
}
@@ -913,7 +912,6 @@
{
max_length=args[0]->max_length;
unsigned_flag=0;
- precision=args[0]->precision;
}
@@ -930,7 +928,6 @@
{
max_length=args[0]->max_length;
unsigned_flag=1;
- precision=args[0]->precision;
}
@@ -1023,10 +1020,15 @@
void Item_func_additive_op::result_precision()
{
decimals= max(args[0]->decimals, args[1]->decimals);
- int max_int_part= max(args[0]->precision - args[0]->decimals,
- args[1]->precision - args[1]->decimals);
- precision= min(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
+ int max_int_part= max(args[0]->decimal_precision() - args[0]->decimals,
+ args[1]->decimal_precision() - args[1]->decimals);
+ int precision= min(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
+ if (result_type() == INT_RESULT)
+ unsigned_flag= args[0]->unsigned_flag || args[1]->unsigned_flag;
+ else
+ unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
+ max_length= my_decimal_precision_to_length(precision, decimals,
+ unsigned_flag);
}
@@ -1121,11 +1123,14 @@
void Item_func_mul::result_precision()
{
- unsigned_flag= (args[0]->unsigned_flag == args[1]->unsigned_flag);
+ if (result_type() == INT_RESULT)
+ unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
+ else
+ unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- precision= min(args[0]->precision + args[1]->precision,
- DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
+ int precision= min(args[0]->decimal_precision() + args[1]->decimal_precision(),
+ DECIMAL_MAX_PRECISION);
+ max_length= my_decimal_precision_to_length(precision, decimals,unsigned_flag);
}
@@ -1172,10 +1177,15 @@
void Item_func_div::result_precision()
{
+ if (result_type() == INT_RESULT)
+ unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
+ else
+ unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- uint precision= min(args[0]->precision + prec_increment,
- DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
+ int precision= min(args[0]->decimal_precision() + prec_increment,
+ DECIMAL_MAX_PRECISION);
+ max_length= my_decimal_precision_to_length(precision, decimals,
+ unsigned_flag);
}
@@ -1183,7 +1193,6 @@
{
DBUG_ENTER("Item_func_div::fix_length_and_dec");
Item_num_op::fix_length_and_dec();
- unsigned_flag= (args[0]->unsigned_flag == args[1]->unsigned_flag);
prec_increment= current_thd->variables.div_precincrement;
switch(hybrid_type) {
case REAL_RESULT:
@@ -1233,7 +1242,6 @@
void Item_func_int_div::fix_length_and_dec()
{
max_length=args[0]->max_length - args[0]->decimals;
- precision= max_length;
maybe_null=1;
unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag;
}
@@ -1299,7 +1307,6 @@
{
decimals= max(args[0]->decimals, args[1]->decimals);
max_length= max(args[0]->max_length, args[1]->max_length);
- precision= max(args[0]->precision, args[1]->precision);
}
@@ -1334,10 +1341,8 @@
void Item_func_neg::fix_num_length_and_dec()
{
decimals= args[0]->decimals;
- precision= args[0]->precision;
/* 1 add because sign can appear */
max_length= args[0]->max_length + 1;
- unsigned_flag= 0;
}
@@ -1362,6 +1367,7 @@
hybrid_type= DECIMAL_RESULT;
DBUG_PRINT("info", ("Type changed: DECIMAL_RESULT"));
}
+ unsigned_flag= 0;
DBUG_VOID_RETURN;
}
@@ -1594,7 +1600,6 @@
void Item_func_integer::fix_length_and_dec()
{
- precision= args[0]->precision - args[0]->decimals;
max_length=args[0]->max_length - args[0]->decimals+1;
uint tmp=float_length(decimals);
set_if_smaller(max_length,tmp);
@@ -1603,7 +1608,6 @@
void Item_func_int_val::fix_num_length_and_dec()
{
- precision= args[0]->precision - args[0]->decimals;
max_length= args[0]->max_length - (args[0]->decimals ?
args[0]->decimals + 1 :
0) + 2;
@@ -1754,7 +1758,6 @@
if (!args[1]->const_item())
{
max_length= args[0]->max_length;
- precision= args[0]->precision;
decimals= args[0]->decimals;
hybrid_type= REAL_RESULT;
return;
@@ -1764,7 +1767,6 @@
if (args[0]->decimals == NOT_FIXED_DEC)
{
max_length= args[0]->max_length;
- precision= args[0]->precision;
decimals= min(decimals_to_set, NOT_FIXED_DEC);
hybrid_type= REAL_RESULT;
return;
@@ -1777,16 +1779,14 @@
hybrid_type= REAL_RESULT;
decimals= decimals_to_set;
max_length= float_length(decimals);
- precision= max_length;
break;
case INT_RESULT:
- if (truncate || (args[0]->precision < DECIMAL_LONGLONG_DIGITS))
+ if (truncate || (args[0]->decimal_precision() < DECIMAL_LONGLONG_DIGITS))
{
/* Here we can keep INT_RESULT */
hybrid_type= INT_RESULT;
int length_can_increase= !truncate && (args[1]->val_int() < 0);
max_length= args[0]->max_length + length_can_increase;
- precision= args[0]->precision + length_can_increase;
decimals= 0;
break;
}
@@ -1794,21 +1794,21 @@
{
hybrid_type= DECIMAL_RESULT;
int decimals_delta= args[0]->decimals - decimals_to_set;
+ int precision= args[0]->decimal_precision();
if (decimals_delta > 0)
{
int length_increase= truncate ? 0:1;
- max_length= args[0]->max_length - decimals_delta + length_increase;
- precision= args[0]->precision - decimals_delta + length_increase;
+ precision-= decimals_delta - length_increase;
decimals= decimals_to_set;
}
else
{
int length_can_increase= !truncate &&
(args[1]->val_int() < args[0]->decimals);
- max_length= args[0]->max_length;
- precision= args[0]->precision;
decimals= args[0]->decimals;
}
+ max_length= my_decimal_precision_to_length(precision, decimals,
+ unsigned_flag);
break;
}
default:
@@ -1984,23 +1984,26 @@
void Item_func_min_max::fix_length_and_dec()
{
+ int max_int_part=0;
decimals=0;
max_length=0;
maybe_null=1;
- precision= 0;
cmp_type=args[0]->result_type();
for (uint i=0 ; i < arg_count ; i++)
{
set_if_bigger(max_length, args[i]->max_length);
set_if_bigger(decimals, args[i]->decimals);
- set_if_bigger(precision, args[i]->precision);
+ set_if_bigger(max_int_part, args[i]->decimal_int_part());
if (!args[i]->maybe_null)
maybe_null=0;
cmp_type=item_cmp_type(cmp_type,args[i]->result_type());
}
if (cmp_type == STRING_RESULT)
agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV);
+ else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT))
+ max_length= my_decimal_precision_to_length(max_int_part+decimals, decimals,
+ unsigned_flag);
}
@@ -2358,7 +2361,6 @@
{
decimals=0;
max_length=3; // 1-999
- precision= max_length;
if (args[0]->const_item() && args[1]->type() == FIELD_ITEM)
{
Field *field= ((Item_field*) args[1])->field;
@@ -3373,7 +3375,6 @@
maybe_null=args[0]->maybe_null;
max_length=args[0]->max_length;
decimals=args[0]->decimals;
- precision= args[0]->precision;
collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT);
}
@@ -3913,7 +3914,6 @@
maybe_null=1;
decimals=NOT_FIXED_DEC;
max_length=MAX_BLOB_WIDTH;
- precision= DECIMAL_MAX_PRECISION;
error= get_var_with_binlog(thd, name, &var_entry);
@@ -3923,10 +3923,9 @@
switch (var_entry->type) {
case REAL_RESULT:
max_length= DBL_DIG + 8;
- precision= DBL_DIG;
case INT_RESULT:
max_length= MAX_BIGINT_WIDTH;
- precision= max_length;
+ decimals=0;
break;
case STRING_RESULT:
max_length= MAX_BLOB_WIDTH;
@@ -4742,23 +4741,19 @@
case STRING_RESULT:
maybe_null= 1;
max_length= MAX_BLOB_WIDTH;
- precision= max_length;
break;
case REAL_RESULT:
decimals= NOT_FIXED_DEC;
max_length= float_length(decimals);
- precision= max_length;
break;
case INT_RESULT:
decimals= 0;
max_length= 21;
- precision= max_length;
break;
case DECIMAL_RESULT:
// TODO: where to find real precision and scale?
decimals= DECIMAL_MAX_SCALE;
max_length= DECIMAL_MAX_STR_LENGTH;
- precision= DECIMAL_MAX_PRECISION;
break;
case ROW_RESULT:
default:
--- 1.106/sql/item_func.h Wed Apr 20 10:52:58 2005
+++ 1.107/sql/item_func.h Sat Apr 30 21:37:14 2005
@@ -237,7 +237,7 @@
class Item_int_func :public Item_func
{
public:
- Item_int_func() :Item_func() { max_length= 21; precision= 21; }
+ Item_int_func() :Item_func() { max_length= 21; }
Item_int_func(Item *a) :Item_func(a) { max_length= 21; }
Item_int_func(Item *a,Item *b) :Item_func(a,b) { max_length= 21; }
Item_int_func(Item *a,Item *b,Item *c) :Item_func(a,b,c)
@@ -270,6 +270,8 @@
}
void fix_length_and_dec();
void print(String *str);
+ uint decimal_precision() const { return args[0]->decimal_precision(); }
+
};
@@ -291,7 +293,6 @@
{
max_length= len + 2;
decimals= dec;
- precision= len;
}
String *val_str(String *str);
double val_real();
@@ -393,6 +394,7 @@
const char *func_name() const { return "-"; }
void fix_length_and_dec();
void fix_num_length_and_dec();
+ uint decimal_precision() const { return args[0]->decimal_precision(); }
};
--- 1.140/sql/item_sum.cc Wed Apr 20 10:52:58 2005
+++ 1.141/sql/item_sum.cc Sat Apr 30 21:37:14 2005
@@ -99,12 +99,8 @@
void Item_sum::fix_num_length_and_dec()
{
decimals=0;
- precision=0;
for (uint i=0 ; i < arg_count ; i++)
- {
set_if_bigger(decimals,args[i]->decimals);
- set_if_bigger(precision,args[i]->precision);
- }
max_length=float_length(decimals);
}
@@ -210,14 +206,12 @@
}
thd->allow_sum_func=0; // No included group funcs
decimals=0;
- precision=0;
maybe_null=0;
for (uint i=0 ; i < arg_count ; i++)
{
if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1))
return TRUE;
set_if_bigger(decimals, args[i]->decimals);
- set_if_bigger(precision, args[i]->precision);
maybe_null |= args[i]->maybe_null;
}
result_field=0;
@@ -273,7 +267,6 @@
(item= args[0])->check_cols(1))
return TRUE;
decimals=item->decimals;
- precision=item->precision;
switch (hybrid_type= item->result_type()) {
case INT_RESULT:
@@ -371,7 +364,6 @@
DBUG_ENTER("Item_sum_sum::fix_length_and_dec");
maybe_null=null_value=1;
decimals= args[0]->decimals;
- precision= args[0]->precision;
switch (args[0]->result_type()) {
case REAL_RESULT:
case STRING_RESULT:
@@ -380,14 +372,16 @@
break;
case INT_RESULT:
case DECIMAL_RESULT:
+ {
/* SUM result can't be longer than length(arg) + length(MAX_ROWS) */
- precision= min(args[0]->precision + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
+ int precision= args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS;
+ max_length= my_decimal_precision_to_length(precision, decimals,
+ unsigned_flag);
curr_dec_buff= 0;
hybrid_type= DECIMAL_RESULT;
my_decimal_set_zero(dec_buffs);
break;
+ }
case ROW_RESULT:
default:
DBUG_ASSERT(0);
@@ -801,9 +795,10 @@
prec_increment= current_thd->variables.div_precincrement;
if (hybrid_type == DECIMAL_RESULT)
{
+ int precision= args[0]->decimal_precision() + prec_increment;
decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- precision= min(args[0]->precision + prec_increment, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
+ max_length= my_decimal_precision_to_length(precision, decimals,
+ unsigned_flag);
f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
f_scale= args[0]->decimals;
dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
@@ -829,10 +824,9 @@
The easyest way is to do this is to store both value in a string
and unpack on access.
*/
- return
- new Field_string(((hybrid_type == DECIMAL_RESULT) ?
- dec_bin_size : sizeof(double)) + sizeof(longlong),
- 0, name, table, &my_charset_bin);
+ return new Field_string(((hybrid_type == DECIMAL_RESULT) ?
+ dec_bin_size : sizeof(double)) + sizeof(longlong),
+ 0, name, table, &my_charset_bin);
}
if (hybrid_type == DECIMAL_RESULT)
return new Field_new_decimal(max_length, maybe_null, name, table,
@@ -947,16 +941,17 @@
switch (args[0]->result_type()) {
case REAL_RESULT:
case STRING_RESULT:
- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- precision= max_length;
+ decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
hybrid_type= REAL_RESULT;
sum= 0.0;
break;
case INT_RESULT:
case DECIMAL_RESULT:
+ {
+ int precision= args[0]->decimal_precision()*2 + prec_increment;
decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- precision= min(args[0]->precision + prec_increment, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
+ max_length= my_decimal_precision_to_length(precision, decimals,
+ unsigned_flag);
cur_dec= 0;
hybrid_type= DECIMAL_RESULT;
my_decimal_set_zero(dec_sum);
@@ -968,14 +963,15 @@
column_value * column_value
*/
f_scale0= args[0]->decimals;
- f_precision0= min(args[0]->precision + DECIMAL_LONGLONG_DIGITS,
+ f_precision0= min(args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS,
DECIMAL_MAX_PRECISION);
f_scale1= min(args[0]->decimals * 2, DECIMAL_MAX_SCALE);
- f_precision1= min(args[0]->precision * 2 + DECIMAL_LONGLONG_DIGITS,
+ f_precision1= min(args[0]->decimal_precision()*2 + DECIMAL_LONGLONG_DIGITS,
DECIMAL_MAX_PRECISION);
dec_bin_size0= my_decimal_get_binary_size(f_precision0, f_scale0);
dec_bin_size1= my_decimal_get_binary_size(f_precision1, f_scale1);
break;
+ }
case ROW_RESULT:
default:
DBUG_ASSERT(0);
@@ -1947,8 +1943,8 @@
{
name=item->name;
decimals=item->decimals;
- precision= item->precision;
max_length= item->max_length;
+ unsigned_flag= item->unsigned_flag;
field=item->result_field;
maybe_null=1;
hybrid_type= res_type;
@@ -2073,8 +2069,8 @@
{
name=item->name;
decimals=item->decimals;
- precision= item->precision;
max_length=item->max_length;
+ unsigned_flag= item->unsigned_flag;
field=item->result_field;
maybe_null=1;
sample= item->sample;
--- 1.81/sql/item_timefunc.cc Wed Apr 20 11:01:21 2005
+++ 1.82/sql/item_timefunc.cc Sat Apr 30 21:37:14 2005
@@ -1323,7 +1323,6 @@
collation.set(&my_charset_bin);
decimals=0;
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- precision=max_length;
store_now_in_TIME(<ime);
@@ -1399,7 +1398,6 @@
value= TIME_to_ulonglong_time(<ime);
buff_length= (uint) my_time_to_str(<ime, buff);
max_length= buff_length;
- precision=max_length;
}
@@ -1449,7 +1447,6 @@
buff_length= (uint) my_datetime_to_str(<ime, buff);
max_length= buff_length;
- precision=max_length;
}
@@ -1565,7 +1562,6 @@
set_if_smaller(max_length,MAX_BLOB_WIDTH);
}
maybe_null=1; // If wrong date
- precision=max_length;
}
@@ -1698,7 +1694,6 @@
max_length=MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null= 1;
thd->time_zone_used= 1;
- precision=max_length;
}
@@ -1757,7 +1752,6 @@
decimals= 0;
max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null= 1;
- precision=max_length;
}
@@ -2418,7 +2412,6 @@
enum_field_types arg0_field_type;
decimals=0;
max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- precision=max_length;
/*
The field type for the result of an Item_func_add_time function is defined
@@ -2942,7 +2935,6 @@
decimals=0;
cached_field_type= MYSQL_TYPE_STRING;
max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- precision=max_length;
cached_timestamp_type= MYSQL_TIMESTAMP_NONE;
if ((const_item= args[1]->const_item()))
{
--- 1.52/sql/item_timefunc.h Wed Apr 13 12:05:08 2005
+++ 1.53/sql/item_timefunc.h Sat Apr 30 21:37:14 2005
@@ -239,7 +239,6 @@
decimals=0;
max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1;
- precision=max_length;
}
};
@@ -266,7 +265,6 @@
decimals=0;
max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1;
- precision=max_length;
}
};
@@ -283,7 +281,6 @@
decimals=0;
max_length=9*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1;
- precision=max_length;
}
};
@@ -300,7 +297,6 @@
{
decimals=0;
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
- precision=max_length;
}
};
@@ -315,7 +311,6 @@
{
decimals=0;
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
- precision=max_length;
}
};
@@ -340,7 +335,6 @@
collation.set(&my_charset_bin);
decimals=0;
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- precision=max_length;
}
int save_in_field(Field *to, bool no_conversions);
Field *tmp_table_field(TABLE *t_arg)
@@ -761,7 +755,6 @@
{
decimals=0;
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- precision=max_length;
}
Field *tmp_table_field(TABLE *t_arg)
{
@@ -811,7 +804,6 @@
{
decimals=0;
max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- precision=max_length;
}
Field *tmp_table_field(TABLE *t_arg)
{
@@ -831,7 +823,6 @@
{
decimals=0;
max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- precision=max_length;
}
Field *tmp_table_field(TABLE *t_arg)
{
@@ -889,7 +880,6 @@
maybe_null= 1;
decimals=0;
max_length=17*MY_CHARSET_BIN_MB_MAXLEN;
- precision=max_length;
}
void print(String *str);
};
--- 1.443/sql/sql_parse.cc Wed Apr 20 11:01:22 2005
+++ 1.444/sql/sql_parse.cc Sat Apr 30 21:37:14 2005
@@ -5408,8 +5408,8 @@
new_field->length >= new_field->decimals)
{
new_field->length=
- my_decimal_precision2length(new_field->length, new_field->decimals,
- type_modifier & UNSIGNED_FLAG);
+ my_decimal_precision_to_length(new_field->length, new_field->decimals,
+ type_modifier & UNSIGNED_FLAG);
break;
}
my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name);
--- 1.10/sql/my_decimal.h Wed Apr 20 10:52:58 2005
+++ 1.11/sql/my_decimal.h Sat Apr 30 21:37:14 2005
@@ -104,6 +104,7 @@
bool sign() const { return decimal_t::sign; }
void sign(bool s) { decimal_t::sign= s; }
+ uint precision() const { return intg + frac; }
};
@@ -132,16 +133,16 @@
return result;
}
-inline uint my_decimal_length2precision(uint length, uint scale,
- bool unsigned_flag)
+inline uint my_decimal_length_to_precision(uint length, uint scale,
+ bool unsigned_flag)
{
-
return (uint) (length - (scale>0 ? 1:0) - (unsigned_flag ? 0:1));
}
-inline uint32 my_decimal_precision2length(uint precision, uint8 scale,
- bool unsigned_flag)
+inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale,
+ bool unsigned_flag)
{
+ set_if_smaller(precision, DECIMAL_MAX_PRECISION);
return (uint32)(precision + (scale>0 ? 1:0) + (unsigned_flag ? 0:1));
}
| Thread |
|---|
| • bk commit into 5.0 tree (hf:1.1829) | holyfoot | 30 Apr |