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
PranavKTiwari
MDEV-40167: GTT created with the InnoDB incorrectly accept FULLTEXT/VECTOR indexes
Problem:
GLOBAL TEMPORARY tables were not subject to the same option/index restrictions as session TEMPORARY tables. Several InnoDB and server-layer checks tested only tmp_table(), so GLOBAL TEMPORARY tables could bypass validation for VECTOR/FULLTEXT indexes, DATA DIRECTORY, KEY_BLOCK_SIZE, and ROW_FORMAT=COMPRESSED.

Cause:
global_tmp_table() was added as a separate predicate from tmp_table(), but not all temp-table checks were updated to test both, so GLOBAL TEMPORARY tables fell through to "permanent table" logic in several places.

Fix:
Added global_tmp_table() alongside tmp_table() at each affected check:

Reject VECTOR and FULLTEXT indexes on GLOBAL TEMPORARY tables.
Reject/warn on DATA DIRECTORY, KEY_BLOCK_SIZE, and ROW_FORMAT=COMPRESSED for GLOBAL TEMPORARY tables, with accurate wording in the DATA DIRECTORY warning.
Fixed zip_allowed and related ut_ad assertions to exclude GLOBAL TEMPORARY tables.
Fixed m_use_file_per_table in set_tablespace_type() to exclude GLOBAL TEMPORARY tables (also fixes m_use_data_dir).
GLOBAL TEMPORARY tables now validate the same as session TEMPORARY tables across these options.
Thirunarayanan Balathandayuthapani
MDEV-38842 Server fails to drop .ibd file when vector table creation fails

Problem:
========
When creating tables with vector indexes, if the secondary table
creation fails after the main table is successfully created,
the server was not properly cleaning up the main table's .ibd file.
Stale file exists because create_table_impl() always called
ddl_log_complete() on any error, which disables DDL log entries
instead of executing them for cleanup. The main table would be
left behind even though the overall CREATE TABLE operation failed.

Solution:
=========
ha_create_table(): Make it responsible for cleaning up
everything it created when it returns an error.
On failure of the high level index creation, drop the main
table and shadow table.
Yuchen Pei
MDEV-37739 Downcase the db part of the new table name in ALTER when lower_case_table_names > 0

When lower_case_table_names > 0 the db part of table names are
downcased in CREATE TABLE or SHOW CREATE TABLE (in
TABLE_LIST::TABLE_LIST). This patch makes ALTER do the same, which
fixes assertion failure caused the inconsistency.
Yuchen Pei
MDEV-37739 Move filename canonicalisation out of handlerton method to ha_delete_table

Just like when creating a table, the name canonicalisation happens in
ha_create_table.

This still allows table name canonicalisation to still take place
normally (e.g. in a DROP TABLE statement), but also fixes call the
handlerton method to drop partitions from DDL recovery, as for files
corresponding to partitions, in the format of
<table_name>#P#<partition_name>, consistently only table names are
canonicalised. For example in ha_partition::drop_partitions, first the
table name is canonicalised, before the #P#<partition_name> part is
appended, and the full name is passed to file->delete_table.

Strengthen some previous failing testcases to show that partition
names don't get lowered.
Vladislav Vaintroub
MDEV-40242 Fix Infer NULLPTR_DEREFERENCE reports in tests

Infer flagged several test/unittest sites that dereference the result of
an allocation (or an allocating helper) without checking it for NULL:

- tests/async_queries.c: fatal() calls exit() but was not marked
  noreturn, so Infer assumed add_query() continued past the
  "if (!e || !q2) fatal(...)" guard. Mark fatal() ATTRIBUTE_NORETURN.
- tests/mysql_client_test.c: add the usual check_stmt() after
  mysql_stmt_init() in test_bug16143, test_bug16144 and test_bug38486.
- unittest/json_lib/json_normalize-t.c: check init_dynamic_string().
- unittest/mysys/bitmap-t.c: check my_bitmap_init().
- unittest/mysys/ma_dyncol-t.c: check the val/upd/res malloc()s.
- unittest/mysys/thr_template.c: replace assert(threads) (compiled out
  under NDEBUG) with an unconditional check.
- unittest/sql/mf_iocache-t.cc: check the buf/buf_i/buf_o malloc()s.

Test-only changes; on allocation failure the tests now abort cleanly
via BAIL_OUT() instead of dereferencing NULL.
sjaakola
MDEV-39681 delayed BF aborting with multi master load

Reason for the hanging, and occasional crashes turned out
to be orphaned innodb lock wait request of a BF aborted
local transaction, which had arrived in commit stage.

Reason is that wsrep BF-abort marks a transaction a deadlock
victim out-of-band, so (unlike native deadlock resolution)
the victim can still own a live LOCK_WAIT request;
if that orphaned waiter survives into commit/rollback,
another transaction granting it calls lock_wait_end() cross-thread
and corrupts the victim's state — surfacing as the lock_wait_end,
que_thr_step, and rollback_finish assertions.

This commit has fixes for claering lock wait status of BF aborted
transactions.

Commit has also a new mtr test: galera.galera_bf_abort_orphan_lock
to work as regression test for the fix.
Thirunarayanan Balathandayuthapani
MDEV-27569  Valgrind/MSAN errors in ha_partition::swap_blobs() for BLOB not in secondary index

Problem:
=======
On a partitioned table containing a BLOB/TEXT column, an ordered
index scan calls ha_partition::swap_blobs() for every buffered
row, because it is being called only when table has blob fields.

When the buffered row comes from a secondary index that does not
cover the blob (e.g. KEY(f2) on (f2,f1)), InnoDB's
row_sel_store_mysql_rec() populates only the templated columns.
The blob column's null bit and its value-pointer bytes in
table->record[0] are left uninitialized. The partition handler
memcpy() this record into rec_buf, then swap_blobs() evaluates
blob->is_null(), reading the uninitialized null bit leads to
"use-of-uninitialized-value".

Solution:
=========
row_sel_store_mysql_rec(): When the record is being stored
from a secondary index, seed the NULL bitmap of mysql_rec
from prebuilt->default_rec before populating the templated columns.
Columns present in the index template have their NULL bit rewritten
explicitly while the row is stored, so only the columns absent from
the template (the uncovered blob) rely on this seed.
default_rec marks such nullable columns as NULL and preserves the
reserved NULL bit, so the uncovered blob is now defined as NULL.

Because of this, ha_partition::swap_blobs() skips it via its
"!bitmap_is_set(read_set) || blob->is_null()" guard and
never calls Field_blob::cached()/get_ptr(). This avoids not
only the uninitialized null-bit read and the follow-on
uninitialized blob value-pointer read.
Vladislav Vaintroub
Use the server's MariaDB::zlib target when built as a submodule (#316)

When Connector/C is built inside the MariaDB server tree, pick up the server's
zlib via the MariaDB::zlib target instead of running FIND_PACKAGE(ZLIB), so the
connector uses exactly the same zlib (bundled or system) as the server and no
longer depends on the FindZLIB result-variable signature. Standalone builds are
unchanged - they still fall back to FIND_PACKAGE(ZLIB).

Also stop adding zlib to CMAKE_REQUIRED_LIBRARIES: ZLIB_LIBRARY may now be an
(ALIAS) target which cannot be used inside try_compile() checks, and none of
those checks need zlib.

Server: MDEV-37996
  • cc-x-codbc-windows: 'dojob pwd if '3.4' == '3.4' ls win32/test SET TEST_DSN=master SET TEST_DRIVER=master SET TEST_PORT=3306 SET TEST_SCHEMA=odbcmaster if '3.4' == '3.4' cd win32/test if '3.4' == '3.4' ctest --output-on-failure' failed -  stdio
Thirunarayanan Balathandayuthapani
MDEV-40085  TRUNCATE of temporary table with ENCRYPTED=NO crashes under innodb_encrypt_tables=FORCE

Problem:
=========
ha_innobase::truncate() recreates the table by calling
ha_innobase::create(). create_table_info_t::check_table_options()
rejects ENCRYPTED=NO when innodb_encrypt_tables=FORCE, which is the
rule that forbids creating a new unencrypted table under FORCE.

TRUNCATE therefore failed in create(). For a temporary table,
truncate() frees m_prebuilt before calling create(). If the create()
fails and left m_prebuilt=nullptr and a subsequent
ha_innobase::reset()/update_thd() dereferenced it.

Solution:
========
check_table_options(): skip the innodb_encrypt_tables=FORCE check on
the internal recreate path (indicated by a non-null m_trx,
which is set only during truncate()). This applies to non-temporary
table also.

ha_innobase::truncate(): validate the create options before dropping
the existing table. Any genuine validation failure
(missing encryption key, unsupported option combination etc)
now returns an error with the original table and m_prebuilt
left intact, instead of dropping the table and then
failing in create()
Thirunarayanan Balathandayuthapani
MDEV-27569  Valgrind/MSAN errors in ha_partition::swap_blobs() for BLOB not in secondary index

