Re: DETOAST Datum

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Nick Raj <nickrajjain(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: DETOAST Datum
Date: 2011-05-16 13:51:30
Message-ID: BANLkTikCjKhKn-HUA1hGzWvLn02GO7Pn8Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 16, 2011 at 3:41 AM, Nick Raj <nickrajjain(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-05-16 14:22:06 Re: DETOAST Datum
Previous Message Robert Haas 2011-05-16 13:45:14 Re: Extensions in schemas