Bug in sub-query

From: Veeranjaneya Vara Prasad Peddireddy <varaprasad(dot)peddireddy(at)valuelabs(dot)com>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Bug in sub-query
Date: 2025-12-12 10:59:25
Message-ID: BMXPR01MB36873720906F9A703D235C37EFAEA@BMXPR01MB3687.INDPRD01.PROD.OUTLOOK.COM
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Team,

I have observed one bug in postgres

How to reproduce:

create table admin.emp (sno integer,name varchar(100),location_id_location integer);

create table admin.emp_dimension (dim_id integer,employee_name varchar(100),location_id integer);

insert into admin.emp select 1,'vara',108;
insert into admin.emp select 2,'saasthra',108;

insert into admin.emp_dimension select 1,'varaprasad',108;
insert into admin.emp_dimension select 2,'saasthra peddireddy',108;

--query 1:
select * from admin.emp_dimension where location_id_location=108;
--Note: it failed because "ERROR: column "location_id_location" does not exist

--query 2:
select * from admin.emp where location_id_location=108
and sno in (select dim_id from admin.emp_dimension where location_id_location=108)
--Note2: it returned two records and no error given.
--But if you observe above query 2; the sub-query is not correct. In sub-query; location_id_location is not present in table admin.emp_dimension. But same sub-query failed in query 1.

select version()--

"PostgreSQL 16.8 on x86_64-pc-linux-gnu, compiled by x86_64-pc-linux-gnu-gcc (GCC) 10.5.0, 64-bit"

The issue is present in other versions as well. Please check and fix it.

From ,
Vara Prasad
+91 9951074005
India,
Hyderabad,

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Álvaro Herrera 2025-12-12 15:01:53 Re: Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem.
Previous Message yanliang lei 2025-12-12 10:23:24 Re:Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem.