From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: biazotogabriel@gmail.com
Subject: BUG #15244: Inherited table queries return null lines that do not exist
Date: Fri, 15 Jun 2018 21:23:41 +0000
Message-ID: <152909782124.24805.5442934323480694751@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 15244
Logged by: Gabriel Nuernberg Biazoto
Email address: biazotogabriel@gmail.com
PostgreSQL version: 10.4
Operating system: Windows 10 64bits
Description:
I was working with table inheritance and started having problems with my
queries.
I noticed that every time I perform a query on a parent table of an
inheritance and perform a query on any table then with more records than the
preceding table, postgres returns me rows with all records in null that do
not exist in the table that I'm consulting.
CREATE TABLE cfe (idcfe serial, fantasia varchar(30), datahora timestamp);
CREATE TABLE cli (tipo_cliente integer, situacao_praca integer) inherits
(cfe);
CREATE TABLE "for" (tipo_fornecedor integer, debito numeric(15,6)) inherits
(cfe);
alter table cfe add constraint pk_cfe primary key (idcfe);
CREATE TABLE cfe2 (idcfe serial, fantasia varchar(30), datahora
timestamp);
alter table cfe2 add constraint pk_cfe2 primary key (idcfe);
create table cli2 (idcfe serial, idcli serial, tipo_cliente integer,
situacao_praca integer);
alter table cli2 add constraint pk_cli2 primary key (idcfe, idcli);
create table for2 (idcfe serial, idfor serial, tipo_fornecedor integer,
debito numeric(15,6))
alter table for2 add constraint pk_for2 primary key (idcfe, idfor);
insert into cli (fantasia, datahora, tipo_cliente, situacao_praca)
"many records"
insert into "for" (fantasia, datahora, tipo_fornecedor, debito)
"many records"
insert into cfe2
"many records"
insert into cli2 (idcfe, tipo_cliente, situacao_praca)
"many records"
insert into for2 (idcfe, tipo_fornecedor, debito)
"many records"
select * from cfe2 (the data returns normal)
select * from cfe (the data returns normal)
select * from cfe2 (>>>>return rows with "null" records that do not exist in
table<<<<<)
From here any table queried that has many records will return the null lines
that do not exist.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, biazotogabriel@gmail.com
Subject: Re: BUG #15244: Inherited table queries return null lines that do not exist
In-Reply-To: <152909782124.24805.5442934323480694751@wrigleys.postgresql.org>
References: <152909782124.24805.5442934323480694751@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox