Re: ERROR: index row size

Поиск
Список
Период
Сортировка
От Jeremy Drake
Тема Re: ERROR: index row size
Дата
Msg-id Pine.BSO.4.64.0706032014370.8873@resin.csoft.net
обсуждение исходный текст
Ответ на ERROR: index row size  ("Rodrigo Sakai" <rodrigo.sakai@poli.usp.br>)
Ответы Re: ERROR: index row size  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: ERROR: index row size  ("Rodrigo Sakai" <rodrigo.sakai@poli.usp.br>)
Список pgsql-hackers
Just glancing at this, a couple things stand out to me:

On Mon, 4 Jun 2007, Rodrigo Sakai wrote:

> Datum
> periodo_in(PG_FUNCTION_ARGS)
> {
>     char    *str = PG_GETARG_CSTRING(0);
>     char    tvi_char[MAXDATEFIELDS];
>     char    tvf_char[MAXDATEFIELDS];
>
>     tvi_char = (char *) palloc(strlen(MAXDATEFIELDS));

What are you doing here?  This is completely broken.  I think you meant to
say:

char *tvi_char;

tvi_char = palloc(MAXDATEFIELDS);

Or:

char tvi_char[MAXDATEFIELDS];

and no palloc.

>     tvf_char = (char *) palloc(strlen(MAXDATEFIELDS));

Same as above.

>
>     Periodo     *result;
>
>     if (sscanf(str, " ( %s , %s )", tvi_char, tvf_char) != 2)

This is asking for trouble if arbitrary input can be fed to this.

>         ereport(ERROR,
>             (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
>             errmsg("invalid input syntax for periodo: \"%s\"", str)));
>
>     result->tvi = StringToDateADT(tvi_char);
>     result->tvi = StringToDateADT(tvf_char);
>
>     result = (Periodo *) palloc(sizeof(Periodo));
>
>     if (result->tvi > result->tvf)
>         ereport(ERROR,
>                 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
>                 errmsg("Initial date (TVi) must be smaller than final date
> (TVf)")));
>
>     PG_RETURN_POINTER(result);
> }
>
>   Please help me!
>
>   Thanks in advance!

Hope this helps.

-- 
My love, he's mad, and my love, he's fleet,And a wild young wood-thing bore him!
The ways are fair to his roaming feet,And the skies are sunlit for him.
As sharply sweet to my heart he seemsAs the fragrance of acacia.
My own dear love, he is all my dreams --And I wish he were in Asia.    -- Dorothy Parker


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Rodrigo Sakai"
Дата:
Сообщение: ERROR: index row size
Следующее
От: Tom Lane
Дата:
Сообщение: Re: What is happening on buildfarm member baiji?