Home - Waterfall Grid T-Grid Console Builders Recent Builds Buildslaves Changesources - JSON API - About

Console View


Categories: connectors experimental galera main
Legend:   Passed Failed Warnings Failed Again Running Exception Offline No data

connectors experimental galera main
Sergei Golubchik
MDEV-7761 Some MTR tests fail when run on a host named 'localhost'

skip the test in the unlikely case of hostname being "localhost"
Dmitry Shulga
MDEV-32694: ASAN errors in Binary_string::alloced_length / reset_stmt_params

Anonymous block is represented internally by the class sp_head,
so every statement inside an anonymous block is a SP instruction.
On the other hand, the anonymous block specified in the FROM clause of
the PREPARE statement is treated as a single statement. In result,
all parameter markers (represented by the character ?) are parts of
the anonymous block specified in the prepared statement and at the same
time parameter are markers, internally represented by instances of
the class Item_param and distributed among SP instructions representing
SQL statements (every SQL statement is represented by an instance of
the class sp_instr_stmt)

In case table metadata changed on running an anonymous block in prepared
statement mode, only SP instruction's statement is re-parsed. Before
re-parsing a SP's statement, all items are cleaned up including
instances of the class Item_param that represent positional parameters.

Unfortunately, this leads to presence of a dangling pointer in
Prepared_statement::param_array that references to the deleted
Item_param while invoking reset_stmt_params happening on every execution
of a prepared statement.

To fix the issue, no instances of Item_param created on re-parsings
a statement for failed SP instruction, rather instances of Item_param
left from first time parsing are re-used. As a consequence, all pointers
to instances of the class Item_param stored in the array
Prepared_statememt::param_array and possibly spread along the code base
  (e.g. select_lex->limit_params.select_limit)
still point to valid Items.
Dmitry Shulga
MDEV-32694: ASAN errors in Binary_string::alloced_length / reset_stmt_params

Anonymous block is represented internally by the class sp_head,
so every statement inside an anonymous block is a SP instruction.
On the other hand, the anonymous block specified in the FROM clause of
the PREPARE statement is treated as a single statement. In result,
all parameter markers (represented by the character ?) are parts of
the anonymous block specified in the prepared statement and at the same
time parameter are markers, internally represented by instances of
the class Item_param and distributed among SP instructions representing
SQL statements (every SQL statement is represented by an instance of
the class sp_instr_stmt)

In case table metadata changed on running an anonymous block in prepared
statement mode, only SP instruction's statement is re-parsed. Before
re-parsing a SP's statement, all items are cleaned up including
instances of the class Item_param that represent positional parameters.

Unfortunately, this leads to presence of a dangling pointer in
Prepared_statement::param_array that references to the deleted
Item_param while invoking reset_stmt_params happening on every execution
of a prepared statement.

To fix the issue, no instances of Item_param created on re-parsings
a statement for failed SP instruction, rather instances of Item_param
left from first time parsing are re-used. As a consequence, all pointers
to instances of the class Item_param stored in the array
Prepared_statememt::param_array and possibly spread along the code base
  (e.g. select_lex->limit_params.select_limit)
still point to valid Items.
Yuchen Pei
MDEV-27260 MDEV-37411 spider sh: Check backends used by spider tables
Kristian Nielsen
MDEV-34705: Binlog-in-engine: Crash-safe slave

This patch makes replication crash-safe with the new binlog implementation,
even when --innodb-flush-log-at-trx-commit=0|2. The point is to not send any
binlog events to the slave until they have become durable on master, thus
avoiding that a slave may replicate a transaction that is lost during master
recovery, diverging the slave from the master.

Keep track of which point in the binlog has been durably synced to disk
(meaning the corresponding LSN has been durably synced to disk in the InnoDB
redo log). Each write to the binlog inserts an entry with offset and
corresponding LSN in a FIFO. Dump threads will first read only up to the
durable point in the binlog. A dump thread will then check the LSN fifo, and
do an InnoDB redo log sync if anything is pending. Then the FIFO is emptied
of any LSNs that have now become durable, and the durable point in the
binlog is updated and reading the binlog can continue.

Signed-off-by: Kristian Nielsen <[email protected]>
Kristian Nielsen
MDEV-34705: Binlog-in-engine: Protect against concurrent RESET MASTER and dump threads

This is actually an existing problem in the old binlog implementation, and
this patch is applicable to old binlog also. The problem is that RESET
MASTER can run concurrently with binlog dump threads / connected slaves.
This will remove the binlog from under the feet of the reader, which can
cause all sorts of strange behaviour.

