Re: Keep notnullattrs in RelOptInfo (Was part of UniqueKey patch series) - Mailing list pgsql-hackers

From Andy Fan
Subject Re: Keep notnullattrs in RelOptInfo (Was part of UniqueKey patch series)
Date
Msg-id CAKU4AWqU=mpe72b7WvVL1Ub0WqxypWu4Th-Fk91qgSAV6AGN4A@mail.gmail.com
Whole thread Raw
In response to Re: Keep notnullattrs in RelOptInfo (Was part of UniqueKey patch series)  (Andy Fan <zhihui.fan1213@gmail.com>)
List pgsql-hackers


I assume we want to know if a Var is nullable with a function like. 
is_var_notnullable(Var *var,  Relids relids).  If so, we can define the data as below:

struct RelOptInfo {

Bitmapset** notnullattrs;
..
}; 

After this we can implement the function as: 

bool
is_var_notnullable(Var* var, Relids relids)
{
  RelOptInfo *rel = find_rel_by_relids(reldis);
  return bms_is_member(var->varattno, rel->notnullattrs[var->varno]);
}

Probably we can make some hackers to reduce the notnullattrs's memory usage
overhead.


To be more precise,  to make the rel->notnullattrs shorter, we can do the following methods:
1). Relids only has single element, we can always use a 1-len array rather than rel->varno
elements. 2).  For multi-elements relids, we use the max(varno) as the length of rel->notnullattrs.
3). For some cases,  the notnullattrs of a baserel is not changed in later stages, we can just
reuse the same Bitmapset * in later stages.   

--
Best Regards

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: multi-install PostgresNode fails with older postgres versions
Next
From: Michael Paquier
Date:
Subject: Re: DROP INDEX docs - explicit lock naming