summaryrefslogtreecommitdiff
path: root/sql/sql_analyse.cc
diff options
context:
space:
mode:
authormonty@mysql.com <>2005-02-19 18:58:27 +0200
committermonty@mysql.com <>2005-02-19 18:58:27 +0200
commit218e00ac681c300ddfb59889d8b6dd7faa0e71f6 (patch)
tree45069dd14961944b02845ab6e42f1993666f63e8 /sql/sql_analyse.cc
parent7bc48798fce1b4010adbd074aa18784fcf0eb07e (diff)
downloadmariadb-git-218e00ac681c300ddfb59889d8b6dd7faa0e71f6.tar.gz
Fixed BUILD script to use --with-berkeley-db instead of --with-bdb
Lots of small fixes to multi-precision-math path Give Note for '123.4e' Added helper functions type 'val_string_from_real() Don't give warnings for end space for string2decimal() Changed storage of values for SP so that we can detect length of argument without strlen() Changed interface for str2dec() so that we must supple the pointer to the last character in the buffer
Diffstat (limited to 'sql/sql_analyse.cc')
-rw-r--r--sql/sql_analyse.cc43
1 files changed, 28 insertions, 15 deletions
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index c2eea524cac..642de13039e 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -133,22 +133,30 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result,
Item *item;
while ((item = it++))
{
- if (item->result_type() == INT_RESULT)
- {
+ field_info *new_field;
+ switch (item->result_type()) {
+ case INT_RESULT:
// Check if fieldtype is ulonglong
if (item->type() == Item::FIELD_ITEM &&
((Item_field*) item)->field->type() == FIELD_TYPE_LONGLONG &&
((Field_longlong*) ((Item_field*) item)->field)->unsigned_flag)
- *f_info++ = new field_ulonglong(item, pc);
+ new_field= new field_ulonglong(item, pc);
else
- *f_info++ = new field_longlong(item, pc);
+ new_field= new field_longlong(item, pc);
+ break;
+ case REAL_RESULT:
+ new_field= new field_real(item, pc);
+ break;
+ case DECIMAL_RESULT:
+ new_field= new field_decimal(item, pc);
+ break;
+ case STRING_RESULT:
+ new_field= new field_str(item, pc);
+ break;
+ default:
+ goto err;
}
- if (item->result_type() == REAL_RESULT)
- *f_info++ = new field_real(item, pc);
- if (item->result_type() == DECIMAL_RESULT)
- *f_info++= new field_decimal(item, pc);
- if (item->result_type() == STRING_RESULT)
- *f_info++ = new field_str(item, pc);
+ *f_info++= new_field;
}
}
DBUG_RETURN(pc);
@@ -470,6 +478,9 @@ void field_decimal::add()
length= my_decimal_string_length(dec);
+ if (decimal_is_zero(dec))
+ empty++;
+
if (room_in_tree)
{
char buf[DECIMAL_MAX_FIELD_SIZE];
@@ -502,7 +513,7 @@ void field_decimal::add()
cur_sum= 0;
min_length = max_length = length;
}
- else
+ else if (!decimal_is_zero(dec))
{
int next_cur_sum= cur_sum ^ 1;
my_decimal sqr_buf;
@@ -972,15 +983,17 @@ void field_decimal::get_opt_type(String *answer,
{
my_decimal zero;
char buff[MAX_FIELD_WIDTH];
+ uint length;
my_decimal_set_zero(&zero);
my_bool is_unsigned= (my_decimal_cmp(&zero, &min_arg) >= 0);
- sprintf(buff, "DECIMAL(%d, %d)",
- (int)(max_length - (item->decimals ? 1 : 0)), item->decimals);
+ length= my_sprintf(buff, (buff, "DECIMAL(%d, %d)",
+ (int) (max_length - (item->decimals ? 1 : 0)),
+ item->decimals));
if (is_unsigned)
- strcat(buff, " UNSIGNED");
- answer->append(buff, (uint) strlen(buff));
+ length= (uint) (strmov(buff+length, " UNSIGNED")- buff);
+ answer->append(buff, length);
}