This patch fixes the problem by disallowing to run RESET MASTER when dump
threads (or other RESET MASTER or SHOW BINARY LOGS) are running. An error is
thrown in this case, user must stop slaves and/or kill dump threads to make
the RESET MASTER go through. A slave that connects in the middle of RESET
MASTER will wait for it to complete.

Fix a lot of test cases to kill any lingering dump threads before doing
RESET MASTER, mostly just by sourcing include/kill_binlog_dump_threads.inc.

Signed-off-by: Kristian Nielsen <[email protected]>
Kristian Nielsen
MDEV-34705: Binlog-in-engine: Fix hang with event group of specific size

If the event group fitted in the binlog cache without the GTID event but not
with, the code would attempt to spill part of the GTID event as out-of-band
data, which is not correct. In release builds this would hang the server as
the spilling would try to lock an already owned mutex.

Fix by checking if the GTID event fits, and spilling any non-GTID data as
oob if it does not.

Signed-off-by: Kristian Nielsen <[email protected]>
Yuchen Pei
MDEV-34711 set first_link_idx and create conn for every ha_spider involved

also return failure when remote query execution fails.
Yuchen Pei
MDEV-34711 Ban spider sh if containing any subqueries

The same limitation applies to gbh
Kristian Nielsen
MDEV-34705: Binlog-in-engine: Protect against concurrent RESET MASTER and dump threads

This is actually an existing problem in the old binlog implementation, and
this patch is applicable to old binlog also. The problem is that RESET
MASTER can run concurrently with binlog dump threads / connected slaves.
This will remove the binlog from under the feet of the reader, which can
cause all sorts of strange behaviour.

This patch fixes the problem by disallowing to run RESET MASTER when dump
threads (or other RESET MASTER or SHOW BINARY LOGS) are running. An error is
thrown in this case, user must stop slaves and/or kill dump threads to make
the RESET MASTER go through. A slave that connects in the middle of RESET
MASTER will wait for it to complete.

Fix a lot of test cases to kill any lingering dump threads before doing
RESET MASTER, mostly just by sourcing include/kill_binlog_dump_threads.inc.

Signed-off-by: Kristian Nielsen <[email protected]>
Sergey Vojtovich
MDEV-29474 - main.lock_sync fails with timeout

Reimplement test for MDEV-28567 such that it behaves consistently and
consistently covers the code that it was intended to cover. The test
itself moved to mdl_sync.test, because lock_sync.test is supposed for
testing THR_LOCK, not MDL. Verified with DBUG_ASSERT(0) in
open_tables() (from 92bfc0e8c4bb) restored.

The test is failing with various symptoms as it was designed to be
sporadic. It did cover the code that it was supposed to cover in
less than 0.1% of runs. That is the following command succeeds often
with DBUG_ASSERT(0) in open_tables() (from 92bfc0e8c4bb) restored:
./mtr --repeat=25 --parallel=40 lock_sync{,,,,}{,,,,}

Test is also reimplemented such that it doesn't rely on buggy "MDL
overweight" behaviour as described in MDEV-36887. Previously it did
require preceding statements that fall in deadlock in default
connection. Now it works consistently in both cases: if there was
preceding deadlock and if there was none.

mdl_after_find_deadlock sync point added to avoid premature deadlock
handling by connections that don't intend to handle it. ALTER VIEW
connection is supposed to handle it, this makes test behaviour
consistent.

Tracking history:
92bfc0e8c4bb MDEV-17554, assert added
f88511647aa MDEV-28567, test added, assertion modified
fe3adde2507 MDEV-29060, test moved, fix attempted
8ee93b9cb48 MDEV-29060, fix attempted
611d4425108 fix attempted
77c465d5aacd assertion modified
4c695c85bdb9 assertion removed
MDEV-29474 - subj
MDEV-36665 - duplicate of MDEV-29474
Alexey Botchkov
MDEV-21376 mysqldump should support wildcards.

Now --wildcards (-L) option is supported by mysqldump.
So user can specify patterns for database names or table names
to dump.
  • kvm-debug-arm64: build failed -  stdiokernel
  • openssl3-fips-debug: build failed -  stdiokernel
  • winx64-debug: compile failed -  stdio
Sergei Golubchik
MDEV-35580 Server using WolfSSL shows different name than OpenSSL for some ciphers

emulate OpenSSL behavior in WolfSSL:
* use IANA cipher names (TLS_ prefix, underscore) for TLSv1.3
  e.g. TLS_AES_256_GCM_SHA384
* use OpenSSL names (no previx, dash) otherwise
  e.g. AES256-GCM-SHA384