Problem:
=======
On a partitioned table containing a BLOB/TEXT column, an ordered
index scan calls ha_partition::swap_blobs() for every buffered
row, because it is being called only when table has blob fields.

When the buffered row comes from a secondary index that does not
cover the blob (e.g. KEY(f2) on (f2,f1)), InnoDB's
row_sel_store_mysql_rec() populates only the templated columns.
The blob column's null bit and its value-pointer bytes in
table->record[0] are left uninitialized. The partition handler
memcpy() this record into rec_buf, then swap_blobs() evaluates
blob->is_null(), reading the uninitialized null bit leads to
"use-of-uninitialized-value".

Solution:
=========
row_sel_store_mysql_rec(): When the record is being stored
from a secondary index, seed the NULL bitmap of mysql_rec
from prebuilt->default_rec before populating the templated columns.
Columns present in the index template have their NULL bit rewritten
explicitly while the row is stored, so only the columns absent from
the template (the uncovered blob) rely on this seed.
default_rec marks such nullable columns as NULL and preserves the
reserved NULL bit, so the uncovered blob is now defined as NULL.

Because of this, ha_partition::swap_blobs() skips it via its
"!bitmap_is_set(read_set) || blob->is_null()" guard and
never calls Field_blob::cached()/get_ptr(). This avoids not
only the uninitialized null-bit read and the follow-on
uninitialized blob value-pointer read.
Yuchen Pei
MDEV-37739 Downcase the db part of the new table name in ALTER when lower_case_table_names > 0

When lower_case_table_names > 0 the db part of table names are
downcased in CREATE TABLE or SHOW CREATE TABLE (in
TABLE_LIST::TABLE_LIST). This patch makes ALTER do the same, which
fixes assertion failure caused the inconsistency.
Raghunandan Bhat
MDEV-39744: Assertion `buf != end` failed in `decimal_mul`

Problem:
  With `div_precision_increment=0`, a division whose quotient rounds
  away to zero (e.g. -299/450) produced a decimal with no digit words
  (intg=0 and frac=0) while still keeping the sign bit set. That is a
  malformed value.

  Multiplying such a malformed zero value by another zero reached the
  negative-zero check in `decimal_mul`, where there were no digit words
  to scan, leading to assertion failure.

Fix:
  Fix `do_div_mod`, which produced the malformed zero. `do_div_mod`
  already normalizes this case to a canonical zero on the modulo path;
  do the same on the division path: when the quotient has no digits
  (intg0 = 0 && frac0 = 0) return a correct decimal zero instead of a
  digit-less, signed value.
Georg Richter
Fix MAX_DECIMAL_LENGTH to support internal precision limits

While the maximum definition for a DECIMAL column is limited to a
precision of 65, MariaDB's internal DECIMAL_MAX_STR_LENGTH for
non-column-bound literals/expressions can reach up to 83 characters
(including sign and decimal point).

Example of a large runtime literal causing this:
SELECT 12185184186.000000000000000000000000000024692343000000000000000000000000000000000002333
  • cc-x-codbc-windows: 'dojob pwd if '3.4' == '3.4' ls win32/test SET TEST_DSN=master SET TEST_DRIVER=master SET TEST_PORT=3306 SET TEST_SCHEMA=odbcmaster if '3.4' == '3.4' cd win32/test if '3.4' == '3.4' ctest --output-on-failure' failed -  stdio
Vladislav Vaintroub
MDEV-40243 Fix Infer MEMORY_LEAK_C leaks in mysqldump/mysqlshow

Infer reported MEMORY_LEAK_C at several client sites. Fix the genuine leaks:

client/mysqldump.c (dump_events_for_db): event_list_res (and, on the inner
paths, event_res) were leaked on the error DBUG_RETURN(1) paths
(switch_character_set_results, SHOW CREATE EVENT failure, create_delimiter,
switch_db_collation, restore_db_collation). Route those paths through a
single "err:" cleanup label that frees both results (event_res is kept NULL
outside the inner loop so the shared cleanup is safe) and also restores the
session state (results charset, and UNLOCK TABLES when locking) like the
normal exit does.

client/mysqlshow.c (list_fields): when --keys is given, the columns result
set was overwritten by the "show keys" result without being freed. Free it
before running the keys query, and NULL the pointer so it cannot dangle if
that query fails.

