Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression, executor: length(binary(m)) should return 'm' instead of the concrete string length(#3644) #3745

Closed
wants to merge 3 commits into from

Conversation

zz-jason
Copy link
Member

No description provided.

return sig.setSelf(sig), errors.Trace(c.verifyArgs(args))
var sig builtinFunc
argTp := args[0].GetType()
if argTp.Tp == mysql.TypeString && mysql.HasBinaryFlag(argTp.Flag) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need varbinary be treated as this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, just binary

DROP TABLE IF EXISTS table_binary;
CREATE TABLE table_binary (
    a BINARY(20),
    b VARBINARY(20),
    c TINYBLOB,
    d BLOB(20),
    e MEDIUMBLOB,
    f LONGBLOB,
    g BIGINT,
    UNIQUE KEY(a),
    UNIQUE KEY(g)
);
INSERT INTO table_binary (a, b, c, d, e, f, g) VALUES ("a ", "b ", "c ", "d ", "e ", "f ", 2);
select length(a), length(b), length(c), length(d), length(e), length(f), length(g) from table_binary;
+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
| length(a) | length(b) | length(c) | length(d) | length(e) | length(f) | length(g) |
+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
|        20 |         2 |         2 |         2 |         2 |         2 |         1 |
+-----------+-----------+-----------+-----------+-----------+-----------+-----------+

@winoros winoros changed the title [fix #3644] length(binary(m)) should return 'm' instead of the concrete string length expression, executor: fix issue#3644 Jul 13, 2017
@hanfei1991
Copy link
Member

LGTM

@XuHuaiyu XuHuaiyu changed the title expression, executor: fix issue#3644 expression, executor: length(binary(m)) should return 'm' instead of the concrete string length(#3644) Jul 14, 2017
@zz-jason zz-jason added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 14, 2017
@XuHuaiyu
Copy link
Contributor

This PR may not really fix #3644 .
In MySQL:

create table t (a binary(10));
select length(concat(a, "123")) from t;
--> 13

alter table t modify a binary(20);
select length(concat(a, "123")) from t;
--> 23

In TiDB, we may still get 13 even after merging this PR.

@XuHuaiyu XuHuaiyu added the DNM label Jul 14, 2017
@zz-jason zz-jason closed this Jul 14, 2017
@zz-jason zz-jason deleted the 3644-length branch September 30, 2017 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants