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

Excessive warnings upon a call to RANDOM_BYTES

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • N/A
    • 10.10.1
    • Server
    • None

    Description

      I am not setting it to critical 10.10v1 to avoid it blocking the release, but it would be good to look into this. Not only does it cause an untidy output with a long list of duplicate warnings, but also my concern is that it may indicate some redundancy in the way the function is executed.

      bb-10.10-MDEV-25704 c33ed04b7e7

      MariaDB [test]> select random_bytes(cast('x' as unsigned)+1);
      +---------------------------------------+
      | random_bytes(cast('x' as unsigned)+1) |
      +---------------------------------------+
      | �                                      |
      +---------------------------------------+
      1 row in set, 5 warnings (0.000 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+----------------------------------------+
      | Level   | Code | Message                                |
      +---------+------+----------------------------------------+
      | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
      | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
      | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
      | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
      | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
      +---------+------+----------------------------------------+
      5 rows in set (0.000 sec)
      

      The CAST alone only produces one warning, as expected:

      MariaDB [test]> select cast('x' as unsigned);
      +-----------------------+
      | cast('x' as unsigned) |
      +-----------------------+
      |                     0 |
      +-----------------------+
      1 row in set, 1 warning (0.000 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+----------------------------------------+
      | Level   | Code | Message                                |
      +---------+------+----------------------------------------+
      | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
      +---------+------+----------------------------------------+
      1 row in set (0.000 sec)
      

      If random_bytes is replaced by another function, no extra warnings are produced (although I didn't try all functions, so maybe random_bytes is not unique in this sense):

      MariaDB [test]> select ceil(cast('x' as unsigned)+1);
      +-------------------------------+
      | ceil(cast('x' as unsigned)+1) |
      +-------------------------------+
      |                             1 |
      +-------------------------------+
      1 row in set, 1 warning (0.000 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+----------------------------------------+
      | Level   | Code | Message                                |
      +---------+------+----------------------------------------+
      | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
      +---------+------+----------------------------------------+
      1 row in set (0.000 sec)
      

      Attachments

        Issue Links

          Activity

            danblack Daniel Black added a comment -

            Have brought the 5 warnings back to a standard 2 consistent with sha2 and format that also call args[x]->val_int() in ::fix_length_and_dec and ::val_str.

            MariaDB [test]> select sha2('bbbbb', cast('x' as unsigned)+224);
            +----------------------------------------------------------+
            | sha2('bbbbb', cast('x' as unsigned)+224)                 |
            +----------------------------------------------------------+
            | abd54ed96011c648e7e012dfef1a9f3174b70c86de55d0840f2a576d |
            +----------------------------------------------------------+
            1 row in set, 2 warnings (21.758 sec)
             
            MariaDB [test]> show warnings;
            +---------+------+----------------------------------------+
            | Level   | Code | Message                                |
            +---------+------+----------------------------------------+
            | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
            | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
            +---------+------+----------------------------------------+
            2 rows in set (0.000 sec)
             
            MariaDB [test]> select format(4, cast('x' as unsigned)+1);
            +------------------------------------+
            | format(4, cast('x' as unsigned)+1) |
            +------------------------------------+
            | 4.0                                |
            +------------------------------------+
            1 row in set, 2 warnings (5.392 sec)
             
            MariaDB [test]> show warnings;
            +---------+------+----------------------------------------+
            | Level   | Code | Message                                |
            +---------+------+----------------------------------------+
            | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
            | Warning | 1292 | Truncated incorrect INTEGER value: 'x' |
            +---------+------+----------------------------------------+
            2 rows in set (0.000 sec)
            
            

            Not a complete solution, but a little more palatable. I think I need a bit of advice how to avoid this in the Item hierarchy with caching or otherwise.

            danblack Daniel Black added a comment - Have brought the 5 warnings back to a standard 2 consistent with sha2 and format that also call args [x] ->val_int() in ::fix_length_and_dec and ::val_str . MariaDB [test]> select sha2('bbbbb', cast('x' as unsigned)+224); +----------------------------------------------------------+ | sha2('bbbbb', cast('x' as unsigned)+224) | +----------------------------------------------------------+ | abd54ed96011c648e7e012dfef1a9f3174b70c86de55d0840f2a576d | +----------------------------------------------------------+ 1 row in set, 2 warnings (21.758 sec)   MariaDB [test]> show warnings; +---------+------+----------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------+ | Warning | 1292 | Truncated incorrect INTEGER value: 'x' | | Warning | 1292 | Truncated incorrect INTEGER value: 'x' | +---------+------+----------------------------------------+ 2 rows in set (0.000 sec)   MariaDB [test]> select format(4, cast('x' as unsigned)+1); +------------------------------------+ | format(4, cast('x' as unsigned)+1) | +------------------------------------+ | 4.0 | +------------------------------------+ 1 row in set, 2 warnings (5.392 sec)   MariaDB [test]> show warnings; +---------+------+----------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------+ | Warning | 1292 | Truncated incorrect INTEGER value: 'x' | | Warning | 1292 | Truncated incorrect INTEGER value: 'x' | +---------+------+----------------------------------------+ 2 rows in set (0.000 sec) Not a complete solution, but a little more palatable. I think I need a bit of advice how to avoid this in the Item hierarchy with caching or otherwise.
            danblack Daniel Black added a comment -

            nikitamalyavin, since you've been drawn back to the discussion here in MDEV-25704 can I get a review of the final fix at the end of the bb-10.10-MDEV-25704 branch.

            elenst if that approach is ok, I guess the other sha2/format can get a similar fix.

            Related to the original 5 warnings by putting function calls in MY_(MAX|MIN) there's other (git grep -A 1 'MY_M[AI][XN]') non-simple args used,

            Attempting to solve at high level:

            fails with too many type unsigned/signed comparison and variable length array warnings

            diff --git a/include/my_global.h b/include/my_global.h
            index 22968900b0a..774cdab4656 100644
            --- a/include/my_global.h
            +++ b/include/my_global.h
            @@ -1112,8 +1112,13 @@ typedef struct { const char *dli_fname, dli_fbase; } Dl_info;
             #endif
             
             /* Define some useful general macros (should be done after all headers). */
            +#ifdef __cplusplus
            +#define MY_MAX(a, b)   std::max((a), (b))
            +#define MY_MIN(a, b)   std::min((a), (b))
            +#else
             #define MY_MAX(a, b)   ((a) > (b) ? (a) : (b))
             #define MY_MIN(a, b)   ((a) < (b) ? (a) : (b))
            +#endif
             
             #define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
             
            

            danblack Daniel Black added a comment - nikitamalyavin , since you've been drawn back to the discussion here in MDEV-25704 can I get a review of the final fix at the end of the bb-10.10- MDEV-25704 branch. elenst if that approach is ok, I guess the other sha2/format can get a similar fix. Related to the original 5 warnings by putting function calls in MY_(MAX|MIN) there's other ( git grep -A 1 'MY_M [AI] [XN] ' ) non-simple args used, Attempting to solve at high level: fails with too many type unsigned/signed comparison and variable length array warnings diff --git a/include/my_global.h b/include/my_global.h index 22968900b0a..774cdab4656 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1112,8 +1112,13 @@ typedef struct { const char *dli_fname, dli_fbase; } Dl_info; #endif /* Define some useful general macros (should be done after all headers). */ +#ifdef __cplusplus +#define MY_MAX(a, b) std::max((a), (b)) +#define MY_MIN(a, b) std::min((a), (b)) +#else #define MY_MAX(a, b) ((a) > (b) ? (a) : (b)) #define MY_MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif #define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
            danblack Daniel Black added a comment -

            Fixed enough thanks serg.

            Reducing double warnings generally should be its own task.

            danblack Daniel Black added a comment - Fixed enough thanks serg . Reducing double warnings generally should be its own task.

            People

              danblack Daniel Black
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.