Re: Allow escape in application_name

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: masao(dot)fujii(at)oss(dot)nttdata(dot)com
Cc: kuroda(dot)hayato(at)fujitsu(dot)com, houzj(dot)fnst(at)fujitsu(dot)com, ikedamsh(at)oss(dot)nttdata(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us
Subject: Re: Allow escape in application_name
Date: 2021-10-12 06:42:23
Message-ID: 20211012.154223.1079581962882569218.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Tue, 12 Oct 2021 15:06:11 +0900 (JST), Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> wrote in
> "%4%5%6%7p" is converted to "57p". Do we need to imitate that bug
> with this patch?

So.. I try to describe the behavior for exhaustive patterns..

current:
A. "^-?[0-9]+.*" : returns valid padding. p goes after the last digit.
B. "^[^0-9-].*" : padding = 0, p doesn't advance.
C. "^-[^0-9].*" : padding = 0, p advances by 1 byte.
D. "^-" : padding = 0, p advances by 1 byte.
(if *p == 0 then breaks)

I think the patterns covers the all possibilities.

If we code as the following:
if (*p == '-' ? isdigit(p[1]) : isdigit(p[0]))
{
char *endptr;
padding = strtol(p, &endptr, 10);
Assert(endptr > p);
if (*endptr == '\0')
break;
p = endptr;
}
else
padding = 0;

A. "^-?[0-9]+.*" : same to the current
B. "^[^0-9-].*" : same to the current
C. "^-[^0-9].*" : padding = 0, p doesn't advance.
D. "^-" : padding = 0, p doesn't advance.

If we wan to make the behaviors C and D same with the current, the
else clause should be like the follows, but I don't think we need to
do that.

else
{
padding = 0;
if (*p == '-')
p++;
}

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-10-12 06:46:07 Re: Accommodate startup process in a separate ProcState array slot instead of in MaxBackends slots.
Previous Message Bharath Rupireddy 2021-10-12 06:40:39 Re: Reword docs of feature "Remove temporary files after backend crash"