summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc14
-rw-r--r--sql/field.h4
-rw-r--r--sql/item.cc42
-rw-r--r--sql/item.h8
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/share/czech/errmsg.txt3
-rw-r--r--sql/share/danish/errmsg.txt3
-rw-r--r--sql/share/dutch/errmsg.txt3
-rw-r--r--sql/share/english/errmsg.txt3
-rw-r--r--sql/share/estonian/errmsg.txt3
-rw-r--r--sql/share/french/errmsg.txt3
-rw-r--r--sql/share/german/errmsg.txt1
-rw-r--r--sql/share/greek/errmsg.txt3
-rw-r--r--sql/share/hungarian/errmsg.txt3
-rw-r--r--sql/share/italian/errmsg.txt3
-rw-r--r--sql/share/japanese/errmsg.txt3
-rw-r--r--sql/share/korean/errmsg.txt3
-rw-r--r--sql/share/norwegian-ny/errmsg.txt3
-rw-r--r--sql/share/norwegian/errmsg.txt3
-rw-r--r--sql/share/polish/errmsg.txt3
-rw-r--r--sql/share/portuguese/errmsg.txt1
-rw-r--r--sql/share/romanian/errmsg.txt3
-rw-r--r--sql/share/russian/errmsg.txt3
-rw-r--r--sql/share/serbian/errmsg.txt3
-rw-r--r--sql/share/slovak/errmsg.txt3
-rw-r--r--sql/share/spanish/errmsg.txt1
-rw-r--r--sql/share/swedish/errmsg.txt1
-rw-r--r--sql/share/ukrainian/errmsg.txt1
-rw-r--r--sql/sql_insert.cc14
-rw-r--r--sql/sql_parse.cc9
-rw-r--r--sql/sql_show.cc4
-rw-r--r--sql/sql_table.cc4
-rw-r--r--sql/sql_update.cc7
-rw-r--r--sql/sql_yacc.yy20
-rw-r--r--sql/table.cc4
35 files changed, 139 insertions, 52 deletions
diff --git a/sql/field.cc b/sql/field.cc
index ada8381653b..1cadf186a4c 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2290,10 +2290,13 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
int error;
char *end;
double nr= my_strntod(cs,(char*) from,len,&end,&error);
- if (error || ((uint) (end-from) != len && table->in_use->count_cuted_fields))
+ if (error || (!len || (uint) (end-from) != len &&
+ table->in_use->count_cuted_fields))
{
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
+ (error ? ER_WARN_DATA_OUT_OF_RANGE : ER_WARN_DATA_TRUNCATED),
+ 1);
error= 1;
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
}
Field_float::store(nr);
return error;
@@ -2592,10 +2595,13 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
int error;
char *end;
double nr= my_strntod(cs,(char*) from, len, &end, &error);
- if (error || ((uint) (end-from) != len && table->in_use->count_cuted_fields))
+ if (error || (!len || (uint) (end-from) != len &&
+ table->in_use->count_cuted_fields))
{
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
+ (error ? ER_WARN_DATA_OUT_OF_RANGE : ER_WARN_DATA_TRUNCATED),
+ 1);
error= 1;
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
}
Field_double::store(nr);
return error;
diff --git a/sql/field.h b/sql/field.h
index f953613deb7..725e962ca07 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1272,6 +1272,7 @@ int set_field_to_null_with_conversions(Field *field, bool no_conversions);
#define FIELDFLAG_LEFT_FULLSCREEN 8192
#define FIELDFLAG_RIGHT_FULLSCREEN 16384
#define FIELDFLAG_FORMAT_NUMBER 16384 // predit: ###,,## in output
+#define FIELDFLAG_NO_DEFAULT 16384 /* sql */
#define FIELDFLAG_SUM ((uint) 32768)// predit: +#fieldflag
#define FIELDFLAG_MAYBE_NULL ((uint) 32768)// sql
#define FIELDFLAG_PACK_SHIFT 3
@@ -1280,8 +1281,6 @@ int set_field_to_null_with_conversions(Field *field, bool no_conversions);
#define FIELDFLAG_NUM_SCREEN_TYPE 0x7F01
#define FIELDFLAG_ALFA_SCREEN_TYPE 0x7800
-#define FIELD_SORT_REVERSE 16384
-
#define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */
#define f_is_dec(x) ((x) & FIELDFLAG_DECIMAL)
@@ -1299,3 +1298,4 @@ int set_field_to_null_with_conversions(Field *field, bool no_conversions);
#define f_is_equ(x) ((x) & (1+2+FIELDFLAG_PACK+31*256))
#define f_settype(x) (((int) x) << FIELDFLAG_PACK_SHIFT)
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
+#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
diff --git a/sql/item.cc b/sql/item.cc
index 3953aecaa08..267560b0709 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1862,6 +1862,34 @@ Item_num *Item_uint::neg()
return new Item_real(name, - ((double) value), 0, max_length);
}
+
+/*
+ This function is only called during parsing. We will signal an error if
+ value is not a true double value (overflow)
+*/
+
+Item_real::Item_real(const char *str_arg, uint length)
+{
+ int error;
+ char *end;
+ value= my_strntod(&my_charset_bin, (char*) str_arg, length, &end, &error);
+ if (error)
+ {
+ /*
+ Note that we depend on that str_arg is null terminated, which is true
+ when we are in the parser
+ */
+ DBUG_ASSERT(str_arg[length] == 0);
+ my_printf_error(ER_ILLEGAL_VALUE_FOR_TYPE, ER(ER_ILLEGAL_VALUE_FOR_TYPE),
+ MYF(0), "double", (char*) str_arg);
+ }
+ presentation= name=(char*) str_arg;
+ decimals=(uint8) nr_of_decimals(str_arg);
+ max_length=length;
+ fixed= 1;
+}
+
+
int Item_real::save_in_field(Field *field, bool no_conversions)
{
double nr=val();
@@ -2381,7 +2409,10 @@ bool Item_default_value::fix_fields(THD *thd,
struct st_table_list *table_list,
Item **items)
{
+ Item_field *field_arg;
+ Field *def_field;
DBUG_ASSERT(fixed == 0);
+
if (!arg)
{
fixed= 1;
@@ -2399,9 +2430,14 @@ bool Item_default_value::fix_fields(THD *thd,
}
arg= ref->ref[0];
}
- Item_field *field_arg= (Item_field *)arg;
- Field *def_field= (Field*) sql_alloc(field_arg->field->size_of());
- if (!def_field)
+ field_arg= (Item_field *)arg;
+ if (field_arg->field->flags & NO_DEFAULT_VALUE_FLAG)
+ {
+ my_printf_error(ER_NO_DEFAULT_FOR_FIELD, ER(ER_NO_DEFAULT_FOR_FIELD),
+ MYF(0), field_arg->field->field_name);
+ return 1;
+ }
+ if (!(def_field= (Field*) sql_alloc(field_arg->field->size_of())))
return 1;
memcpy(def_field, field_arg->field, field_arg->field->size_of());
def_field->move_field(def_field->table->default_values -
diff --git a/sql/item.h b/sql/item.h
index 8094a2a10d7..71db03ad687 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -707,13 +707,7 @@ class Item_real :public Item_num
public:
double value;
// Item_real() :value(0) {}
- Item_real(const char *str_arg, uint length) :value(my_atof(str_arg))
- {
- presentation= name=(char*) str_arg;
- decimals=(uint8) nr_of_decimals(str_arg);
- max_length=length;
- fixed= 1;
- }
+ Item_real(const char *str_arg, uint length);
Item_real(const char *str,double val_arg,uint decimal_par,uint length)
:value(val_arg)
{
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 59abee55a3a..8ab5daffc16 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2090,7 +2090,7 @@ extern "C" int my_message_sql(uint error, const char *str,
{
THD *thd;
DBUG_ENTER("my_message_sql");
- DBUG_PRINT("error", ("Message: '%s'", str));
+ DBUG_PRINT("error", ("error: %u message: '%s'", error, str));
if ((thd= current_thd))
{
if (thd->spcont &&
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index 7b24036d385..1bfc7a1af0a 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -291,7 +291,7 @@ character-set=latin2
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -395,3 +395,4 @@ character-set=latin2
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index 81a310a3f0a..8dda6c5af37 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -282,7 +282,7 @@ character-set=latin1
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -386,3 +386,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt
index a67577b1c99..308e48adcd9 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -291,7 +291,7 @@ character-set=latin1
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -395,3 +395,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index e7f1d1b7f64..4ae4e1c4b6e 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -279,7 +279,7 @@ character-set=latin1
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -383,3 +383,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index b6058bc56fc..390771c2564 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -284,7 +284,7 @@ character-set=latin7
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -388,3 +388,4 @@ character-set=latin7
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt
index 345d20e2203..22c52dade49 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -279,7 +279,7 @@ character-set=latin1
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -383,3 +383,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt
index ccc69c68683..b673c105c92 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -396,3 +396,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt
index edd4e07c4d0..cf2fe96a68b 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -279,7 +279,7 @@ character-set=greek
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -383,3 +383,4 @@ character-set=greek
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt
index 27c51b3ce2b..9f311af93a7 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -284,7 +284,7 @@ character-set=latin2
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -388,3 +388,4 @@ character-set=latin2
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt
index 40e1271b187..2a2fdde7892 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -279,7 +279,7 @@ character-set=latin1
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -383,3 +383,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt
index 67de9337ff5..e6f274d9da3 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -283,7 +283,7 @@ character-set=ujis
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -387,3 +387,4 @@ character-set=ujis
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt
index e2d4e29ede7..b740bd339b8 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -279,7 +279,7 @@ character-set=euckr
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -383,3 +383,4 @@ character-set=euckr
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt
index a8bc6129db9..76cb88b8717 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -281,7 +281,7 @@ character-set=latin1
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -385,3 +385,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt
index ddf6960c740..b74972e3510 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -281,7 +281,7 @@ character-set=latin1
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -385,3 +385,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt
index 5a871fbf776..526a15bda61 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -284,7 +284,7 @@ character-set=latin2
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -388,3 +388,4 @@ character-set=latin2
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index c0861879702..7b1d377b6b7 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -385,3 +385,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt
index 60c3cb4245d..56431481eb0 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -284,7 +284,7 @@ character-set=latin2
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -388,3 +388,4 @@ character-set=latin2
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt
index e62c5a84a44..c8780936c4f 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -284,7 +284,7 @@ character-set=koi8r
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -388,3 +388,4 @@ character-set=koi8r
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt
index 2c366890653..a8119a21f21 100644
--- a/sql/share/serbian/errmsg.txt
+++ b/sql/share/serbian/errmsg.txt
@@ -272,7 +272,7 @@ character-set=cp1250
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -376,3 +376,4 @@ character-set=cp1250
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt
index 12eacb82dac..9f8f28aaae5 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -287,7 +287,7 @@ character-set=latin2
"%d line(s) were cut by GROUP_CONCAT()",
"Row %ld doesn't contain data for all columns",
"Row %ld was truncated; it contained more data than there were input columns",
-"Data truncated; NULL supplied to NOT NULL column '%s' at row %ld",
+"Column set to default value; NULL supplied to NOT NULL column '%s' at row %ld",
"Out of range value adjusted for column '%s' at row %ld",
"Data truncated for column '%s' at row %ld",
"Using storage engine %s for table '%s'",
@@ -391,3 +391,4 @@ character-set=latin2
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt
index 94b180914fe..c94aa99ee90 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -387,3 +387,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index 718db694494..3b75eaea5e6 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -383,3 +383,4 @@ character-set=latin1
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt
index 7a4c37abd1d..3ee6324794a 100644
--- a/sql/share/ukrainian/errmsg.txt
+++ b/sql/share/ukrainian/errmsg.txt
@@ -389,3 +389,4 @@ character-set=koi8u
"Field '%-.64s' doesn't have a default value",
"Division by 0",
"Incorrect %-.32s value: '%-.128s' for column '%.64s' at row %ld",
+"Illegal %s '%-.64s' value found during parsing",
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 8f082c45e75..314a8ca9e44 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -246,9 +246,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
/*
Count warnings for all inserts.
For single line insert, generate an error if try to set a NOT NULL field
- to NULL
+ to NULL.
*/
- thd->count_cuted_fields= ((values_list.elements == 1) ?
+ thd->count_cuted_fields= ((values_list.elements == 1 &&
+ duplic != DUP_IGNORE) ?
CHECK_FIELD_ERROR_FOR_NULL :
CHECK_FIELD_WARN);
thd->cuted_fields = 0L;
@@ -276,7 +277,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
- if (check_that_all_fields_are_given_values(thd, table))
+ if (fields.elements && check_that_all_fields_are_given_values(thd, table))
{
/* thd->net.report_error is now set, which will abort the next loop */
error= 1;
@@ -784,13 +785,11 @@ err:
/******************************************************************************
Check that all fields with arn't null_fields are used
- If DONT_USE_DEFAULT_FIELDS isn't defined use default value for not set
- fields.
******************************************************************************/
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry)
{
- if (!thd->abort_on_warning)
+ if (!thd->abort_on_warning) // No check if not strict mode
return 0;
for (Field **field=entry->field ; *field ; field++)
@@ -1666,7 +1665,8 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
- DBUG_RETURN(check_that_all_fields_are_given_values(thd, table));
+ DBUG_RETURN(fields->elements &&
+ check_that_all_fields_are_given_values(thd, table));
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 7be33c751e1..32748ffef81 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4710,9 +4710,14 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
new_field->comment.str= (char*) comment->str;
new_field->comment.length=comment->length;
}
- /* Set flag if this field doesn't have a default value */
+ /*
+ Set flag if this field doesn't have a default value
+ Enum values has always the first value as a default (set in
+ make_empty_rec().
+ */
if (!default_value && !(type_modifier & AUTO_INCREMENT_FLAG) &&
- (type_modifier & NOT_NULL_FLAG) && type != FIELD_TYPE_TIMESTAMP)
+ (type_modifier & NOT_NULL_FLAG) && type != FIELD_TYPE_TIMESTAMP &&
+ type != FIELD_TYPE_ENUM)
new_field->flags|= NO_DEFAULT_VALUE_FLAG;
if (length && !(new_field->length= (uint) atoi(length)))
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 49e2c244d32..951fc9de6d4 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -786,7 +786,8 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
protocol->store("CURRENT_TIMESTAMP", system_charset_info);
}
else if (field->unireg_check != Field::NEXT_NUMBER &&
- !field->is_null())
+ !field->is_null() &&
+ !(field->flags & NO_DEFAULT_VALUE_FLAG))
{ // Not null by default
/*
Note: we have to convert the default value into
@@ -1396,6 +1397,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
field->unireg_check != Field::TIMESTAMP_UN_FIELD;
has_default= (field->type() != FIELD_TYPE_BLOB &&
+ !(field->flags & NO_DEFAULT_VALUE_FLAG) &&
field->unireg_check != Field::NEXT_NUMBER &&
!((foreign_db_mode || limited_mysql_mode) &&
has_now_default));
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index fb4ad28202a..399fed00040 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -609,7 +609,9 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
break;
}
if (!(sql_field->flags & NOT_NULL_FLAG))
- sql_field->pack_flag|=FIELDFLAG_MAYBE_NULL;
+ sql_field->pack_flag|= FIELDFLAG_MAYBE_NULL;
+ if (sql_field->flags & NO_DEFAULT_VALUE_FLAG)
+ sql_field->pack_flag|= FIELDFLAG_NO_DEFAULT;
sql_field->offset= pos;
if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
auto_increment++;
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 024d220b08d..c3741c4c94c 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -351,9 +351,10 @@ int mysql_update(THD *thd,
transactional_table= table->file->has_transactions();
thd->no_trans_update= 0;
- thd->abort_on_warning= test(thd->variables.sql_mode &
- (MODE_STRICT_TRANS_TABLES |
- MODE_STRICT_ALL_TABLES));
+ thd->abort_on_warning= test(handle_duplicates != DUP_IGNORE &&
+ (thd->variables.sql_mode &
+ (MODE_STRICT_TRANS_TABLES |
+ MODE_STRICT_ALL_TABLES)));
while (!(error=info.read_record(&info)) && !thd->killed)
{
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 79c5c094c58..800b586072b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -6448,8 +6448,24 @@ NUM_literal:
NUM { int error; $$ = new Item_int($1.str, (longlong) my_strtoll10($1.str, NULL, &error), $1.length); }
| LONG_NUM { int error; $$ = new Item_int($1.str, (longlong) my_strtoll10($1.str, NULL, &error), $1.length); }
| ULONGLONG_NUM { $$ = new Item_uint($1.str, $1.length); }
- | REAL_NUM { $$ = new Item_real($1.str, $1.length); }
- | FLOAT_NUM { $$ = new Item_float($1.str, $1.length); }
+ | REAL_NUM
+ {
+ $$= new Item_real($1.str, $1.length);
+ if (YYTHD->net.report_error)
+ {
+ send_error(YYTHD, 0, NullS);
+ YYABORT;
+ }
+ }
+ | FLOAT_NUM
+ {
+ $$ = new Item_float($1.str, $1.length);
+ if (YYTHD->net.report_error)
+ {
+ send_error(YYTHD, 0, NullS);
+ YYABORT;
+ }
+ }
;
/**********************************************************************
diff --git a/sql/table.cc b/sql/table.cc
index 88f0cefc09a..b6e6ad69f04 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -461,7 +461,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
field_length= (uint) strpos[3];
recpos= uint2korr(strpos+4),
pack_flag= uint2korr(strpos+6);
- pack_flag&= ~NO_DEFAULT_VALUE_FLAG; // Safety for old files
+ pack_flag&= ~FIELDFLAG_NO_DEFAULT; // Safety for old files
unireg_type= (uint) strpos[8];
interval_nr= (uint) strpos[10];
@@ -498,6 +498,8 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
null_bit=1;
}
}
+ if (f_no_default(pack_flag))
+ reg_field->flags|= NO_DEFAULT_VALUE_FLAG;
if (reg_field->unireg_check == Field::NEXT_NUMBER)
outparam->found_next_number_field= reg_field;
if (outparam->timestamp_field == reg_field)