Re: texteq/byteaeq: avoid detoast [REVIEW] - Mailing list pgsql-hackers

From Noah Misch
Subject Re: texteq/byteaeq: avoid detoast [REVIEW]
Date
Msg-id 20110116224738.GD4600@tornado.leadboat.com
Whole thread Raw
In response to Re: texteq/byteaeq: avoid detoast [REVIEW]  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: texteq/byteaeq: avoid detoast [REVIEW]
List pgsql-hackers
On Sun, Jan 16, 2011 at 10:07:13PM +0100, Pavel Stehule wrote:
> I think, so we can have a function or macro that compare a varlena
> sizes. Some like
> 
> Datum texteq(..)
> {
>      if (!datumsHasSameLength(PG_GETARG_DATUM(0), PG_GETARG_DATUM(1))
>         PG_RETURN_FALSE();
> 
>      ... actual code ..
> }

Good point.  Is this something that would be useful many places?  One thing that
bugged me slightly writing this patch is that texteq, textne, byteaeq and
byteane all follow the same pattern rather tightly.  (Indeed, I think one could
easily implement texteq and byteaeq with the exact same C function.)  I like how
we handle this for tsvector (see TSVECTORCMPFUNC in tsvector_op.c) to avoid the
redundancy.  If datumHasSameLength would mainly apply to these four functions or
ones very similar to them, maybe we should abstract out the entire function body
like we do for tsvector?

A topic for a different patch in any case, I think.


pgsql-hackers by date:

Previous
From: Marti Raudsepp
Date:
Subject: Re: auto-sizing wal_buffers
Next
From: Robert Haas
Date:
Subject: Re: limiting hint bit I/O