maria:bb-11.2-MDEV-30145

Last commit made on 2023-06-16
Get this branch:
git clone -b bb-11.2-MDEV-30145 https://git.launchpad.net/maria

Branch merges

Branch information

Name:
bb-11.2-MDEV-30145
Repository:
lp:maria

Recent commits

7bef4c6... by Rucha Deodhar <email address hidden>

MDEV-30145: JSON_TABLE: allow to retrieve the key when iterating on JSON
objects

Idea behind implementation:
We get the json object specified by the json path. Then, transform it into
key-value pairs by going over the json. Get each key-value pair
one-by-one and return the result.

46ba0fd... by THIRUNARAYANAN BALATHANDAYUTHAPANI

MDEV-14795 InnoDB system tablespace cannot be shrunk

- Patch does shrinking the system tablespace during startup
process. Steps for shrinking the system tablespace:

1) Find the last used extent in the system tablespace
by iterating through the BITMAP in extent descriptor page

2) Check whether tablespace is being used within fixed size
and If the last used extent is lesser than fixed size then
set the desired target size to fixed size

3) Flush all the pages belong to system tablespace in flush list

4) Truncate the truncated pages from FSP_FREE and FSP_FREE_FRAG list

5) Reset the bitmap in descriptor pages for the truncated pages

6) Update the FSP_SIZE and FSP_FREE_LIMIT in header page

7) In case of multiple files, calculate the truncated last
file size and do the truncation in last file

- recv_sys_t::apply(): Handle the truncation of the system
tablespace only if we have recv_size of tablespace exists

6ddb67a... by THIRUNARAYANAN BALATHANDAYUTHAPANI

MDEV-31442 page_cleaner thread aborts while releasing the tablespace

After further I/O on a tablespace has been stopped
(for example due to DROP TABLE or an operation that
rebuilds a table), page cleaner thread tries to
flush the pending writes for the tablespace and
releases the tablespace reference even though it was not
acquired.

fil_space_t::flush(): Don't release the tablespace when it is
being stopped and closed

Thanks to Marko Mäkelä for suggesting this patch.

393bad0... by Dmitry Shulga <email address hidden>

MDEV-5816: Stored programs: validation of stored program statements

The follow-up patch to check in mtr tests that recompilation of
a SP's instruction doesn't lead to eviction of SP from sp_cache.

This patch adds the debug keyword 'check_sp_cache_not_invalidated'
checked in sp_cache_flush_obsolete. In case this debug keyword
is set the macros DBUG_SUICIDE() called to cause test failure.

The function sp_cache_flush_obsolete() is called on opening
a stored routine. So setting this keyword before second execution
of some stored routine that supposed to cause recompilation of
SP's statement will guarantee that this stored routing not evicted
from sp_cache.

Suggested approach has one limitation - the statement
 CREATE/ALTER/DROP VIEW
forces invalidation of the whole sp_cache (by invoking the function
 sp_cache_invalidate()).
So, for those tests (actually, there are very small number of such tests)
that create/alter/drop a view before the second execution of some stored
routine, the debug keyword 'check_sp_cache_not_invalidated' isn't set.

The proposal to add some way a check that a stored routine is not force out
from sp_cache on re-parsing a failing statement of a stored routine was
done during reiew, that is the reason the proposed change has been formatted
as a separate patch.

6e01ab4... by Dmitry Shulga <email address hidden>

MDEV-5816: Stored programs: validation of stored program statements

Added mtr tests for MDEV-5816

3b5be39... by Dmitry Shulga <email address hidden>

MDEV-5816: Stored programs: validation of stored program statements

Fix of existing mtr tests.

641751c... by Dmitry Shulga <email address hidden>

MDEV-5816: Stored programs: validation of stored program statements

This patch fixes the issue with missing warnings generated on re-parsing
a failing SP instruction's statement. That is, any warning generated
on re-parsing a statement was discarded after SP instruction's a statement
has been successfully re-parsed.

The reason for discarding warnings after re-parsing is that the method
  THD::set_query_id()
called every time when a failing SP instruction re-parsed.
In result,
  Warning_info::m_warn_id != thd->query_id
