From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | jbe-mlist(at)magnetkern(dot)de |
Subject: | BUG #18693: Column names not set when using SELECT STRICT INTO with RECORD type |
Date: | 2024-11-06 18:05:53 |
Message-ID: | 18693-65968418890877b4@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: 18693
Logged by: Jan Behrens
Email address: jbe-mlist(at)magnetkern(dot)de
PostgreSQL version: 16.4
Operating system: FreeBSD
Description:
I used the following SQL code:
CREATE TABLE tbl (a TEXT, b TEXT);
CREATE FUNCTION "buggy"() RETURNS VOID LANGUAGE plpgsql AS $$
DECLARE
t tbl%ROWTYPE;
r RECORD;
BEGIN
SELECT a, b INTO t FROM (SELECT 'A' AS a, 'B' AS b) AS q;
RAISE NOTICE 'non-strict t = %', t;
RAISE NOTICE 'non-strict t.a = %', t.a;
RAISE NOTICE 'non-strict t.b = %', t.b;
SELECT a, b STRICT INTO t FROM (SELECT 'A' AS a, 'B' AS b) AS q;
RAISE NOTICE 'STRICT t = %', t;
RAISE NOTICE 'STRICT t.a = %', t.a;
RAISE NOTICE 'STRICT t.b = %', t.b;
SELECT a, b INTO r FROM (SELECT 'A' AS a, 'B' AS b) AS q;
RAISE NOTICE 'non-strict r = %', r;
RAISE NOTICE 'non-strict r.a = %', r.a;
RAISE NOTICE 'non-strict r.b = %', r.b;
SELECT a, b STRICT INTO r FROM (SELECT 'A' AS a, 'B' AS b) AS q;
RAISE NOTICE 'STRICT r = %', r;
RAISE NOTICE 'STRICT r.a = %', r.a;
RAISE NOTICE 'STRICT r.b = %', r.b;
END;
$$;
SELECT buggy();
Invoking the buggy() function resulted in:
NOTICE: non-strict t = (A,B)
NOTICE: non-strict t.a = A
NOTICE: non-strict t.b = B
NOTICE: STRICT t = (A,B)
NOTICE: STRICT t.a = A
NOTICE: STRICT t.b = B
NOTICE: non-strict r = (A,B)
NOTICE: non-strict r.a = A
NOTICE: non-strict r.b = B
NOTICE: STRICT r = (A,B)
NOTICE: STRICT r.a = A
ERROR: record "r" has no field "b"
CONTEXT: SQL expression "r.b"
PL/pgSQL function buggy() line 21 at RAISE
I would expect the last statement to not result in an error but to correctly
access field "b" as in the non-strict case or tbl%ROWTYPE case.
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2024-11-06 20:48:50 | Re: BUG #18691: Turkish Character Encoding |
Previous Message | Jeff Davis | 2024-11-06 17:35:27 | 17: lc_collate_is_c() when LC_CTYPE != LC_COLLATE |