Hi Alexey,

Thanks for the patch. I think this patch can go into 10.6 because it is
a relatively simple and straightforward fix that only affects spider
(the only engine with HA_CAN_DIRECT_UPDATE_AND_DELETE). OK to push after
addressing the review comments below.

> From: Alexey Botchkov <[email protected]>
> Date: Mon, 22 Sep 2025 23:38:36 +0400
> Subject: [PATCH] MDEV-26540 Spider: Assertion `inited==RND' failed in
>  handler::ha_rnd_end on DELETE.
> The ha_partition::direct_delete_rows() should not call ::ha_rnd_end() if
> rnd_seq isn't set.

Can you write a more explanatory commit message? One that mentions why
this is needed and preferably describes what goes wrong otherwise.

> ---
>  sql/ha_partition.cc                           | 11 ++++---
>  .../spider/bugfix/r/mdev_26540.result         | 16 ++++++++++
>  .../spider/bugfix/t/mdev_26540.test           | 29 +++++++++++++++++++
>  3 files changed, 52 insertions(+), 4 deletions(-)
>  create mode 100644 
> storage/spider/mysql-test/spider/bugfix/r/mdev_26540.result
>  create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_26540.test

> diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
> index 3c3c51f92eb..f282f972777 100644
> --- a/sql/ha_partition.cc
> +++ b/sql/ha_partition.cc
> @@ -12157,10 +12157,13 @@ int ha_partition::direct_delete_rows(ha_rows 
> *delete_rows_result)
>                     file->pre_direct_delete_rows() :
>                     file->ha_direct_delete_rows(&delete_rows))))
>        {
> -        if (m_pre_calling)
> -          file->ha_pre_rnd_end();
> -        else
> -          file->ha_rnd_end();
> +        if (rnd_seq)
> +        {
> +          if (m_pre_calling)
> +            file->ha_pre_rnd_end();
> +          else
> +            file->ha_rnd_end();
> +        }
>          DBUG_RETURN(error);
>        }
>        delete_rows_result+= delete_rows;
> diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_26540.result 
> b/storage/spider/mysql-test/spider/bugfix/r/mdev_26540.result
> new file mode 100644
> index 00000000000..db6d4ba73c6
> --- /dev/null
> +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_26540.result
> @@ -0,0 +1,16 @@
> +for master_1
> +for child2
> +for child3
> +SET spider_same_server_link=1;
> +CREATE SERVER srv FOREIGN DATA WRAPPER mysql
> +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
> +CREATE TABLE t (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=InnoDB;
> +CREATE TABLE t2 (pk INT,c1 INT) ENGINE=Spider COMMENT='TABLE "st"' PARTITION 
> BY LIST COLUMNS (c1)
> +(PARTITION p DEFAULT COMMENT='srv "d"' ENGINE=Spider COMMENT='WRAPPER 
> "mysql",SRV "srv",TABLE "t"');
> +DELETE FROM t2 WHERE pk=2;
> +ERROR 42S22: Unknown column 'pk' in 'WHERE'
> +DROP TABLE t, t2;
> +DROP SERVER srv;
> +for master_1
> +for child2
> +for child3
> diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_26540.test 
> b/storage/spider/mysql-test/spider/bugfix/t/mdev_26540.test
> new file mode 100644
> index 00000000000..09a7fa8e105
> --- /dev/null
> +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_26540.test
> @@ -0,0 +1,29 @@
> +--disable_query_log
> +--disable_result_log
> +--source ../../t/test_init.inc
> +--enable_result_log
> +--enable_query_log
> +
> +--source include/have_innodb.inc
> +--source include/have_partition.inc
> +
> +--let $SOCKET= `SELECT @@global.socket`

$SOCKET is unused.

> +SET spider_same_server_link=1;
> +
> +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
> +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
> +
> +CREATE TABLE t (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=InnoDB;
> +CREATE TABLE t2 (pk INT,c1 INT) ENGINE=Spider COMMENT='TABLE "st"' PARTITION 
> BY LIST COLUMNS (c1)
> +   (PARTITION p DEFAULT COMMENT='srv "d"' ENGINE=Spider COMMENT='WRAPPER 
> "mysql",SRV "srv",TABLE "t"');
> +--error ER_BAD_FIELD_ERROR
> +DELETE FROM t2 WHERE pk=2;
> +
> +DROP TABLE t, t2;
> +DROP SERVER srv;
> +
> +--disable_query_log
> +--disable_result_log
> +--source ../../t/test_deinit.inc
> +--enable_result_log
> +--enable_query_log

I was wondering why only this testcase out of all the cases in the
description or comments of the JIRA issue are included, so I tried all
other cases, and all but this and another case still reproduce without
the patch. Ideally the other case should be included too. Your call.

> -- 
> 2.39.2

Best,
Yuchen
_______________________________________________
developers mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to