and when the method
  Diagnostics_area::opt_clear_warning_info(thd->query_id)
is invoked from sp_head::execute all warnings accumulated during
execution of the current SP instruction is cleared.

So, to fix the issue invokes the method THD::set_query_id()
once per SP instruction, on its first execution. Re-parsing of failing
SP instruction and following run of it don't invoke the method
THD::set_query_id().

59e0db5... by Dmitry Shulga <email address hidden>

MDEV-5816: Stored programs: validation of stored program statements

This patch is the second part of implementation for cursor's statement
re-parsing. The patch does the following changes:
  - on re-parsing a failed SP instruction that does need to get access
    to LEX a new lex is instantiated for every SP instruction except
    cursor relating SP instructions.
  - items created on re-parsing a cursor relating statement are moved
    to the free_list of sp_lex_cursor.

06d0ae5... by Dmitry Shulga <email address hidden>

MDEV-5816: Stored programs: validation of stored program statements

Added re-parsing of a failing cursor body. Re-parsing of a failing
SP statement is implemented by the method validate_lex_and_exec_core(),
therefore invocation of the method reset_lex_and_exec_core() inside
  sp_lex_keeper::cursor_reset_lex_and_exec_core
was replaced by the method validate_lex_and_exec_core().

Re-parsing of a failed SP statement is relied upon interface provided
by the class sp_lex_instr (the methods used for this goal are
is_invalid(), parse_expr(), invalidate(), get_query(), get_expr_query()).
To provide access to these methods on opening a cursor, the signature of
the method
  sp_lex_keeper::cursor_reset_lex_and_exec_core
was changed to accept a pointer to the class sp_lex_instr instead of
the class sp_instr, and the new method get_push_instr() was added
into the class sp_cursor. This method is to get access to an instance
of the class sp_instr_cpush on opening a cursor (on handling the statement
OPEN cursors_name).

Default implementation of this method just returns NULL pointer of
the type sp_instr_cpush. This method is overridden in the class
sp_instr_cpush with trivial implementation
  { return this; }

On handling the statement DECLARE CURSOR FOR the new instruction of
the type sp_instr_cpush is added into sp_head. The class sp_instr_cpush
holds a text of SELECT query referencing by a cursor declaration.
When a cursor is being opened (on handling the statement 'OPEN cur_name')
a pointer to sp_instr_cpush is returned by the method
  sp_cursor::get_push_instr()
and this pointer is passed to the method
  sp_lex_keeper::cursor_reset_lex_and_exec_core
in order to open a cursor and provide access to an interface required
for SP statement re-parsing in case metadata changes took place.
Since real access to a lex object is required on handling instruction
sp_instr_cpush (an instance of this class is created during parsing of
cursor declaration statement), calling of the method sp_cursor::open
is moved from the method
  sp_instr_copen::exec_core
into the method
  sp_instr_cpush::exec_core.

Additionally, updated the methods get_query/get_expr_query in the classes
sp_instr_cpush, sp_instr_cursor_copy_struct in order to return correct text of
cursor's body taking into account that lexer treated the clause CURSOR FOR/
CURSOR IS as two different tokens following one after another. So, to return
a correct text of SELECT statement specified in CURSOR declaration statement,
the token FOR/IS should be skipped and text following it should be returned as
a text of cursors's query.

247ae4f... by Dmitry Shulga <email address hidden>

MDEV-5816: Stored programs: validation of stored program statements

Introduced the new data member new_query_arena_is_set of the class sp_head.
This data member is used as a protection against double invocation of
the method restore_thd_mem_root that is called for restoration of the
current query arena. Previously, the data member sp_head::m_thd
is used for this goal but after support for re-compilation of a failed
stored routine statement has been added the data member sp_head::m_thd
can't be used for this goal. The reason is that on a statement re-compilation
after the method restore_thd_mem_root() is called the method
sp_head::add_instr() invoked to add a new instruction for just re-compiled
statement. The method sp_head::add_instr() de-references m_thd to access
the free_list data member. If m_thd was used as a guard against double
invocation it would result in a crash on dereferencing null pointer.