Vladislav Vaintroub
MDEV-37143 mariabackup fails on Windows with "SSL certificate is self-signed"

This is the same as MDEV-35368, which was  previously incompletely fixed
(on *nix-only, for unix socket connections)

This time, we fix it compatibly to Connector/C, by not verifying
server certificate for local connections, which, in addition to socket
and named pipe, are also "127.0.0.1" and "::1", and on Windows "localhost"
as well.

The corresponding code in Connector/C is was added by
1287c901dc8515823d28edcebfe4be65e6c5a6b3.

It remain a good question whether mariabackup should use SSL at all
since all it does are local connections, for "BACKUP STAGE" stuff.
Alexander Barkov
MDEV-36053 CURSOR declarations in PACKAGE BODY

This change adds CURSOR declarations inside PACKAGE BODY.

PL/SQL mode:

  SET sql_mode=ORACLE;
  CREATE PACKAGE BODY pkg AS
    CURSOR mc0 IS SELECT c0, c1 FROM t1;
    PROCEDURE p1 AS
      rec mc0%ROWTYPE;
    BEGIN
      OPEN mc0;
      FETCH mc0 INTO rec;
      CLOSE mc0
    END;
  END;
  /

SQL/PSM mode:

  SET sql_mode=DEFAULT;
  CREATE PACKAGE BODY pkg
    mc0 CURSOR FOR SELECT c0, c1 FROM t1;
    PROCEDURE p1()
    BEGIN
      DECLARE rec ROW TYPE OF mc0;
      OPEN mc0;
      FETCH mc0 INTO rec;
      CLOSE mc0
    END;
  END;
  /

PACKAGE BODY cursors like local cursors
(declared inside a FUNCTION or a PROCEDURE) support:
  - OPEN/FETCH/CLOSE
  - FOR rec IN cur - an explicit cursor loop
  - Using a cursor row as an anchored variable data type:
    * DECLARE var cur%ROWTYPE;    -- sql_mode=ORACLE
    * DECLARE var ROW TYPE OF cur; -- sql_mode=DEFAULT

The patch details:

- Changing various class members and function/method parameters which
  store a CURSOR run-time address from "uint" to sp_rcontext_addr.
  A few classes now derive from sp_rcontext_addr instead of having
  a "uint m_cursor;" member.

  This change uses the same idea with what we did for SP variables,
  when we implemented PACKAGE BODY variables a few years ago.

- Fixing the grammar in sql_yacc.yy to allow CURSOR declarations
  inside PACKAGE BODY.

- Adding a new class sp_pcontext_top. It's used for the top level parse
  context (of an sp_head). Note, its children contexts still use the old
  class sp_pcontext.

  sp_pcontext_top context additionally to sp_pcontext has:

    const sp_head *m_sp; -- The pointer to the sp_head owning this context
    Dynamic_array<sp_pcursor> m_member_cursors; -- PACKAGE BODY wide cursors

  m_sp->m_parent->get_parse_context() is used to find the sp_pcontext
  belonging to the parent PACKAGE BODY from a sp_pcontext_top instance
  belonging to a PROCEDURE/FUNCTION sp_pcontext_top.

- Adding a new member in sp_rcontext:
    Dynamic_array<sp_cursor*> m_member_cursors;
  It's used to store run-time data of PACKAGE BODY wide cursors.

- Adding a new class sp_instr_copen2. It's used to open PACKAGE BODY cursors.
  Unlike the usual cursors, PACKAGE BODY cursors:
  * do not use the cursor stack (sp_rcontext::m_cstack)
  * do not need a preceeding sp_instr_cpush
  * do not need a following sp_instr_cpop

  All cursor information such as "sp_lex_cursor" resides inside
  sp_instr_copen2 itself (rather than inside sp_instr_cpush which is
  used to store "sp_lex_cursor" in case of sp_instr_copen).

  Note, the other cursor related instructions:
    sp_instr_cfetch
    sp_instr_cclose
    sp_instr_cursor_copy_struct
  do not need sp_instr_xxx2 counter-parts.
  Thy just use sp_rcontext_addr to address cursors.

- Adding Sp_rcontext_handler_member
  It's used to handle PACKAGE BODY members:
  cursors and variables declared in the PACKAGE BODY,
  when they are accessed from its executable initialization section:

    CREATE PACKAGE BODY pkg AS
      CURSOR mc0 IS SELECT c0, c1 FROM t1; -- A member (PACKAGE BODY cursor)
      mv0 mc0%ROWTYPE;                    -- A member (PACKAGE BODY variable)
      PROCEDURE p1 AS
      BEGIN
        -- Accessing members from here use sp_rcontext_handler_package_body
        -- (members of the parent PACKAGE BODY)
        OPEN mc0;
        FETCH mc0 INTO mv0;
        CLOSE mc0;
      END;
    BEGIN
      -- NEW:
      -- Accessing members from here use sp_rcontext_handler_member
      -- (PACKAGE BODY own members)
      OPEN mc0;
      FETCH mc0 INTO mv0;
      CLOSE mc0;
    END;
    /

  Member variables and cursor are now marked with the "MEMBER." prefix
  in the "SHOW PACKAGE BODY code" output.
  Some old MTR tests have been re-recorded accordingly.

- Adding new virtual methods into Sp_rcontext_handler:

  virtual const sp_variable *get_pvariable(const sp_pcontext *pctx,
                                          uint offset) const;

  virtual const sp_pcursor *get_pcursor(const sp_pcontext *pctx,
                                        uint offset) const;

  They're used from sp_instr::print() virtual implementations.
  They internally calculate a proper sp_pcontext using as a parameter
  the sp_pcontext pointed by sp_instr::m_ctx.

  For example, Sp_handler_package_body::get_pvariable()/get_pcursor()
  accesses to this sp_pcontext:
      m_ctx->top_context()->m_sp->m_parent->get_parse_context(),
  i.e. the parse context of the PACKAGE BODY which is the parent for
  the current package PROCEDURE of FUNCTION an sp_instr belongs to.

- Adding a new method LEX::find_cursor(). It searches for a cursor in
  this order:
  * Local cursors in the nearst upper BEGIN/END block.
  * A member cursor of the current PACKAGE BODY
    (used from the PACKAGE BODY initialization section)
  * A member cursor of the parrent PACKAGE BODY
    (used from a package PROCEDURE or a package FUNCTION)

  Adding a new method LEX::find_cursor_with_error().
  In case when a cursor is not found, it automatically
  raises the ER_SP_CURSOR_MISMATCH SQL condition into
  the diagnostics area.

- Adding a new method sp_head::add_instr_copenX().
  It creates sp_instr_copen for local cursors,
  or sp_instr_copen2 for non-local cursors.

- Adding a new abstract class sp_lex_cursor_instr.
  It's used a common parent class for a few sp_instr_xxx classes,
  including the new sp_instr_copen2.
  This change is needed to avoid code duplication.

- Adding a new protected method sp_instr::print_cmd_and_var(), to print
  an instruction using this format: "command name@offset".
  It's used from a few implementations of sp_instr_xxx::print(),
  including sp_instr_copen2::print().
  This change is also needed to avoid code duplication.

- Adding a new method sp_pcontext::frame_for_members_candidate(),
  to distinguish easier between local cursors/variables and
  PACKAGE BODY cursors/variables.

- Fixing "struct Lex_for_loop_st" to addionally store
  a const pointer to Sp_rcontext_handler, to distinguish between:
    * FOR rec IN local_cursor
    * FOR rec IN package_body_cursor
Thirunarayanan Balathandayuthapani
MDEV-35163  InnoDB persistent statistics fail to update after ALTER TABLE...ALGORITHM=COPY

Problem:
=======
- InnoDB statistics calculation for the table is done after
every 10 seconds by default in background thread dict_stats_thread()

- Doing multiple ALTER TABLE..ALGORITHM=COPY causes the
dict_stats_thread() to lag behind, therefore calculation of stats
for newly created intermediate table gets delayed

Fix:
====
- Stats calculation for newly created intermediate table is made
independent of background thread. After copying gets completed,
stats for new table is calculated as part of ALTER TABLE ... ALGORITHM=COPY.

dict_stats_rename_table(): Rename the table statistics from
intermediate table to new table

Before calling extra() with HA_EXTRA_END_ALTER_COPY, disable
abort_on_warning for the thread. Copy alter algorithm doesn't
have to report error when persistent statistics table doesn't exist.

alter_stats_rebuild(): Removes the table name from the warning.
Because this warning can print for intermediate table as well.


This is a cherry-pick fix of mysql commit@cfe5f287ae99d004e8532a30003a7e8e77d379e3
Yuchen Pei
MDEV-34711 mtr --record spider.direct_join
Kristian Nielsen
MDEV-34705: Binlog-in-engine: Protect against concurrent RESET MASTER and dump threads

This is actually an existing problem in the old binlog implementation, and
this patch is applicable to old binlog also. The problem is that RESET
MASTER can run concurrently with binlog dump threads / connected slaves.
This will remove the binlog from under the feet of the reader, which can
cause all sorts of strange behaviour.

This patch fixes the problem by disallowing to run RESET MASTER when dump
threads (or other RESET MASTER or SHOW BINARY LOGS) are running. An error is
thrown in this case, user must stop slaves and/or kill dump threads to make
the RESET MASTER go through. A slave that connects in the middle of RESET
MASTER will wait for it to complete.

Fix a lot of test cases to kill any lingering dump threads before doing
RESET MASTER, mostly just by sourcing include/kill_binlog_dump_threads.inc.

Signed-off-by: Kristian Nielsen <[email protected]>
Yuchen Pei
MDEV-37411 spider sh: do not create for partitioned tables

neither does gbh except when there's one partition only.
Sergei Golubchik
MDEV-35184 Corruption errors upon creation or usage of Federated table with vector key

disallow vector indexes in FederatedX, both in normal create
and in assisted discovery
Julius Goryavsky
debian/changelog automatic update
Thirunarayanan Balathandayuthapani
MDEV-37138 innochecksum misinterprets doublewrite buffer pages

- Innochecksum misinterprets the doublewrite buffer pages
as index pages. This leads the user to think there could be
stale table exist in system tablespace.

- To avoid this confusion, innochecksum wired the skipping
of doublewrite buffer pages to option -r while doing
page dumping or printing the summary of the tablespace
Yuchen Pei
MDEV-34711 Fix some result mismatch

Later we'll have to find a way (rdiff?) to accommodate both sh and gbh
Kristian Nielsen
MDEV-34705: Binlog-in-engine: Crash-safe slave

This patch makes replication crash-safe with the new binlog implementation,
even when --innodb-flush-log-at-trx-commit=0|2. The point is to not send any
binlog events to the slave until they have become durable on master, thus
avoiding that a slave may replicate a transaction that is lost during master
recovery, diverging the slave from the master.

Keep track of which point in the binlog has been durably synced to disk
(meaning the corresponding LSN has been durably synced to disk in the InnoDB
redo log). Each write to the binlog inserts an entry with offset and
corresponding LSN in a FIFO. Dump threads will first read only up to the
durable point in the binlog. A dump thread will then check the LSN fifo, and
do an InnoDB redo log sync if anything is pending. Then the FIFO is emptied
of any LSNs that have now become durable, and the durable point in the
binlog is updated and reading the binlog can continue.

Signed-off-by: Kristian Nielsen <[email protected]>
Dave Gosselin
MDEV-23699 Assertion failed in ha_tina::delete_row

When REPAIRing a CSV table, the CSV engine marks the table as having
no rows in the case that there are rows only in memory but not yet
written to disk.  In this case, there's actually nothing to repair,
since nothing exists on disk; make REPAIR idempotent for CSV tables.
Vladislav Vaintroub
MDEV-37143 mariabackup fails on Windows with "SSL certificate is self-signed"

This is the same as MDEV-35368, which was  previously incompletely fixed
(on *nix-only, for unix socket connections)

This time, we fix it compatibly to Connector/C, by not verifying
server certificate for local connections, which, in addition to socket
and named pipe, are also "127.0.0.1" and "::1", and on Windows "localhost"
as well.

The corresponding code in Connector/C is was added by
1287c901dc8515823d28edcebfe4be65e6c5a6b3.

It remain a good question whether mariabackup should use SSL at all
since all it does are local connections, for "BACKUP STAGE" stuff.
Kristian Nielsen
MDEV-34705: Binlog-in-engine: Crash-safe slave

This patch makes replication crash-safe with the new binlog implementation,
even when --innodb-flush-log-at-trx-commit=0|2. The point is to not send any
binlog events to the slave until they have become durable on master, thus
avoiding that a slave may replicate a transaction that is lost during master
recovery, diverging the slave from the master.

Keep track of which point in the binlog has been durably synced to disk
(meaning the corresponding LSN has been durably synced to disk in the InnoDB
redo log). Each write to the binlog inserts an entry with offset and
corresponding LSN in a FIFO. Dump threads will first read only up to the
durable point in the binlog. A dump thread will then check the LSN fifo, and
do an InnoDB redo log sync if anything is pending. Then the FIFO is emptied
of any LSNs that have now become durable, and the durable point in the
binlog is updated and reading the binlog can continue.

Signed-off-by: Kristian Nielsen <[email protected]>
Andrei
MDEV-35570 parallel slave ALTER-SEQUENCE attempted to binlog out-of-order

Since MDEV-31503 fixes ALTER-SEQUENCE might be able to  complete its
work including binlogging before a preceding in binlog-order
transaction. There may not be data dependency between the two
transactions, but there would be
  "an attempt was made to binlog GTID D-S-XYZ which would create an
  out-of-order sequence number"
error in the gtid_strict_mode = ON.

After the preceding transaction started committing, and does it rather
slow, ALTER-SEQUNCE was able to find a time window to complete because
it temporarily releases its link with the waitee parent transaction.
And while having it released it also erroneously executes the binlogging part.

Fixed with restoring the commit dependency on the parent before
ALTER-SEQUNCE takes on binlogging.
Alexander Barkov
MDEV-36053 CURSOR declarations in PACKAGE BODY

This change adds CURSOR declarations inside PACKAGE BODY.

PL/SQL mode:

  SET sql_mode=ORACLE;
  CREATE PACKAGE BODY pkg AS
    CURSOR mc0 IS SELECT c0, c1 FROM t1;
    PROCEDURE p1 AS
      rec mc0%ROWTYPE;
    BEGIN
      OPEN mc0;
      FETCH mc0 INTO rec;
      CLOSE mc0
    END;
  END;
  /

SQL/PSM mode:

  SET sql_mode=DEFAULT;
  CREATE PACKAGE BODY pkg
    mc0 CURSOR FOR SELECT c0, c1 FROM t1;
    PROCEDURE p1()
    BEGIN
      DECLARE rec ROW TYPE OF mc0;
      OPEN mc0;
      FETCH mc0 INTO rec;
      CLOSE mc0
    END;
  END;
  /

PACKAGE BODY cursors like local cursors
(declared inside a FUNCTION or a PROCEDURE) support:
  - OPEN/FETCH/CLOSE
  - FOR rec IN cur - an explicit cursor loop
  - Using a cursor row as an anchored variable data type:
    * DECLARE var cur%ROWTYPE;    -- sql_mode=ORACLE
    * DECLARE var ROW TYPE OF cur; -- sql_mode=DEFAULT

The patch details:

- Changing various class members and function/method parameters which
  store a CURSOR run-time address from "uint" to sp_rcontext_addr.
  A few classes now derive from sp_rcontext_addr instead of having
  a "uint m_cursor;" member.

  This change uses the same idea with what we did for SP variables,
  when we implemented PACKAGE BODY variables a few years ago.

- Fixing the grammar in sql_yacc.yy to allow CURSOR declarations
  inside PACKAGE BODY.

- Adding a new class sp_pcontext_top. It's used for the top level parse
  context (of an sp_head). Note, its children contexts still use the old
  class sp_pcontext.

  sp_pcontext_top context additionally to sp_pcontext has:

    const sp_head *m_sp; -- The pointer to the sp_head owning this context
    Dynamic_array<sp_pcursor> m_member_cursors; -- PACKAGE BODY wide cursors

  m_sp->m_parent->get_parse_context() is used to find the sp_pcontext
  belonging to the parent PACKAGE BODY from a sp_pcontext_top instance
  belonging to a PROCEDURE/FUNCTION sp_pcontext_top.

- Adding a new member in sp_rcontext:
    Dynamic_array<sp_cursor*> m_member_cursors;
  It's used to store run-time data of PACKAGE BODY wide cursors.

- Adding a new class sp_instr_copen2. It's used to open PACKAGE BODY cursors.
  Unlike the usual cursors, PACKAGE BODY cursors:
  * do not use the cursor stack (sp_rcontext::m_cstack)
  * do not need a preceeding sp_instr_cpush
  * do not need a following sp_instr_cpop

  All cursor information such as "sp_lex_cursor" resides inside
  sp_instr_copen2 itself (rather than inside sp_instr_cpush which is
  used to store "sp_lex_cursor" in case of sp_instr_copen).

  Note, the other cursor related instructions:
    sp_instr_cfetch
    sp_instr_cclose
    sp_instr_cursor_copy_struct
  do not need sp_instr_xxx2 counter-parts.
  Thy just use sp_rcontext_addr to address cursors.

- Adding Sp_rcontext_handler_member
  It's used to handle PACKAGE BODY members:
  cursors and variables declared in the PACKAGE BODY,
  when they are accessed from its executable initialization section:

    CREATE PACKAGE BODY pkg AS
      CURSOR mc0 IS SELECT c0, c1 FROM t1; -- A member (PACKAGE BODY cursor)
      mv0 mc0%ROWTYPE;                    -- A member (PACKAGE BODY variable)
      PROCEDURE p1 AS
      BEGIN
        -- Accessing members from here use sp_rcontext_handler_package_body
        -- (members of the parent PACKAGE BODY)
        OPEN mc0;
        FETCH mc0 INTO mv0;
        CLOSE mc0;
      END;
    BEGIN
      -- NEW:
      -- Accessing members from here use sp_rcontext_handler_member
      -- (PACKAGE BODY own members)
      OPEN mc0;
      FETCH mc0 INTO mv0;
      CLOSE mc0;
    END;
    /

  Member variables and cursor are now marked with the "MEMBER." prefix
  in the "SHOW PACKAGE BODY code" output.
  Some old MTR tests have been re-recorded accordingly.

- Adding new virtual methods into Sp_rcontext_handler:

  virtual const sp_variable *get_pvariable(const sp_pcontext *pctx,
                                          uint offset) const;

  virtual const sp_pcursor *get_pcursor(const sp_pcontext *pctx,
                                        uint offset) const;

  They're used from sp_instr::print() virtual implementations.
  They internally calculate a proper sp_pcontext using as a parameter
  the sp_pcontext pointed by sp_instr::m_ctx.

  For example, Sp_handler_package_body::get_pvariable()/get_pcursor()
  accesses to this sp_pcontext:
      m_ctx->top_context()->m_sp->m_parent->get_parse_context(),
  i.e. the parse context of the PACKAGE BODY which is the parent for
  the current package PROCEDURE of FUNCTION an sp_instr belongs to.

- Adding a new method LEX::find_cursor(). It searches for a cursor in
  this order:
  * Local cursors in the nearst upper BEGIN/END block.
  * A member cursor of the current PACKAGE BODY
    (used from the PACKAGE BODY initialization section)
  * A member cursor of the parrent PACKAGE BODY
    (used from a package PROCEDURE or a package FUNCTION)

  Adding a new method LEX::find_cursor_with_error().
  In case when a cursor is not found, it automatically
  raises the ER_SP_CURSOR_MISMATCH SQL condition into
  the diagnostics area.

- Adding a new method sp_head::add_instr_copenX().
  It creates sp_instr_copen for local cursors,
  or sp_instr_copen2 for non-local cursors.

- Adding a new abstract class sp_lex_cursor_instr.
  It's used a common parent class for a few sp_instr_xxx classes,
  including the new sp_instr_copen2.
  This change is needed to avoid code duplication.

- Adding a new protected method sp_instr::print_cmd_and_var(), to print
  an instruction using this format: "command name@offset".
  It's used from a few implementations of sp_instr_xxx::print(),
  including sp_instr_copen2::print().
  This change is also needed to avoid code duplication.

- Adding a new method sp_pcontext::frame_for_members_candidate(),
  to distinguish easier between local cursors/variables and
  PACKAGE BODY cursors/variables.

- Fixing "struct Lex_for_loop_st" to addionally store
  a const pointer to Sp_rcontext_handler, to distinguish between:
    * FOR rec IN local_cursor
    * FOR rec IN package_body_cursor
Kristian Nielsen
MDEV-34705: Binlog-in-engine: Crash-safe slave

This patch makes replication crash-safe with the new binlog implementation,
even when --innodb-flush-log-at-trx-commit=0|2. The point is to not send any
binlog events to the slave until they have become durable on master, thus
avoiding that a slave may replicate a transaction that is lost during master
recovery, diverging the slave from the master.

Keep track of which point in the binlog has been durably synced to disk
(meaning the corresponding LSN has been durably synced to disk in the InnoDB
redo log). Each write to the binlog inserts an entry with offset and
corresponding LSN in a FIFO. Dump threads will first read only up to the
durable point in the binlog. A dump thread will then check the LSN fifo, and
do an InnoDB redo log sync if anything is pending. Then the FIFO is emptied
of any LSNs that have now become durable, and the durable point in the
binlog is updated and reading the binlog can continue.

Signed-off-by: Kristian Nielsen <[email protected]>
Aleksey Midenkov
MDEV-33957 UPDATE fails on replica replicating blob virtual column in NOBLOB mode when replica logging is off

The sequence that causes the issue:

1. file->row_logging is false because slave-bin was not open;
2. TABLE::mark_columns_per_binlog_row_image() didn't mark column for
  read because file->row_logginbg is false. This was implemented in
  e53ad95b733 (MDEV-6877);
3. TABLE::update_virtual_fields() didn't update virtual field value
  because column is not marked for read;
4. calc_row_difference() sees o_len as UNIV_SQL_NULL, but new row
  value is "1". The virtual column is added to update vector;
5. row_upd() tries to update secondary index, but row_upd_sec_step()
  doesn't see old value in the index.

