BUG #17364: Errors caused by views

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: 1165125080(at)qq(dot)com
Subject: BUG #17364: Errors caused by views
Date: 2022-01-12 15:53:31
Message-ID: 17364-3072d21ebb3da224@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: 17364
Logged by: ERROR: invalid value &quot;erro&quot; for &quot;YYYY&quot;
Email address: 1165125080(at)qq(dot)com
PostgreSQL version: 13.2
Operating system: centos
Description:

I run the following SQL statements on postgres13.2. They are simple, but an
error occurs.

create table test1 (id int, c_data varchar);
insert into test1 values (1, '201201');
insert into test1 values (2, 'error');

create table test2(id int, status varchar);
insert into test2 values (1, 'on');
insert into test2 values (2, 'off');

create view test_view as
SELECT test1.c_data
from test1 LEFT JOIN test2
ON (test2.id = test1.id)
WHERE (test2.status)::text = 'on'::text;

select * from test_view;
c_data
----------
20201101
(1 row)

select * from
(select to_date(c_data, 'YYYYMMDD') as date
from test_view) t1
where t1.date >= '2020 - 10 - 01':: TIMESTAMP;
ERROR: invalid value "erro" for "YYYY"
DETAIL: Value must be an integer.
` ` `
Obviously, the error data in the test table should not be displayed, but the
error data in the test table is displayed, which causes an error during SQL
execution.
It is hoped that the cause can be located and the problem can be rectified.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Timur Khanjanov 2022-01-12 16:59:52 Re: wrong output in dump of rules with old values of row type columns
Previous Message Tom Lane 2022-01-12 15:34:55 Re: BUG #17363: 14 regression: "could not identify a hash function for type record" in a nested record in sublink