Commit b0cfa449 authored by unknown's avatar unknown

Fix for #233 (the second one)


sql/field.cc:
  Field_geom::store() returns -1 as a sign of fatal error
sql/field_conv.cc:
  set_field_to_null* return -1 now as the fatal error
sql/item.cc:
  no sign inversions needed
sql/opt_range.cc:
  -1 is the sign of fatal error now
sql/sql_base.cc:
  -1 is the fatal error
parent 17f8d3d7
...@@ -5081,7 +5081,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) ...@@ -5081,7 +5081,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
wkb_type= uint4korr(from + WKB_HEADER_SIZE); wkb_type= uint4korr(from + WKB_HEADER_SIZE);
if (wkb_type < (uint32) Geometry::wkb_point || if (wkb_type < (uint32) Geometry::wkb_point ||
wkb_type > (uint32) Geometry::wkb_end) wkb_type > (uint32) Geometry::wkb_end)
return 1; return -1;
Field_blob::store_length(length); Field_blob::store_length(length);
if (table->copy_blobs || length <= MAX_FIELD_WIDTH) if (table->copy_blobs || length <= MAX_FIELD_WIDTH)
{ // Must make a copy { // Must make a copy
...@@ -5094,7 +5094,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) ...@@ -5094,7 +5094,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
err: err:
bzero(ptr, Field_blob::pack_length()); bzero(ptr, Field_blob::pack_length());
return 1; return -1;
} }
#endif /*HAVE_SPATIAL*/ #endif /*HAVE_SPATIAL*/
......
...@@ -127,7 +127,7 @@ set_field_to_null(Field *field) ...@@ -127,7 +127,7 @@ set_field_to_null(Field *field)
if (!current_thd->no_errors) if (!current_thd->no_errors)
my_printf_error(ER_BAD_NULL_ERROR,ER(ER_BAD_NULL_ERROR),MYF(0), my_printf_error(ER_BAD_NULL_ERROR,ER(ER_BAD_NULL_ERROR),MYF(0),
field->field_name); field->field_name);
return 1; return -1;
} }
...@@ -145,7 +145,7 @@ set_field_to_null(Field *field) ...@@ -145,7 +145,7 @@ set_field_to_null(Field *field)
RETURN VALUES RETURN VALUES
0 Field could take 0 or an automatic conversion was used 0 Field could take 0 or an automatic conversion was used
1 Field could not take NULL and no conversion was used. -1 Field could not take NULL and no conversion was used.
If no_conversion was not set, an error message is printed If no_conversion was not set, an error message is printed
*/ */
...@@ -159,7 +159,7 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions) ...@@ -159,7 +159,7 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
return 0; return 0;
} }
if (no_conversions) if (no_conversions)
return 1; return -1;
/* /*
Check if this is a special type, which will get a special walue Check if this is a special type, which will get a special walue
...@@ -184,7 +184,7 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions) ...@@ -184,7 +184,7 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
if (!current_thd->no_errors) if (!current_thd->no_errors)
my_printf_error(ER_BAD_NULL_ERROR,ER(ER_BAD_NULL_ERROR),MYF(0), my_printf_error(ER_BAD_NULL_ERROR,ER(ER_BAD_NULL_ERROR),MYF(0),
field->field_name); field->field_name);
return 1; return -1;
} }
......
...@@ -639,7 +639,7 @@ int Item_param::save_in_field(Field *field, bool no_conversions) ...@@ -639,7 +639,7 @@ int Item_param::save_in_field(Field *field, bool no_conversions)
return 0; return 0;
} }
String *result=val_str(&str_value); String *result=val_str(&str_value);
return (field->store(result->ptr(),result->length(),field->charset())) ? -1 : 0; return field->store(result->ptr(),result->length(),field->charset());
} }
bool Item_param::get_time(TIME *res) bool Item_param::get_time(TIME *res)
...@@ -1236,7 +1236,7 @@ int Item::save_in_field(Field *field, bool no_conversions) ...@@ -1236,7 +1236,7 @@ int Item::save_in_field(Field *field, bool no_conversions)
field->set_notnull(); field->set_notnull();
error=field->store(nr); error=field->store(nr);
} }
return (error) ? -1 : 0; return error;
} }
...@@ -1247,8 +1247,7 @@ int Item_string::save_in_field(Field *field, bool no_conversions) ...@@ -1247,8 +1247,7 @@ int Item_string::save_in_field(Field *field, bool no_conversions)
if (null_value) if (null_value)
return set_field_to_null(field); return set_field_to_null(field);
field->set_notnull(); field->set_notnull();
return (field->store(result->ptr(),result->length(),collation.collation)) ? return field->store(result->ptr(),result->length(),collation.collation);
-1 : 0;
} }
int Item_uint::save_in_field(Field *field, bool no_conversions) int Item_uint::save_in_field(Field *field, bool no_conversions)
...@@ -1267,7 +1266,7 @@ int Item_int::save_in_field(Field *field, bool no_conversions) ...@@ -1267,7 +1266,7 @@ int Item_int::save_in_field(Field *field, bool no_conversions)
if (null_value) if (null_value)
return set_field_to_null(field); return set_field_to_null(field);
field->set_notnull(); field->set_notnull();
return (field->store(nr)) ? -1 : 0; return field->store(nr);
} }
...@@ -1277,7 +1276,7 @@ int Item_real::save_in_field(Field *field, bool no_conversions) ...@@ -1277,7 +1276,7 @@ int Item_real::save_in_field(Field *field, bool no_conversions)
if (null_value) if (null_value)
return set_field_to_null(field); return set_field_to_null(field);
field->set_notnull(); field->set_notnull();
return (field->store(nr)) ? -1 : 0; return field->store(nr);
} }
/**************************************************************************** /****************************************************************************
...@@ -1339,7 +1338,7 @@ int Item_varbinary::save_in_field(Field *field, bool no_conversions) ...@@ -1339,7 +1338,7 @@ int Item_varbinary::save_in_field(Field *field, bool no_conversions)
longlong nr=val_int(); longlong nr=val_int();
error=field->store(nr); error=field->store(nr);
} }
return (error) ? -1 : 0; return error;
} }
......
...@@ -1095,7 +1095,7 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, ...@@ -1095,7 +1095,7 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
field->cmp_type() != value->result_type()) field->cmp_type() != value->result_type())
DBUG_RETURN(0); DBUG_RETURN(0);
if (value->save_in_field(field, 1) > 0) if (value->save_in_field(field, 1) < 0)
{ {
/* This happens when we try to insert a NULL field in a not null column */ /* This happens when we try to insert a NULL field in a not null column */
DBUG_RETURN(&null_element); // cmp with NULL is never true DBUG_RETURN(&null_element); // cmp with NULL is never true
......
...@@ -2424,7 +2424,7 @@ fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors) ...@@ -2424,7 +2424,7 @@ fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors)
TABLE *table= rfield->table; TABLE *table= rfield->table;
if (rfield == table->next_number_field) if (rfield == table->next_number_field)
table->auto_increment_field_not_null= true; table->auto_increment_field_not_null= true;
if (value->save_in_field(rfield, 0) > 0 && !ignore_errors) if ((value->save_in_field(rfield, 0) < 0) && !ignore_errors)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -2445,7 +2445,7 @@ fill_record(Field **ptr,List<Item> &values, bool ignore_errors) ...@@ -2445,7 +2445,7 @@ fill_record(Field **ptr,List<Item> &values, bool ignore_errors)
TABLE *table= field->table; TABLE *table= field->table;
if (field == table->next_number_field) if (field == table->next_number_field)
table->auto_increment_field_not_null= true; table->auto_increment_field_not_null= true;
if (value->save_in_field(field, 0) == 1 && !ignore_errors) if ((value->save_in_field(field, 0) < 0) && !ignore_errors)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment