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

CAST(11068046444225730969 AS SIGNED) does not return a warning

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 10.1, 10.2, 10.3, 10.4, 10.0
    • Fix Version/s: 10.3.15, 10.4.5
    • Component/s: OTHER
    • Labels:
      None

      Description

      This script:

      SELECT CAST(-7378697629483820647 AS UNSIGNED);
      

      returns

      +----------------------------------------+
      | CAST(-7378697629483820647 AS UNSIGNED) |
      +----------------------------------------+
      |                   11068046444225730969 |
      +----------------------------------------+
      1 row in set, 1 warning (0.00 sec)
      

      with a warning:

      +-------+------+-------------------------------------------------------------------------+
      | Level | Code | Message                                                                 |
      +-------+------+-------------------------------------------------------------------------+
      | Note  | 1105 | Cast to unsigned converted negative integer to it's positive complement |
      +-------+------+-------------------------------------------------------------------------+
      

      If I now do the other way around:

      SELECT CAST(11068046444225730969 AS SIGNED);
      

      it returns this result:

      +--------------------------------------+
      | CAST(11068046444225730969 AS SIGNED) |
      +--------------------------------------+
      |                 -7378697629483820647 |
      +--------------------------------------+
      1 row in set (0.00 sec)
      

      but no warning is issued.

      Expect to get a warning Cast to signed converted positive integer to it's negative complement

        Attachments

          Activity

            People

            Assignee:
            bar Alexander Barkov
            Reporter:
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: