maria:bb-11.3-mdev-22534-ps-fix2

Last commit made on 2023-09-14
Get this branch:
git clone -b bb-11.3-mdev-22534-ps-fix2 https://git.launchpad.net/maria

Branch merges

Branch information

Name:
bb-11.3-mdev-22534-ps-fix2
Repository:
lp:maria

Recent commits

5454f70... by Yuchen Pei <email address hidden>

MDEV-22534 Fix self-referencing Item_direct_view_ref

The loop is created in substitute_for_best_equal_field().

It calls Item_ref::transform (for the Item_direct_view_ref object)
which calls:

  Item *new_item= (*ref)->transform(thd, transformer, arg); // TRANSFORM-CALL

where transformer is Item::replace_equal_field().

Consider *vr1->ref==field, where vr1 is an Item_direct_view_ref, and
field is an Item_field that erroneously participates in a multiple
equality. If field->replace_equal_field() returns vr2, another
Item_direct_view_ref, with vr2->ref == vr1->ref. vr1->transform()
will, after the call on field->transform() that returns vr2 for
replacement, update its ref to point to vr2, so now *vr1->ref==vr2,
and since vr2->ref==vr1->ref, this gives us *vr2->ref == vr2, a self
reference.

This can be generalised to nested Item_direct_view_refs too, if
field->transform() returns an Item_direct_view_ref that has the same
ref field as the ref field of any Item_direct_view_ref in the chain.

On to the fix. If we maintain the rule that

  Objects inside Item_direct_view_ref do not participate in multiple
  equalities.

then the TRANSFORM-CALL will have new_item == *ref. That is, the
transform will be a no-op and no loop will be created.

The participation of multiple equalities is set during call to
Item::propagate_equal_fields(). This commit fixes
Item_ref::propagate_equal_fields() so that the rule is not violated
when a (non-Item_direct_view_ref) Item_ref points to an
Item_direct_view_ref:

Item_ref->Item_ref->...->Item_direct_view_ref->Item_direct_view_ref->...->Item_field

More specifically, we now delegate to the dereferenced
item (i.e. *ref) in such calls, rather than directly to the underlying
Item_field. By doing this, the call to propagate_equal_fields() on
toplevel Item_direct_view_ref will make it participate in the multiple
equality, instead of any of its downstream items.

4236b12... by Yuchen Pei <email address hidden>

MDEV-22534: Decorrelation for IN: workaround for MDEV-31269

Skip the decorrelation of IN subquery if
- we are running in a prepared statement
- any of trivial correlation expressions uses an Item_ref-derived object.

f393ece... by Yuchen Pei <email address hidden>

MDEV-22534 Decorrelate IN subquery

Transform

