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

Like operator does not work as in other databases

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not a Bug
    • Affects Version/s: 10.1.3
    • Fix Version/s: N/A
    • Labels:
      None
    • Environment:
      Linux

      Description

      This is a bug that makes it impossible to replace some applications written for MS SQL or Oracle, etc.
      The Like operator works only when the column is on the left, and in the right side there is an expression to be matched.
      for instance
      select * from Table where npanxx like '9544%'
      it correctly finds row with value '954444'

      But,in all databases that I know of, this also finds that match

      select * from Table where '9544447408' like concat(npanxx,'%')

      It does not work in MariaDB, and it should. I am not sure about MySQL, but in any case, it is a bug and we need to fix it and make it efficient.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            Works for me:

            MariaDB [test]> create table t (npanxx varchar(16));
            Query OK, 0 rows affected (0.08 sec)
            
            MariaDB [test]> insert into t values ( '954444');
            Query OK, 1 row affected (0.27 sec)
            
            MariaDB [test]> select * from t where '9544447408' like concat(npanxx,'%');
            +--------+
            | npanxx |
            +--------+
            | 954444 |
            +--------+
            1 row in set (0.00 sec)
            
            MariaDB [test]> select @@version;
            +----------------------+
            | @@version            |
            +----------------------+
            | 10.1.3-MariaDB-wsrep |
            +----------------------+
            1 row in set (0.00 sec)
            

            Please paste the exact queries and output from the client.

            Show
            elenst Elena Stepanova added a comment - Works for me: MariaDB [test]> create table t (npanxx varchar(16)); Query OK, 0 rows affected (0.08 sec) MariaDB [test]> insert into t values ( '954444'); Query OK, 1 row affected (0.27 sec) MariaDB [test]> select * from t where '9544447408' like concat(npanxx,'%'); +--------+ | npanxx | +--------+ | 954444 | +--------+ 1 row in set (0.00 sec) MariaDB [test]> select @@version; +----------------------+ | @@version | +----------------------+ | 10.1.3-MariaDB-wsrep | +----------------------+ 1 row in set (0.00 sec) Please paste the exact queries and output from the client.
            Hide
            philip_38 Philip orleans added a comment - - edited

            I cannot explain it, look

             select * from ratedeck where code like '1954444%';
            +------------+--------+--------+
            +------------+--------+--------+
            +------------+--------+--------+
            1 row in set (0.00 sec)
            
            MariaDB [asterisk]> select * from ratedeck where '19544447408' like
            concat(code,'%');
            Empty set (0.00 sec)
            
             select @@version;
            +-----------------+
            +-----------------+
            +-----------------+
            
            
            CREATE TABLE ratedeck (
              code varchar(10) NOT NULL,
              inter float NOT NULL DEFAULT 0,
              intra float NOT NULL DEFAULT 0,
              PRIMARY KEY (code)
            )
            

            I can give you access to the box, it is not a production box.

            this is a mystery

            If this email is private, I can send you the password, or I can create a
            user name on the database and you may login directly. It is on the public
            internet.

            Yours
            Philip

            On Tue, Mar 31, 2015 at 9:04 AM, Elena Stepanova (JIRA) <
            jira@mariadb.atlassian.net> wrote:

            Show
            philip_38 Philip orleans added a comment - - edited I cannot explain it, look select * from ratedeck where code like '1954444%'; +------------+--------+--------+ +------------+--------+--------+ +------------+--------+--------+ 1 row in set (0.00 sec) MariaDB [asterisk]> select * from ratedeck where '19544447408' like concat(code,'%'); Empty set (0.00 sec) select @@version; +-----------------+ +-----------------+ +-----------------+ CREATE TABLE ratedeck ( code varchar(10) NOT NULL, inter float NOT NULL DEFAULT 0, intra float NOT NULL DEFAULT 0, PRIMARY KEY (code) ) I can give you access to the box, it is not a production box. this is a mystery If this email is private, I can send you the password, or I can create a user name on the database and you may login directly. It is on the public internet. Yours Philip On Tue, Mar 31, 2015 at 9:04 AM, Elena Stepanova (JIRA) < jira@mariadb.atlassian.net> wrote:
            Hide
            elenst Elena Stepanova added a comment -

            Your paste came to JIRA broken.
            Anyway, if you want me to look at it at your box, my public SSH key is here https://launchpad.net/~elenst/+sshkeys .

            Show
            elenst Elena Stepanova added a comment - Your paste came to JIRA broken. Anyway, if you want me to look at it at your box, my public SSH key is here https://launchpad.net/~elenst/+sshkeys .
            Hide
            philip_38 Philip orleans added a comment - - edited

            I already added your key
            My IP is 8.19.245.233, root
            cannot explain it, look

            mysql asterisk
             select * from ratedeck where code like '1954444%';
            +------------+--------+--------+
            +------------+--------+--------+
            +------------+--------+--------+
            1 row in set (0.00 sec)
            
            select * from ratedeck where '19544447408' like concat(code,'%');
            Empty set (0.00 sec)
            
             select @@version;
            +-----------------+
            +-----------------+
            +-----------------+
            
            
            CREATE TABLE ratedeck (
              code varchar(10) NOT NULL,
              inter float NOT NULL DEFAULT 0,
              intra float NOT NULL DEFAULT 0,
              PRIMARY KEY (code)
            )
            
            Show
            philip_38 Philip orleans added a comment - - edited I already added your key My IP is 8.19.245.233, root cannot explain it, look mysql asterisk select * from ratedeck where code like '1954444%'; +------------+--------+--------+ +------------+--------+--------+ +------------+--------+--------+ 1 row in set (0.00 sec) select * from ratedeck where '19544447408' like concat(code,'%'); Empty set (0.00 sec) select @@version; +-----------------+ +-----------------+ +-----------------+ CREATE TABLE ratedeck ( code varchar(10) NOT NULL, inter float NOT NULL DEFAULT 0, intra float NOT NULL DEFAULT 0, PRIMARY KEY (code) )
            Hide
            philip_38 Philip orleans added a comment -

            The Jira system kills any information between plus signs

            On Tue, Mar 31, 2015 at 9:55 AM, Philip orleans (JIRA) <

            Show
            philip_38 Philip orleans added a comment - The Jira system kills any information between plus signs On Tue, Mar 31, 2015 at 9:55 AM, Philip orleans (JIRA) <
            Hide
            philip_38 Philip orleans added a comment - - edited

            here I go again

             select * from ratedeck where code like '1954444%';
            +------------+--------+--------+
             code       inter   intra  |
            +------------+--------+--------+
             1954444     0.0007  0.0007 |
            +------------+--------+--------+
            

            select * from ratedeck where '19544447408' like concat(code,'%');
            Empty set (0.00 sec)

            On Tue, Mar 31, 2015 at 10:01 AM, Philip orleans (JIRA) <

            Show
            philip_38 Philip orleans added a comment - - edited here I go again select * from ratedeck where code like '1954444%'; +------------+--------+--------+ code inter intra | +------------+--------+--------+ 1954444 0.0007 0.0007 | +------------+--------+--------+ select * from ratedeck where '19544447408' like concat(code,'%'); Empty set (0.00 sec) On Tue, Mar 31, 2015 at 10:01 AM, Philip orleans (JIRA) <
            Hide
            elenst Elena Stepanova added a comment - - edited

            Here is the problem:

            MariaDB [test]> select hex(code) from asterisk.ratedeck where code like '1954444%';
            +----------------------+
            | hex(code)            |
            +----------------------+
            | 31393534343434202020 |
            +----------------------+
            1 row in set (0.00 sec)
            

            Your value has 3 extra symbols at the end, so naturally it doesn't match the numeric string '19544447408'.

            Show
            elenst Elena Stepanova added a comment - - edited Here is the problem: MariaDB [test]> select hex(code) from asterisk.ratedeck where code like '1954444%'; +----------------------+ | hex(code) | +----------------------+ | 31393534343434202020 | +----------------------+ 1 row in set (0.00 sec) Your value has 3 extra symbols at the end, so naturally it doesn't match the numeric string '19544447408'.
            Hide
            philip_38 Philip orleans added a comment -

            Thanks, please close the case.
            Yours
            Federico

            On Tue, Mar 31, 2015 at 10:29 AM, Elena Stepanova (JIRA) <

            Show
            philip_38 Philip orleans added a comment - Thanks, please close the case. Yours Federico On Tue, Mar 31, 2015 at 10:29 AM, Elena Stepanova (JIRA) <

              People

              • Assignee:
                Unassigned
                Reporter:
                philip_38 Philip orleans
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: