mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
- Fix bugs in handling of remote index when updating and deleting
modified: storage/connect/ha_connect.cc storage/connect/tabdos.cpp storage/connect/tabfmt.cpp storage/connect/tabmysql.cpp - add AVG_REC_LENGTH option to avoid result mismatch between Windows and Linux 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
This commit is contained in:
@@ -966,21 +966,21 @@ bool ha_connect::SetBooleanOption(char *opname, bool b)
|
|||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
int ha_connect::GetIntegerOption(char *opname)
|
int ha_connect::GetIntegerOption(char *opname)
|
||||||
{
|
{
|
||||||
ulonglong opval= NO_IVAL;
|
ulonglong opval= NO_IVAL;
|
||||||
char *pv;
|
char *pv;
|
||||||
PTOS options= GetTableOptionStruct();
|
PTOS options= GetTableOptionStruct();
|
||||||
|
TABLE_SHARE *tsp= (tshp) ? tshp : table_share;
|
||||||
|
|
||||||
if (!options)
|
if (!stricmp(opname, "Avglen"))
|
||||||
|
opval= (ulonglong)tsp->avg_row_length;
|
||||||
|
else if (!stricmp(opname, "Estimate"))
|
||||||
|
opval= (ulonglong)tsp->max_rows;
|
||||||
|
else if (!options)
|
||||||
;
|
;
|
||||||
else if (!stricmp(opname, "Lrecl"))
|
else if (!stricmp(opname, "Lrecl"))
|
||||||
opval= options->lrecl;
|
opval= options->lrecl;
|
||||||
else if (!stricmp(opname, "Elements"))
|
else if (!stricmp(opname, "Elements"))
|
||||||
opval= options->elements;
|
opval= options->elements;
|
||||||
else if (!stricmp(opname, "Estimate"))
|
|
||||||
// opval= options->estimate;
|
|
||||||
opval= (int)table->s->max_rows;
|
|
||||||
else if (!stricmp(opname, "Avglen"))
|
|
||||||
opval= (int)table->s->avg_row_length;
|
|
||||||
else if (!stricmp(opname, "Multiple"))
|
else if (!stricmp(opname, "Multiple"))
|
||||||
opval= options->multiple;
|
opval= options->multiple;
|
||||||
else if (!stricmp(opname, "Header"))
|
else if (!stricmp(opname, "Header"))
|
||||||
|
@@ -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
|
) ENGINE=CONNECT TABLE_TYPE=CSV AVG_ROW_LENGTH=8
|
||||||
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,14 @@ 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 23 Using where
|
1 SIMPLE t1 last ALL NULL NULL NULL NULL 4 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';
|
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
|
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 9 69 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned `TABLE_TYPE`=CSV
|
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 +69,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 24 Using where
|
1 SIMPLE t1 first ALL NULL NULL NULL NULL 4 Using where
|
||||||
SELECT * FROM t1 WHERE id=10;
|
SELECT * FROM t1 WHERE id=10;
|
||||||
id msg
|
id msg
|
||||||
10 ten
|
10 ten
|
||||||
|
@@ -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 38 Using where
|
1 SIMPLE t1 3 ALL NULL NULL NULL NULL 14 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 (
|
|||||||
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
|
) ENGINE=CONNECT TABLE_TYPE=CSV AVG_ROW_LENGTH=8
|
||||||
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),
|
||||||
|
@@ -1894,30 +1894,25 @@ int TDBDOS::GetMaxSize(PGLOBAL g)
|
|||||||
int len = GetFileLength(g);
|
int len = GetFileLength(g);
|
||||||
|
|
||||||
if (len >= 0) {
|
if (len >= 0) {
|
||||||
|
int rec;
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
htrc("Estimating lines len=%d ending=%d\n",
|
htrc("Estimating lines len=%d ending=%d/n",
|
||||||
len, ((PDOSDEF)To_Def)->Ending);
|
len, ((PDOSDEF)To_Def)->Ending);
|
||||||
|
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
/* 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 the minimum line length assuming */
|
/* dividing the file length by average record length. */
|
||||||
/* only the last column can be of variable length. This will be */
|
|
||||||
/* a ceiling estimate (as last column is never totally absent). */
|
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
int rec = ((PDOSDEF)To_Def)->Ending; // +2: CRLF +1: LF
|
if (AvgLen <= 0) // No given average estimate
|
||||||
|
rec = EstimatedLength(g) + ((PDOSDEF)To_Def)->Ending;
|
||||||
if (AvgLen <= 0) // No given average estimate
|
else // An estimate was given for the average record length
|
||||||
rec += EstimatedLength(g);
|
rec = (int)AvgLen; // Including line ending
|
||||||
else // A lower estimate was given for the average record length
|
|
||||||
rec += (int)AvgLen;
|
|
||||||
|
|
||||||
if (trace)
|
|
||||||
htrc(" Filen=%d min_rec=%d\n", len, rec);
|
|
||||||
|
|
||||||
MaxSize = (len + rec - 1) / rec;
|
MaxSize = (len + rec - 1) / rec;
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
htrc(" Estimated max_K=%d\n", MaxSize);
|
htrc("avglen=%d MaxSize%d\n", rec, MaxSize);
|
||||||
|
|
||||||
} // endif len
|
} // endif len
|
||||||
|
|
||||||
|
@@ -590,22 +590,17 @@ bool TDBCSV::CheckErr(void)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int TDBCSV::EstimatedLength(PGLOBAL g)
|
int TDBCSV::EstimatedLength(PGLOBAL g)
|
||||||
{
|
{
|
||||||
|
int n = 0;
|
||||||
|
PCOLDEF cdp;
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
htrc("EstimatedLength: Fields=%d Columns=%p\n", Fields, Columns);
|
htrc("EstimatedLength: Fields=%d Columns=%p\n", Fields, Columns);
|
||||||
|
|
||||||
if (!Fields) {
|
for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext())
|
||||||
PCSVCOL colp;
|
if (!cdp->IsSpecial() && !cdp->IsVirtual()) // A true column
|
||||||
|
n++;
|
||||||
|
|
||||||
for (colp = (PCSVCOL)Columns; colp; colp = (PCSVCOL)colp->Next)
|
return --n; // Number of separators if all fields are null
|
||||||
if (!colp->IsSpecial() && !colp->IsVirtual()) // A true column
|
|
||||||
Fields = MY_MAX(Fields, (int)colp->Fldnum);
|
|
||||||
|
|
||||||
if (Columns)
|
|
||||||
Fields++; // Fldnum was 0 based
|
|
||||||
|
|
||||||
} // endif Fields
|
|
||||||
|
|
||||||
return (int)Fields; // Number of separators if all fields are null
|
|
||||||
} // end of Estimated Length
|
} // end of Estimated Length
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@@ -653,7 +653,7 @@ int TDBMYSQL::MakeCommand(PGLOBAL g)
|
|||||||
|
|
||||||
|
|
||||||
// Make a lower case copy of the originale query
|
// Make a lower case copy of the originale query
|
||||||
qrystr = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 1);
|
qrystr = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 5);
|
||||||
strlwr(strcpy(qrystr, Qrystr));
|
strlwr(strcpy(qrystr, Qrystr));
|
||||||
|
|
||||||
// Check whether the table name is equal to a keyword
|
// Check whether the table name is equal to a keyword
|
||||||
@@ -673,6 +673,7 @@ int TDBMYSQL::MakeCommand(PGLOBAL g)
|
|||||||
strcat(Query, Tabname);
|
strcat(Query, Tabname);
|
||||||
|
|
||||||
strcat(Query, Qrystr + (p - qrystr) + strlen(name));
|
strcat(Query, Qrystr + (p - qrystr) + strlen(name));
|
||||||
|
strlwr(strcpy(qrystr, Query));
|
||||||
} else {
|
} else {
|
||||||
sprintf(g->Message, "Cannot use this %s command",
|
sprintf(g->Message, "Cannot use this %s command",
|
||||||
(Mode == MODE_UPDATE) ? "UPDATE" : "DELETE");
|
(Mode == MODE_UPDATE) ? "UPDATE" : "DELETE");
|
||||||
@@ -1035,7 +1036,8 @@ bool TDBMYSQL::ReadKey(PGLOBAL g, OPVAL op, const void *key, int len)
|
|||||||
{
|
{
|
||||||
int oldlen = strlen(Query);
|
int oldlen = strlen(Query);
|
||||||
|
|
||||||
if (!key || op == OP_NEXT)
|
if (!key || op == OP_NEXT ||
|
||||||
|
Mode == MODE_UPDATE || Mode == MODE_DELETE)
|
||||||
return false;
|
return false;
|
||||||
else if (op == OP_FIRST) {
|
else if (op == OP_FIRST) {
|
||||||
if (To_CondFil)
|
if (To_CondFil)
|
||||||
@@ -1054,7 +1056,7 @@ bool TDBMYSQL::ReadKey(PGLOBAL g, OPVAL op, const void *key, int len)
|
|||||||
|
|
||||||
m_Rc = Myc.ExecSQL(g, Query);
|
m_Rc = Myc.ExecSQL(g, Query);
|
||||||
Query[oldlen] = 0;
|
Query[oldlen] = 0;
|
||||||
return false;
|
return (m_Rc == RC_FX) ? true : false;
|
||||||
} // end of ReadKey
|
} // end of ReadKey
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
Reference in New Issue
Block a user