Skip to content

[Bug]: length func result wrong #3256

Closed

Description

@dengn

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Environment

- Version or commit-id (e.g. v0.1.0 or 8b23a93):e086b4d
- Hardware parameters:Mac M1 ARM 16GB
- OS type: OSX
- Others:

Actual Behavior

[SQL STATEMENT]: select length(space(1024*1024)) as a;
[EXPECT RESULT]:
a
1048576
[ACTUAL RESULT]:
a
null

[SQL STATEMENT]: select length('\n\t\r\b\0_%\');
[EXPECT RESULT]:
length('\n\t\r\b\0_%\')
10
[ACTUAL RESULT]:
length(

��_%)
8

[SQL STATEMENT]: SELECT t1.t1_fld1, t2.t2_fld1, t3.t3_fld1 FROM t1 JOIN t2 JOIN t3 ON (length(t1.b) = length(t2.b));
[EXPECT RESULT]:
t1_fld1 t2_fld1 t3_fld1
300 65680 65680
300 65680 65680
300 65680 16777300
300 65680 16777300
300 65680 16777300
300 65680 16777300
[ACTUAL RESULT]:
t1_fld1 t2_fld1 t3_fld1
300 null null
300 null null
300 null null
300 null null
300 null null
300 null null

CREATE TABLE t1 (t1_fld1 int, b varchar(255));
CREATE TABLE t2 (t2_fld1 int, b varchar(255));
CREATE TABLE t3 (t3_fld1 int, b varchar(255));
INSERT INTO t1 select LENGTH(space(300)), "abcdefg";
INSERT INTO t1 select LENGTH(space(300)), "123124141";
INSERT INTO t2 select LENGTH(space(65680)), "abcdefg";
INSERT INTO t2 select LENGTH(space(65680)), "1238193";
INSERT INTO t3 select LENGTH(space(65680)), "1238193";
INSERT INTO t3 select LENGTH(space(16777300)),"123124141";
INSERT INTO t3 select LENGTH(space(16777300)),"123asdq";
SELECT DISTINCT * from t1;
SELECT t1.t1_fld1, t2.t2_fld1, t3.t3_fld1 FROM t1 JOIN t2 JOIN t3 ON (length(t1.b) = length(t2.b));
drop table t1;
drop table t2;
drop table t3;

Expected Behavior

No response

Steps to Reproduce

No response

Additional information

No response

Activity

  1. added
    kind/bug
    on Jun 23, 2022
  2. added this to the v0.5.0 milestone on Jun 23, 2022
  3. added
    bvt
    and removed on Jun 24, 2022
  4. daviszhen commented on Jun 30, 2022

    @daviszhen
    Contributor

    resolved:
    [SQL STATEMENT]: select length(space(1024*1024)) as a;

    CREATE TABLE t1 (t1_fld1 int, b varchar(255));
    CREATE TABLE t2 (t2_fld1 int, b varchar(255));
    CREATE TABLE t3 (t3_fld1 int, b varchar(255));
    INSERT INTO t1 select LENGTH(space(300)), "abcdefg";
    INSERT INTO t1 select LENGTH(space(300)), "123124141";
    INSERT INTO t2 select LENGTH(space(65680)), "abcdefg";
    INSERT INTO t2 select LENGTH(space(65680)), "1238193";
    INSERT INTO t3 select LENGTH(space(65680)), "1238193";
    INSERT INTO t3 select LENGTH(space(16777300)),"123124141";
    INSERT INTO t3 select LENGTH(space(16777300)),"123asdq";
    SELECT DISTINCT * from t1;
    SELECT t1.t1_fld1, t2.t2_fld1, t3.t3_fld1 FROM t1 JOIN t2 JOIN t3 ON (length(t1.b) = length(t2.b));
    drop table t1;
    drop table t2;
    drop table t3;

    can not input in shell: same as #3313
    select length('\n\t\r\b\0_%');

  5. added a commit that references this issue on Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bvtkind/bugtriage/accepted

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions