BUG #19969: Result inconsistency with scale() over an INTERSECT subquery

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: enjolras_k(at)outlook(dot)com
Subject: BUG #19969: Result inconsistency with scale() over an INTERSECT subquery
Date: 2026-12-02 08:24:27
Message-ID: 19969-70d2b9f1bb47182d@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19969
Logged by: Xiaoyuan Xie
Email address: enjolras_k(at)outlook(dot)com
PostgreSQL version: 19.0
Operating system: Ubuntu Linux, x86_64
Description:

Hi,

On PostgreSQL 19.0, I observed different results for an
INTERSECT query and its explicitly materialized version.
I expected the two queries to return the same count, but
they return 0 and 1 respectively.

CREATE TABLE a(v numeric);
CREATE TABLE b(v numeric);
INSERT INTO a VALUES (1);
INSERT INTO b VALUES (1.0);

SELECT count(*)
FROM (
SELECT v FROM a
INTERSECT
SELECT v FROM b
) q
WHERE scale(v) = 0;
-- Actual: 0

WITH q AS MATERIALIZED (
SELECT v FROM a
INTERSECT
SELECT v FROM b
)
SELECT count(*) FROM q WHERE scale(v) = 0;
-- Actual: 1

Reproduced on PostgreSQL 19.0, built from the unmodified
official source release, on Ubuntu Linux x86_64.

Could you confirm whether this difference is expected?

Thank you.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Raja Sai pranav 2026-12-02 08:49:21 Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance
Previous Message Zejiang Zhang 2026-12-02 08:19:54 Re: BUG #19958: jsonpath: a word directly followed by a /* comment */ is silently dropped, so strict becomes lax