Re: Understanding Datum - Mailing list pgsql-general

From rsmogura
Subject Re: Understanding Datum
Date
Msg-id e4f370d4495d809dda357c95621c444c@mail.softperience.eu
Whole thread Raw
In response to Re: Understanding Datum  (Nick Raj <nickrajjain@gmail.com>)
List pgsql-general
 On Thu, 24 Mar 2011 10:50:32 +0530, Nick Raj wrote:
> If Datum contains only the value (not having type specific info.),
> then
> Suppose i want to print the Datum V value (already defined in
> postgres)
> then printf("%??", V);
>
> Because V is assigned by PG_GETARG_POINTER(1);
>  I dont having the information of type Datum.
>
> How to print the value of Datum in postgres?
>
> On Thu, Mar 24, 2011 at 2:35 AM, Tom Lane  wrote:
>
>> Nick Raj writes:
>> > In postgres, typedef uintptr_t Datum
>> > Datum is getting value from PG_GETARG_POINTER(1);
>> > But, now problem is how would i know the type of
>> PG_GETARG_POINTER(1)
>> > (postgres internally pass this argument) to figure out datum
>> type?
>>
>> Datum does not carry any type information, only a value.
>>  Functions are
>> typically coded to know their input types a priori.  If you want
>> to
>> write code that is not type-specific then youd better be passing
>> around
>> type OIDs as well as values.
>>
>>                        regards, tom lane
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general@postgresql.org
>> [2])
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general [3]
>
>
>
> Links:
> ------
> [1] mailto:nickrajjain@gmail.com
> [2] mailto:pgsql-general@postgresql.org
> [3] http://www.postgresql.org/mailpref/pgsql-general
> [4] mailto:tgl@sss.pgh.pa.us

 You may only find this from code context. Bear in mind, in simple
 words, datum is like void* with additional size header.

 If You write C function you now what kind of datum will income, and
 what should outcome (You declare this!). If you examine table, it's same
 situation, but You need ask system for this. Even if PG will have type
 bytes in Datum, PG supports custom types...

 If you wan't to operate on datums You can't work in a way take some
 datum and work on it.

 You need to obtain /context/, by getting what type tables has on column
 x, what type of results function will return, etc; You need to know from
 where Your datum income.

pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Database recovery.
Next
From: Erik Hesselink
Date:
Subject: Deadlock in libpq