Skip to content

Equivalent view extraction retags UNION ALL constant 1 as a BIT(1) byte #288

Description

@123lpygithub

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions