Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

RuntimeAppend returns garbage when left join and where used #91

Closed
Assignees
Labels
Milestone
@dimarick

Description

Schema and data:

create table parent (
 id SERIAL NOT NULL,
 owner_id INTEGER NOT NULL
);
create table child (
 parent_id INTEGER NOT NULL,
 owner_id INTEGER NOT NULL
);
create table child_nopart (
 parent_id INTEGER NOT NULL,
 owner_id INTEGER NOT NULL
);
insert into parent (owner_id) values (1), (2), (3), (3);
insert into child (parent_id, owner_id) values (1, 1), (2, 2), (3, 3), (5, 3);
insert into child_nopart (parent_id, owner_id) values (1, 1), (2, 2), (3, 3), (5, 3);
select create_hash_partitions('child', 'owner_id', 2);

The select SQL to reproduce:

select *
 from parent
 left join child on child.parent_id = parent.id and child.owner_id = parent.owner_id
 where parent.owner_id = 3 and parent.id in (3, 4);

Actual result:

id	owner_id	parent_id	owner_id
3	3		3		3
3	3		5		3
4	3		3		3
4	3		5		3

https://explain.depesz.com/s/ioD5K

All of this will work as expected:

select *
 from parent
 left join child on child.parent_id = parent.id and child.owner_id = 3
 where parent.owner_id = 3 and parent.id in (3, 4);
select *
 from parent
 left join child_1 child on child.parent_id = parent.id and child.owner_id = parent.owner_id
 where parent.owner_id = 3 and parent.id in (3, 4);
select *
 from parent
 left join child_nopart child on child.parent_id = parent.id and child.owner_id = parent.owner_id
 where parent.owner_id = 3 and parent.id in (3, 4);
select *
 from parent
 left join child on child.parent_id = parent.id and child.owner_id = parent.owner_id
 where parent.owner_id = 3;

Result:

id	owner_id	parent_id	owner_id
3	3		3		3
4	3		<null>		<null>

Affected version 1.3.2

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    AltStyle によって変換されたページ (->オリジナル) /