Re: TODO Item - Return compressed length of TOAST datatypes

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Mark Kirkwood <markir(at)paradise(dot)net(dot)nz>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Neil Conway <neilc(at)samurai(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: TODO Item - Return compressed length of TOAST datatypes
Date: 2005-07-07 04:36:10
Message-ID: 200507070436.j674aAE13855@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


Patch applied. Thanks.

---------------------------------------------------------------------------

Mark Kirkwood wrote:
> Alvaro Herrera wrote:
> > On Thu, Jul 07, 2005 at 03:01:46PM +1200, Mark Kirkwood wrote:
> >
> >>Neil Conway wrote:
> >
> >
> >>>elog(ERROR) is usually used for "can't happen" errors.
> >>
> >>I have attached a little change to varlena.c that uses it. I left the
> >>ereport as it was, but am not fussed about it either way.
> >
> >
> > I am, because it gives useless messages to the translators to work on.
> > elog parameters are not marked for translation, ereport are (errmsg and
> > friends, really). So please don't do that.
> >
>
> Ok, didn't realize the difference! Revised patch attached that uses elog.
>
> Neil, I will runs some tests to see if there is any performance saving
> with the first-call-only business.
>
> Cheers
>
> Mark
>

> Index: src/backend/utils/adt/varlena.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/varlena.c,v
> retrieving revision 1.125
> diff -c -r1.125 varlena.c
> *** src/backend/utils/adt/varlena.c 6 Jul 2005 19:02:52 -0000 1.125
> --- src/backend/utils/adt/varlena.c 7 Jul 2005 03:40:44 -0000
> ***************
> *** 28,34 ****
> #include "utils/builtins.h"
> #include "utils/lsyscache.h"
> #include "utils/pg_locale.h"
> - #include "utils/syscache.h"
>
>
> typedef struct varlena unknown;
> --- 28,33 ----
> ***************
> *** 2364,2385 ****
> {
> /* On the first call lookup the datatype of the supplied argument */
> Oid argtypeid = get_fn_expr_argtype(fcinfo->flinfo, 0);
> ! HeapTuple tp;
> ! int typlen;
>
> ! tp = SearchSysCache(TYPEOID,
> ! ObjectIdGetDatum(argtypeid),
> ! 0, 0, 0);
> ! if (!HeapTupleIsValid(tp))
> {
> /* Oid not in pg_type, should never happen. */
> ! ereport(ERROR,
> ! (errcode(ERRCODE_INTERNAL_ERROR),
> ! errmsg("invalid typid: %u", argtypeid)));
> }
> !
> ! typlen = ((Form_pg_type)GETSTRUCT(tp))->typlen;
> ! ReleaseSysCache(tp);
> fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
> sizeof(int));
> *(int *)fcinfo->flinfo->fn_extra = typlen;
> --- 2363,2377 ----
> {
> /* On the first call lookup the datatype of the supplied argument */
> Oid argtypeid = get_fn_expr_argtype(fcinfo->flinfo, 0);
> ! int typlen = get_typlen(argtypeid);
>
> !
> ! if (typlen == 0)
> {
> /* Oid not in pg_type, should never happen. */
> ! elog(ERROR, "cache lookup failed for type %u", argtypeid);
> }
> !
> fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
> sizeof(int));
> *(int *)fcinfo->flinfo->fn_extra = typlen;
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-07-07 04:41:20 Re: [HACKERS] Mistake in latest plperl patch
Previous Message Mark Kirkwood 2005-07-07 04:34:18 Re: TODO Item - Return compressed length of TOAST datatypes