> > 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 Andy Fan (https://www.aliyun.com/)