Re: describe objects, as in pg_depend

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: describe objects, as in pg_depend
Дата
Msg-id 1290106326-sup-6018@alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: describe objects, as in pg_depend  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: describe objects, as in pg_depend  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
I just noticed that this is leaking a bit of memory, because we call
getObjectDescription (which pallocs its result) and then
cstring_to_text which pallocs a copy.  This is not a lot and it's not
going to live much anyway, is it worrying about?  I reworked it like
this:

{char       *description = NULL;text       *tdesc;
...
description = getObjectDescription(&address);tdesc = cstring_to_text(description);pfree(description);
PG_RETURN_TEXT_P(tdesc);
}

I notice that ruleutils.c has a convenience function string_to_text which is
designed to avoid this problem:

static text *
string_to_text(char *str)
{text       *result;
result = cstring_to_text(str);pfree(str);return result;
}

So I could just make that non-static (though I'd move it to varlena.c
while at it) and use that instead.

I wonder if it's worth going through some of the other callers of
cstring_to_text and change them to use this wrapper.  There are some
that are leaking some memory, though it's a tiny amount and I'm not
sure it's worth the bother.  (But if so, why is ruleutils going the
extra mile?)

-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: final patch - plpgsql: for-in-array
Следующее
От: Greg Stark
Дата:
Сообщение: Re: Indent authentication overloading