in (select inner_col' from inner_table where inner_col = outer_col)

to

, outer_col in (select inner_col', inner_col from inner_table)

Achieved by implementing Item_in_subselect::exists2in_processor(),
accompanied with comprehensive test coverage. Factored out common code
between the two transformations.

Caveat:

- Cannot recognise bad item mismatch in equalities that causes
  materialization to not materialize down the road

8ad1e26... by Alexander Barkov

MDEV-32081 Remove my_casedn_str() from get_canonical_filename()

- Moving get_canonical_filename() from a public function to a method in handler.
- Adding a helper method is_canonical_filename() to handler.
- Adding helper methods left(), substr(), starts_with() to Lex_cstring.
- Adding helper methods is_sane(), buffer_overlaps(),
  max_data_size() to CharBuffer.
- Adding append_casedn() to CharBuffer. It implements the main functionality
  that replaces the being removed my_casedn_str() call.
- Adding a class Table_path_buffer,
  a descendant of CharBuffer with size FN_REFLEN.
- Changing get_canonical_filename() to get a pointer to Table_path_buffer
  instead just a pointer to char.
- Changing the data type of the "path" parameter and the return type of
  get_canonical_filename() from char* to Lex_cstring.

5de23b1... by Alexander Barkov

MDEV-31505 Deprecate mariabackup --innobackupex mode

1. "mariabackup --innobackupex" now prints a new warning:
       '--innobackupex' is deprecated and will be removed in a future release

2. "mariabackup --innobackupex" does not print this wrong warning any more:
        --innobackupex: Deprecated program name.
          It will be removed in a future release,
          use '/path/to/mariadb-backup' instead

7ba9c7f... by Anel Husakovic <email address hidden>

MDEV-31231: Remove JavaWrappers.jar from mariadb-test-data and create new mariadb-plugin-connect-jdbc package

- Jar file created
```bash
$ find .|grep JdbcInterface
./storage/connect/connect_jars/JdbcInterface.jar
```
- Debian package created
```bash
$ dpkg -c mariadb-plugin-connect-jdbc_11.2.0+maria~ubu2004_amd64.deb
drwxr-xr-x root/root 0 2023-05-16 09:50 ./
drwxr-xr-x root/root 0 2023-05-16 09:50 ./usr/
drwxr-xr-x root/root 0 2023-05-16 09:50 ./usr/share/
drwxr-xr-x root/root 0 2023-05-16 09:50 ./usr/share/doc/
drwxr-xr-x root/root 0 2023-05-16 09:50 ./usr/share/doc/mariadb-plugin-connect-jdbc/
-rw-r--r-- root/root 253 2023-05-16 09:50 ./usr/share/doc/mariadb-plugin-connect-jdbc/changelog.gz
-rw-r--r-- root/root 2502 2023-05-09 15:14 ./usr/share/doc/mariadb-plugin-connect-jdbc/copyright
drwxr-xr-x root/root 0 2023-05-16 09:50 ./usr/share/mariadb/
-rw-r--r-- root/root 7538 2023-05-16 09:50 ./usr/share/mariadb/JdbcInterface.jar
```

- Tested on RPM
```
$ ls -la|grep connect
-rw-r--r-- 1 root root 2633772 May 23 11:27 MariaDB-connect-engine-11.2.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 3430040 May 23 11:27 MariaDB-connect-engine-debuginfo-11.2.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 9872 May 23 11:27 MariaDB-connect-engine-jdbc-11.2.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 36 May 23 11:21 install_manifest_connect-engine-jdbc.txt
-rw-r--r-- 1 root root 123 May 23 11:21 install_manifest_connect-engine.txt
-rw-r--r-- 1 root root 0 May 23 11:21 install_manifest_connect-engineSymlinks.txt

$ rpm -qlp MariaDB-connect-engine-jdbc-11.2.0-1.el7.x86_64.rpm
/usr/share/mariadb
/usr/share/mariadb/JdbcInterface.jar

$ for o in --conflicts --enhances --obsoletes --provides --recommends --requires --suggests --supplements ; do echo opt $o; rpm -q $o /home/dan/repos/build-mariadb-server-11.2/MariaDB-connect-engine-jdbc-11.2.0-1.fc38.x86_64.rpm; done
opt --conflicts
opt --enhances
opt --obsoletes
opt --provides
MariaDB-connect-engine-jdbc = 11.2.0-1.fc38
MariaDB-connect-engine-jdbc(x86-64) = 11.2.0-1.fc38
opt --recommends
MariaDB-connect-engine
mariadb-java-client
mysql-connector-java
postgresql-jdbc
opt --requires
java-1.8.0-openjdk-headless
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsZstd) <= 5.4.18-1
opt --suggests
opt --supplements
```

Closes PR #1890 (MDEV-26218)

Reviewer: <email address hidden>

9cb75f3... by Alexander Barkov

MDEV-32026 lowercase_table2.test failures in 11.3

Also fixes MDEV-32025 Crashes in MDL_key::mdl_key_init with lower-case-table-names=2

Change overview:
- In changes made in MDEV-31948, MDEV-31982 the code path
  which originaly worked only in case of lower-case-table-names==1
  also started to work in case of lower-case-table-names==2 in a mistake.

  Restoring the original check_db_name() compatible behavior
  (but without re-using check_db_name() itself).
- MDEV-31978 erroneously added a wrong DBUG_ASSERT. Removing.

Details:

- In mysql_change_db() the database name should be lower-cased only
  in case of lower_case_table_names==1. It should not be lower-cased
  for lower_case_table_names==2. The problem was caused by MDEV-31948.
  The new code version restored the pre-MDEV-31948 behavior, which
  used check_db_name() behavior.

- Passing lower_case_table_names==1 instead of just lower_case_table_names
  to the "casedn" parameter to DBNameBuffer constructor in sql_parse.cc
  The database name should not be lower-cased for lower_case_table_names==2.
  This restores pre-MDEV-31982 behavioir which used check_db_name() here.

- Adding a new data type Lex_ident_db_normalized, it stores database
  names which are both checked and normalized to lower case
  in case lower_case_table_names==1 and lower_case_table_names==2.

- Changing the data type for the "db" parameter to Lex_ident_db_normalized in
  lock_schema_name(), lock_db_routines(), find_db_tables_and_rm_known_files().

  This is to avoid incorrectly passing a non-normalized name in the future.

- Restoring the database name normalization in mysql_create_db_internal()
  and mysql_rm_db_internal() before calling lock_schema_name().
  The problem was caused MDEV-31982.

- Adding database name normalization in mysql_alter_db_internal()
  and mysql_upgrade_db(). This fixes MDEV-32026.

- Removing a wrong assert in Create_sp_func::create_with_db() was incorrect:

    DBUG_ASSERT(Lex_ident_fs(*db).ok_for_lower_case_names());

  The database name comes to here checked, but not normalized
  to lower case with lower-case-table-names=2.
  The assert was erroneously added by MDEV-31978.

- Recording lowercase_tables2.results and lowercase_tables4.results
  according to
    MDEV-29446 Change SHOW CREATE TABLE to display default collations
  These tests are skipped on buildbot on all platforms, so this change
  was forgotten in the patch for MDEV-29446.

cb37c99... by Alexander Barkov

MDEV-32019 Replace my_casedn_str(local_buffer) to CharBuffer::copy_casedn()

Replacing my_casedn_str() called on local char[] buffer variables
to CharBuffer::copy_casedn() calls.

This is a sub-task for MDEV-31531 Remove my_casedn_str()

Details:
- Adding a helper template class IdentBuffer (a CharBuffer descendant),
  which assumes utf8 data. Like CharBuffer, it's initialized to an empty
  string in the constructor, but can be populated with lower-cased data
  later.

- Adding a helper template class IdentBufferCasedn, which initializes
  to lower case right in the constructor.

- Removing char[] buffers, replacing them to IdentBuffer and IdentBufferCasedn.

- Changing the data type of "db" and "table" parameters from
  "const char*" to LEX_CSTRING in the following functions:

    find_field_in_table_ref()
    insert_fields()
    set_thd_db()
    mysql_grant()

  to reuse IdentBuffer easeir.

e0949cd... by Alexander Barkov

MDEV-32013 Add Field::val_lex_string_strmake()

There are two functions to extract a Field::val_str() value
as a LEX_STRING or LEX_CSTRING pointing to the data allocated on a MEM_ROOT:

  char *get_field(MEM_ROOT *mem, Field *field);
  bool get_field(MEM_ROOT *mem, Field *field, class String *res);

The first function requires strlen() calls to make a LEX_CSTRING/LEX_STRING.
The second function requires a redundant String buffer,
which is used only as a temporary proxy value pointing to a MEM_ROOT fragment
(and does not use any String dynamic allocation methods).

This patch add a native way to extract a Field::val_str() value
as a LEX_STRING or LEX_CSTRING pointing to a MEM_ROOT fragment.
It helps to remove redundant strlen() calls and redundant String buffers.

- Adding a new method:

    LEX_STRING Field::val_lex_string_strmake(MEM_ROOT *mem);

- Reusing the new method Field::val_lex_string_strmake() in;

    bool get_field(MEM_ROOT *mem, Field *field, String *res);

  Also, moving it from table.cc to a static function in sql_help.cc.
  It is used in sql_help.cc only, and we don't want it to be reused
  in other parts of the code (to avoid redundant String buffers).

- Reusing the new method Field::val_lex_string_strmake() in this function:

    char *get_field(MEM_ROOT *mem, Field *field);

- Replacing get_field() to Field::val_lex_string_strmake() in these files:

    sql_plugin.cc (redundant String buffers were removed)
    sql_udf.cc (redundant strlen() calls were removed)

Note, this function:

   char *get_field(MEM_ROOT *mem, Field *field);

is still used in a number of files:

   event_data_objects.cc
   event_db_repository.cc
   sql_acl.cc
   sql_servers.cc

These remaining calls will be removed by separate patches,
and get_field() will be removed after that.

781ec16... by Alexander Barkov

An addon change for MDEV-32002 Remove my_casedn_str() in append_identifier() context

There was one more place with my_casedn_str() in append_identifier() context
in TABLE_LIST::print() forgotten in the main patch for MDEV-32002.
Reusing append_identifier_opt_casedn() in this code.