oceanbase / oceanbase/oceanbase

[Bug]: Incompatible result with MySQL

Open
#2,200 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: confirmed type: bug
Dominant language
C++
Stars
10.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Environment

  • OS Version and CPU Arch(uname -a):
Linux 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
  • OB Version(LD_LIBRARY_PATH=../lib:$LD_LIBRARY_PATH ./observer -V):
select version();
-- 5.7.25-OceanBase_CE-v4.3.4.0

Fast Reproduce Steps(Required)

Steps to reproduce the behavior:

DROP TABLE IF EXISTS t1;

CREATE TABLE t1 (
    c0 TIMESTAMP,
    c1 DOUBLE,
    c2 TIMESTAMP AS (c0) VIRTUAL NOT NULL,
    c3 INT UNSIGNED NOT NULL,
    c4 VARCHAR(255),
    c5 JSON,
    PRIMARY KEY (c3),
    UNIQUE INDEX idx1 (c2, c0),
    INDEX idx2 (c4)
) WITH COLUMN GROUP (all columns, each column);

INSERT IGNORE INTO t1(c1, c3, c4, c5) 
VALUES 
    (-10.0, 2900, 'example', '{"key": "value"}'),
    (232.0, 3921, 'test', '{"key": "test"}'),
    (12222.0, 2123, 'demo', '{"key": "demo"}');

Expected behavior

I find that the query in OceanBase is inconsistent with MySQL 8.4.1

// MySQL
MySQL [test]> SELECT c2
    -> FROM t1
    -> WHERE c1 = -10 or JSON_UNQUOTE(JSON_EXTRACT(c5, '$.key')) = 'demo';
+---------------------+
| c2                  |
+---------------------+
| 0000-00-00 00:00:00 |
| 0000-00-00 00:00:00 |
+---------------------+
2 rows in set (0.00 sec)

Actual Behavior

// OceanBase
MySQL [test]> SELECT /*+ USE_COLUMN_TABLE(t1) */ c2
    -> FROM t1
    -> WHERE c1 = -10 or JSON_UNQUOTE(JSON_EXTRACT(c5, '$.key')) = 'demo';
+----+
| c2 |
+----+
| NULL |
| NULL |
+----+
2 rows in set (0.01 sec)

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided CREATE TABLE, INSERT IGNORE, and SELECT statements on OceanBase 4.3.4 and MySQL 8.4.1, comparing the virtual TIMESTAMP column results with and without USE_COLUMN_TABLE(t1). Trace the handling of the virtual column, JSON predicate, and column-table execution path. Done means OceanBase returns the same values as MySQL for this reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, json, mysql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.