StringInfo misc. issues

Поиск
Список
Период
Сортировка
От NikhilS
Тема StringInfo misc. issues
Дата
Msg-id d3c4af540708290740m2ac46220k608bd96b409f4c6c@mail.gmail.com
обсуждение исходный текст
Ответы Re: StringInfo misc. issues  (Andrew Dunstan <andrew@dunslane.net>)
Re: StringInfo misc. issues  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

I palloc0'ed a variable of type StringInfo and without doing an initStringInfo() (forgot to do it i.e.) tried to append some stuff to it using appendStringInfo(). It went into a tight loop within the function enlargeStringInfo() at:

while (needed > newlen)

Must be a common enough case for a palloc0'ed field right?

The attached patch should fix this.

*** 226,232 ****
!       if (needed < 0 ||
                ((Size) needed) >= (MaxAllocSize - (Size) str->len))
                elog(ERROR, "invalid string enlargement request size %d",
                         needed);
--- 226,232 ----
!       if (needed <= 0 ||
                ((Size) needed) >= (MaxAllocSize - (Size) str->len))
                elog(ERROR, "invalid string enlargement request size %d",
                         needed);

I also found the absence of a function like resetStringInfo() a bit puzzling. A found a lot of places where the code was resetting the "len" field to 0 and assigning '\0' to the data field to reset the variable. This seems to be the only missing API which will be needed while working with the StringInfo type.

Regards,
Nikhils

--
EnterpriseDB               http://www.enterprisedb.com
Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Dictionary chaining and stop words
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: Dictionary chaining and stop words