Re: Support a wildcard in backtrace_functions

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Support a wildcard in backtrace_functions
Дата
Msg-id 202403051911.trwlk7ct7cgl@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: Support a wildcard in backtrace_functions  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Ответы Re: Support a wildcard in backtrace_functions  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Список pgsql-hackers
On 2024-Mar-06, Bharath Rupireddy wrote:

> +1 for disallowing *foo or foo* or foo*bar etc. combinations.

Cool.

> I think we need to go a bit further and convert backtrace_functions of
> type GUC_LIST_INPUT so that check_backtrace_functions can just use
> SplitIdentifierString to parse the list of identifiers. Then, the
> strspn can just be something like below for each token:
> 
>         validlen = strspn(*tok,
>                         "0123456789_"
>                         "abcdefghijklmnopqrstuvwxyz"
>                         "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
> 
> Does anyone see a problem with it?

IIRC the reason it's coded as it is, is so that we have a single palloc
chunk of memory to free when the value changes; we purposefully stayed
away from SplitIdentifierString and the like.  What problem do you see
with the idea I proposed?  That was:

> On Thu, Feb 29, 2024 at 4:05 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

> > I think we should tighten this up: an asterisk should be allowed
> > only if it appears alone in the string (short-circuiting
> > check_backtrace_functions before strspn); and let's leave the
> > strspn() call alone.

That means, just add something like this at the top of
check_backtrace_functions and don't do anything to this function
otherwise (untested code):

    if (newval[0] == '*' && newval[1] == '\0')
    {
        someval = guc_malloc(ERROR, 2);
        if (someval == NULL)
            return false;
        someval[0] = '*';
        someval[1] = '\0';
        *extra = someval;
        return true;
    }

(Not sure if a second trailing \0 is necessary.)

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/
Voy a acabar con todos los humanos / con los humanos yo acabaré
voy a acabar con todos (bis) / con todos los humanos acabaré ¡acabaré! (Bender)



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

Предыдущее
От: Jacob Champion
Дата:
Сообщение: Re: Experiments with Postgres and SSL
Следующее
От: Bharath Rupireddy
Дата:
Сообщение: Re: Introduce XID age and inactive timeout based replication slot invalidation