Skip to content

RuntimeAppend returns garbage when left join and where used #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dimarick opened this issue May 16, 2017 · 2 comments
Closed

RuntimeAppend returns garbage when left join and where used #91

dimarick opened this issue May 16, 2017 · 2 comments
Assignees
Labels
Milestone

Comments

@dimarick
Copy link

dimarick commented May 16, 2017

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

@dimarick dimarick changed the title RuntimeAppend returns trash when left join and where used RuntimeAppend returns garbage when left join and where used May 16, 2017
@funbringer funbringer added the bug label May 16, 2017
@funbringer funbringer self-assigned this May 16, 2017
@funbringer funbringer added this to the Release 1.4 milestone May 16, 2017
@funbringer
Copy link
Collaborator

Hi @dimarick,

We're investigating the problem you've reported. As a temporary workaround, you can disable RuntimeAppend using:

alter system set pg_pathman.enable_runtimeappend = f;

and reload PostgreSQL's config (via pg_ctl reload).

Our current dev branch (rel_future_beta) is not affected, which means that we've already fixed this, but it might be hard to backport this fix to master. I'll tell the details later.

funbringer added a commit to funbringer/pg_pathman that referenced this issue May 25, 2017
@funbringer
Copy link
Collaborator

Version 1.4 is out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants