diff options
author | unknown <venu@myvenu.com> | 2003-04-30 00:02:28 -0700 |
---|---|---|
committer | unknown <venu@myvenu.com> | 2003-04-30 00:02:28 -0700 |
commit | 58613a85fdc72e2357b6a4586e9737753ac06235 (patch) | |
tree | cabb1435029397264db6d20a3a7da3ab9fed3d00 /sql/sql_load.cc | |
parent | 1f4309fa7e3fa703145374e7050647766a25cd02 (diff) | |
download | mariadb-git-58613a85fdc72e2357b6a4586e9737753ac06235.tar.gz |
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
Diffstat (limited to 'sql/sql_load.cc')
-rw-r--r-- | sql/sql_load.cc | 53 |
1 files changed, 16 insertions, 37 deletions
diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 47e4be16b8e..c9c0e36ff7b 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -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 |