Skip to content
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

Segfault when qual on view using expressions #5

Closed
rjuju opened this issue May 31, 2016 · 2 comments
Closed

Segfault when qual on view using expressions #5

rjuju opened this issue May 31, 2016 · 2 comments
Labels

Comments

@rjuju
Copy link
Member

rjuju commented May 31, 2016

Found with sqlsmith. Minimal test case to reproduce:

create table bug1 (id1 integer, val1 integer);
create table bug2 (id2 integer, val2 integer);
create view vbug as select id1, int4smaller(val1, val2) val12 from bug1 join bug2 on id1 = id2;
create table bug3 (id3 integer);
select * from vbug join bug3 on id3 = val12;

At least, pgqs_resolve_var() doesn't handle get_tle_by_resno() returning NULL.

@rjuju
Copy link
Member Author

rjuju commented Jun 2, 2016

After fixing this problem, it looks like there's also an infinite recursion in https://github.com/dalibo/pg_qualstats/blob/master/pg_qualstats.c#L1734 which isn't triggered by this simplified test case.

The original sqlsmith query raising both issue (on regression database) is:

select                  
  ref_33.nslots as c0
from 
  (select  
          74 as c0
        from 
          pg_catalog.pg_ts_parser as sample_0 tablesample system (6.4) 
        where 96 = 78
        limit 174) as subq_0
    left join regress_rls_schema.rls_tbl_force as ref_31
            inner join public.credit_usage as sample_28 tablesample system (5.3) 
            on (ref_31.c1 = sample_28.cid )
          inner join public.shoe_ready as ref_32
            right join public.hub as ref_33
            on (ref_32.total_avail = ref_33.nslots )
          on (sample_28.usage = ref_32.sh_avail )
        left join public.check_tbl as ref_34
          inner join pg_catalog.pg_class as sample_29 tablesample system (8.5) 
          on (ref_34.x = sample_29.relpages )
        on (ref_32.total_avail = ref_34.x )
      left join (select  
              ref_35.stuff as c0
            from 
              public.thethings as ref_35
            where public.max_xacttest() is not NULL
            limit 72) as subq_15
        inner join pg_catalog.pg_ts_config_map as sample_30 tablesample bernoulli (7.3) 
        on (subq_15.c0 = sample_30.maptokentype )
      on (ref_32.sl_avail = sample_30.maptokentype )
    on (subq_0.c0 = ref_34.x )
where ref_31.c1 >= sample_28.usage
limit 8;

@rdunklau
Copy link
Collaborator

rdunklau commented Aug 8, 2016

This should be fixed by dalibo@e0ddf70

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