Обсуждение: heap_form_tuple crashing

Поиск
Список
Период
Сортировка

heap_form_tuple crashing

От
Atri Sharma
Дата:
Hi all,

I am trying to call heap_form_tuple to create a tuple from a datum.

My call to heap_form_tuple looks like:


val1=0;
tupledesc1=BlessTupleDesc(node->ss.ss_currentRelation->rd_att);
tuple=heap_form_tuple(tupledesc1,p1,&val1);


p1 is a pointer to a Datum instance which is created from a char array.

When I am running the code,the system is crashing.

Please let me know what can the problem be and also what I should do
to rectify it.

Atri
-- 
Regards,

Atri
l'apprenant


Re: heap_form_tuple crashing

От
Heikki Linnakangas
Дата:
On 31.05.2012 13:42, Atri Sharma wrote:
> I am trying to call heap_form_tuple to create a tuple from a datum.
>
> My call to heap_form_tuple looks like:
>
>
> val1=0;
> tupledesc1=BlessTupleDesc(node->ss.ss_currentRelation->rd_att);
> tuple=heap_form_tuple(tupledesc1,p1,&val1);
>
>
> p1 is a pointer to a Datum instance which is created from a char array.
>
> When I am running the code,the system is crashing.
>
> Please let me know what can the problem be and also what I should do
> to rectify it.

Hard to say without seeing the full code...

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


Re: heap_form_tuple crashing

От
Atri Sharma
Дата:
On Thu, May 31, 2012 at 5:02 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:
> On 31.05.2012 13:42, Atri Sharma wrote:
>>
>> I am trying to call heap_form_tuple to create a tuple from a datum.
>>
>> My call to heap_form_tuple looks like:
>>
>>
>> val1=0;
>> tupledesc1=BlessTupleDesc(node->ss.ss_currentRelation->rd_att);
>> tuple=heap_form_tuple(tupledesc1,p1,&val1);
>>
>>
>> p1 is a pointer to a Datum instance which is created from a char array.
>>
>> When I am running the code,the system is crashing.
>>
>> Please let me know what can the problem be and also what I should do
>> to rectify it.
>
>
> Hard to say without seeing the full code...
>
> --
>  Heikki Linnakangas
>  EnterpriseDB   http://www.enterprisedb.com

Hi Heikki,

Thanks for the reply.

Another thing I wanted to ask was that would you recommend building
tuples from strings directly or converting them to Datum first and
then build the tuples from Datum instances?

Atri
--
Regards,

Atri
l'apprenant


Re: heap_form_tuple crashing

От
Heikki Linnakangas
Дата:
On 31.05.2012 14:42, Atri Sharma wrote:
> Another thing I wanted to ask was that would you recommend building
> tuples from strings directly or converting them to Datum first and
> then build the tuples from Datum instances?

It depends. If you have all the values in strings already, then 
BuildTupleFromCStrings() is probably the easiest. But if you have some 
attributes in Datum format already, then it's probably easier and faster 
to use heap_form_tuple().

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


Re: heap_form_tuple crashing

От
Atri Sharma
Дата:
On Thu, May 31, 2012 at 5:14 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:
> On 31.05.2012 14:42, Atri Sharma wrote:
>>
>> Another thing I wanted to ask was that would you recommend building
>> tuples from strings directly or converting them to Datum first and
>> then build the tuples from Datum instances?
>
>
> It depends. If you have all the values in strings already, then
> BuildTupleFromCStrings() is probably the easiest. But if you have some
> attributes in Datum format already, then it's probably easier and faster to
> use heap_form_tuple().
>
>
> --
>  Heikki Linnakangas
>  EnterpriseDB   http://www.enterprisedb.com

Performance wise,which one would be better(I am envisioning a large
set of strings to be converted to tuples)....?


--
Regards,

Atri
l'apprenant


Re: heap_form_tuple crashing

От
Tom Lane
Дата:
Atri Sharma <atri.jiit@gmail.com> writes:
> My call to heap_form_tuple looks like:
> val1=0;
> tupledesc1=BlessTupleDesc(node->ss.ss_currentRelation->rd_att);
> tuple=heap_form_tuple(tupledesc1,p1,&val1);

> p1 is a pointer to a Datum instance which is created from a char array.

Does that actually match the tupdesc you're using?  Are you sure you
created the Datum correctly (ie, did you call the appropriate datatype
input routine)?

BTW, the BlessTupleDesc call here seems to be pure cargo-cult
programming.  It should not be necessary to bless a relation's tupdesc
(because that should be a named type already); and even if it were,
heap_form_tuple doesn't care.
        regards, tom lane


Re: heap_form_tuple crashing

От
Atri Sharma
Дата:
On Thu, May 31, 2012 at 7:01 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Atri Sharma <atri.jiit@gmail.com> writes:
>> My call to heap_form_tuple looks like:
>> val1=0;
>> tupledesc1=BlessTupleDesc(node->ss.ss_currentRelation->rd_att);
>> tuple=heap_form_tuple(tupledesc1,p1,&val1);
>
>> p1 is a pointer to a Datum instance which is created from a char array.
>
> Does that actually match the tupdesc you're using?  Are you sure you
> created the Datum correctly (ie, did you call the appropriate datatype
> input routine)?
>
> BTW, the BlessTupleDesc call here seems to be pure cargo-cult
> programming.  It should not be necessary to bless a relation's tupdesc
> (because that should be a named type already); and even if it were,
> heap_form_tuple doesn't care.
>
>                        regards, tom lane

Hi Tom,

Thanks for the advice and help.Your diagnosis is correct,I used the
correct datatype input routine and it worked like a charm.

I will remove the calls to BlessTupleDesc then?

Atri

--
Regards,

Atri
l'apprenant