From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | marcus(at)cockroachlabs(dot)com |
Subject: | BUG #17398: Casts from BYTEA to TEXT and FLOAT4/8 to TEXT should not be immutable |
Date: | 2022-02-07 20:40:15 |
Message-ID: | 17398-8fb0c02a60e2e565@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 17398
Logged by: Marcus Gartner
Email address: marcus(at)cockroachlabs(dot)com
PostgreSQL version: 14.0
Operating system: macOS Monterey 12.2
Description:
Casts from BYTEA to TEXT should not be immutable because the result is
dependent on the bytea_output parameter. Casts from FLOAT4 and FLOAT8 to
TEXT should not be immutable because the result is dependent on the
extra_float_digits parameter. Incorrect results are possible because of
these incorrectly labeled cast volatilities. This bug is similar to BUG
#17371.
Example 1: BYTEA::TEXT
SET bytea_output = hex;
CREATE TABLE t (b BYTEA);
INSERT INTO t SELECT 'a' FROM generate_series(1, 10000) s(i);
INSERT INTO t VALUES ('b');
CREATE INDEX i ON t((b::TEXT), b);
SET bytea_output = escape;
-- Returns false.
SELECT b::TEXT = '\x62' FROM t WHERE b::TEXT = '\x62';
ANALYZE t;
-- Same query as above, now performing an index-only scan, returns true.
SELECT b::TEXT = '\x62' FROM t WHERE b::TEXT = '\x62';
DROP INDEX i;
-- Same query as above returns zero rows.
SELECT b::TEXT = '\x62' FROM t WHERE b::TEXT = '\x62';
Example 2: FLOAT::TEXT
SET extra_float_digits = 0;
CREATE TABLE t (f FLOAT);
INSERT INTO t SELECT 1 FROM generate_series(1, 10000) s(i);
INSERT INTO t VALUES (123.4567890123456789);
CREATE INDEX i ON t((f::TEXT), f);
SET extra_float_digits = 3;
-- Returns false.
SELECT f::TEXT = '123.456789012346' FROM t WHERE f::TEXT =
'123.456789012346';
ANALYZE t;
-- Same query as above, now performing an index-only scan, returns true.
SELECT f::TEXT = '123.456789012346' FROM t WHERE f::TEXT =
'123.456789012346';
DROP INDEX i;
-- Same query as above returns zero rows.
SELECT f::TEXT = '123.456789012346' FROM t WHERE f::TEXT =
'123.456789012346';
From | Date | Subject | |
---|---|---|---|
Next Message | Luis Díaz | 2022-02-08 00:15:49 | PSQL Client command line password leak when using Connection String |
Previous Message | PG Bug reporting form | 2022-02-07 15:32:39 | BUG #17396: Missing pckages to instal Patroni |