Re: DETOAST Datum - Mailing list pgsql-hackers

From Robert Haas
Subject Re: DETOAST Datum
Date
Msg-id BANLkTikCjKhKn-HUA1hGzWvLn02GO7Pn8Q@mail.gmail.com
Whole thread Raw
In response to DETOAST Datum  (Nick Raj <nickrajjain@gmail.com>)
Responses Re: DETOAST Datum  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Mon, May 16, 2011 at 3:41 AM, Nick Raj <nickrajjain@gmail.com> wrote:
> When i called my function, it gives NDBOX to be null
> On debugging, i found out ,FunctionInvokeCall invokes fmgr_oldstyle
> function, for getting argument
>
> if (fnextra->arg_toastable[i])    //this returns false, not able to get
> arguments
>             fcinfo->arg[i] =
> PointerGetDatum(PG_DETOAST_DATUM(fcinfo->arg[i]));
>     }
>
> "How to get arguments toastable??" and even my table pg_class.reltoastrelid
> entry is zero.

It's pretty hard to guess what's going wrong here from the information
you've provided.  But reltoastid should not be 0 if you're using a
variable-length data type.  It's not exactly clear what you've done
wrong though.  Are you sure that the type is defined properly, as a
variable-length type?

> Can i have to tell explicitly to toast?

No, you don't have to tell it that.

> If i commented that if conditions then, it got stuck below:
>
> struct varlena *
> pg_detoast_datum(struct varlena * datum)
> {
>     if (VARATT_IS_EXTENDED(datum))      //My code get stuck here
>         return heap_tuple_untoast_attr(datum);
>     else
>         return datum;
> }
>
> Can anyone tell me what VARATT_IS_EXTENDED(datum) mean?

VARATT_IS_EXTENDED() returns true for datums that can be detoasted,
because they are (1) they are stored out-of-line in the TOAST table,
(2) compressed, or (3) unaligned, using a 1-byte header.  See
src/include/postgres.h.  But I seriously doubt that you need to debug
pg_detoast_datum().  If you're getting a failure there, it's because
something wasn't done right much earlier on in the process.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Extensions in schemas
Next
From: Tom Lane
Date:
Subject: Re: DETOAST Datum