summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-05-11 02:41:02 +0300
committerMichael Widenius <monty@askmonty.org>2011-05-11 02:41:02 +0300
commit052d1bfb1a215d927e31bbe521a7e29d5da8a384 (patch)
tree0181353047727b1dee0e785d3412f0d14d1e1757 /sql/item_strfunc.cc
parent03483e7bfd21a61fca796a163376b77cd965870e (diff)
downloadmariadb-git-052d1bfb1a215d927e31bbe521a7e29d5da8a384.tar.gz
Fixed all reported bugs for dynamic columns.
Bugs fixed: - Added automatic detection of unsigned arguments to COLUMN_CREATE() - If string length is not know for COLUMN_GET() use MAX_DYNAMIC_COLUMN_LENGTH instead of MAX_FIELD_BLOBLENGTH - null_value flag was not propery reset for COLUMN_LIST() and COLUMN_CREATE() which could lead to crashes later: - lp:778905 Assertion `value->year <= 9999' failed in dynamic_column_date_store - lp:778912 Assertion `field_pos < field_count' failed in Protocol_text::store in maria-5.3-mwl34 include/ma_dyncol.h: Added define for max dynamic column length. mysql-test/r/cast.result: Added test of cast big unsigned int to signed (this test case was missing) mysql-test/r/dyncol.result: Added tests from reported bugs Added testing of automatic store of signed/unsigned integers mysql-test/t/cast.test: Added test of cast big unsigned int to signed (this test case was missing) mysql-test/t/dyncol.test: Added tests from reported bugs Added testing of automatic store of signed/unsigned integers sql/item.cc: Added assert to catch cases where null_value is not set properly sql/item_strfunc.cc: Added automatic detection of unsigned arguments to COLUMN_CREATE() COLUMN_GET() returned wrong value for illegal strings which lead to assert later null_value flag was not propery reset for COLUMN_LIST() and COLUMN_CREATE() which could lead to crashes later. sql/item_strfunc.h: If string length is not know for COLUMN_GET() use MAX_DYNAMIC_COLUMN_LENGTH
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 1471fcab001..4170b356fb7 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -3511,7 +3511,7 @@ void Item_func_dyncol_create::prepare_arguments()
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_BIT:
- type= DYN_COL_INT;
+ type= args[valpos]->unsigned_flag ? DYN_COL_UINT : DYN_COL_INT;
break;
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
@@ -3653,6 +3653,7 @@ String *Item_func_dyncol_create::val_str(String *str)
str_value.reassociate(ptr, (uint32) length, (uint32) alloc_length,
&my_charset_bin);
res= &str_value;
+ null_value= FALSE;
}
/* cleanup */
@@ -3756,6 +3757,7 @@ String *Item_func_dyncol_add::val_str(String *str)
dynamic_column_reassociate(&col, &ptr, &length, &alloc_length);
str->reassociate(ptr, (uint32) length, (uint32) alloc_length,
&my_charset_bin);
+ null_value= FALSE;
}
/* cleanup */
@@ -3781,6 +3783,14 @@ void Item_func_dyncol_add::print(String *str,
str->append(')');
}
+
+/**
+ Get value for a column stored in a dynamic column
+
+ @notes
+ This function ensures that null_value is set correctly
+*/
+
bool Item_dyncol_get::get_dyn_value(DYNAMIC_COLUMN_VALUE *val, String *tmp)
{
DYNAMIC_COLUMN dyn_str;
@@ -4104,7 +4114,7 @@ bool Item_dyncol_get::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
bool signed_value= 0;
if (get_dyn_value(&val, &tmp))
- return 0;
+ return 1; // Error
switch (val.type) {
case DYN_COL_NULL:
@@ -4208,6 +4218,7 @@ String *Item_func_dyncol_list::val_str(String *str)
str->qs_append(',');
}
+ null_value= FALSE;
delete_dynamic(&arr);
return str;