Skip to content

Commit b59bc62

Browse files
spliticegrooverdan
authored andcommitted
MDEV-27766: connect engine; INSERT ignore option, was ignored
Test prior to this change: CURRENT_TEST: connect.mysql mysqltest: At line 485: query 'INSERT IGNORE INTO t3 VALUES (5),(10),(30)' failed: ER_GET_ERRMSG (1296): Got error 122 '(1062) Duplicate entry '10' for key 'PRIMARY' [INSERT INTO `t1` (`a`) VALUES (10)]' from CONNECT So the ignore table option wasn't getting passed to the remove server. Closes #2008
1 parent ace2e03 commit b59bc62

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

storage/connect/mysql-test/connect/r/mysql.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,15 @@ a
294294
30
295295
DROP TABLE t2;
296296
DROP TABLE t1;
297+
#
298+
# MDEV-27766 CONNECT Engine Support for INSERT IGNORE with Mysql Table type
299+
#
300+
CREATE TABLE t1 (a INT PRIMARY KEY);
301+
INSERT INTO t1 VALUES (10),(20),(30);
302+
CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@localhost:PORT/test/t1' OPTION_LIST="Delayed=1,Ignored=1";
303+
INSERT INTO t2 VALUES (10),(20),(30),(40);
304+
DROP TABLE t2;
305+
DROP TABLE t1;
306+
#
307+
# End of 10.3 tests
308+
#

storage/connect/mysql-test/connect/t/mysql.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,3 +470,19 @@ SELECT * FROM t2;
470470
DROP TABLE t2;
471471
DROP TABLE t1;
472472

473+
474+
--echo #
475+
--echo # MDEV-27766 CONNECT Engine Support for INSERT IGNORE with Mysql Table type
476+
--echo #
477+
478+
CREATE TABLE t1 (a INT PRIMARY KEY);
479+
INSERT INTO t1 VALUES (10),(20),(30);
480+
--replace_result $PORT PORT
481+
--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@localhost:$PORT/test/t1' OPTION_LIST="Delayed=1,Ignored=1"
482+
INSERT INTO t2 VALUES (10),(20),(30),(40);
483+
DROP TABLE t2;
484+
DROP TABLE t1;
485+
486+
--echo #
487+
--echo # End of 10.3 tests
488+
--echo #

storage/connect/tabmysql.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ MYSQLDEF::MYSQLDEF(void)
9494
Isview = false;
9595
Bind = false;
9696
Delayed = false;
97+
Ignored = false;
9798
//Xsrc = false;
9899
Huge = false;
99100
} // end of MYSQLDEF constructor
@@ -321,6 +322,9 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
321322

322323
Desc = "MySQL Table";
323324

325+
Delayed = !!GetIntCatInfo("Delayed", 0);
326+
Ignored = !!GetIntCatInfo("Ignored", 0);
327+
324328
if (stricmp(am, "MYPRX")) {
325329
// Normal case of specific MYSQL table
326330
url = GetStringCatInfo(g, "Connect", NULL);
@@ -339,7 +343,6 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
339343
return true;
340344

341345
Bind = !!GetIntCatInfo("Bind", 0);
342-
Delayed = !!GetIntCatInfo("Delayed", 0);
343346
} else {
344347
// MYSQL access from a PROXY table
345348
TABLE_SHARE* s;
@@ -425,6 +428,7 @@ TDBMYSQL::TDBMYSQL(PMYDEF tdp) : TDBEXT(tdp)
425428
Isview = tdp->Isview;
426429
Prep = tdp->Bind;
427430
Delayed = tdp->Delayed;
431+
Ignored = tdp->Ignored;
428432
Myc.m_Use = tdp->Huge;
429433
} else {
430434
Host = NULL;
@@ -440,6 +444,7 @@ TDBMYSQL::TDBMYSQL(PMYDEF tdp) : TDBEXT(tdp)
440444
Isview = false;
441445
Prep = false;
442446
Delayed = false;
447+
Ignored = false;
443448
} // endif tdp
444449

445450
Bind = NULL;
@@ -466,6 +471,7 @@ TDBMYSQL::TDBMYSQL(PTDBMY tdbp) : TDBEXT(tdbp)
466471
Isview = tdbp->Isview;
467472
Prep = tdbp->Prep;
468473
Delayed = tdbp->Delayed;
474+
Ignored = tdbp->Ignored;
469475
Bind = NULL;
470476
//Query = tdbp->Query;
471477
Fetched = tdbp->Fetched;
@@ -623,11 +629,13 @@ bool TDBMYSQL::MakeInsert(PGLOBAL g)
623629
len += (strlen(TableName) + 40);
624630
Query = new(g) STRING(g, len);
625631

632+
Query->Set("INSERT ");
626633
if (Delayed)
627-
Query->Set("INSERT DELAYED INTO ");
628-
else
629-
Query->Set("INSERT INTO ");
634+
Query->Append("DELAYED ");
635+
if (Ignored)
636+
Query->Append("IGNORE ");
630637

638+
Query->Append("INTO ");
631639
Query->Append(tk);
632640
Query->Append(TableName);
633641
Query->Append("` (");

storage/connect/tabmysql.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class MYSQLDEF : public EXTDEF {/* Logical table description */
6060
bool Isview; /* true if this table is a MySQL view */
6161
bool Bind; /* Use prepared statement on insert */
6262
bool Delayed; /* Delayed insert */
63+
bool Ignored; /* Use insert IGNORE */
6364
//bool Xsrc; /* Execution type */
6465
bool Huge; /* True for big table */
6566
}; // end of MYSQLDEF
@@ -132,6 +133,7 @@ class TDBMYSQL : public TDBEXT {
132133
bool Isview; // True if this table is a MySQL view
133134
bool Prep; // Use prepared statement on insert
134135
bool Delayed; // Use delayed insert
136+
bool Ignored; // Use insert IGNORE
135137
int m_Rc; // Return code from command
136138
//int AftRows; // The number of affected rows
137139
int N; // The current table index

0 commit comments

Comments
 (0)