oceanbase / oceanbase/oceanbase
[Bug]: Inconsistent Results Between Materialized Table and View with LIKE Operator
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
A query using the LIKE operator and logical conditions in OceanBase produces inconsistent results when executed on a materialized table versus a view with the same definition.
Environment
- OS Version and CPU Arch(
uname -a):
[root@332f4c044dbb ~]# uname -a
Linux 332f4c044dbb 5.15.49-linuxkit-pr #1 SMP PREEMPT Thu May 25 07:27:39 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
- OB Version:
obclient [oceanbase]> select version();
+------------------------------+
| version() |
+------------------------------+
| 5.7.25-OceanBase_CE-v4.2.1.9 |
+------------------------------+
1 row in set (0.002 sec)
Fast Reproduce Steps(Required)
Steps to reproduce the behavior:
-- Step 1: Create table t0 and insert data
CREATE TABLE t0 (c0 DATETIME, c1 TIMESTAMP, c2 VARBINARY(21), c3 JSON);
INSERT INTO t0 (c0, c1, c2, c3) VALUES ('2065-02-20 15:04:30', '2006-05-21 07:29:57', 0x11FA4443A3C5D750F078E, 'false');
INSERT INTO t0 (c0, c1, c2, c3) VALUES ('1966-02-04 03:02:42', '1983-02-11 00:23:35', 0x04A019891D572E9176817, 'false');
INSERT INTO t0 (c0, c1, c2, c3) VALUES ('2039-02-19 10:39:22', '1997-02-16 11:48:04', 0xC6806F69231BCE60BC86A, 'false');
INSERT INTO t0 (c0, c1, c2, c3) VALUES ('1978-07-22 11:09:29', '1976-09-16 18:43:30', 0x9BA907E7A40EE4D28A73B, '-4');
INSERT INTO t0 (c0, c1, c2, c3) VALUES ('1939-09-10 21:15:41', '1975-01-06 22:19:02', 0xB10BE14BC19C52F499D62, 'true');
-- Step 2: Create materialized table t1 and query it
CREATE TABLE t1 AS (SELECT (c0 LIKE c1) AS c0 , c2 AS c2, c3 AS c3 FROM t0 );
SELECT c2, c3 FROM t1 WHERE ((c3 = (c0)) AND (1592972218101984383 OR (-3838296295401480336))) ORDER BY c2 ASC;
Empty set (0.008 sec)
-- Step 3: Create view t1 instead and query it
CREATE VIEW t1 AS (SELECT (c0 LIKE c1) AS c0 , c2 AS c2, c3 AS c3 FROM t0 );
SELECT c2, c3 FROM t1 WHERE ((c3 = (c0)) AND (1592972218101984383 OR (-3838296295401480336))) ORDER BY c2 ASC;
ORDER BY c2 ASC;
+-------------+-------+
| c2 | c3 |
+-------------+-------+
| Jrh | false |
| D:<]u | false |
|
h1
j | false |
+-------------+-------+
3 rows in set (0.010 sec)
Expected behavior
Both the materialized table and the view should return the same results.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the SQL reproduction against OceanBase 5.7.25-OceanBase_CE-v4.2.1.9, comparing the materialized table and view queries that use LIKE, logical conditions, and ORDER BY. Trace the differing execution paths for the materialized table and view. Done means both forms return the same rows for the supplied case and a regression test covers it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100