Remove post-increment in function quote_identifier of pg_upgrade

Поиск
Список
Период
Сортировка
От Vaibhav Dalvi
Тема Remove post-increment in function quote_identifier of pg_upgrade
Дата
Msg-id CA+vB=AHVLrO=Pgr-ZyJ_31+bK1pug5oapU0VbqTckpqLYEcd+g@mail.gmail.com
обсуждение исходный текст
Ответы Re: Remove post-increment in function quote_identifier of pg_upgrade
Список pgsql-hackers
Hi,

The function quote_identifier has extra post-increment operation as highlighted below,

char *
quote_identifier(const char *s)
{
   char   *result = pg_malloc(strlen(s) * 2 + 3);
   char   *r = result;

   *r++ = '"';
   while (*s)
   {
      if (*s == '"')
      *r++ = *s;
      *r++ = *s;
      s++;
   }
   *r++ = '"';
   *r++ = '\0';

   return result;
}


I think *r = '\0' is enough here. Per precedence table the precedence of postfix increment operator is higher. The above statement increments 'r' pointer address but returns the original un-incremented pointer address, which is then dereferenced. Correct me if I am wrong here. 

If my understanding is correct then '++' is not needed in the above highlighted statement which is leading to overhead.

Find an attached patch which does the same. This can be backported till v96.

Thanks & Regards,
Vaibhav Dalvi
image.png

Вложения

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

Предыдущее
От: vignesh C
Дата:
Сообщение: Re: Replication slot stats misgivings
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Unresolved repliaction hang and stop problem.