public inbox for [email protected]  
help / color / mirror / Atom feed
Re: [PATCH] Simplify ExecWithoutOverlapsNotEmpty by removing unused parameter
2+ messages / 2 participants
[nested] [flat]

* Re: [PATCH] Simplify ExecWithoutOverlapsNotEmpty by removing unused parameter
@ 2026-02-24 22:42  Chao Li <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Chao Li @ 2026-02-24 22:42 UTC (permalink / raw)
  To: zengman <[email protected]>; +Cc: pgsql-hackers <[email protected]>



> On Feb 24, 2026, at 23:09, zengman <[email protected]> wrote:
> 
> Hi all,
> 
> I noticed that ExecWithoutOverlapsNotEmpty() accepts an atttypid parameter that isn't actually used. The function only needs typtype to distinguish between range and multirange types.
> Currently lookup_type_cache() is called just to extract typtype, but I think using get_typtype() directly seems more appropriate.
> 
> ```
> static void ExecWithoutOverlapsNotEmpty(Relation rel, NameData attname, Datum attval,
> -                                                                               char typtype, Oid atttypid);
> +                                                                               char typtype);
> 
> /* ----------------------------------------------------------------
>  *             ExecOpenIndices
> @@ -753,11 +754,10 @@ check_exclusion_or_unique_constraint(Relation heap, Relation index,
>                {
>                        TupleDesc       tupdesc = RelationGetDescr(heap);
>                        Form_pg_attribute att = TupleDescAttr(tupdesc, attno - 1);
> -                       TypeCacheEntry *typcache = lookup_type_cache(att->atttypid, 0);
> 
>                        ExecWithoutOverlapsNotEmpty(heap, att->attname,
>                                                                                values[indnkeyatts - 1],
> -                                                                               typcache->typtype, att->atttypid);
> +                                                                               get_typtype(att->atttypid));
>                }
>        }
> 
> @@ -1149,7 +1149,7 @@ index_expression_changed_walker(Node *node, Bitmapset *allUpdatedCols)
>  * range or multirange in the given attribute.
>  */
> static void
> -ExecWithoutOverlapsNotEmpty(Relation rel, NameData attname, Datum attval, char typtype, Oid atttypid)
> +ExecWithoutOverlapsNotEmpty(Relation rel, NameData attname, Datum attval, char typtype)
> {
>        bool            isempty;
>        RangeType  *r;
> ```
> 
> --
> regards,
> Man Zeng<0001-refactor-Simplify-ExecWithoutOverlapsNotEmpty-functi.patch>

Removing the parameter atttypid from ExecWithoutOverlapsNotEmpty looks okay as it’s a static function and is only called once.

For the other change, I see a difference between lookup_type_cache and get_typtype, where lookup_type_cache never returns NULL but ereport(ERROR) when oid is invalid; while get_typtype will return ‘\0'. Though ExecWithoutOverlapsNotEmpty() will end up also elog(ERROR), the log message is changed.

I am not sure if there could be some edge cases where att->atttypid could be invalid. If yes, then this change will lead to a small behavior change.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/










^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [PATCH] Simplify ExecWithoutOverlapsNotEmpty by removing unused parameter
@ 2026-03-11 16:50  shihao zhong <[email protected]>
  parent: Chao Li <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: shihao zhong @ 2026-03-11 16:50 UTC (permalink / raw)
  To: Chao Li <[email protected]>; +Cc: zengman <[email protected]>; pgsql-hackers <[email protected]>

On Tue, Feb 24, 2026 at 5:43 PM Chao Li <[email protected]> wrote:
>
>
>
> > On Feb 24, 2026, at 23:09, zengman <[email protected]> wrote:
> >
> > Hi all,
> >
> > I noticed that ExecWithoutOverlapsNotEmpty() accepts an atttypid parameter that isn't actually used. The function only needs typtype to distinguish between range and multirange types.
> > Currently lookup_type_cache() is called just to extract typtype, but I think using get_typtype() directly seems more appropriate.
> >
> > ```
> > static void ExecWithoutOverlapsNotEmpty(Relation rel, NameData attname, Datum attval,
> > -                                                                               char typtype, Oid atttypid);
> > +                                                                               char typtype);
> >
> > /* ----------------------------------------------------------------
> >  *             ExecOpenIndices
> > @@ -753,11 +754,10 @@ check_exclusion_or_unique_constraint(Relation heap, Relation index,
> >                {
> >                        TupleDesc       tupdesc = RelationGetDescr(heap);
> >                        Form_pg_attribute att = TupleDescAttr(tupdesc, attno - 1);
> > -                       TypeCacheEntry *typcache = lookup_type_cache(att->atttypid, 0);
> >
> >                        ExecWithoutOverlapsNotEmpty(heap, att->attname,
> >                                                                                values[indnkeyatts - 1],
> > -                                                                               typcache->typtype, att->atttypid);
> > +                                                                               get_typtype(att->atttypid));
> >                }
> >        }
> >
> > @@ -1149,7 +1149,7 @@ index_expression_changed_walker(Node *node, Bitmapset *allUpdatedCols)
> >  * range or multirange in the given attribute.
> >  */
> > static void
> > -ExecWithoutOverlapsNotEmpty(Relation rel, NameData attname, Datum attval, char typtype, Oid atttypid)
> > +ExecWithoutOverlapsNotEmpty(Relation rel, NameData attname, Datum attval, char typtype)
> > {
> >        bool            isempty;
> >        RangeType  *r;
> > ```
> >
> > --
> > regards,
> > Man Zeng<0001-refactor-Simplify-ExecWithoutOverlapsNotEmpty-functi.patch>
>
> Removing the parameter atttypid from ExecWithoutOverlapsNotEmpty looks okay as it’s a static function and is only called once.
>
> For the other change, I see a difference between lookup_type_cache and get_typtype, where lookup_type_cache never returns NULL but ereport(ERROR) when oid is invalid; while get_typtype will return ‘\0'. Though ExecWithoutOverlapsNotEmpty() will end up also elog(ERROR), the log message is changed.
>
> I am not sure if there could be some edge cases where att->atttypid could be invalid. If yes, then this change will lead to a small behavior change.
>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
>
>
>
>

That patch looks good to me.

Thanks,
Shihao





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-03-11 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-02-24 22:42 Re: [PATCH] Simplify ExecWithoutOverlapsNotEmpty by removing unused parameter Chao Li <[email protected]>
2026-03-11 16:50 ` shihao zhong <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox