Details

    Description

      Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

      Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

      Remove cached TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

      Remove cached TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).

      Debug build: check consistency between opened foreign and referenced tables on table flush.

      Store foreign keys into FRM files

      1. Introduce Foreign_key_io class which creates/parses binary stream containing foreign key structures. Referenced tables store there only hints about foreign tables (their db and name), they restore full info from the corresponding tables.

      Foreign_key_io is stored under new EXTRA2_FOREIGN_KEY_INFO field in extra2 section of FRM file.

      2. Modify mysql_prepare_create_table() to generate names for foreign keys. Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name.

      3. Keep stored data in sync on DDL changes. Referenced tables update their foreign hints after following operations on foreign tables:

      RENAME TABLE
      DROP TABLE
      CREATE TABLE
      ADD FOREIGN KEY
      DROP FOREIGN KEY
      Foreign tables update their foreign info after following operations on referenced tables:

      RENAME TABLE
      RENAME COLUMN

      4. To achieve 3. there must be ability to rewrite extra2 section of FRM file without full reparse. FRM binary is built from primary structures like HA_CREATE_INFO and cannot be built from TABLE_SHARE.

      Use shadow write and rename like fast_alter_partition_table() does.

      Converge Foreign_key and supplemental generated Key together

      mysql_prepare_create_table() does data validation and such utilities as automatic name generation. But it does that only for indexes and ignores Foreign_key objects. Now as Foreign_key data needs to be stored in FRM files as well this processing must be done for them like for any other Key objects.

      Replace Key::FOREIGN_KEY type with Key::foreign flag of type Key::MULTIPLE and Key::generated set to true. Construct one object with Key::foreign == true instead of two objects of type Key::FOREIGN_KEY and Key::MULTIPLE.

      Attachments

        Issue Links

          Activity

            midenok Aleksey Midenkov created issue -
            midenok Aleksey Midenkov made changes -
            Field Original Value New Value
            midenok Aleksey Midenkov made changes -
            midenok Aleksey Midenkov made changes -
            Fix Version/s 10.5 [ 23123 ]
            midenok Aleksey Midenkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            midenok Aleksey Midenkov made changes -
            Component/s Server [ 13907 ]
            midenok Aleksey Midenkov made changes -
            Parent MDEV-20480 [ 78682 ]
            Issue Type Technical task [ 7 ] Task [ 3 ]
            midenok Aleksey Midenkov made changes -
            midenok Aleksey Midenkov made changes -
            midenok Aleksey Midenkov made changes -
            midenok Aleksey Midenkov made changes -
            midenok Aleksey Midenkov made changes -
            midenok Aleksey Midenkov made changes -
            Fixing Priority 250
            Parent MDEV-16417 [ 68014 ]
            Issue Type Task [ 3 ] Technical task [ 7 ]
            midenok Aleksey Midenkov made changes -
            Description Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Keep in sync referenced TABLE_SHARE::referenced_keys when foreign table is dropped, renamed or altered.
            Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Release TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column).
            midenok Aleksey Midenkov made changes -
            Description Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Release TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column).
            Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Release TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Release TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).
            midenok Aleksey Midenkov made changes -
            Description Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Release TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Release TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).
            Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).
            midenok Aleksey Midenkov made changes -
            Description Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).
            Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).

            Debug build: check consistency between opened foreign and referenced tables on table flush.
            midenok Aleksey Midenkov made changes -
            midenok Aleksey Midenkov made changes -
            Assignee Aleksey Midenkov [ midenok ] Sergei Golubchik [ serg ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            midenok Aleksey Midenkov added a comment - - edited Branch bb-10.5-midenok-MDEV-16417 .
            nikitamalyavin Nikita Malyavin made changes -
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.5 [ 23123 ]
            midenok Aleksey Midenkov made changes -
            Description Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).

            Debug build: check consistency between opened foreign and referenced tables on table flush.
            Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).

            Debug build: check consistency between opened foreign and referenced tables on table flush.

            h3. Store foreign keys into FRM files

            1. Introduce Foreign_key_io class which creates/parses binary stream containing foreign key structures. Referenced tables store there only hints about foreign tables (their db and name), they restore full info from the corresponding tables.

            Foreign_key_io is stored under new EXTRA2_FOREIGN_KEY_INFO field in extra2 section of FRM file.

            2. Modify mysql_prepare_create_table() to generate names for foreign keys. Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name.

            3. Keep stored data in sync on DDL changes. Referenced tables update their foreign hints after following operations on foreign tables:

            RENAME TABLE
            DROP TABLE
            CREATE TABLE
            ADD FOREIGN KEY
            DROP FOREIGN KEY
            Foreign tables update their foreign info after following operations on referenced tables:

            RENAME TABLE
            RENAME COLUMN
            4. To achieve 3. there must be ability to rewrite extra2 section of FRM file without full reparse. FRM binary is built from primary structures like HA_CREATE_INFO and cannot be built from TABLE_SHARE.

            Use shadow write and rename like fast_alter_partition_table() does.
            midenok Aleksey Midenkov made changes -
            midenok Aleksey Midenkov made changes -
            midenok Aleksey Midenkov made changes -
            Description Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).

            Debug build: check consistency between opened foreign and referenced tables on table flush.

            h3. Store foreign keys into FRM files

            1. Introduce Foreign_key_io class which creates/parses binary stream containing foreign key structures. Referenced tables store there only hints about foreign tables (their db and name), they restore full info from the corresponding tables.

            Foreign_key_io is stored under new EXTRA2_FOREIGN_KEY_INFO field in extra2 section of FRM file.

            2. Modify mysql_prepare_create_table() to generate names for foreign keys. Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name.

            3. Keep stored data in sync on DDL changes. Referenced tables update their foreign hints after following operations on foreign tables:

            RENAME TABLE
            DROP TABLE
            CREATE TABLE
            ADD FOREIGN KEY
            DROP FOREIGN KEY
            Foreign tables update their foreign info after following operations on referenced tables:

            RENAME TABLE
            RENAME COLUMN
            4. To achieve 3. there must be ability to rewrite extra2 section of FRM file without full reparse. FRM binary is built from primary structures like HA_CREATE_INFO and cannot be built from TABLE_SHARE.

            Use shadow write and rename like fast_alter_partition_table() does.
            Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).

            Debug build: check consistency between opened foreign and referenced tables on table flush.

            h3. Store foreign keys into FRM files

            1. Introduce Foreign_key_io class which creates/parses binary stream containing foreign key structures. Referenced tables store there only hints about foreign tables (their db and name), they restore full info from the corresponding tables.

            Foreign_key_io is stored under new EXTRA2_FOREIGN_KEY_INFO field in extra2 section of FRM file.

            2. Modify mysql_prepare_create_table() to generate names for foreign keys. Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name.

            3. Keep stored data in sync on DDL changes. Referenced tables update their foreign hints after following operations on foreign tables:

            RENAME TABLE
            DROP TABLE
            CREATE TABLE
            ADD FOREIGN KEY
            DROP FOREIGN KEY
            Foreign tables update their foreign info after following operations on referenced tables:

            RENAME TABLE
            RENAME COLUMN
            4. To achieve 3. there must be ability to rewrite extra2 section of FRM file without full reparse. FRM binary is built from primary structures like HA_CREATE_INFO and cannot be built from TABLE_SHARE.

            Use shadow write and rename like fast_alter_partition_table() does.

            h3. Converge Foreign_key and supplemental generated Key together
            {{mysql_prepare_create_table()}} does data validation and such utilities as automatic name generation. But it does that only for indexes and ignores {{Foreign_key}} objects. Now as {{Foreign_key}} data needs to be stored in FRM files as well this processing must be done for them like for any other {{Key}} objects.

            Replace {{Key::FOREIGN_KEY}} type with {{Key::foreign}} flag of type {{Key::MULTIPLE}} and {{Key::generated}} set to *true*. Construct one object with {{Key::foreign}} == *true* instead of two objects of type {{Key::FOREIGN_KEY}} and {{Key::MULTIPLE}}.
            midenok Aleksey Midenkov made changes -
            Fix Version/s 10.7 [ 24805 ]
            Fix Version/s 10.6 [ 24028 ]
            serg Sergei Golubchik made changes -
            Priority Critical [ 2 ] Major [ 3 ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 10.8 [ 26121 ]
            Fix Version/s 10.7 [ 24805 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 100531 ] MariaDB v4 [ 143752 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.10 [ 27530 ]
            Fix Version/s 10.8 [ 26121 ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 10.11 [ 27614 ]
            Fix Version/s 10.10 [ 27530 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.12 [ 28320 ]
            Fix Version/s 10.11 [ 27614 ]
            midenok Aleksey Midenkov made changes -
            Assignee Sergei Golubchik [ serg ] Aleksey Midenkov [ midenok ]
            midenok Aleksey Midenkov made changes -
            Status In Review [ 10002 ] Stalled [ 10000 ]
            midenok Aleksey Midenkov made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            AirFocus AirFocus made changes -
            Description Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).

            Debug build: check consistency between opened foreign and referenced tables on table flush.

            h3. Store foreign keys into FRM files

            1. Introduce Foreign_key_io class which creates/parses binary stream containing foreign key structures. Referenced tables store there only hints about foreign tables (their db and name), they restore full info from the corresponding tables.

            Foreign_key_io is stored under new EXTRA2_FOREIGN_KEY_INFO field in extra2 section of FRM file.

            2. Modify mysql_prepare_create_table() to generate names for foreign keys. Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name.

            3. Keep stored data in sync on DDL changes. Referenced tables update their foreign hints after following operations on foreign tables:

            RENAME TABLE
            DROP TABLE
            CREATE TABLE
            ADD FOREIGN KEY
            DROP FOREIGN KEY
            Foreign tables update their foreign info after following operations on referenced tables:

            RENAME TABLE
            RENAME COLUMN
            4. To achieve 3. there must be ability to rewrite extra2 section of FRM file without full reparse. FRM binary is built from primary structures like HA_CREATE_INFO and cannot be built from TABLE_SHARE.

            Use shadow write and rename like fast_alter_partition_table() does.

            h3. Converge Foreign_key and supplemental generated Key together
            {{mysql_prepare_create_table()}} does data validation and such utilities as automatic name generation. But it does that only for indexes and ignores {{Foreign_key}} objects. Now as {{Foreign_key}} data needs to be stored in FRM files as well this processing must be done for them like for any other {{Key}} objects.

            Replace {{Key::FOREIGN_KEY}} type with {{Key::foreign}} flag of type {{Key::MULTIPLE}} and {{Key::generated}} set to *true*. Construct one object with {{Key::foreign}} == *true* instead of two objects of type {{Key::FOREIGN_KEY}} and {{Key::MULTIPLE}}.
            Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE\_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE\_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).

            Debug build: check consistency between opened foreign and referenced tables on table flush.

            h3. Store foreign keys into FRM files

            # Introduce Foreign_key_io class which creates/parses binary stream containing foreign key structures. Referenced tables store there only hints about foreign tables (their db and name), they restore full info from the corresponding tables.

            Foreign_key_io is stored under new EXTRA2_FOREIGN_KEY\_INFO field in extra2 section of FRM file.

            # Modify mysql_prepare_create\_table() to generate names for foreign keys. Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name.

            # Keep stored data in sync on DDL changes. Referenced tables update their foreign hints after following operations on foreign tables:

            RENAME TABLE
            DROP TABLE
            CREATE TABLE
            ADD FOREIGN KEY
            DROP FOREIGN KEY
            Foreign tables update their foreign info after following operations on referenced tables:

            RENAME TABLE
            RENAME COLUMN

            # To achieve 3. there must be ability to rewrite extra2 section of FRM file without full reparse. FRM binary is built from primary structures like HA_CREATE_INFO and cannot be built from TABLE\_SHARE.

            Use shadow write and rename like fast_alter_partition\_table() does.

            h3. Converge Foreign\_key and supplemental generated Key together

            {{mysql_prepare_create_table()}} does data validation and such utilities as automatic name generation. But it does that only for indexes and ignores {{Foreign_key}} objects. Now as {{Foreign_key}} data needs to be stored in FRM files as well this processing must be done for them like for any other {{Key}} objects.

            Replace {{Key::FOREIGN_KEY}} type with {{Key::foreign}} flag of type {{Key::MULTIPLE}} and {{Key::generated}} set to *true*. Construct one object with {{Key::foreign}} == *true* instead of two objects of type {{Key::FOREIGN_KEY}} and {{Key::MULTIPLE}}.
            midenok Aleksey Midenkov made changes -
            Assignee Aleksey Midenkov [ midenok ] Oleksandr Byelkin [ sanja ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            midenok Aleksey Midenkov made changes -
            Assignee Oleksandr Byelkin [ sanja ] Aleksey Midenkov [ midenok ]
            midenok Aleksey Midenkov made changes -
            Status In Review [ 10002 ] Stalled [ 10000 ]
            midenok Aleksey Midenkov made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            midenok Aleksey Midenkov added a comment - - edited
            midenok Aleksey Midenkov added a comment - - edited Please review bb-11.0-midenok-MDEV-20865
            midenok Aleksey Midenkov made changes -
            Assignee Aleksey Midenkov [ midenok ] Oleksandr Byelkin [ sanja ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 11.1 [ 28549 ]
            Fix Version/s 11.0 [ 28320 ]
            sanja Oleksandr Byelkin made changes -
            Description Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE\_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE\_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).

            Debug build: check consistency between opened foreign and referenced tables on table flush.

            h3. Store foreign keys into FRM files

            # Introduce Foreign_key_io class which creates/parses binary stream containing foreign key structures. Referenced tables store there only hints about foreign tables (their db and name), they restore full info from the corresponding tables.

            Foreign_key_io is stored under new EXTRA2_FOREIGN_KEY\_INFO field in extra2 section of FRM file.

            # Modify mysql_prepare_create\_table() to generate names for foreign keys. Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name.

            # Keep stored data in sync on DDL changes. Referenced tables update their foreign hints after following operations on foreign tables:

            RENAME TABLE
            DROP TABLE
            CREATE TABLE
            ADD FOREIGN KEY
            DROP FOREIGN KEY
            Foreign tables update their foreign info after following operations on referenced tables:

            RENAME TABLE
            RENAME COLUMN

            # To achieve 3. there must be ability to rewrite extra2 section of FRM file without full reparse. FRM binary is built from primary structures like HA_CREATE_INFO and cannot be built from TABLE\_SHARE.

            Use shadow write and rename like fast_alter_partition\_table() does.

            h3. Converge Foreign\_key and supplemental generated Key together

            {{mysql_prepare_create_table()}} does data validation and such utilities as automatic name generation. But it does that only for indexes and ignores {{Foreign_key}} objects. Now as {{Foreign_key}} data needs to be stored in FRM files as well this processing must be done for them like for any other {{Key}} objects.

            Replace {{Key::FOREIGN_KEY}} type with {{Key::foreign}} flag of type {{Key::MULTIPLE}} and {{Key::generated}} set to *true*. Construct one object with {{Key::foreign}} == *true* instead of two objects of type {{Key::FOREIGN_KEY}} and {{Key::MULTIPLE}}.
            Add TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys as pointers to List<FOREIGN_KEY_INFO>.

            Remove handler foreign key interface: get_foreign_key_list(), get_parent_foreign_key_list(), referenced_by_foreign_key().

            Remove cached TABLE\_SHARE objects of referenced tables when foreign table is dropped, renamed or altered (add foreign key, rename column of foreign key).

            Remove cached TABLE\_SHARE objects of foreign tables when referenced table is renamed or altered (rename column of referenced key).

            Debug build: check consistency between opened foreign and referenced tables on table flush.

            h3. Store foreign keys into FRM files

            1. Introduce Foreign_key_io class which creates/parses binary stream containing foreign key structures. Referenced tables store there only hints about foreign tables (their db and name), they restore full info from the corresponding tables.

            Foreign_key_io is stored under new EXTRA2_FOREIGN_KEY\_INFO field in extra2 section of FRM file.

            2. Modify mysql_prepare_create\_table() to generate names for foreign keys. Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name.

            3. Keep stored data in sync on DDL changes. Referenced tables update their foreign hints after following operations on foreign tables:

            RENAME TABLE
            DROP TABLE
            CREATE TABLE
            ADD FOREIGN KEY
            DROP FOREIGN KEY
            Foreign tables update their foreign info after following operations on referenced tables:

            RENAME TABLE
            RENAME COLUMN

            4. To achieve 3. there must be ability to rewrite extra2 section of FRM file without full reparse. FRM binary is built from primary structures like HA_CREATE_INFO and cannot be built from TABLE\_SHARE.

            Use shadow write and rename like fast_alter_partition\_table() does.

            h3. Converge Foreign\_key and supplemental generated Key together

            {{mysql_prepare_create_table()}} does data validation and such utilities as automatic name generation. But it does that only for indexes and ignores {{Foreign_key}} objects. Now as {{Foreign_key}} data needs to be stored in FRM files as well this processing must be done for them like for any other {{Key}} objects.

            Replace {{Key::FOREIGN_KEY}} type with {{Key::foreign}} flag of type {{Key::MULTIPLE}} and {{Key::generated}} set to *true*. Construct one object with {{Key::foreign}} == *true* instead of two objects of type {{Key::FOREIGN_KEY}} and {{Key::MULTIPLE}}.
            sanja Oleksandr Byelkin made changes -
            Assignee Oleksandr Byelkin [ sanja ] Aleksey Midenkov [ midenok ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            midenok Aleksey Midenkov made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            sanja Oleksandr Byelkin made changes -
            Assignee Aleksey Midenkov [ midenok ] Oleksandr Byelkin [ sanja ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 11.2 [ 28603 ]
            Fix Version/s 11.1 [ 28549 ]
            midenok Aleksey Midenkov made changes -
            Comment [ Please review first party of refactorings in [bb-10.10-midenok-MDEV-20865|https://github.com/MariaDB/server/commits/bb-10.10-midenok-MDEV-20865] ]
            midenok Aleksey Midenkov made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 11.4 [ 29301 ]
            Fix Version/s 11.2 [ 28603 ]
            sanja Oleksandr Byelkin made changes -
            Status In Progress [ 3 ] In Review [ 10002 ]
            midenok Aleksey Midenkov made changes -
            Assignee Oleksandr Byelkin [ sanja ] Aleksey Midenkov [ midenok ]
            midenok Aleksey Midenkov made changes -
            Assignee Aleksey Midenkov [ midenok ] Oleksandr Byelkin [ sanja ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 11.5 [ 29506 ]
            Fix Version/s 11.4 [ 29301 ]

            OK to push

            sanja Oleksandr Byelkin added a comment - OK to push
            sanja Oleksandr Byelkin made changes -
            Assignee Oleksandr Byelkin [ sanja ] Aleksey Midenkov [ midenok ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            midenok Aleksey Midenkov made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]

            Rebased to 11.4 (bb-11.4-midenok-MDEV-20865)

            https://buildbot.mariadb.org/#/builders/551/builds/9239/steps/7/logs/stdio

            ==112184== Invalid write of size 4
            ==112184==    at 0xA6859D: base_list::operator=(base_list const&) (sql_list.h:153)
            ==112184==    by 0xC758F6: List<FK_info>::operator=(List<FK_info> const&) (sql_list.h:497)
            ==112184==    by 0xC75924: FK_list::operator=(FK_list const&) (handler.h:1093)
            ==112184==    by 0xCFDDA7: FK_table_backup::rollback() (sql_alter.h:52)
            ==112184==    by 0xCFDCC4: FK_table_backup::~FK_table_backup() (sql_alter.h:42)
            ==112184==    by 0xCFF8DD: Alter_table_ctx::~Alter_table_ctx() (sql_alter.h:396)
            ==112184==    by 0xD90489: vers_create_partitions(THD*, TABLE_LIST*, unsigned int) (partition_info.cc:998)
            ==112184==    by 0xB07688: Open_table_context::recover_from_failed_open() (sql_base.cc:3531)
            ==112184==    by 0xB09C68: open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) (sql_base.cc:4675)
            ==112184==    by 0xAFFE18: open_tables(THD*, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) (sql_base.h:270)
            ==112184==  Address 0xbe57610 is 928 bytes inside a block of size 1,800 free'd
            ==112184==    at 0x484B27F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
            ==112184==    by 0x1A3D34E: my_free (my_malloc.c:221)
            ==112184==    by 0x1A2CACF: root_free (my_alloc.c:83)
            ==112184==    by 0x1A2D865: free_root (my_alloc.c:516)
            ==112184==    by 0xD485A9: TABLE_SHARE::destroy() (table.cc:525)
            ==112184==    by 0xD485E0: free_table_share(TABLE_SHARE*) (table.cc:541)
            ==112184==    by 0xF05311: tdc_delete_share_from_hash(TDC_element*) (table_cache.cc:534)
            ==112184==    by 0xF06895: tdc_release_share(TABLE_SHARE*) (table_cache.cc:1007)
            ==112184==    by 0xF03CD8: intern_close_table(TABLE*) (table_cache.cc:231)
            ==112184==    by 0xF03E59: tc_remove_table(TABLE*) (table_cache.cc:268)
            

            midenok Aleksey Midenkov added a comment - Rebased to 11.4 (bb-11.4-midenok- MDEV-20865 ) https://buildbot.mariadb.org/#/builders/551/builds/9239/steps/7/logs/stdio ==112184== Invalid write of size 4 ==112184== at 0xA6859D: base_list::operator=(base_list const&) (sql_list.h:153) ==112184== by 0xC758F6: List<FK_info>::operator=(List<FK_info> const&) (sql_list.h:497) ==112184== by 0xC75924: FK_list::operator=(FK_list const&) (handler.h:1093) ==112184== by 0xCFDDA7: FK_table_backup::rollback() (sql_alter.h:52) ==112184== by 0xCFDCC4: FK_table_backup::~FK_table_backup() (sql_alter.h:42) ==112184== by 0xCFF8DD: Alter_table_ctx::~Alter_table_ctx() (sql_alter.h:396) ==112184== by 0xD90489: vers_create_partitions(THD*, TABLE_LIST*, unsigned int) (partition_info.cc:998) ==112184== by 0xB07688: Open_table_context::recover_from_failed_open() (sql_base.cc:3531) ==112184== by 0xB09C68: open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) (sql_base.cc:4675) ==112184== by 0xAFFE18: open_tables(THD*, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) (sql_base.h:270) ==112184== Address 0xbe57610 is 928 bytes inside a block of size 1,800 free'd ==112184== at 0x484B27F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==112184== by 0x1A3D34E: my_free (my_malloc.c:221) ==112184== by 0x1A2CACF: root_free (my_alloc.c:83) ==112184== by 0x1A2D865: free_root (my_alloc.c:516) ==112184== by 0xD485A9: TABLE_SHARE::destroy() (table.cc:525) ==112184== by 0xD485E0: free_table_share(TABLE_SHARE*) (table.cc:541) ==112184== by 0xF05311: tdc_delete_share_from_hash(TDC_element*) (table_cache.cc:534) ==112184== by 0xF06895: tdc_release_share(TABLE_SHARE*) (table_cache.cc:1007) ==112184== by 0xF03CD8: intern_close_table(TABLE*) (table_cache.cc:231) ==112184== by 0xF03E59: tc_remove_table(TABLE*) (table_cache.cc:268)
            midenok Aleksey Midenkov made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]
            midenok Aleksey Midenkov made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]

            Please test bb-11.4-midenok-MDEV-20865

            midenok Aleksey Midenkov added a comment - Please test bb-11.4-midenok- MDEV-20865
            midenok Aleksey Midenkov made changes -
            Status In Progress [ 3 ] In Testing [ 10301 ]
            serg Sergei Golubchik made changes -
            Assignee Aleksey Midenkov [ midenok ] Elena Stepanova [ elenst ]
            lstartseva Lena Startseva made changes -
            Assignee Elena Stepanova [ elenst ] Lena Startseva [ JIRAUSER50478 ]
            midenok Aleksey Midenkov made changes -
            Assignee Lena Startseva [ JIRAUSER50478 ] Aleksey Midenkov [ midenok ]
            Status In Testing [ 10301 ] Stalled [ 10000 ]
            midenok Aleksey Midenkov made changes -
            Status Stalled [ 10000 ] In Testing [ 10301 ]
            midenok Aleksey Midenkov made changes -
            Assignee Aleksey Midenkov [ midenok ] Lena Startseva [ JIRAUSER50478 ]

            I think that the InnoDB changes must be reviewed by an InnoDB developer. One claim in the commit message that I found caught my eye:

            Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name.

            This is not entirely correct. I think that we may face failure scenarios like MDEV-28933 for the MDEV-25292 CREATE OR REPLACE TABLE that had to be reverted.

            marko Marko Mäkelä added a comment - I think that the InnoDB changes must be reviewed by an InnoDB developer. One claim in the commit message that I found caught my eye: Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name. This is not entirely correct. I think that we may face failure scenarios like MDEV-28933 for the MDEV-25292 CREATE OR REPLACE TABLE that had to be reverted.

            Do I understand it correctly that this implementation is increasing the memory footprint when FOREIGN KEY constraints exist? If the metadata storage was moved to a higher layer, then the lower-level storage (such as dict_foreign_t) would have to be removed. Apart from increased memory usage, duplicated data structures would create a potential problem that the two data dictionary caches become inconsistent with each other.

            marko Marko Mäkelä added a comment - Do I understand it correctly that this implementation is increasing the memory footprint when FOREIGN KEY constraints exist? If the metadata storage was moved to a higher layer, then the lower-level storage (such as dict_foreign_t ) would have to be removed . Apart from increased memory usage, duplicated data structures would create a potential problem that the two data dictionary caches become inconsistent with each other.

            The current Description says what is being done but not why it needs to be done. I can imagine one possible motivation: making the implementation of MDEV-21051 easier. (It is currently marked as a duplicate of this task; I think that it might be more appropriate to say that it is blocked by this task.)

            I think that before this can be included in a release, we also need performance testing, which should include not only execution time but also the memory usage, including any fragmentation. We have dismissed such issues as "not a bug" in the past (for example, in MDEV-14050), but I do not think that it is acceptable to increase the memory usage or the amount of allocation anti-patterns.

            marko Marko Mäkelä added a comment - The current Description says what is being done but not why it needs to be done. I can imagine one possible motivation: making the implementation of MDEV-21051 easier. (It is currently marked as a duplicate of this task; I think that it might be more appropriate to say that it is blocked by this task.) I think that before this can be included in a release, we also need performance testing, which should include not only execution time but also the memory usage, including any fragmentation. We have dismissed such issues as "not a bug" in the past (for example, in MDEV-14050 ), but I do not think that it is acceptable to increase the memory usage or the amount of allocation anti-patterns.
            marko Marko Mäkelä made changes -
            lstartseva Lena Startseva made changes -
            midenok Aleksey Midenkov made changes -
            Fix Version/s 11.6 [ 29515 ]
            Fix Version/s 11.5 [ 29506 ]
            lstartseva Lena Startseva made changes -
            serg Sergei Golubchik made changes -
            Assignee Lena Startseva [ JIRAUSER50478 ] Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Status In Testing [ 10301 ] Stalled [ 10000 ]
            serg Sergei Golubchik made changes -
            Status Stalled [ 10000 ] In Review [ 10002 ]

            It is always percentage of overhead which is acceptable or not. 10% total increase is unacceptable. 0.5% is acceptable. What is the threshold between these two numbers is the subject of consideration. I think it should be 2% which is far sufficient for the task IMO.

            This subtask should not be merged alone due to MDEV-33741 and it seems to depend on the last subtask (crash safety), so it turns out the whole MDEV-16417 should be pushed at once. I'm currently updating MDEV-21053.

            midenok Aleksey Midenkov added a comment - It is always percentage of overhead which is acceptable or not. 10% total increase is unacceptable. 0.5% is acceptable. What is the threshold between these two numbers is the subject of consideration. I think it should be 2% which is far sufficient for the task IMO. This subtask should not be merged alone due to MDEV-33741 and it seems to depend on the last subtask (crash safety), so it turns out the whole MDEV-16417 should be pushed at once. I'm currently updating MDEV-21053 .
            serg Sergei Golubchik made changes -
            Fix Version/s 11.7 [ 29815 ]
            Fix Version/s 11.6 [ 29515 ]

            I was asked to review MDEV-21652 in a branch that includes many other changes, including a version of this MDEV-20865, as well as MDEV-21052 which I have not been asked to review.

            I think that MDEV-21052 and MDEV-20865 needs to be in one atomic changeset, because InnoDB currently is the only storage engine that handles FOREIGN KEY metadata. Doing that would address my 2024-03-05 comment.

            The branch currently bundles too many changes that have a similar topic but should be fixable in isolation.

            I think that the changes to memory cache data structures (including MDEV-20865, MDEV-21052) need to be thoroughly tested and reviewed first, in a way that does not involve any file format changes. My point is that we may store FOREIGN KEY metadata in TABLE_SHARE, by populating the data structure both from a .frm file and the InnoDB SYS_FOREIGN and SYS_FOREIGN_COLS tables.

            marko Marko Mäkelä added a comment - I was asked to review MDEV-21652 in a branch that includes many other changes, including a version of this MDEV-20865 , as well as MDEV-21052 which I have not been asked to review. I think that MDEV-21052 and MDEV-20865 needs to be in one atomic changeset, because InnoDB currently is the only storage engine that handles FOREIGN KEY metadata. Doing that would address my 2024-03-05 comment. The branch currently bundles too many changes that have a similar topic but should be fixable in isolation. I think that the changes to memory cache data structures (including MDEV-20865 , MDEV-21052 ) need to be thoroughly tested and reviewed first, in a way that does not involve any file format changes. My point is that we may store FOREIGN KEY metadata in TABLE_SHARE , by populating the data structure both from a .frm file and the InnoDB SYS_FOREIGN and SYS_FOREIGN_COLS tables.
            marko Marko Mäkelä made changes -
            serg Sergei Golubchik made changes -
            Fix Version/s 11.8 [ 29921 ]
            Fix Version/s 11.7 [ 29815 ]

            As far as I understand, implementing this would remove a significant amount of contention on dict_sys.latch, with the following kind of stack traces:

            ssux_lock_impl<false>::rd_wait()
            ha_innobase::referenced_by_foreign_key()
            prepare_fk_prelocking_list(THD*, Query_tables_list*, TABLE_LIST*, bool*, unsigned char)
            DML_prelocking_strategy::handle_table(THD*, Query_tables_list*, TABLE_LIST*, bool*)
            extend_table_list(THD*, TABLE_LIST*, Prelocking_strategy*, bool)
            open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*)
            open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*)
            

            Note that this affects any workloads, including those that do not use any FOREIGN KEY constraints at all.

            marko Marko Mäkelä added a comment - As far as I understand, implementing this would remove a significant amount of contention on dict_sys.latch , with the following kind of stack traces: ssux_lock_impl<false>::rd_wait() ha_innobase::referenced_by_foreign_key() prepare_fk_prelocking_list(THD*, Query_tables_list*, TABLE_LIST*, bool*, unsigned char) DML_prelocking_strategy::handle_table(THD*, Query_tables_list*, TABLE_LIST*, bool*) extend_table_list(THD*, TABLE_LIST*, Prelocking_strategy*, bool) open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) Note that this affects any workloads, including those that do not use any FOREIGN KEY constraints at all.
            marko Marko Mäkelä made changes -
            Labels foreign-keys performance
            midenok Aleksey Midenkov made changes -
            Summary Store foreign key info in TABLE_SHARE Store foreign key info in FRM and TABLE_SHARE
            mokraemer Marc made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Fix Version/s 11.9 [ 29945 ]
            Fix Version/s 11.8 [ 29921 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 12.1 [ 29992 ]
            Fix Version/s 12.0 [ 29945 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 12.3 [ 30147 ]
            Fix Version/s 12.1 [ 29992 ]

            People

              serg Sergei Golubchik
              midenok Aleksey Midenkov
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.