From 6a00401a6090b58c2141da86b19fcc17e7102072 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 17 Sep 2014 00:51:40 +0200 Subject: [PATCH 1/7] - Fix a compile error (MDEV-6723) modified: storage/connect/tabwmi.cpp - Was change in revision 4029 but not listed then. modified: storage/connect/mysql-test/connect/r/updelx.result --- storage/connect/tabwmi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/tabwmi.cpp b/storage/connect/tabwmi.cpp index e47df028dc2..f93776c31da 100644 --- a/storage/connect/tabwmi.cpp +++ b/storage/connect/tabwmi.cpp @@ -200,7 +200,7 @@ PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info) } // endif res len = (unsigned)SysStringLen(propname); - length[0] = max(length[0], len); + length[0] = MY_MAX(length[0], len); } // enfor i res = SafeArrayDestroy(prnlist); From 8585a6b58654610839139653e7793d7e6e485199 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 27 Sep 2014 12:09:37 +0200 Subject: [PATCH 2/7] - Fix: Crash of an XCOL table when the Colname column size is too small. Was because of buffer overrun in XCLCOL::ReadColumn. The Cbuf buffer was unconditionally filled Now it is limited to its size. This happened because this buffer was allocated according to the XCOL column size. It is now allocated according to the source column size. modified: storage/connect/plgdbsem.h storage/connect/tabutil.h storage/connect/tabxcl.cpp storage/connect/tabxcl.h --- storage/connect/plgdbsem.h | 2 +- storage/connect/tabutil.h | 2 +- storage/connect/tabxcl.cpp | 20 +++++++++++++++++--- storage/connect/tabxcl.h | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index 7d5931285ce..ef209a9b8b8 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -582,7 +582,7 @@ DllExport void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size); DllExport void *PlgDBalloc(PGLOBAL, void *, MBLOCK&); DllExport void *PlgDBrealloc(PGLOBAL, void *, MBLOCK&, size_t); DllExport void NewPointer(PTABS, void *, void *); -DllExport char *GetIni(int n= 0); +//lExport char *GetIni(int n= 0); // Not used anymore DllExport void SetTrc(void); DllExport char *GetListOption(PGLOBAL, const char *, const char *, const char *def=NULL); diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h index 11f18be074a..606e532d526 100644 --- a/storage/connect/tabutil.h +++ b/storage/connect/tabutil.h @@ -114,7 +114,7 @@ class DllExport PRXCOL : public COLBLK { {return false;} virtual void ReadColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g); - bool Init(PGLOBAL g, PTDBASE tp = NULL); + virtual bool Init(PGLOBAL g, PTDBASE tp = NULL); protected: // Default constructor not to be used diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp index bd3d57257ff..66e2577056a 100644 --- a/storage/connect/tabxcl.cpp +++ b/storage/connect/tabxcl.cpp @@ -184,7 +184,7 @@ bool TDBXCL::OpenDB(PGLOBAL g) /* Check and initialize the subtable columns. */ /*********************************************************************/ for (PCOL cp = Columns; cp; cp = cp->GetNext()) - if (((PXCLCOL)cp)->Init(g)) + if (((PPRXCOL)cp)->Init(g)) return TRUE; /*********************************************************************/ @@ -240,12 +240,25 @@ XCLCOL::XCLCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i) : PRXCOL(cdp, tdbp, cprec, i, "XCL") { // Set additional XXL access method information for column. - Cbuf = (char*)PlugSubAlloc(g, NULL, Long + 1); + Cbuf = NULL; // Will be allocated later Cp = NULL; // Pointer to current position in Cbuf Sep = ((PTDBXCL)tdbp)->Sep; AddStatus(BUF_READ); // Only evaluated from TDBXCL::ReadDB } // end of XCLCOL constructor +/***********************************************************************/ +/* XCLCOL initialization routine. */ +/* Allocate Cbuf that will contain the Colp value. */ +/***********************************************************************/ +bool XCLCOL::Init(PGLOBAL g, PTDBASE tp) + { + if (PRXCOL::Init(g, tp)) + return true; + + Cbuf = (char*)PlugSubAlloc(g, NULL, Colp->GetLength() + 1); + return false; + } // end of Init + /***********************************************************************/ /* What this routine does is to get the comma-separated string */ /* from the source table column, extract the single values and */ @@ -255,7 +268,8 @@ void XCLCOL::ReadColumn(PGLOBAL g) { if (((PTDBXCL)To_Tdb)->New) { Colp->Eval(g); - strcpy(Cbuf, To_Val->GetCharValue()); + strncpy(Cbuf, To_Val->GetCharValue(), Colp->GetLength()); + Cbuf[Colp->GetLength()] = 0; Cp = Cbuf; } // endif New diff --git a/storage/connect/tabxcl.h b/storage/connect/tabxcl.h index 24122573100..05118c5dd25 100644 --- a/storage/connect/tabxcl.h +++ b/storage/connect/tabxcl.h @@ -90,6 +90,7 @@ class XCLCOL : public PRXCOL { // Methods virtual void Reset(void) {Colp->Reset();} // Evaluated only by TDBXCL virtual void ReadColumn(PGLOBAL g); + virtual bool Init(PGLOBAL g, PTDBASE tp = NULL); protected: // Default constructor not to be used From ed72d2d2105b65419e3b7bb04132fada030fbd6f Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 27 Sep 2014 12:26:36 +0200 Subject: [PATCH 3/7] - Add some new tests added: storage/connect/mysql-test/connect/r/datest.result storage/connect/mysql-test/connect/r/mrr.result storage/connect/mysql-test/connect/r/updelx2.result storage/connect/mysql-test/connect/t/datest.test storage/connect/mysql-test/connect/t/mrr.test storage/connect/mysql-test/connect/t/updelx2.test --- .../mysql-test/connect/r/datest.result | 32 +++++ .../connect/mysql-test/connect/r/mrr.result | 117 +++++++++++++++ .../mysql-test/connect/r/updelx2.result | 133 ++++++++++++++++++ .../connect/mysql-test/connect/t/datest.test | 16 +++ storage/connect/mysql-test/connect/t/mrr.test | 66 +++++++++ .../connect/mysql-test/connect/t/updelx2.test | 22 +++ 6 files changed, 386 insertions(+) create mode 100644 storage/connect/mysql-test/connect/r/datest.result create mode 100644 storage/connect/mysql-test/connect/r/mrr.result create mode 100644 storage/connect/mysql-test/connect/r/updelx2.result create mode 100644 storage/connect/mysql-test/connect/t/datest.test create mode 100644 storage/connect/mysql-test/connect/t/mrr.test create mode 100644 storage/connect/mysql-test/connect/t/updelx2.test diff --git a/storage/connect/mysql-test/connect/r/datest.result b/storage/connect/mysql-test/connect/r/datest.result new file mode 100644 index 00000000000..203a7419a8e --- /dev/null +++ b/storage/connect/mysql-test/connect/r/datest.result @@ -0,0 +1,32 @@ +# +# Testing out of range dates as (var)char +# +CREATE TABLE t1 ( +id INT NOT NULL, +dat CHAR(10) NOT NULL, +tim CHAR(8) DEFAULT '09:35:08', +datim CHAR(19) DEFAULT '1789-08-10 14:20:30') +ENGINE=CONNECT TABLE_TYPE=FIX; +Warnings: +Warning 1105 No file name. Table will use t1.fix +INSERT INTO t1(id,dat) VALUES(1,'1515-04-01'),(2,'2014-07-26'),(3,'2118-11-02'); +SELECT * FROM t1; +id dat tim datim +1 1515-04-01 09:35:08 1789-08-10 14:20:30 +2 2014-07-26 09:35:08 1789-08-10 14:20:30 +3 2118-11-02 09:35:08 1789-08-10 14:20:30 +SELECT id, DATE(datim) FROM t1 LIMIT 1; +id DATE(datim) +1 1789-08-10 +SELECT id, DAYNAME(dat) FROM t1; +id DAYNAME(dat) +1 Thursday +2 Saturday +3 Wednesday +SELECT id, DAYNAME(datim) FROM t1 LIMIT 1; +id DAYNAME(datim) +1 Monday +SELECT id, TIME(tim) FROM t1 LIMIT 1; +id TIME(tim) +1 09:35:08.000000 +DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/r/mrr.result b/storage/connect/mysql-test/connect/r/mrr.result new file mode 100644 index 00000000000..0d31daa736c --- /dev/null +++ b/storage/connect/mysql-test/connect/r/mrr.result @@ -0,0 +1,117 @@ +# +# Show MRR setting. The way it is done is because the t3 table cannot be directly based on +# the information_schema.session_variables table. Not being a CONNECT table, it would be +# read using an intermediate MYSQL table using the MySQL API and could not reflect the +# current session variable change (the call would create another session) This would be +# correct only for querying GLOBAL variables but is not what we want to do here. +# +CREATE TABLE t2 ( +name VARCHAR(64) NOT NULL, +value VARCHAR(1024) NOT NULL +) ENGINE=CONNECT TABLE_TYPE=DOS; +Warnings: +Warning 1105 No file name. Table will use t2.dos +INSERT INTO t2 SELECT * FROM information_schema.session_variables WHERE variable_name = 'OPTIMIZER_SWITCH'; +create table t3 ( +name CHAR(32) NOT NULL, +value CHAR(64) NOT NULL +) ENGINE=CONNECT TABLE_TYPE=XCOL TABNAME=t2 OPTION_LIST='Colname=value'; +SELECT value FROM t3 WHERE value LIKE 'mrr%'; +value +mrr=off +mrr_cost_based=off +mrr_sort_keys=off +# +# Testing indexing with MRR OFF +# +CREATE TABLE t1 +( +matricule INT(4) KEY NOT NULL field_format='Z', +nom VARCHAR(16) NOT NULL, +prenom VARCHAR(20) NOT NULL, +sexe SMALLINT(1) NOT NULL COMMENT 'sexe 1:M 2:F', +aanais INT(4) NOT NULL, +mmnais INT(2) NOT NULL, +ddentree DATE NOT NULL date_format='YYYYMM', +ddnom DATE NOT NULL date_format='YYYYMM', +brut INT(5) NOT NULL, +net DOUBLE(8,2) NOT NULL, +service INT(2) NOT NULL, +sitmat CHAR(1) NOT NULL, +formation CHAR(5) NOT NULL, +INDEX NP(nom,prenom) +) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='emp.txt' ENDING=2; +SELECT * FROM t1 LIMIT 10; +matricule nom prenom sexe aanais mmnais ddentree ddnom brut net service sitmat formation +5745 ESCOURCHE BENEDICTE 2 1935 7 1962-12-01 1994-05-01 18345 14275.50 0 M TECHN +9692 VICENTE LAURENCE 2 1941 8 1967-10-01 1989-01-01 16212 13032.80 0 M ANGL +9146 NICOLAS ROGER 1 1941 6 1964-07-01 1995-02-01 34173 25098.65 0 M SANS +2985 TESSEREAU MARIE HELENE 2 1941 9 1967-01-01 1990-01-01 19323 14933.78 0 V SANS +3368 MOGADOR ALAIN 1 1941 1 1961-09-01 1993-11-01 43303 31420.55 0 C SANS +7394 CHAUSSEE ERIC DENIS 1 1944 9 1965-11-01 1983-12-01 32002 23583.86 0 M ANGL +4655 MAILLOT GEORGES 1 1945 5 1970-09-01 1986-12-01 24700 18541.64 0 C ANGL +2825 CAMILLE NADINE 2 1956 9 1994-01-01 1993-01-01 19494 15050.45 0 M SANS +1460 BRUYERES JEAN MARC 1 1958 8 1984-08-01 1988-05-01 20902 15980.07 0 M SANS +4974 LONES GERARD 1 1959 10 1979-01-01 1994-12-01 16081 12916.70 0 M SANS +# Without MRR, the rows are retrieved sorted by name +SELECT matricule, nom, prenom, sitmat, net FROM t1 WHERE nom IN ('ETANG','FOCH','CERF','ITALIE','ROI'); +matricule nom prenom sitmat net +5324 CERF CLAUDE M 9503.34 +7703 CERF NICOLE M 12025.61 +3110 CERF VALERIE M 10472.37 +4454 ETANG BEATRICE M 11017.61 +1022 ETANG GERARD L 8729.58 +8222 ETANG LIONEL M 13497.90 +2492 ETANG PASCAL VINCENT M 11986.62 +1977 FOCH BERNADETTE . 8145.03 +5707 FOCH DENIS C 7679.36 +2552 FOCH FRANCK M 10745.81 +2634 FOCH JOCELYNE M 10473.09 +5765 FOCH ROBERT M 12916.32 +4080 FOCH SERGE M 9658.24 +5898 ITALIE DENIS M 9502.41 +7606 ITALIE JACQUES C 7679.45 +1067 ITALIE SVETLANA M 11713.61 +5853 ROI CHANTAL . 8147.06 +2995 ROI JEAN M 11715.50 +2531 ROI MICHEL L 10240.44 +5846 ROI PATRICIA M 15669.57 +# +# Testing indexing with MRR ON +# +SET @@LOCAL.OPTIMIZER_SWITCH='mrr=on'; +# Refresh the t2 table to reflect the change +UPDATE t2, information_schema.session_variables SET value = variable_value WHERE variable_name = 'OPTIMIZER_SWITCH'; +# Check that MRR is ON for the session +SELECT value FROM t3 WHERE value LIKE 'mrr%'; +value +mrr=on +mrr_cost_based=off +mrr_sort_keys=off +# With MRR, the rows are retrieved sorted by their position in the table +SELECT matricule, nom, prenom, sitmat, net FROM t1 WHERE nom IN ('ETANG','FOCH','CERF','ITALIE','ROI'); +matricule nom prenom sitmat net +1977 FOCH BERNADETTE . 8145.03 +2995 ROI JEAN M 11715.50 +3110 CERF VALERIE M 10472.37 +5324 CERF CLAUDE M 9503.34 +4080 FOCH SERGE M 9658.24 +4454 ETANG BEATRICE M 11017.61 +5898 ITALIE DENIS M 9502.41 +2552 FOCH FRANCK M 10745.81 +2531 ROI MICHEL L 10240.44 +5853 ROI CHANTAL . 8147.06 +8222 ETANG LIONEL M 13497.90 +5707 FOCH DENIS C 7679.36 +1067 ITALIE SVETLANA M 11713.61 +7606 ITALIE JACQUES C 7679.45 +7703 CERF NICOLE M 12025.61 +2634 FOCH JOCELYNE M 10473.09 +1022 ETANG GERARD L 8729.58 +5846 ROI PATRICIA M 15669.57 +2492 ETANG PASCAL VINCENT M 11986.62 +5765 FOCH ROBERT M 12916.32 +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +SET @@LOCAL.OPTIMIZER_SWITCH='mrr=off'; diff --git a/storage/connect/mysql-test/connect/r/updelx2.result b/storage/connect/mysql-test/connect/r/updelx2.result new file mode 100644 index 00000000000..1ed3709f0ba --- /dev/null +++ b/storage/connect/mysql-test/connect/r/updelx2.result @@ -0,0 +1,133 @@ +# +# Testing multiple indexed UPDATE and DELETE +# +CREATE TABLE t1 ( +id INT(4) NOT NULL, +msg VARCHAR(16) NOT NULL, +INDEX IDM(id,msg)) +ENGINE=CONNECT TABLE_TYPE=DOS; +Warnings: +Warning 1105 No file name. Table will use t1.dos +INSERT INTO t1 VALUES(1,'one'),(4, 'four'),(7,'seven'),(8,'eight'),(10,'ten'),(11,'eleven'),(40,'forty'),(35,'thirty five'),(60,'sixty'),(72,'seventy two'),(81,'eighty one'); +INSERT INTO t1 VALUES(1,'un'),(4, 'quatre'),(7,'sept'),(8,'huit'),(10,'dix'),(11,'onze'),(40,'quarante'),(35,'trente cinq'),(60,'soixante'),(72,'soixante douze'),(81,'quatrevingt un'); +SELECT * FROM t1 IGNORE INDEX (IDM); +id msg +1 one +4 four +7 seven +8 eight +10 ten +11 eleven +40 forty +35 thirty five +60 sixty +72 seventy two +81 eighty one +1 un +4 quatre +7 sept +8 huit +10 dix +11 onze +40 quarante +35 trente cinq +60 soixante +72 soixante douze +81 quatrevingt un +UPDATE t1 SET msg = 'dieci' WHERE id = 10; +SELECT * FROM t1 IGNORE INDEX (IDM); +id msg +1 one +4 four +7 seven +8 eight +10 dieci +11 eleven +40 forty +35 thirty five +60 sixty +72 seventy two +81 eighty one +1 un +4 quatre +7 sept +8 huit +10 dieci +11 onze +40 quarante +35 trente cinq +60 soixante +72 soixante douze +81 quatrevingt un +UPDATE t1 SET msg = 'septante deux' WHERE id = 72; +SELECT * FROM t1 IGNORE INDEX (IDM); +id msg +1 one +4 four +7 seven +8 eight +10 dieci +11 eleven +40 forty +35 thirty five +60 sixty +72 septante deux +81 eighty one +1 un +4 quatre +7 sept +8 huit +10 dieci +11 onze +40 quarante +35 trente cinq +60 soixante +72 septante deux +81 quatrevingt un +UPDATE t1 SET id=2, msg='deux' WHERE id=4 AND msg='quatre'; +SELECT * FROM t1 IGNORE INDEX (IDM); +id msg +1 one +4 four +7 seven +8 eight +10 dieci +11 eleven +40 forty +35 thirty five +60 sixty +72 septante deux +81 eighty one +1 un +2 deux +7 sept +8 huit +10 dieci +11 onze +40 quarante +35 trente cinq +60 soixante +72 septante deux +81 quatrevingt un +DELETE FROM t1 WHERE id IN (8,40); +SELECT * FROM t1 IGNORE INDEX (IDM); +id msg +1 one +4 four +7 seven +10 dieci +11 eleven +35 thirty five +60 sixty +72 septante deux +81 eighty one +1 un +2 deux +7 sept +10 dieci +11 onze +35 trente cinq +60 soixante +72 septante deux +81 quatrevingt un +DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/t/datest.test b/storage/connect/mysql-test/connect/t/datest.test new file mode 100644 index 00000000000..a986ce15a80 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/datest.test @@ -0,0 +1,16 @@ +--echo # +--echo # Testing out of range dates as (var)char +--echo # +CREATE TABLE t1 ( +id INT NOT NULL, +dat CHAR(10) NOT NULL, +tim CHAR(8) DEFAULT '09:35:08', +datim CHAR(19) DEFAULT '1789-08-10 14:20:30') +ENGINE=CONNECT TABLE_TYPE=FIX; +INSERT INTO t1(id,dat) VALUES(1,'1515-04-01'),(2,'2014-07-26'),(3,'2118-11-02'); +SELECT * FROM t1; +SELECT id, DATE(datim) FROM t1 LIMIT 1; +SELECT id, DAYNAME(dat) FROM t1; +SELECT id, DAYNAME(datim) FROM t1 LIMIT 1; +SELECT id, TIME(tim) FROM t1 LIMIT 1; +DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/t/mrr.test b/storage/connect/mysql-test/connect/t/mrr.test new file mode 100644 index 00000000000..37289ad427f --- /dev/null +++ b/storage/connect/mysql-test/connect/t/mrr.test @@ -0,0 +1,66 @@ +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file $MTR_SUITE_DIR/std_data/emp.txt $MYSQLD_DATADIR/test/emp.txt + +--echo # +--echo # Show MRR setting. The way it is done is because the t3 table cannot be directly based on +--echo # the information_schema.session_variables table. Not being a CONNECT table, it would be +--echo # read using an intermediate MYSQL table using the MySQL API and could not reflect the +--echo # current session variable change (the call would create another session) This would be +--echo # correct only for querying GLOBAL variables but is not what we want to do here. +--echo # +CREATE TABLE t2 ( +name VARCHAR(64) NOT NULL, +value VARCHAR(1024) NOT NULL +) ENGINE=CONNECT TABLE_TYPE=DOS; +INSERT INTO t2 SELECT * FROM information_schema.session_variables WHERE variable_name = 'OPTIMIZER_SWITCH'; +# Check that MRR is OFF by default +create table t3 ( +name CHAR(32) NOT NULL, +value CHAR(64) NOT NULL +) ENGINE=CONNECT TABLE_TYPE=XCOL TABNAME=t2 OPTION_LIST='Colname=value'; +SELECT value FROM t3 WHERE value LIKE 'mrr%'; + +--echo # +--echo # Testing indexing with MRR OFF +--echo # +CREATE TABLE t1 +( + matricule INT(4) KEY NOT NULL field_format='Z', + nom VARCHAR(16) NOT NULL, + prenom VARCHAR(20) NOT NULL, + sexe SMALLINT(1) NOT NULL COMMENT 'sexe 1:M 2:F', + aanais INT(4) NOT NULL, + mmnais INT(2) NOT NULL, + ddentree DATE NOT NULL date_format='YYYYMM', + ddnom DATE NOT NULL date_format='YYYYMM', + brut INT(5) NOT NULL, + net DOUBLE(8,2) NOT NULL, + service INT(2) NOT NULL, + sitmat CHAR(1) NOT NULL, + formation CHAR(5) NOT NULL, + INDEX NP(nom,prenom) +) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='emp.txt' ENDING=2; +SELECT * FROM t1 LIMIT 10; +--echo # Without MRR, the rows are retrieved sorted by name +SELECT matricule, nom, prenom, sitmat, net FROM t1 WHERE nom IN ('ETANG','FOCH','CERF','ITALIE','ROI'); + +--echo # +--echo # Testing indexing with MRR ON +--echo # +SET @@LOCAL.OPTIMIZER_SWITCH='mrr=on'; +--echo # Refresh the t2 table to reflect the change +UPDATE t2, information_schema.session_variables SET value = variable_value WHERE variable_name = 'OPTIMIZER_SWITCH'; +--echo # Check that MRR is ON for the session +SELECT value FROM t3 WHERE value LIKE 'mrr%'; +--echo # With MRR, the rows are retrieved sorted by their position in the table +SELECT matricule, nom, prenom, sitmat, net FROM t1 WHERE nom IN ('ETANG','FOCH','CERF','ITALIE','ROI'); + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; + +# +# Clean up +# +SET @@LOCAL.OPTIMIZER_SWITCH='mrr=off'; +--remove_file $MYSQLD_DATADIR/test/emp.txt diff --git a/storage/connect/mysql-test/connect/t/updelx2.test b/storage/connect/mysql-test/connect/t/updelx2.test new file mode 100644 index 00000000000..bf5434636ee --- /dev/null +++ b/storage/connect/mysql-test/connect/t/updelx2.test @@ -0,0 +1,22 @@ +-- source include/not_embedded.inc + +--echo # +--echo # Testing multiple indexed UPDATE and DELETE +--echo # +CREATE TABLE t1 ( +id INT(4) NOT NULL, +msg VARCHAR(16) NOT NULL, +INDEX IDM(id,msg)) +ENGINE=CONNECT TABLE_TYPE=DOS; +INSERT INTO t1 VALUES(1,'one'),(4, 'four'),(7,'seven'),(8,'eight'),(10,'ten'),(11,'eleven'),(40,'forty'),(35,'thirty five'),(60,'sixty'),(72,'seventy two'),(81,'eighty one'); +INSERT INTO t1 VALUES(1,'un'),(4, 'quatre'),(7,'sept'),(8,'huit'),(10,'dix'),(11,'onze'),(40,'quarante'),(35,'trente cinq'),(60,'soixante'),(72,'soixante douze'),(81,'quatrevingt un'); +SELECT * FROM t1 IGNORE INDEX (IDM); +UPDATE t1 SET msg = 'dieci' WHERE id = 10; +SELECT * FROM t1 IGNORE INDEX (IDM); +UPDATE t1 SET msg = 'septante deux' WHERE id = 72; +SELECT * FROM t1 IGNORE INDEX (IDM); +UPDATE t1 SET id=2, msg='deux' WHERE id=4 AND msg='quatre'; +SELECT * FROM t1 IGNORE INDEX (IDM); +DELETE FROM t1 WHERE id IN (8,40); +SELECT * FROM t1 IGNORE INDEX (IDM); +DROP TABLE t1; From 4b2b2abe8bdb12a2e97e5d27805477013b49edde Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 29 Sep 2014 14:42:50 +0200 Subject: [PATCH 4/7] - fix MDEV-6802: MPXFAM::GetNextPos redefined modified: storage/connect/filamap.h --- storage/connect/filamap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/filamap.h b/storage/connect/filamap.h index 1d85fa36155..1d44239e610 100644 --- a/storage/connect/filamap.h +++ b/storage/connect/filamap.h @@ -104,7 +104,7 @@ class DllExport MPXFAM : public MBKFAM { virtual int MaxBlkSize(PGLOBAL g, int s) {return TXTFAM::MaxBlkSize(g, s);} virtual bool SetPos(PGLOBAL g, int recpos); - virtual int GetNextPos(void) {return (int)Fpos + Nrec;} + virtual int GetNextPos(void) {return GetPos() + 1;} virtual bool DeferReading(void) {return false;} virtual int ReadBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g); From e4ff01e47d4ac9a95dda688ac709b22186559422 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 30 Sep 2014 00:53:00 +0200 Subject: [PATCH 5/7] - Fix all compiler issues on FreeBSD clang. modified: storage/connect/array.cpp storage/connect/filamap.cpp --- storage/connect/array.cpp | 2 +- storage/connect/filamap.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp index fb8dbfd7869..9c679456b68 100644 --- a/storage/connect/array.cpp +++ b/storage/connect/array.cpp @@ -129,7 +129,7 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp) break; case TYPE_VOID: // Integer stored inside pp->Value - par->AddValue(g, (int)parmp->Value); + par->AddValue(g, (int)(uintptr_t)parmp->Value); break; } // endswitch valtyp diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp index c0ca40f4c01..d79296a8497 100644 --- a/storage/connect/filamap.cpp +++ b/storage/connect/filamap.cpp @@ -290,8 +290,8 @@ bool MAPFAM::RecordPos(PGLOBAL g) /***********************************************************************/ int MAPFAM::InitDelete(PGLOBAL g, int fpos, int spos) { - Fpos = Memory + fpos; - Mempos = Memory + spos; + Fpos = Memory + (uintptr_t)fpos; + Mempos = Memory + (uintptr_t)spos; return RC_OK; } // end of InitDelete @@ -685,7 +685,7 @@ bool MPXFAM::SetPos(PGLOBAL g, int pos) /***********************************************************************/ int MPXFAM::InitDelete(PGLOBAL g, int fpos, int spos) { - Fpos = Memory + Headlen + fpos * Lrecl; + Fpos = Memory + Headlen + (uintptr_t)fpos * Lrecl; Mempos = Fpos + Lrecl; return RC_OK; } // end of InitDelete From dd5eb7ae6781e963c6eb20049087c3f3c7e7b510 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 30 Sep 2014 01:25:53 +0200 Subject: [PATCH 6/7] - Add #include needed by GCC to declare uintptr_t modified: storage/connect/array.cpp storage/connect/filamap.cpp --- storage/connect/array.cpp | 1 + storage/connect/filamap.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp index 9c679456b68..2519191f6e6 100644 --- a/storage/connect/array.cpp +++ b/storage/connect/array.cpp @@ -25,6 +25,7 @@ #include #include #include +#include // for uintprt_h #endif // !WIN32 /***********************************************************************/ diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp index d79296a8497..85ad3865237 100644 --- a/storage/connect/filamap.cpp +++ b/storage/connect/filamap.cpp @@ -30,6 +30,7 @@ #include #endif // !UNIX #include +#include // for uintprt_h #endif // !WIN32 /***********************************************************************/ From 38c3fd2099577b932999766df41c77a81429fdc4 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 30 Sep 2014 12:59:24 +0200 Subject: [PATCH 7/7] - Fix MDEV-6802 in a clean way. Add an union in the PARM structure to contain int values Use a cast to ptrdiff_t in MAPFAM/MXPFAM::InitDelete required by some compilers modified: storage/connect/array.cpp storage/connect/filamap.cpp storage/connect/filamtxt.cpp storage/connect/global.h - Suppress some GCC warnings modified: storage/connect/array.cpp storage/connect/filter.cpp storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/value.cpp --- storage/connect/array.cpp | 6 +++--- storage/connect/filamap.cpp | 7 +++---- storage/connect/filamtxt.cpp | 2 +- storage/connect/filter.cpp | 28 +++++++++++++++++++++++++++- storage/connect/global.h | 5 ++++- storage/connect/tabdos.cpp | 14 +++++++------- storage/connect/tabmysql.cpp | 5 +++-- storage/connect/value.cpp | 26 -------------------------- 8 files changed, 48 insertions(+), 45 deletions(-) diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp index 2519191f6e6..a2ee902bc59 100644 --- a/storage/connect/array.cpp +++ b/storage/connect/array.cpp @@ -130,7 +130,7 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp) break; case TYPE_VOID: // Integer stored inside pp->Value - par->AddValue(g, (int)(uintptr_t)parmp->Value); + par->AddValue(g, parmp->Intval); break; } // endswitch valtyp @@ -609,13 +609,13 @@ int ARRAY::Convert(PGLOBAL g, int k, PVAL vp) Size = Nval; Nval = 0; - Vblp = Valblk->Allocate(g, Type, Len, 0, Size); + Vblp = Valblk->Allocate(g, Type, Len, prec, Size); if (!Valblk->GetMemp()) // The error message was built by PlgDBalloc return TYPE_ERROR; else - Value = AllocateValue(g, Type, Len, 0, NULL); + Value = AllocateValue(g, Type, Len, prec, NULL); /*********************************************************************/ /* Converting STRING to DATE can be done according to date format. */ diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp index 85ad3865237..5efe9c95d81 100644 --- a/storage/connect/filamap.cpp +++ b/storage/connect/filamap.cpp @@ -30,7 +30,6 @@ #include #endif // !UNIX #include -#include // for uintprt_h #endif // !WIN32 /***********************************************************************/ @@ -291,8 +290,8 @@ bool MAPFAM::RecordPos(PGLOBAL g) /***********************************************************************/ int MAPFAM::InitDelete(PGLOBAL g, int fpos, int spos) { - Fpos = Memory + (uintptr_t)fpos; - Mempos = Memory + (uintptr_t)spos; + Fpos = Memory + (ptrdiff_t)fpos; + Mempos = Memory + (ptrdiff_t)spos; return RC_OK; } // end of InitDelete @@ -686,7 +685,7 @@ bool MPXFAM::SetPos(PGLOBAL g, int pos) /***********************************************************************/ int MPXFAM::InitDelete(PGLOBAL g, int fpos, int spos) { - Fpos = Memory + Headlen + (uintptr_t)fpos * Lrecl; + Fpos = Memory + Headlen + (ptrdiff_t)fpos * Lrecl; Mempos = Fpos + Lrecl; return RC_OK; } // end of InitDelete diff --git a/storage/connect/filamtxt.cpp b/storage/connect/filamtxt.cpp index 9c23944ff42..f2757e0c0fc 100644 --- a/storage/connect/filamtxt.cpp +++ b/storage/connect/filamtxt.cpp @@ -287,7 +287,7 @@ bool TXTFAM::AddListValue(PGLOBAL g, int type, void *val, PPARM *top) // *((int*)pp->Value) = *((int*)val); // break; case TYPE_VOID: - pp->Value = (void*)*(int*)val; + pp->Intval = *(int*)val; break; // case TYPE_STRING: // pp->Value = PlugSubAlloc(g, NULL, strlen((char*)val) + 1); diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp index 9212432cdde..ce4f69c5ecc 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -63,7 +63,7 @@ static PPARM MakeParm(PGLOBAL g, PXOB xp) } // end of MakeParm /***********************************************************************/ -/* Routines called externally by FILTER function. */ +/* Routines called internally/externally by FILTER functions. */ /***********************************************************************/ bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool); //bool ReadSubQuery(PGLOBAL, PSUBQ); @@ -72,6 +72,32 @@ bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool); BYTE OpBmp(PGLOBAL g, OPVAL opc); PARRAY MakeValueArray(PGLOBAL g, PPARM pp); +/***********************************************************************/ +/* Returns the bitmap representing the conditions that must not be */ +/* met when returning from TestValue for a given operator. */ +/* Bit one is EQ, bit 2 is LT, and bit 3 is GT. */ +/***********************************************************************/ +BYTE OpBmp(PGLOBAL g, OPVAL opc) + { + BYTE bt; + + switch (opc) { + case OP_IN: + case OP_EQ: bt = 0x06; break; + case OP_NE: bt = 0x01; break; + case OP_GT: bt = 0x03; break; + case OP_GE: bt = 0x02; break; + case OP_LT: bt = 0x05; break; + case OP_LE: bt = 0x04; break; + case OP_EXIST: bt = 0x00; break; + default: + sprintf(g->Message, MSG(BAD_FILTER_OP), opc); + longjmp(g->jumper[g->jump_level], TYPE_ARRAY); + } // endswitch opc + + return bt; + } // end of OpBmp + /***********************************************************************/ /* Routines called externally by CondFilter. */ /***********************************************************************/ diff --git a/storage/connect/global.h b/storage/connect/global.h index d35cef2de6f..ae4440b12bc 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -205,7 +205,10 @@ typedef struct _activity { /* Describes activity and language */ /*---------------- UNIT ?????????? VERSION ? ----------------------*/ typedef struct _parm { - void *Value; + union { + void *Value; + int Intval; + }; // end union short Type, Domain; PPARM Next; } PARM; diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index 054e46f7f10..1af10183687 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -322,7 +322,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode) && mode == MODE_UPDATE) && !(tmp == TMP_FORCE && (mode == MODE_UPDATE || mode == MODE_DELETE)); - PTXF txfp; + PTXF txfp = NULL; PTDBASE tdbp; /*********************************************************************/ @@ -574,7 +574,7 @@ int TDBDOS::ResetTableOpt(PGLOBAL g, bool dop, bool dox) int TDBDOS::MakeBlockValues(PGLOBAL g) { int i, lg, nrec, rc, n = 0; - int curnum, curblk, block, last, savndv, savnbm; + int curnum, curblk, block, savndv, savnbm; void *savmin, *savmax; bool blocked, xdb2 = false; //POOLHEADER save; @@ -611,7 +611,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g) // to Rows+1 by unblocked variable length table access methods. curblk = -1; curnum = nrec - 1; - last = 0; +//last = 0; Txfp->Block = block; // This is useful mainly for Txfp->CurBlk = curblk; // blocked tables (ZLBFAM), for Txfp->CurNum = curnum; // others it is just to be clean. @@ -742,7 +742,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g) Txfp->BlkPos[curblk] = Txfp->GetPos(); } // endif CurNum - last = curnum + 1; // curnum is zero based +// last = curnum + 1; // curnum is zero based Txfp->CurBlk = curblk; // Used in COLDOS::SetMinMax Txfp->CurNum = curnum; // Used in COLDOS::SetMinMax } // endif blocked @@ -1351,7 +1351,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv) //int i, n1, n2, ctype = TYPE_ERROR, n = 0, type[2] = {0,0}; //bool conv = false, xdb2 = false, ok = false, b[2]; //PXOB *xarg1, *xarg2 = NULL, xp[2]; - int i, ctype = TYPE_ERROR, n = 0, type[2] = {0,0}; + int i, n = 0, type[2] = {0,0}; bool conv = false, xdb2 = false, ok = false; PXOB *xarg2 = NULL, xp[2]; PCOL colp; @@ -1363,7 +1363,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv) switch (arg[i]->GetType()) { case TYPE_CONST: type[i] = 1; - ctype = arg[i]->GetResultType(); + // ctype = arg[i]->GetResultType(); break; case TYPE_COLBLK: conv = cnv[i]; @@ -1388,7 +1388,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv) // correlated subquery, it has a constant value during // each execution of the subquery. type[i] = 1; - ctype = arg[i]->GetResultType(); +// ctype = arg[i]->GetResultType(); } // endif this break; diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index e11fac3a6b2..08938cb9626 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -888,6 +888,7 @@ bool TDBMYSQL::OpenDB(PGLOBAL g) } else if (Mode == MODE_INSERT) { if (Srcdef) { strcpy(g->Message, "No insert into anonym views"); + Myc.Close(); return true; } // endif Srcdef @@ -906,12 +907,12 @@ bool TDBMYSQL::OpenDB(PGLOBAL g) } // endif MakeInsert if (m_Rc != RC_FX) { - int rc; char cmd[64]; int w; sprintf(cmd, "ALTER TABLE `%s` DISABLE KEYS", Tabname); - rc = Myc.ExecSQL(g, cmd, &w); // may fail for some engines + + m_Rc = Myc.ExecSQL(g, cmd, &w); // may fail for some engines } // endif m_Rc } else diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 4c1c36369ef..b2935743bd5 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -91,32 +91,6 @@ PSZ strlwr(PSZ s); } #endif // !WIN32 -/***********************************************************************/ -/* Returns the bitmap representing the conditions that must not be */ -/* met when returning from TestValue for a given operator. */ -/* Bit one is EQ, bit 2 is LT, and bit 3 is GT. */ -/***********************************************************************/ -BYTE OpBmp(PGLOBAL g, OPVAL opc) - { - BYTE bt; - - switch (opc) { - case OP_IN: - case OP_EQ: bt = 0x06; break; - case OP_NE: bt = 0x01; break; - case OP_GT: bt = 0x03; break; - case OP_GE: bt = 0x02; break; - case OP_LT: bt = 0x05; break; - case OP_LE: bt = 0x04; break; - case OP_EXIST: bt = 0x00; break; - default: - sprintf(g->Message, MSG(BAD_FILTER_OP), opc); - longjmp(g->jumper[g->jump_level], TYPE_ARRAY); - } // endswitch opc - - return bt; - } // end of OpBmp - /***********************************************************************/ /* Get a long long number from its character representation. */ /* IN p: Pointer to the numeric string */