summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-11-09 09:30:37 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2022-11-09 09:30:37 +0200
commit3278c57917642fa5ab9b88f7e56ad3b1e364e2c4 (patch)
tree915857d2385fcf92be96795d6cbb056025bc5bee
parentb955f4eff72e8602ef60cb57bf1420e38802681f (diff)
parent20969aa41251045a890a29e7b68ae5abae7d0a95 (diff)
downloadmariadb-git-3278c57917642fa5ab9b88f7e56ad3b1e364e2c4.tar.gz
Merge 10.4 into 10.5
-rw-r--r--storage/connect/mysql-test/connect/r/odbc_postgresql.result9
-rw-r--r--storage/connect/mysql-test/connect/t/odbc_postgresql.test9
-rw-r--r--storage/connect/odbconn.cpp2
-rw-r--r--storage/connect/tabext.cpp4
-rw-r--r--storage/innobase/btr/btr0btr.cc4
-rw-r--r--storage/innobase/dict/dict0defrag_bg.cc4
-rw-r--r--storage/innobase/dict/dict0stats.cc6
7 files changed, 28 insertions, 10 deletions
diff --git a/storage/connect/mysql-test/connect/r/odbc_postgresql.result b/storage/connect/mysql-test/connect/r/odbc_postgresql.result
index 6bd8d75a601..9ecb66307e6 100644
--- a/storage/connect/mysql-test/connect/r/odbc_postgresql.result
+++ b/storage/connect/mysql-test/connect/r/odbc_postgresql.result
@@ -319,3 +319,12 @@ SELECT * from pg_in_maria;
my space column
My value
DROP TABLE pg_in_maria;
+#
+# MDEV-29397 UPDATE with WHERE on part of two-part primary key causes
+# info to turn into error.
+#
+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';
+UPDATE t1 SET a='10' WHERE a='20';
+Warnings:
+Note 1105 schema1.t3: 0 affected rows
+DROP TABLE t1;
diff --git a/storage/connect/mysql-test/connect/t/odbc_postgresql.test b/storage/connect/mysql-test/connect/t/odbc_postgresql.test
index ec98453d630..187bec55b38 100644
--- a/storage/connect/mysql-test/connect/t/odbc_postgresql.test
+++ b/storage/connect/mysql-test/connect/t/odbc_postgresql.test
@@ -223,3 +223,12 @@ DROP TABLE t1;
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;
SELECT * from pg_in_maria;
DROP TABLE pg_in_maria;
+
+--echo #
+--echo # MDEV-29397 UPDATE with WHERE on part of two-part primary key causes
+--echo # info to turn into error.
+--echo #
+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';
+UPDATE t1 SET a='10' WHERE a='20';
+DROP TABLE t1;
+
diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp
index b0026860054..a47d954c0a7 100644
--- a/storage/connect/odbconn.cpp
+++ b/storage/connect/odbconn.cpp
@@ -2579,7 +2579,7 @@ int ODBConn::Rewind(char *sql, ODBCCOL *tocols)
int rc, rbuf = -1;
if (!m_hstmt)
- rbuf = -1;
+ rbuf = 0;
else if (m_Full)
rbuf = m_Rows; // No need to "rewind"
else if (m_Scrollable) {
diff --git a/storage/connect/tabext.cpp b/storage/connect/tabext.cpp
index dcd93539f19..96a9f70e4a3 100644
--- a/storage/connect/tabext.cpp
+++ b/storage/connect/tabext.cpp
@@ -472,7 +472,7 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
my_len= res - buf + 1;
my_schema_table= (char *) malloc(my_len);
memcpy(my_schema_table, buf, my_len - 1);
- my_schema_table[my_len] = 0;
+ my_schema_table[my_len - 1] = 0;
Query->Append(Quote);
Query->Append(my_schema_table);
Query->Append(Quote);
@@ -480,7 +480,7 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
Query->Append(".");
// Parse table
my_len= strlen(buf) - my_len + 1;
- my_schema_table= (char *) malloc(my_len);
+ my_schema_table= (char *) malloc(my_len + 1);
memcpy(my_schema_table, ++res, my_len);
my_schema_table[my_len] = 0;
Query->Append(Quote);
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index 2b4bc0e9ed5..4b77277263f 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -590,7 +590,7 @@ btr_get_size(
ulint n=0;
ut_ad(srv_read_only_mode
- || mtr->memo_contains(index->lock, MTR_MEMO_S_LOCK));
+ || mtr->memo_contains(index->lock, MTR_MEMO_SX_LOCK));
ut_ad(flag == BTR_N_LEAF_PAGES || flag == BTR_TOTAL_SIZE);
if (index->page == FIL_NULL
@@ -636,7 +636,7 @@ btr_get_size_and_reserved(
{
ulint dummy;
- ut_ad(mtr->memo_contains(index->lock, MTR_MEMO_S_LOCK));
+ ut_ad(mtr->memo_contains(index->lock, MTR_MEMO_SX_LOCK));
ut_a(flag == BTR_N_LEAF_PAGES || flag == BTR_TOTAL_SIZE);
if (index->page == FIL_NULL
diff --git a/storage/innobase/dict/dict0defrag_bg.cc b/storage/innobase/dict/dict0defrag_bg.cc
index 0d9cb185b81..b4542f79703 100644
--- a/storage/innobase/dict/dict0defrag_bg.cc
+++ b/storage/innobase/dict/dict0defrag_bg.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2016, 2019, MariaDB Corporation.
+Copyright (c) 2016, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -280,7 +280,7 @@ dict_stats_save_defrag_stats(
ulint n_leaf_pages;
ulint n_leaf_reserved;
mtr.start();
- mtr_s_lock_index(index, &mtr);
+ mtr_sx_lock_index(index, &mtr);
n_leaf_reserved = btr_get_size_and_reserved(index, BTR_N_LEAF_PAGES,
&n_leaf_pages, &mtr);
mtr.commit();
diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc
index 42f75252cee..3bbb6483b6a 100644
--- a/storage/innobase/dict/dict0stats.cc
+++ b/storage/innobase/dict/dict0stats.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2009, 2019, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2021, MariaDB Corporation.
+Copyright (c) 2015, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -851,7 +851,7 @@ dict_stats_update_transient_for_index(
ulint size;
mtr.start();
- mtr_s_lock_index(index, &mtr);
+ mtr_sx_lock_index(index, &mtr);
size = btr_get_size(index, BTR_TOTAL_SIZE, &mtr);
if (size != ULINT_UNDEFINED) {
@@ -1945,7 +1945,7 @@ static index_stats_t dict_stats_analyze_index(dict_index_t* index)
DEBUG_PRINTF(" %s(index=%s)\n", __func__, index->name());
mtr.start();
- mtr_s_lock_index(index, &mtr);
+ mtr_sx_lock_index(index, &mtr);
size = btr_get_size(index, BTR_TOTAL_SIZE, &mtr);
if (size != ULINT_UNDEFINED) {