mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Support of warnings for all DML statements (Insert, Update and Alter)
Fix LOAD DATA INFILE warnings to have a better meanigful messages Fix to make the mysql command line to automatically show the warnings count for all basic commands
This commit is contained in:
@@ -368,11 +368,10 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
|
||||
List_iterator_fast<Item> it(fields);
|
||||
Item_field *sql_field;
|
||||
ulonglong id;
|
||||
ulong row_pos;
|
||||
DBUG_ENTER("read_fixed_length");
|
||||
|
||||
id= 0;
|
||||
row_pos= 1;
|
||||
|
||||
/* No fields can be null in this format. mark all fields as not null */
|
||||
while ((sql_field= (Item_field*) it++))
|
||||
sql_field->field->set_notnull();
|
||||
@@ -391,14 +390,14 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
|
||||
#endif
|
||||
while ((sql_field= (Item_field*) it++))
|
||||
{
|
||||
Field *field=sql_field->field;
|
||||
Field *field= sql_field->field;
|
||||
if (pos == read_info.row_end)
|
||||
{
|
||||
thd->cuted_fields++; /* Not enough fields */
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_TOO_FEW_RECORDS,
|
||||
ER(ER_WARN_TOO_FEW_RECORDS), row_pos);
|
||||
field->reset();
|
||||
ER(ER_WARN_TOO_FEW_RECORDS), thd->row_count);
|
||||
field->reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -408,13 +407,7 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
|
||||
field->field_length)
|
||||
length=field->field_length;
|
||||
save_chr=pos[length]; pos[length]='\0'; // Safeguard aganst malloc
|
||||
if (field->store((char*) pos,length,read_info.read_charset))
|
||||
{
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_DATA_TRUNCATED,
|
||||
ER(ER_WARN_DATA_TRUNCATED),
|
||||
field->field_name, row_pos);
|
||||
}
|
||||
field->store((char*) pos,length,read_info.read_charset);
|
||||
pos[length]=save_chr;
|
||||
if ((pos+=length) > read_info.row_end)
|
||||
pos= read_info.row_end; /* Fills rest with space */
|
||||
@@ -425,7 +418,7 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
|
||||
thd->cuted_fields++; /* To long row */
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_TOO_MANY_RECORDS,
|
||||
ER(ER_WARN_TOO_MANY_RECORDS), row_pos);
|
||||
ER(ER_WARN_TOO_MANY_RECORDS), thd->row_count);
|
||||
}
|
||||
if (write_record(table,&info))
|
||||
DBUG_RETURN(1);
|
||||
@@ -446,9 +439,9 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
|
||||
thd->cuted_fields++; /* To long row */
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_TOO_MANY_RECORDS,
|
||||
ER(ER_WARN_TOO_MANY_RECORDS), row_pos);
|
||||
ER(ER_WARN_TOO_MANY_RECORDS), thd->row_count);
|
||||
}
|
||||
row_pos++;
|
||||
thd->row_count++;
|
||||
}
|
||||
if (id && !read_info.error)
|
||||
thd->insert_id(id); // For binary/update log
|
||||
@@ -466,12 +459,10 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
|
||||
Item_field *sql_field;
|
||||
uint enclosed_length;
|
||||
ulonglong id;
|
||||
ulong row_pos;
|
||||
DBUG_ENTER("read_sep_field");
|
||||
|
||||
enclosed_length=enclosed.length();
|
||||
id= 0;
|
||||
row_pos= 1;
|
||||
|
||||
for (;;it.rewind())
|
||||
{
|
||||
@@ -501,27 +492,15 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
|
||||
{
|
||||
if (field->type() == FIELD_TYPE_TIMESTAMP)
|
||||
((Field_timestamp*) field)->set_time();
|
||||
else if (field != table->next_number_field)
|
||||
{
|
||||
thd->cuted_fields++;
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_NULL_TO_NOTNULL,
|
||||
ER(ER_WARN_NULL_TO_NOTNULL),
|
||||
field->field_name, row_pos);
|
||||
}
|
||||
else if (field != table->next_number_field)
|
||||
field->set_warning((uint)MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_NULL_TO_NOTNULL);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
field->set_notnull();
|
||||
read_info.row_end[0]=0; // Safe to change end marker
|
||||
if (field->store((char*) read_info.row_start,length,read_info.read_charset))
|
||||
{
|
||||
// Data truncated or out of bounds
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_DATA_TRUNCATED,
|
||||
ER(ER_WARN_DATA_TRUNCATED),
|
||||
field->field_name, row_pos);
|
||||
}
|
||||
field->store((char*) read_info.row_start,length,read_info.read_charset);
|
||||
}
|
||||
if (read_info.error)
|
||||
break;
|
||||
@@ -536,7 +515,7 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
|
||||
thd->cuted_fields++;
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_TOO_FEW_RECORDS,
|
||||
ER(ER_WARN_TOO_FEW_RECORDS), row_pos);
|
||||
ER(ER_WARN_TOO_FEW_RECORDS), thd->row_count);
|
||||
}
|
||||
}
|
||||
if (write_record(table,&info))
|
||||
@@ -557,10 +536,10 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
|
||||
{
|
||||
thd->cuted_fields++; /* To long row */
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARN_TOO_MANY_RECORDS,
|
||||
ER(ER_WARN_TOO_MANY_RECORDS), row_pos);
|
||||
ER_WARN_TOO_MANY_RECORDS, ER(ER_WARN_TOO_MANY_RECORDS),
|
||||
thd->row_count);
|
||||
}
|
||||
row_pos++;
|
||||
thd->row_count++;
|
||||
}
|
||||
if (id && !read_info.error)
|
||||
thd->insert_id(id); // For binary/update log
|
||||
|
||||
Reference in New Issue
Block a user