Jeremy Drake <pgsql@jdrake.com> writes:
>> char tvi_char[MAXDATEFIELDS];
>>
>> tvi_char = (char *) palloc(strlen(MAXDATEFIELDS));
> What are you doing here? This is completely broken.
Indeed ... *please* tell us your compiler issued a warning about that.
If not an error --- none of the compilers I use will take it at all.
Maybe you need to get a real C compiler.
>> result->tvi = StringToDateADT(tvi_char);
>> result->tvi = StringToDateADT(tvf_char);
>>
>> result = (Periodo *) palloc(sizeof(Periodo));
Well, you oughta allocate result before you store into it, not after,
and I bet you meant to assign to the tvi and tvf fields, not tvi twice.
Bad as these mistakes are, they don't directly explain why a later index
entry creation would fail. What I'm betting is that your CREATE TYPE
command does not correctly describe the datatype size. Based on this
code it should be pass-by-reference, fixed-size-8-bytes, but I'll bet
a nickel your CREATE TYPE says something else --- probably varlena.
regards, tom lane