summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@host.loc>2008-05-06 21:43:46 +0500
committerunknown <gshchepa/uchum@host.loc>2008-05-06 21:43:46 +0500
commit5a1b7ddb683a34c0a512c890a11170e0b0b14da2 (patch)
tree274f7ab47cd2d388e2f9a34437a09d2eaba46f74 /sql/field.cc
parent65a310fe2a594aca6e73308896763933adb59e3e (diff)
downloadmariadb-git-5a1b7ddb683a34c0a512c890a11170e0b0b14da2.tar.gz
Partial rollback of fix for bug #30059: End-space truncation is inconsistent
or incorrect. For better conformance with standard, truncation procedure of CHAR columns has been changed to ignore truncation of trailing whitespace characters (note has been removed). Finally, for columns with non-binary charsets: 1. CHAR(N) columns silently ignore trailing whitespace truncation; 2. VARCHAR and TEXT columns issue Note about truncation. BLOBs and other columns with BINARY charset are unaffected. mysql-test/r/bdb.result: Rollback of bug #30059 fix. mysql-test/r/heap.result: Rollback of bug #30059 fix. mysql-test/r/innodb.result: Rollback of bug #30059 fix. mysql-test/r/myisam.result: Rollback of bug #30059 fix. mysql-test/r/strict.result: Rollback of bug #30059 fix. mysql-test/r/type_binary.result: Rollback of bug #30059 fix. mysql-test/r/warnings.result: Updated test case for bug #30059. sql/field.cc: Post-commit fix for bug #30059. The Field_longstr::report_if_important_data method has been changed to notify about trailing spaces only if the new count_spaces parameter is TRUE. The Field_string::store method has been changed to ignore trailing whitespace truncation (CHAR column type). sql/field.h: Post-commit fix for bug #30059. The Field_longstr::report_if_important_data method declaration has been changed to accept extra parameter: bool count_spaces.
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 18bb7153060..d840034f8dc 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5868,6 +5868,7 @@ check_string_copy_error(Field_str *field,
Field_longstr::report_if_important_data()
ptr - Truncated rest of string
end - End of truncated string
+ count_spaces - Treat traling spaces as important data
RETURN VALUES
0 - None was truncated (or we don't count cut fields)
@@ -5877,10 +5878,12 @@ check_string_copy_error(Field_str *field,
Check if we lost any important data (anything in a binary string,
or any non-space in others). If only trailing spaces was lost,
send a truncation note, otherwise send a truncation error.
+ Silently ignore traling spaces if the count_space parameter is FALSE.
*/
int
-Field_longstr::report_if_important_data(const char *ptr, const char *end)
+Field_longstr::report_if_important_data(const char *ptr, const char *end,
+ bool count_spaces)
{
if ((ptr < end) && table->in_use->count_cuted_fields)
{
@@ -5890,10 +5893,13 @@ Field_longstr::report_if_important_data(const char *ptr, const char *end)
set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
else
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
+ return 2;
}
- else /* If we lost only spaces then produce a NOTE, not a WARNING */
+ else if (count_spaces)
+ { /* If we lost only spaces then produce a NOTE, not a WARNING */
set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1);
- return 2;
+ return 2;
+ }
}
return 0;
}
@@ -5929,7 +5935,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
cannot_convert_error_pos, from + length))
return 2;
- return report_if_important_data(from_end_pos, from + length);
+ return report_if_important_data(from_end_pos, from + length, FALSE);
}
@@ -6388,7 +6394,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
cannot_convert_error_pos, from + length))
return 2;
- return report_if_important_data(from_end_pos, from + length);
+ return report_if_important_data(from_end_pos, from + length, TRUE);
}
@@ -7025,7 +7031,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
cannot_convert_error_pos, from + length))
return 2;
- return report_if_important_data(from_end_pos, from + length);
+ return report_if_important_data(from_end_pos, from + length, TRUE);
oom_error:
/* Fatal OOM error */