Commit 178acd10 authored by unknown's avatar unknown

Fix Bug #21328 mysqld issues warnings on ALTER CSV table to MyISAM


mysql-test/r/csv.result:
  update result file
mysql-test/r/log_tables.result:
  log_tables test contains alter of a CSV table with
  NULLs which results in warnings. In fact this is how
  the bug noticed. So, now when it is fixed we should
  update result file.
mysql-test/t/csv.test:
  add a test for the bug
storage/csv/ha_tina.cc:
  We should write 0 to the data file in the
  case we meet NULL. CSV does not support
  NULL values internally and we shouldn't
  distinguish them from 0 when writing a row
  (the alternative is to implement full NULL
  support). Otherwise other routines (such as
  Field::check_int() become confused).
  In 5.0 NULLs are stored as zeroes. In 5.1 it
  somehow turned into empty string. Which is wrong.
parent 507e9f56
...@@ -5223,3 +5223,11 @@ check table bug22080_3; ...@@ -5223,3 +5223,11 @@ check table bug22080_3;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.bug22080_3 check error Corrupt test.bug22080_3 check error Corrupt
drop tables bug22080_1,bug22080_2,bug22080_3; drop tables bug22080_1,bug22080_2,bug22080_3;
CREATE TABLE `bug21328` (
`col1` int(11) DEFAULT NULL,
`col2` int(11) DEFAULT NULL,
`col3` int(11) DEFAULT NULL
) ENGINE=CSV;
insert into bug21328 values (1,NULL,NULL);
alter table bug21328 engine=myisam;
drop table bug21328;
...@@ -111,9 +111,6 @@ slow_log CREATE TABLE `slow_log` ( ...@@ -111,9 +111,6 @@ slow_log CREATE TABLE `slow_log` (
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log' ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
alter table mysql.general_log engine=myisam; alter table mysql.general_log engine=myisam;
alter table mysql.slow_log engine=myisam; alter table mysql.slow_log engine=myisam;
Warnings:
Warning 1366 Incorrect integer value: '' for column 'last_insert_id' at row 0
Warning 1366 Incorrect integer value: '' for column 'insert_id' at row 0
show create table mysql.general_log; show create table mysql.general_log;
Table Create Table Table Create Table
general_log CREATE TABLE `general_log` ( general_log CREATE TABLE `general_log` (
......
...@@ -1605,3 +1605,17 @@ check table bug22080_2; ...@@ -1605,3 +1605,17 @@ check table bug22080_2;
check table bug22080_3; check table bug22080_3;
drop tables bug22080_1,bug22080_2,bug22080_3; drop tables bug22080_1,bug22080_2,bug22080_3;
#
# Bug #21328 mysqld issues warnings on ALTER CSV table to MyISAM
#
CREATE TABLE `bug21328` (
`col1` int(11) DEFAULT NULL,
`col2` int(11) DEFAULT NULL,
`col3` int(11) DEFAULT NULL
) ENGINE=CSV;
insert into bug21328 values (1,NULL,NULL);
alter table bug21328 engine=myisam;
drop table bug21328;
...@@ -542,14 +542,16 @@ int ha_tina::encode_quote(byte *buf) ...@@ -542,14 +542,16 @@ int ha_tina::encode_quote(byte *buf)
const char *end_ptr; const char *end_ptr;
/* /*
Write an empty string to the buffer in case of a NULL value. CSV does not support nulls. Write quoted 0 to the buffer. In fact,
(*field)->val_str(&attribute,&attribute) would usually return 0
in this case but we write it explicitly here.
Basically this is a safety check, as no one ensures that the Basically this is a safety check, as no one ensures that the
field content is cleaned up every time we use Field::set_null() field content is cleaned up every time we use Field::set_null()
in the code. in the code.
*/ */
if ((*field)->is_null()) if ((*field)->is_null())
{ {
buffer.append(STRING_WITH_LEN("\"\",")); buffer.append(STRING_WITH_LEN("\"0\","));
continue; continue;
} }
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment