Skip to content

Commit fda5846

Browse files
authored
MDEV-29397 CONNECT engine: Fix note turning into error (#2325)
* MDEV-29397 Fix note turning into error ODBC Rewind triggered an error with no SQL, but this is sometimes a valid condition (as can be seen with other classes). Setting this to a 0 return stops errors firing when they shouldn't. Also fixes ASAN hits from in MDEV-29687 tabext.cpp.
1 parent 2ef2e23 commit fda5846

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,12 @@ SELECT * from pg_in_maria;
319319
my space column
320320
My value
321321
DROP TABLE pg_in_maria;
322+
#
323+
# MDEV-29397 UPDATE with WHERE on part of two-part primary key causes
324+
# info to turn into error.
325+
#
326+
CREATE TABLE t1 (a VARCHAR(6), b VARCHAR(6), PRIMARY KEY(a, b)) ENGINE=CONNECT TABNAME='schema1.t3' CHARSET=utf8 DATA_CHARSET=utf8 TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr';
327+
UPDATE t1 SET a='10' WHERE a='20';
328+
Warnings:
329+
Note 1105 schema1.t3: 0 affected rows
330+
DROP TABLE t1;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,12 @@ DROP TABLE t1;
223223
CREATE TABLE pg_in_maria ENGINE=CONNECT TABNAME='schema1.space_in_column_name' CHARSET=utf8 DATA_CHARSET=utf8 TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' quoted=1;
224224
SELECT * from pg_in_maria;
225225
DROP TABLE pg_in_maria;
226+
227+
--echo #
228+
--echo # MDEV-29397 UPDATE with WHERE on part of two-part primary key causes
229+
--echo # info to turn into error.
230+
--echo #
231+
CREATE TABLE t1 (a VARCHAR(6), b VARCHAR(6), PRIMARY KEY(a, b)) ENGINE=CONNECT TABNAME='schema1.t3' CHARSET=utf8 DATA_CHARSET=utf8 TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr';
232+
UPDATE t1 SET a='10' WHERE a='20';
233+
DROP TABLE t1;
234+

storage/connect/odbconn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2582,7 +2582,7 @@ int ODBConn::Rewind(char *sql, ODBCCOL *tocols)
25822582
int rc, rbuf = -1;
25832583

25842584
if (!m_hstmt)
2585-
rbuf = -1;
2585+
rbuf = 0;
25862586
else if (m_Full)
25872587
rbuf = m_Rows; // No need to "rewind"
25882588
else if (m_Scrollable) {

storage/connect/tabext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,15 +473,15 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
473473
my_len= res - buf + 1;
474474
my_schema_table= (char *) malloc(my_len);
475475
memcpy(my_schema_table, buf, my_len - 1);
476-
my_schema_table[my_len] = 0;
476+
my_schema_table[my_len - 1] = 0;
477477
Query->Append(Quote);
478478
Query->Append(my_schema_table);
479479
Query->Append(Quote);
480480
free(my_schema_table);
481481
Query->Append(".");
482482
// Parse table
483483
my_len= strlen(buf) - my_len + 1;
484-
my_schema_table= (char *) malloc(my_len);
484+
my_schema_table= (char *) malloc(my_len + 1);
485485
memcpy(my_schema_table, ++res, my_len);
486486
my_schema_table[my_len] = 0;
487487
Query->Append(Quote);

0 commit comments

Comments
 (0)