Commit c1d1dc25 authored by Olivier Bertrand's avatar Olivier Bertrand

- Modif avglen calculation and add AVG_ROW_LENGTH option to test

  This is to get same test results on Linux and Windows
modified:
  storage/connect/mysql-test/connect/r/part_file.result
  storage/connect/mysql-test/connect/r/part_table.result
  storage/connect/mysql-test/connect/t/part_file.test
  storage/connect/mysql-test/connect/t/part_table.test
  storage/connect/tabdos.cpp
parent decc23cb
...@@ -10,7 +10,7 @@ ftype CHAR(8) NOT NULL FLAG=3 ...@@ -10,7 +10,7 @@ ftype CHAR(8) NOT NULL FLAG=3
CREATE TABLE t1 ( CREATE TABLE t1 (
id INT NOT NULL, id INT NOT NULL,
msg VARCHAR(32) msg VARCHAR(32)
) ENGINE=CONNECT TABLE_TYPE=CSV AVG_ROW_LENGTH=8 ) ENGINE=CONNECT TABLE_TYPE=CSV AVG_ROW_LENGTH=10
PARTITION BY RANGE(id) ( PARTITION BY RANGE(id) (
PARTITION first VALUES LESS THAN(10), PARTITION first VALUES LESS THAN(10),
PARTITION middle VALUES LESS THAN(50), PARTITION middle VALUES LESS THAN(50),
...@@ -33,14 +33,11 @@ id msg ...@@ -33,14 +33,11 @@ id msg
81 eighty one 81 eighty one
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id > 50; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id > 50;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 last ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 last ALL NULL NULL NULL NULL 3 Using where
SELECT * FROM t1 WHERE id > 50; SELECT * FROM t1 WHERE id > 50;
id msg id msg
60 sixty 60 sixty
81 eighty one 81 eighty one
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 CONNECT 10 Dynamic 7 10 76 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL avg_row_length=8 partitioned `TABLE_TYPE`=CSV
UPDATE t1 set id = 41 WHERE msg = 'four'; UPDATE t1 set id = 41 WHERE msg = 'four';
ERROR HY000: Got error 174 'Cannot update column id because it is used for partitioning' from CONNECT ERROR HY000: Got error 174 'Cannot update column id because it is used for partitioning' from CONNECT
UPDATE t1 set msg = 'quatre' WHERE id = 4; UPDATE t1 set msg = 'quatre' WHERE id = 4;
...@@ -69,7 +66,7 @@ t1#P#last .csv ...@@ -69,7 +66,7 @@ t1#P#last .csv
t1#P#middle .csv t1#P#middle .csv
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id=10; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id=10;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 first ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 first ALL NULL NULL NULL NULL 3 Using where
SELECT * FROM t1 WHERE id=10; SELECT * FROM t1 WHERE id=10;
id msg id msg
10 ten 10 ten
......
...@@ -22,7 +22,7 @@ id msg ...@@ -22,7 +22,7 @@ id msg
CREATE TABLE xt3 ( CREATE TABLE xt3 (
id INT KEY NOT NULL, id INT KEY NOT NULL,
msg VARCHAR(32)) msg VARCHAR(32))
ENGINE=CONNECT TABLE_TYPE=CSV; ENGINE=CONNECT TABLE_TYPE=CSV AVG_ROW_LENGTH=10;
Warnings: Warnings:
Warning 1105 No file name. Table will use xt3.csv Warning 1105 No file name. Table will use xt3.csv
INSERT INTO xt3 VALUES(60,'sixty'),(81,'eighty one'),(72,'seventy two'); INSERT INTO xt3 VALUES(60,'sixty'),(81,'eighty one'),(72,'seventy two');
...@@ -91,7 +91,7 @@ id msg ...@@ -91,7 +91,7 @@ id msg
EXPLAIN PARTITIONS EXPLAIN PARTITIONS
SELECT * FROM t1 WHERE id = 81; SELECT * FROM t1 WHERE id = 81;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 3 ALL NULL NULL NULL NULL 14 Using where 1 SIMPLE t1 3 ALL NULL NULL NULL NULL 4 Using where
DELETE FROM t1; DELETE FROM t1;
Warnings: Warnings:
Note 1105 xt1: 4 affected rows Note 1105 xt1: 4 affected rows
......
...@@ -14,7 +14,7 @@ CREATE TABLE dr1 ( ...@@ -14,7 +14,7 @@ CREATE TABLE dr1 (
CREATE TABLE t1 ( CREATE TABLE t1 (
id INT NOT NULL, id INT NOT NULL,
msg VARCHAR(32) msg VARCHAR(32)
) ENGINE=CONNECT TABLE_TYPE=CSV AVG_ROW_LENGTH=8 ) ENGINE=CONNECT TABLE_TYPE=CSV AVG_ROW_LENGTH=10
PARTITION BY RANGE(id) ( PARTITION BY RANGE(id) (
PARTITION first VALUES LESS THAN(10), PARTITION first VALUES LESS THAN(10),
PARTITION middle VALUES LESS THAN(50), PARTITION middle VALUES LESS THAN(50),
...@@ -25,7 +25,8 @@ SELECT partition_name, table_rows FROM information_schema.partitions WHERE table ...@@ -25,7 +25,8 @@ SELECT partition_name, table_rows FROM information_schema.partitions WHERE table
SELECT * FROM t1; SELECT * FROM t1;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id > 50; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id > 50;
SELECT * FROM t1 WHERE id > 50; SELECT * FROM t1 WHERE id > 50;
SHOW TABLE STATUS LIKE 't1'; #TODO: Differences between Linux and Windows
#SHOW TABLE STATUS LIKE 't1';
--error ER_GET_ERRMSG --error ER_GET_ERRMSG
UPDATE t1 set id = 41 WHERE msg = 'four'; UPDATE t1 set id = 41 WHERE msg = 'four';
UPDATE t1 set msg = 'quatre' WHERE id = 4; UPDATE t1 set msg = 'quatre' WHERE id = 4;
......
...@@ -19,7 +19,7 @@ SELECT * FROM xt2; ...@@ -19,7 +19,7 @@ SELECT * FROM xt2;
CREATE TABLE xt3 ( CREATE TABLE xt3 (
id INT KEY NOT NULL, id INT KEY NOT NULL,
msg VARCHAR(32)) msg VARCHAR(32))
ENGINE=CONNECT TABLE_TYPE=CSV; ENGINE=CONNECT TABLE_TYPE=CSV AVG_ROW_LENGTH=10;
INSERT INTO xt3 VALUES(60,'sixty'),(81,'eighty one'),(72,'seventy two'); INSERT INTO xt3 VALUES(60,'sixty'),(81,'eighty one'),(72,'seventy two');
SELECT * FROM xt3; SELECT * FROM xt3;
......
...@@ -1904,10 +1904,12 @@ int TDBDOS::GetMaxSize(PGLOBAL g) ...@@ -1904,10 +1904,12 @@ int TDBDOS::GetMaxSize(PGLOBAL g)
/* Estimate the number of lines in the table (if not known) by */ /* Estimate the number of lines in the table (if not known) by */
/* dividing the file length by average record length. */ /* dividing the file length by average record length. */
/*****************************************************************/ /*****************************************************************/
rec = ((PDOSDEF)To_Def)->Ending;
if (AvgLen <= 0) // No given average estimate if (AvgLen <= 0) // No given average estimate
rec = EstimatedLength(g) + ((PDOSDEF)To_Def)->Ending; rec += EstimatedLength(g);
else // An estimate was given for the average record length else // An estimate was given for the average record length
rec = (int)AvgLen; // Including line ending rec += AvgLen;
MaxSize = (len + rec - 1) / rec; MaxSize = (len + rec - 1) / rec;
......
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