The client/mysqltest.cc reports are false positives (do_save_master_pos only
leaves the result unfreed right before a noreturn die(); read_stmt_results
frees on every path), so no change is needed there.
Vladislav Vaintroub
MDEV-40243 Fix leak and NULL-deref in mysqldump dump_all_servers()

The SHOW CREATE SERVER dumping loop added by MDEV-34716 has two defects:

- When "show create server <name>" fails, the function returned without
  freeing the outer "SELECT Server_name FROM mysql.servers" result
  (tableres), leaking it (Infer MEMORY_LEAK_C).

- The result of that query was used without checking: "row=
  mysql_fetch_row(serverres); row[1]+= 14;" dereferences a NULL row (and
  assumes >= 2 columns). If the result is empty -- e.g. the server was
  dropped between the two queries, or is not visible -- mysqldump crashes.

Free tableres on the error return, and validate the SHOW CREATE SERVER
result (non-NULL row and at least two columns) before use, freeing both
results on failure.

This code path exists since MDEV-34716
diego dupin
Update CI workflow to correct ps-protocol tests
  • cc-x-codbc-windows: 'dojob pwd if '3.4' == '3.4' ls win32/test SET TEST_DSN=master SET TEST_DRIVER=master SET TEST_PORT=3306 SET TEST_SCHEMA=odbcmaster if '3.4' == '3.4' cd win32/test if '3.4' == '3.4' ctest --output-on-failure' failed -  stdio
Yuchen Pei
MDEV-37739 fix part 1
Alexander Barkov
MDEV-39587 Package-wide TYPE for variable declarations

SET sql_mode=ORACLE;
DELIMITER $$
CREATE OR REPLACE PACKAGE pkg AS
  -- Declare a package public data type
  TYPE varchar_array IS TABLE OF VARCHAR(2000) INDEX BY INTEGER;
END;
$$
DELIMITER ;
DELIMITER $$

CREATE OR REPLACE PROCEDURE p1 AS
  v pkg.varchar_array; -- Use the package public data type
BEGIN
  v(0):='test';
  SELECT v(0);
END;
$$
DELIMITER ;

Note, the change is done only for sql_mode=ORACLE, because the TYPE
declaration is not available for the default mode.

Where package-wide types are available
--------------------------------------
- Variabe list type:
    DECLARE var pkg1.type1;

- RETURN type for a package routine:
    CREATE FUNCTION .. RETURN pkg1.type1 ...

- Parameter type for a package routine:
    PROCEDURE p1(param1 pkg1.type1);

- Assoc array element type:
    TYPE assoc1_t IS TABLE OF pkg1.type1 ...

- REF CURSOR RETURN type:
    TYPE cur1_t IS REF CURSOR RETURN pkg1.type1;

Change details
--------------

- Adding a member Lex_length_and_dec_st::m_foreign_module_type
  It's set to true when the data type was initialized from a TYPE
  in foreign routine (e.g. in PACKAGE spec).
  It's needed to prevent use of qualified identifiers in public contexts,
  i.e. in schema public routine parameter types and schema publuc function
  RETURN types.
  Adding a helper method sp_head::check_applicability() which prevents
  use of qualified types in public context.

- Adding a helper method sp_head::raise_unknown_data_type().

- Adding methods LEX::set_field_type_typedef_package_spec() for
  2-step and 3-step qualified indentifiers.
  It's used in field_type_all_with_typedefs which covers cases:
  - Variabe list type        : DECLARE var pkg1.type1;
  - RETURN type              : CREATE FUNCTION .. RETURN pkg1.type1 ...
  - Parameter type          : PROCEDURE p1(param1 pkg1.type1);
  - Assoc array element type : TYPE assoc1_t IS TABLE OF pkg1.type1 ...

- Adding a method LEX::declare_type_ref_cursor_return_typedef().
  It handles cases when a new TYPE REF CURSOR RETURN is declared,
  for both for qualified RETURN types and non-qualified RETURN types:
  - TYPE cur0_t IS REF CURSOR RETURN rec1_t;
  - TYPE cur0_t IS REF CURSOR RETURN pkg1.rec1_t;
  - TYPE cur0_t IS REF CURSOR RETURN db1.pkg1.rec1_t;

  The code was moved from LEX::declare_type_ref_cursor() into
  LEX::declare_type_ref_cursor_return_typedef() and extended
  to cover qualified RETURN types.

- Adding a method Sql_path::find_package_spec_type().
  It iterates through all schemas specified in @@path and searches
  for the given type in the given package.

- Adding a helper method sp_pcontext::type_defs_add_ref_cursor()
  to reuse the code.

- Adding a new method sp_package::get_typedef() to search
  for TYPE definitions in PACKAGE specifications.

- Adding a new method sp_head::get_typedef_package_spec()
  to search for TYPE definitions used by a PROCEDURE or FUNCTION.

- Adding a helper method
    Sp_handler::sp_cache_routine_reentrant_suppress_errors
  Adding a method Sp_handler::find_package_spec().
sjaakola
MDEV-39681 delayed BF aborting with multi master load

Reason for the hanging, and occasional crashes turned out
to be orphaned innodb lock wait request of a BF aborted
local transaction, which had arrived in commit stage.

Reason is that wsrep BF-abort marks a transaction a deadlock
victim out-of-band, so (unlike native deadlock resolution)
the victim can still own a live LOCK_WAIT request;
if that orphaned waiter survives into commit/rollback,
another transaction granting it calls lock_wait_end() cross-thread
and corrupts the victim's state — surfacing as the lock_wait_end,
que_thr_step, and rollback_finish assertions.

This commit has fixes for claering lock wait status of BF aborted
transactions.

Commit has also a new mtr test: galera.galera_bf_abort_orphan_lock
to work as regression test for the fix.
Thirunarayanan Balathandayuthapani
MDEV-38842 Server fails to drop .ibd file when vector table creation fails

Problem:
========
When creating tables with vector indexes, if the secondary table
creation fails after the main table is successfully created,
the server was not properly cleaning up the main table's .ibd file.
Stale file exists because create_table_impl() always called
ddl_log_complete() on any error, which disables DDL log entries
instead of executing them for cleanup. The main table would be
left behind even though the overall CREATE TABLE operation failed.

Solution:
=========
ha_create_table(): Make it responsible for cleaning up
everything it created when it returns an error.
On failure of the high level index creation, drop the main
table and shadow table.
PranavKTiwari
MDEV-40167: GTT created with the InnoDB incorrectly accept FULLTEXT/VECTOR indexes
Problem:
GLOBAL TEMPORARY tables were not subject to the same option/index restrictions as session TEMPORARY tables. Several InnoDB and server-layer checks tested only tmp_table(), so GLOBAL TEMPORARY tables could bypass validation for VECTOR/FULLTEXT indexes, DATA DIRECTORY, KEY_BLOCK_SIZE, and ROW_FORMAT=COMPRESSED.

Cause:
global_tmp_table() was added as a separate predicate from tmp_table(), but not all temp-table checks were updated to test both, so GLOBAL TEMPORARY tables fell through to "permanent table" logic in several places.

Fix:
Added global_tmp_table() alongside tmp_table() at each affected check:

Reject VECTOR and FULLTEXT indexes on GLOBAL TEMPORARY tables.
Reject/warn on DATA DIRECTORY, KEY_BLOCK_SIZE, and ROW_FORMAT=COMPRESSED for GLOBAL TEMPORARY tables, with accurate wording in the DATA DIRECTORY warning.
Fixed zip_allowed and related ut_ad assertions to exclude GLOBAL TEMPORARY tables.
Fixed m_use_file_per_table in set_tablespace_type() to exclude GLOBAL TEMPORARY tables (also fixes m_use_data_dir).
GLOBAL TEMPORARY tables now validate the same as session TEMPORARY tables across these options.
Vladislav Vaintroub
MDEV-40214 Suppress false-positive Infer MEMORY_LEAK_C in mysql_client_test.c

The MEMORY_LEAK_C reports in this file are false positives. Real leaks are
reported by ASAN, which we run regularly. Suppress the leak checker for the
file with the documented @infer-ignore-every directive.
Raghunandan Bhat
MDEV-39744: Assertion `buf != end` failed in `decimal_mul`

Problem:
  With `div_precision_increment=0`, a division whose quotient rounds
  away to zero (e.g. -299/450) produced a decimal with no digit words
  (intg=0 and frac=0) while still keeping the sign bit set. That is a
  malformed value.

  Multiplying such a malformed zero value by another zero reached the
  negative-zero check in `decimal_mul`, where there were no digit words
  to scan, leading to assertion failure.

Fix:
  Fix `do_div_mod`, which produced the malformed zero. `do_div_mod`
  already normalizes this case to a canonical zero on the modulo path;
  do the same on the division path: when the quotient has no digits
  (intg0 = 0 && frac0 = 0) return a correct decimal zero instead of a
  digit-less, signed value.
Yuchen Pei
MDEV-37739 Move filename canonicalisation out of handlerton method to ha_delete_table

Just like when creating a table, the canonicalisation happens in
ha_create_table.

This allows table name canonicalisation to still take place
normally (e.g. in a DROP TABLE statement), but also fixes call the
handlerton method to drop partitions from DDL recovery, as for files
corresponding to partitions, in the format of
<table_name>#P#<partition_name>, consistently only table names are
canonicalised. For example in ha_partition::drop_partitions, first the
table name is canonicalised, before the #P#<partition_name> part is
appended, and the full name is passed to file->delete_table.
PranavKTiwari
MDEV-40167: GTT created with the InnoDB incorrectly accept FULLTEXT/VECTOR indexes
Problem:
GLOBAL TEMPORARY tables were not subject to the same option/index restrictions as session TEMPORARY tables. Several InnoDB and server-layer checks tested only tmp_table(), so GLOBAL TEMPORARY tables could bypass validation for VECTOR/FULLTEXT indexes, DATA DIRECTORY, KEY_BLOCK_SIZE, and ROW_FORMAT=COMPRESSED.

Cause:
global_tmp_table() was added as a separate predicate from tmp_table(), but not all temp-table checks were updated to test both, so GLOBAL TEMPORARY tables fell through to "permanent table" logic in several places.

Fix:
Added global_tmp_table() alongside tmp_table() at each affected check:

Reject VECTOR and FULLTEXT indexes on GLOBAL TEMPORARY tables.
Reject/warn on DATA DIRECTORY, KEY_BLOCK_SIZE, and ROW_FORMAT=COMPRESSED for GLOBAL TEMPORARY tables, with accurate wording in the DATA DIRECTORY warning.
Fixed zip_allowed and related ut_ad assertions to exclude GLOBAL TEMPORARY tables.
Fixed m_use_file_per_table in set_tablespace_type() to exclude GLOBAL TEMPORARY tables (also fixes m_use_data_dir).
GLOBAL TEMPORARY tables now validate the same as session TEMPORARY tables across these options.
Thirunarayanan Balathandayuthapani
MDEV-27569  Valgrind/MSAN errors in ha_partition::swap_blobs() for BLOB not in secondary index

Problem:
=======
On a partitioned table containing a BLOB/TEXT column, an ordered
index scan calls ha_partition::swap_blobs() for every buffered
row, because it is being called only when table has blob fields.

When the buffered row comes from a secondary index that does not
cover the blob (e.g. KEY(f2) on (f2,f1)), InnoDB's
row_sel_store_mysql_rec() populates only the templated columns.
The blob column's null bit and its value-pointer bytes in
table->record[0] are left uninitialized. The partition handler
memcpy() this record into rec_buf, then swap_blobs() evaluates
blob->is_null(), reading the uninitialized null bit leads to
"use-of-uninitialized-value".

Solution:
=========
row_sel_store_mysql_rec(): When the record is being stored
from a secondary index, seed the NULL bitmap of mysql_rec
from prebuilt->default_rec before populating the templated columns.
Columns present in the index template have their NULL bit rewritten
explicitly while the row is stored, so only the columns absent from
the template (the uncovered blob) rely on this seed.
default_rec marks such nullable columns as NULL and preserves the
reserved NULL bit, so the uncovered blob is now defined as NULL.

Because of this, ha_partition::swap_blobs() skips it via its
"!bitmap_is_set(read_set) || blob->is_null()" guard and
never calls Field_blob::cached()/get_ptr(). This avoids not
only the uninitialized null-bit read and the follow-on
uninitialized blob value-pointer read.
Georg Richter
Fix ci error introduced by previous merge
Yuchen Pei
MDEV-37739 Move filename canonicalisation out of handlerton method to ha_delete_table

Just like when creating a table, the name canonicalisation happens in
ha_create_table.

This still allows table name canonicalisation to still take place
normally (e.g. in a DROP TABLE statement), but also fixes call the
handlerton method to drop partitions from DDL recovery, as for files
corresponding to partitions, in the format of
<table_name>#P#<partition_name>, consistently only table names are
canonicalised. For example in ha_partition::drop_partitions, first the
table name is canonicalised, before the #P#<partition_name> part is
appended, and the full name is passed to file->delete_table.

Strengthen some previous failing testcases to show that partition
names don't get lowered.
Yuchen Pei
MDEV-37739 Move filename canonicalisation out of handlerton method to ha_delete_table

Just like when creating a table, the name canonicalisation happens in
ha_create_table.

This still allows table name canonicalisation to still take place
normally (e.g. in a DROP TABLE statement), but also fixes call the
handlerton method to drop partitions from DDL recovery, as for files
corresponding to partitions, in the format of
<table_name>#P#<partition_name>, consistently only table names are
canonicalised. For example in ha_partition::drop_partitions, first the
table name is canonicalised, before the #P#<partition_name> part is
appended, and the full name is passed to file->delete_table.

Strengthen some previous failing testcases to show that partition
names don't get lowered.
Yuchen Pei
MDEV-37739 Move filename canonicalisation out of handlerton method to ha_delete_table

Just like when creating a table, the name canonicalisation happens in
ha_create_table.

This still allows table name canonicalisation to still take place
normally (e.g. in a DROP TABLE statement), but also fixes call the
handlerton method to drop partitions from DDL recovery, as for files
corresponding to partitions, in the format of
<table_name>#P#<partition_name>, consistently only table names are
canonicalised. For example in ha_partition::drop_partitions, first the
table name is canonicalised, before the #P#<partition_name> part is
appended, and the full name is passed to file->delete_table.

Strengthen some previous failing testcases to show that partition
names don't get lowered.
Vladislav Vaintroub
MDEV-40243 Fix Infer MEMORY_LEAK_C leaks in mysqldump/mysqlshow

Infer reported MEMORY_LEAK_C at several client sites. Fix the genuine leaks:

client/mysqldump.c (dump_events_for_db): event_list_res (and, on the inner
paths, event_res) were leaked on the error DBUG_RETURN(1) paths
(switch_character_set_results, SHOW CREATE EVENT failure, create_delimiter,
switch_db_collation, restore_db_collation). Route those paths through a
single "err:" cleanup label that frees both results (event_res is kept NULL
outside the inner loop so the shared cleanup is safe) and also restores the
session state (results charset, and UNLOCK TABLES when locking) like the
normal exit does.

client/mysqlshow.c (list_fields): when --keys is given, the columns result
set was overwritten by the "show keys" result without being freed. Free it
before running the keys query, and NULL the pointer so it cannot dangle if
that query fails.

The client/mysqltest.cc reports are false positives (do_save_master_pos only
leaves the result unfreed right before a noreturn die(); read_stmt_results
frees on every path), so no change is needed there.
Yuchen Pei
MDEV-37739 Downcase the db part of the new table name in ALTER when lower_case_table_names > 0

When lower_case_table_names > 0 the db part of table names are
downcased in CREATE TABLE or SHOW CREATE TABLE (in
TABLE_LIST::TABLE_LIST). This patch makes ALTER do the same, which
fixes assertion failure caused the inconsistency.
Thirunarayanan Balathandayuthapani
MDEV-40085  TRUNCATE of temporary table with ENCRYPTED=NO crashes under innodb_encrypt_tables=FORCE

Problem:
=========
ha_innobase::truncate() recreates the table by calling
ha_innobase::create(). create_table_info_t::check_table_options()
rejects ENCRYPTED=NO when innodb_encrypt_tables=FORCE, which is the
rule that forbids creating a new unencrypted table under FORCE.

TRUNCATE therefore failed in create(). For a temporary table,
truncate() frees m_prebuilt before calling create(). If the create()
fails and left m_prebuilt=nullptr and a subsequent
ha_innobase::reset()/update_thd() dereferenced it.

Solution:
========
check_table_options(): skip the innodb_encrypt_tables=FORCE check on
the internal recreate path (indicated by a non-null m_trx,
which is set only during truncate()). This applies to non-temporary
table also.

ha_innobase::truncate(): validate the create options before dropping
the existing table. Any genuine validation failure
(missing encryption key, unsupported option combination etc)
now returns an error with the original table and m_prebuilt
left intact, instead of dropping the table and then
failing in create()
Alexander Barkov
MDEV-40153 Assertion `rec->field->head()->charset == nullptr' failed in virtual bool Type_handler_row::Column_definition_prepare_stage1(THD *, MEM_ROOT *, Column_definition *, column_definition_type_t, const Column_derived_attributes *) const

The assertion in Type_handler_row::Column_definition_prepare_stage1()
erroneously assumes that the character set is implicitely defined
in a record field definition. So in crached when
- there is an explicit CHARACTER SET clause
- the data type is BLOB (implicit my_charset_bin)

Removing the assert.
Thirunarayanan Balathandayuthapani
MDEV-38842 Server fails to drop .ibd file when vector table creation fails

Problem:
========
When creating tables with vector indexes, if the secondary table
creation fails after the main table is successfully created,
the server was not properly cleaning up the main table's .ibd file.
Stale file exists because create_table_impl() always called
ddl_log_complete() on any error, which disables DDL log entries
instead of executing them for cleanup. The main table would be
left behind even though the overall CREATE TABLE operation failed.

Solution:
=========
ha_create_table(): Make it responsible for cleaning up
everything it created when it returns an error.
On failure of the high level index creation, drop the main
table and shadow table.
Aleksey Midenkov
MDEV-39384 Comments on update_virtual_fields() modes
Georg Richter
Merge branch '3.3' into 3.4
  • cc-x-codbc-windows: 'dojob pwd if '3.4' == '3.4' ls win32/test SET TEST_DSN=master SET TEST_DRIVER=master SET TEST_PORT=3306 SET TEST_SCHEMA=odbcmaster if '3.4' == '3.4' cd win32/test if '3.4' == '3.4' ctest --output-on-failure' failed -  stdio
Alexander Barkov
MDEV-39587 Package-wide TYPE for variable declarations

SET sql_mode=ORACLE;
DELIMITER $$
CREATE OR REPLACE PACKAGE pkg AS
  -- Declare a package public data type
  TYPE varchar_array IS TABLE OF VARCHAR(2000) INDEX BY INTEGER;
END;
$$
DELIMITER ;
DELIMITER $$

CREATE OR REPLACE PROCEDURE p1 AS
  v pkg.varchar_array; -- Use the package public data type
BEGIN
  v(0):='test';
  SELECT v(0);
END;
$$
DELIMITER ;

Note, the change is done only for sql_mode=ORACLE, because the TYPE
declaration is not available for the default mode.

Where package-wide types are available
--------------------------------------
- Variabe list type:
    DECLARE var pkg1.type1;

- RETURN type for a package routine:
    CREATE FUNCTION .. RETURN pkg1.type1 ...

- Parameter type for a package routine:
    PROCEDURE p1(param1 pkg1.type1);

- Assoc array element type:
    TYPE assoc1_t IS TABLE OF pkg1.type1 ...

- REF CURSOR RETURN type:
    TYPE cur1_t IS REF CURSOR RETURN pkg1.type1;

Change details
--------------

- Adding a member Lex_length_and_dec_st::m_foreign_module_type
  It's set to true when the data type was initialized from a TYPE
  in foreign routine (e.g. in PACKAGE spec).
  It's needed to prevent use of qualified identifiers in public contexts,
  i.e. in schema public routine parameter types and schema publuc function
  RETURN types.
  Adding a helper method sp_head::check_applicability() which prevents
  use of qualified types in public context.

- Adding a helper method sp_head::raise_unknown_data_type().

- Adding methods LEX::set_field_type_typedef_package_spec() for
  2-step and 3-step qualified indentifiers.
  It's used in field_type_all_with_typedefs which covers cases:
  - Variabe list type        : DECLARE var pkg1.type1;
  - RETURN type              : CREATE FUNCTION .. RETURN pkg1.type1 ...
  - Parameter type          : PROCEDURE p1(param1 pkg1.type1);
  - Assoc array element type : TYPE assoc1_t IS TABLE OF pkg1.type1 ...

- Adding a method LEX::declare_type_ref_cursor_return_typedef().
  It handles cases when a new TYPE REF CURSOR RETURN is declared,
  for both for qualified RETURN types and non-qualified RETURN types:
  - TYPE cur0_t IS REF CURSOR RETURN rec1_t;
  - TYPE cur0_t IS REF CURSOR RETURN pkg1.rec1_t;
  - TYPE cur0_t IS REF CURSOR RETURN db1.pkg1.rec1_t;

  The code was moved from LEX::declare_type_ref_cursor() into
  LEX::declare_type_ref_cursor_return_typedef() and extended
  to cover qualified RETURN types.

- Adding a method Sql_path::find_package_spec_type().
  It iterates through all schemas specified in @@path and searches
  for the given type in the given package.

- Adding a helper method sp_pcontext::type_defs_add_ref_cursor()
  to reuse the code.

- Adding a new method sp_package::get_typedef() to search
  for TYPE definitions in PACKAGE specifications.

- Adding a new method sp_head::get_typedef_package_spec()
  to search for TYPE definitions used by a PROCEDURE or FUNCTION.

- Adding a helper method
    Sp_handler::sp_cache_routine_reentrant_suppress_errors
  Adding a method Sp_handler::find_package_spec().