polardb / polardb/polardbx-sql
Equivalent view extraction retags `UNION ALL` constant `1` as a `BIT(1)` byte
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 337
- PR merge metrics
- No merged PRs in 30d
Description
Under semantic-equivalent rewriting, the source and mutated queries are logically equivalent, but produce different results in polardbx-sql.
Summary: when an empty first UNION ALL arm has type BIT(1), moving the second arm into a view changes integer constant 1 into byte string 0x01.
version: 5.4.19-SNAPSHOT
How to repeat:
DROP DATABASE IF EXISTS t1;
CREATE DATABASE t1;
USE t1;
CREATE TABLE t2 (
c12 BIT(1)
);
-- Source Original SQL
SELECT c12 AS col1 FROM t2 WHERE 1=0
UNION ALL
SELECT 1 AS col1;
-- View SQL
CREATE VIEW V AS
SELECT 1 AS col1;
-- Mutated SQL
SELECT c12 AS col1 FROM t2 WHERE 1=0
UNION ALL
SELECT col1 FROM V;
Observed result - Query A (original):
| col1 |
|---|
| 1 |
Observed result - Query B (mutated):
| col1 |
|---|
\x01 |
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 supplied polardbx-sql reproduction with the original UNION ALL query and the view-based query, then trace the semantic-equivalent rewriting and type handling for the empty BIT(1) arm. Done means both queries return integer 1 rather than converting the view result to the byte string 0x01.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100