summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@magare.gmz>2007-05-30 09:55:38 +0300
committerunknown <gkodinov/kgeorge@magare.gmz>2007-05-30 09:55:38 +0300
commita61d53eb60b1d26aeb0f88fdc77a3854bbae0be1 (patch)
tree8b6ba297a0680998c82b88152afa4a516515dda0 /sql
parente5ab3b7e9f33601dd2e0a4670be75a1ef1cf06f7 (diff)
downloadmariadb-git-a61d53eb60b1d26aeb0f88fdc77a3854bbae0be1.tar.gz
Bug #28492: subselect returns LONG in >5.0.24a and LONGLONG in <=5.0.24a
Integer values with 10 digits may or may not fit into an int column (e.g. 2147483647 vs 6147483647). Thus when creating a temp table column for such an int we must use bigint instead. Fixed to use bigint. Also subsituted a "magic number" with a named constant. mysql-test/r/analyse.result: Bug #28492: Adjusted the results after having fixed the bug mysql-test/r/metadata.result: Bug #28492: test case mysql-test/r/olap.result: Bug #28492: Adjusted the results after having fixed the bug mysql-test/r/sp.result: Bug #28492: Adjusted the results after having fixed the bug mysql-test/r/view.result: Bug #28492: Adjusted the results after having fixed the bug mysql-test/t/metadata.test: Bug #28492: test case sql/field.h: Bug #28492: Replaced a magic number with a constant sql/sql_select.cc: Bug #28492: Treat integers with 10 and more digits as bigint.
Diffstat (limited to 'sql')
-rw-r--r--sql/field.h2
-rw-r--r--sql/sql_select.cc9
2 files changed, 8 insertions, 3 deletions
diff --git a/sql/field.h b/sql/field.h
index 997ae1f2cd4..37ce6b88453 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -675,7 +675,7 @@ public:
void sort_string(char *buff,uint length);
uint32 pack_length() const { return 4; }
void sql_type(String &str) const;
- uint32 max_display_length() { return 11; }
+ uint32 max_display_length() { return MY_INT32_NUM_DECIMAL_DIGITS; }
};
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 57dff4b23a5..54ea4a8496c 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8869,8 +8869,13 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
item->name, table, item->decimals, TRUE);
break;
case INT_RESULT:
- /* Select an integer type with the minimal fit precision */
- if (item->max_length > MY_INT32_NUM_DECIMAL_DIGITS)
+ /*
+ Select an integer type with the minimal fit precision.
+ MY_INT32_NUM_DECIMAL_DIGITS is sign inclusive, don't consider the sign.
+ Values with MY_INT32_NUM_DECIMAL_DIGITS digits may or may not fit into
+ Field_long : make them Field_longlong.
+ */
+ if (item->max_length >= (MY_INT32_NUM_DECIMAL_DIGITS - 1))
new_field=new Field_longlong(item->max_length, maybe_null,
item->name, table, item->unsigned_flag);
else