[MDEV-7889] Like operator does not work as in other databases Created: 2015-03-31  Updated: 2015-03-31  Due: 2015-04-30  Resolved: 2015-03-31

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Subquery
Affects Version/s: 10.1.3
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Philip orleans Assignee: Unassigned
Resolution: Not a Bug Votes: 0
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.



 Comments   
Comment by Elena Stepanova [ 2015-03-31 ]

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.

Comment by Philip orleans [ 2015-03-31 ]

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:

Comment by Elena Stepanova [ 2015-03-31 ]

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 .

Comment by Philip orleans [ 2015-03-31 ]

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)
)

Comment by Philip orleans [ 2015-03-31 ]

The Jira system kills any information between plus signs

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

Comment by Philip orleans [ 2015-03-31 ]

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) <

Comment by Elena Stepanova [ 2015-03-31 ]

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'.

Comment by Philip orleans [ 2015-03-31 ]

Thanks, please close the case.
Yours
Federico

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

Generated at Thu Feb 08 07:23:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.