Commit b91386c2 authored by Alexander Barkov's avatar Alexander Barkov

Changing maximum possible column length for DBF tables from 11 to 10.

There is actually one extra byte for the 11th character, however it seems
to be meant for the '\0' terminating byte in the DBF specifications.
Also, the third party software (e.g. OpenOffice) do not correctly open
tables with column length=11.

modified:
  mysql-test/suite/connect/r/dbf.result
  mysql-test/suite/connect/t/dbf.test
  storage/connect/ha_connect.cc
parent 2adf52b8
......@@ -182,16 +182,44 @@ CREATE TABLE t1
(
a012345678901234567890123456789 INT DEFAULT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
ERROR HY000: DBF: Column name 'a012345678901234567890123456789' is too long (max=11)
ERROR HY000: DBF: Column name 'a012345678901234567890123456789' is too long (max=10)
#
# Testing 2 columns with long names
# Testing 2 columns with long names (12)
#
CREATE TABLE t1
(
a0123456789a INT DEFAULT NULL,
b0123456789b INT DEFAULT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x11.dbf';
ERROR HY000: DBF: Column name 'a0123456789a' is too long (max=11)
ERROR HY000: DBF: Column name 'a0123456789a' is too long (max=10)
#
# Testing 2 columns with long names (11)
#
CREATE TABLE t1
(
a012345678a INT DEFAULT NULL,
b012345678b INT DEFAULT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x12.dbf';
ERROR HY000: DBF: Column name 'a012345678a' is too long (max=10)
#
# Testing 2 columns name length 10 (maximum possible length)
#
CREATE TABLE t1
(
a01234567a INT DEFAULT NULL,
b01234567b INT DEFAULT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x13.dbf';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a01234567a` int(11) DEFAULT NULL,
`b01234567b` int(11) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=DBF `FILE_NAME`='t02x13.dbf'
INSERT INTO t1 VALUES (1,2);
SELECT * FROM t1;
a01234567a b01234567b
1 2
DROP TABLE t1;
#
# Testing BIGINT
#
......
......@@ -136,7 +136,7 @@ CREATE TABLE t1
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
--echo #
--echo # Testing 2 columns with long names
--echo # Testing 2 columns with long names (12)
--echo #
--error ER_UNKNOWN_ERROR
CREATE TABLE t1
......@@ -145,9 +145,29 @@ CREATE TABLE t1
b0123456789b INT DEFAULT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x11.dbf';
#
# TODO: add a test with shorter name 'a012345678a'. It should also fail.
#
--echo #
--echo # Testing 2 columns with long names (11)
--echo #
--error ER_UNKNOWN_ERROR
CREATE TABLE t1
(
a012345678a INT DEFAULT NULL,
b012345678b INT DEFAULT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x12.dbf';
--echo #
--echo # Testing 2 columns name length 10 (maximum possible length)
--echo #
CREATE TABLE t1
(
a01234567a INT DEFAULT NULL,
b01234567b INT DEFAULT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x13.dbf';
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (1,2);
SELECT * FROM t1;
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t02x13.dbf
--echo #
......
......@@ -3607,8 +3607,8 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (dbf) {
bool b= false;
if ((b= strlen(fp->field_name) > 11))
sprintf(g->Message, "DBF: Column name '%s' is too long (max=11)",
if ((b= strlen(fp->field_name) > 10))
sprintf(g->Message, "DBF: Column name '%s' is too long (max=10)",
fp->field_name);
else if ((b= fp->field_length > 255))
sprintf(g->Message, "DBF: Column length too big for '%s' (max=255)",
......
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