Below is the list of changes that have just been committed into a local
5.1 repository of antony. When antony does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-16 13:37:16-07:00, antony@stripped +3 -0
Bug#31473
"CSV does not work with NULL value in datetime fields"
Attempting to insert a row with a NULL value for a DATETIME field
results in a CSV file which the storage engine cannot read.
Don't blindly assume that "0" is acceptable for all field types,
Since CSV does not support NULL, we find out from the field the
default non-null value.
mysql-test/r/csv.result@stripped, 2007-10-16 13:37:07-07:00, antony@stripped +6 -0
test for bug 31473
mysql-test/t/csv.test@stripped, 2007-10-16 13:37:07-07:00, antony@stripped +8 -0
test for bug 31473
storage/csv/ha_tina.cc@stripped, 2007-10-16 13:37:07-07:00, antony@stripped +7 -3
bug31473
Don't blindly assume that "0" is acceptable for all field types,
Since CSV does not support NULL, we find out from the field the
default non-null value.
diff -Nrup a/mysql-test/r/csv.result b/mysql-test/r/csv.result
--- a/mysql-test/r/csv.result 2007-07-10 01:09:05 -07:00
+++ b/mysql-test/r/csv.result 2007-10-16 13:37:07 -07:00
@@ -5315,4 +5315,10 @@ test.t1 check status OK
select * from t1;
a
drop table t1;
+create table t1(a datetime default null) engine=csv;
+insert into t1 values();
+select * from t1;
+a
+0000-00-00 00:00:00
+drop table t1;
End of 5.1 tests
diff -Nrup a/mysql-test/t/csv.test b/mysql-test/t/csv.test
--- a/mysql-test/t/csv.test 2007-08-08 07:39:12 -07:00
+++ b/mysql-test/t/csv.test 2007-10-16 13:37:07 -07:00
@@ -1727,4 +1727,12 @@ check table t1;
select * from t1;
drop table t1;
+#
+# Bug #31473: does not work with NULL value in datetime field
+#
+create table t1(a datetime default null) engine=csv;
+insert into t1 values();
+select * from t1;
+drop table t1;
+
--echo End of 5.1 tests
diff -Nrup a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
--- a/storage/csv/ha_tina.cc 2007-08-13 06:11:15 -07:00
+++ b/storage/csv/ha_tina.cc 2007-10-16 13:37:07 -07:00
@@ -471,6 +471,7 @@ int ha_tina::encode_quote(uchar *buf)
{
const char *ptr;
const char *end_ptr;
+ const bool was_null= (*field)->is_null();
/*
CSV does not support nulls. Write quoted 0 to the buffer. In fact,
@@ -480,13 +481,16 @@ int ha_tina::encode_quote(uchar *buf)
field content is cleaned up every time we use Field::set_null()
in the code.
*/
- if ((*field)->is_null())
+ if (was_null)
{
- buffer.append(STRING_WITH_LEN("\"0\","));
- continue;
+ (*field)->set_default();
+ (*field)->set_notnull();
}
(*field)->val_str(&attribute,&attribute);
+
+ if (was_null)
+ (*field)->set_null();
if ((*field)->str_needs_quotes())
{
| Thread |
|---|
| • bk commit into 5.1 tree (antony:1.2574) BUG#31473 | antony | 16 Oct |