BUG #17364: Errors caused by views - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #17364: Errors caused by views
Date
Msg-id 17364-3072d21ebb3da224@postgresql.org
Whole thread Raw
Responses Re: BUG #17364: Errors caused by views
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17364
Logged by:          ERROR: invalid value "erro" for "YYYY"
Email address:      1165125080@qq.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.


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #17363: 14 regression: "could not identify a hash function for type record" in a nested record in sublink
Next
From: Timur Khanjanov
Date:
Subject: Re: wrong output in dump of rules with old values of row type columns