Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35598

foreign key error is unnecessary truncated

Details

    Description

      The error message I'm getting when executing a query:

      ERROR 1451 (23000) at line 2: Cannot delete or update a parent row: a foreign key constraint fails
      (`adex_sales_smtm_yourspace_api`.`conemu_conemu_file`, CONSTRAINT `fk_conemu_conemu_file_root_conemu_conemu_file_key_id`
      FOREIGN KEY (`root_conemu_conemu_file_key_id`) REFERENCES `conemu_conemu)
      

      Part of the error message is truncated. Is there a way to disable this behavior?

      Attachments

        Activity

          The error is defined like this in sql/share/errmsg-utf8.txt:

          ER_ROW_IS_REFERENCED_2 23000
                  eng "Cannot delete or update a parent row: a foreign key constraint fails (%.192s)"
          

          which sets the limit of 192 chars that is seen in the example.
          Besides that, there seem to be a limit of 256 characters inside InnoDB:

          static const ulint MAX_DETAILED_ERROR_LEN = 256;
           
          trx_set_detailed_error(trx_t* trx, const char* msg) {
          	strncpy(trx->detailed_error, msg, MAX_DETAILED_ERROR_LEN - 1);
          

          You can try increasing those two limits and recompile. Or put another way, there does not seem to be a way with the current code.

          - Kristian.

          knielsen Kristian Nielsen added a comment - The error is defined like this in sql/share/errmsg-utf8.txt : ER_ROW_IS_REFERENCED_2 23000 eng "Cannot delete or update a parent row: a foreign key constraint fails (%.192s)" which sets the limit of 192 chars that is seen in the example. Besides that, there seem to be a limit of 256 characters inside InnoDB: static const ulint MAX_DETAILED_ERROR_LEN = 256;   trx_set_detailed_error(trx_t* trx, const char* msg) { strncpy(trx->detailed_error, msg, MAX_DETAILED_ERROR_LEN - 1); You can try increasing those two limits and recompile. Or put another way, there does not seem to be a way with the current code. - Kristian.
          danblack Daniel Black added a comment -

          If you're trying to get the full query associated, https://mariadb.com/kb/en/sql-error-log-plugin/ can assist by logging the query.

          danblack Daniel Black added a comment - If you're trying to get the full query associated, https://mariadb.com/kb/en/sql-error-log-plugin/ can assist by logging the query.

          The error message is stored in the NET structure on the client side: https://github.com/mariadb-corporation/mariadb-connector-c/blob/fb0eea663ac3f8c89cd96a0f32204e950003cb9c/include/mariadb_com.h#L308

          which is part of MYSQL structure: https://github.com/mariadb-corporation/mariadb-connector-c/blob/fb0eea663ac3f8c89cd96a0f32204e950003cb9c/include/mysql.h#L355

          Max error message size is MYSQL_ERRMSG_SIZE=512 https://github.com/mariadb-corporation/mariadb-connector-c/blob/fb0eea663ac3f8c89cd96a0f32204e950003cb9c/include/mariadb_com.h#L256

          and it cannot be changed because it'll break the ABI and will make the library incompatible with existing clients.

          serg Sergei Golubchik added a comment - The error message is stored in the NET structure on the client side: https://github.com/mariadb-corporation/mariadb-connector-c/blob/fb0eea663ac3f8c89cd96a0f32204e950003cb9c/include/mariadb_com.h#L308 which is part of MYSQL structure: https://github.com/mariadb-corporation/mariadb-connector-c/blob/fb0eea663ac3f8c89cd96a0f32204e950003cb9c/include/mysql.h#L355 Max error message size is MYSQL_ERRMSG_SIZE=512 https://github.com/mariadb-corporation/mariadb-connector-c/blob/fb0eea663ac3f8c89cd96a0f32204e950003cb9c/include/mariadb_com.h#L256 and it cannot be changed because it'll break the ABI and will make the library incompatible with existing clients.

          Perhaps this particular error message length can be increased from 256 to 512, but not beyond that

          serg Sergei Golubchik added a comment - Perhaps this particular error message length can be increased from 256 to 512, but not beyond that
          savemetenminutes Milen added a comment - - edited

          I'm just trying to get the full messages with as little effort as possible. Recompiling used to take ages last time I went that route and I had problems with the CMake config.

          I'm not trying to log the query specifically... it's just that I don't see the point in such patchy query result messages, but that's just my point of view. I'm sure there was a reason to trash half of the log for some performance benefits or something.

          I guess I'm out of options except to file a feature request.

          I understand the increase could break compatibility with some clients and that's why IMO it should be configurable.

          Due to my rusty condition of C++ knowledge and experience, I'm generally having a hard time understanding why there is a need to impose such limitations in general to the platform in terms of strings and identifier names. One thing that has been consistently bothering me for years now is the 64 character limit on index and constraint names and IIRC there is also a limit to the schema and table name length. It becomes a nuissance when you're trying to keep things consistent and descriptive and are generally generating these identifiers programmatically.

          Then again there are bigger fish to fry and it mostly boils down to keeping up with general MySQL compatibility, one of them being the support for DELETE and UPDATE in CTEs.

          savemetenminutes Milen added a comment - - edited I'm just trying to get the full messages with as little effort as possible. Recompiling used to take ages last time I went that route and I had problems with the CMake config. I'm not trying to log the query specifically... it's just that I don't see the point in such patchy query result messages, but that's just my point of view. I'm sure there was a reason to trash half of the log for some performance benefits or something. I guess I'm out of options except to file a feature request. I understand the increase could break compatibility with some clients and that's why IMO it should be configurable. Due to my rusty condition of C++ knowledge and experience, I'm generally having a hard time understanding why there is a need to impose such limitations in general to the platform in terms of strings and identifier names. One thing that has been consistently bothering me for years now is the 64 character limit on index and constraint names and IIRC there is also a limit to the schema and table name length. It becomes a nuissance when you're trying to keep things consistent and descriptive and are generally generating these identifiers programmatically. Then again there are bigger fish to fry and it mostly boils down to keeping up with general MySQL compatibility, one of them being the support for DELETE and UPDATE in CTEs.

          People

            serg Sergei Golubchik
            savemetenminutes Milen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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