The patch does mark_virtual_column_with_deps() via
column_bitmaps_signal() in case of rgi_slave in
mark_columns_per_binlog_row_image() so that non-stored virtual columns
are marked for update in slave thread.

Also fixed column_bitmaps_signal() for partitioning where the signal
did not reach the partition storage engine.
mariadb-DebarunBanerjee
MDEV-37117 Assertion `!thd->transaction->xid_state.is_explicit_XA() || thd->lex->xa_opt == XA_ONE_PHASE' failed after deadlock between XA

Issue: MDEV-36959 fix hits debug assert, while trying DML after
implicit rollback without a transaction block.

Fix: Relax the condition in implicit rollback for XA transaction.
Manjul Mohan
MDEV-37107 - Optimise dot_product by loop-unrolling by a factor of 4

This patch introduces loop unrolling by a factor of 4 in the
dot_product() function used in vector-based distance calculations.

The goal is to improve SIMD utilization and overall performance during
high-throughput vector operations, particularly in indexing and search
routines that rely on this function.

Observations from benchmarking (ann-benchmark):
- Query Performance (QPS) improved by 4–10% across datasets.
- Indexation time reduced by 22–28%.
- Loop unrolling factors of 8 or 16 yielded similar performance to
  factor-4 but made the code less readable. Hence, a factor of 4 was
  chosen to maintain a balance between performance and code clarity.

This change is architecture-specific (PowerPC) and should not
introduce any behavioral regressions or side effects in unrelated
parts of the codebase.

Signed-off-by: Manjul Mohan <[email protected]>
Kristian Nielsen
MDEV-34705: Binlog-in-engine: Protect against concurrent RESET MASTER and dump threads

This is actually an existing problem in the old binlog implementation, and
this patch is applicable to old binlog also. The problem is that RESET
MASTER can run concurrently with binlog dump threads / connected slaves.
This will remove the binlog from under the feet of the reader, which can
cause all sorts of strange behaviour.

This patch fixes the problem by disallowing to run RESET MASTER when dump
threads (or other RESET MASTER or SHOW BINARY LOGS) are running. An error is
thrown in this case, user must stop slaves and/or kill dump threads to make
the RESET MASTER go through. A slave that connects in the middle of RESET
MASTER will wait for it to complete.

Fix a lot of test cases to kill any lingering dump threads before doing
RESET MASTER, mostly just by sourcing include/kill_binlog_dump_threads.inc.

Signed-off-by: Kristian Nielsen <[email protected]>
Yuchen Pei
MDEV-34711 spider sh: reset select_column_mode just like gbh
Sergei Golubchik
MDEV-36870 Spurious unrelated permission error when selecting from table with default that uses nextval(sequence)

Lots of different cases, SELECT, SELECT DEFAULT(),
UPDATE t SET x=DEFAULT, prepares statements,
opening of a table for the I_S, prelocking (so TL_WRITE),
insert with subquery (so SQLCOM_SELECT), etc.

Don't check NEXTVAL privileges in fix_fields() anymore, it cannot
possibly handle all the cases correctly. Make a special method
Item_func_nextval::check_access() for that and invoke it from

* fix_fields on explicit SELECT NEXTVAL()
  (but not if NEXTVAL() is used in a DEFAULT clause)
* when DEFAULT bareword in used in, say, UPDATE t SET x=DEFAULT
  (but not if DEFAULT() itself is used in a DEFAULT clause)
* in CREATE TABLE
* in ALTER TABLE ALGORITHM=INPLACE (that doesn't go CREATE TABLE path)
* on INSERT

helpers
* Virtual_column_info::check_access() to walk the item tree and invoke
  Item::check_access()
* TABLE::check_sequence_privileges() to iterate default expressions
  and invoke Virtual_column_info::check_access()

also, single-table UPDATE in prepared statements now associates
value items with fields just as multi-update already did, fixes the
case of PREPARE s "UPDATE t SET x=?"; EXECUTE s USING DEFAULT.
Thirunarayanan Balathandayuthapani
MDEV-37123 dict_table_open_on_id() fails to release dict_sys.latch

While updating the persistent defragmentation statistics
for the table, InnoDB opens the table only if it is in cache.
If dict_table_open_on_id() fails to find the table in cache
then it fails to unfreeze dict_sys.latch. This lead to crash
Dave Gosselin
MDEV-23699 Assertion failed in ha_tina::delete_row

When REPAIRing a CSV table, the CSV engine marks the table as having
no rows in the case that there are rows only in memory but not yet
written to disk.  In this case, there's actually nothing to repair,
since nothing exists on disk; make REPAIR idempotent for CSV tables.