Re: [PATCH] Add function to_oct

Поиск
Список
Период
Сортировка
От Nathan Bossart
Тема Re: [PATCH] Add function to_oct
Дата
Msg-id 20230820151937.GA290672@nathanxps13
обсуждение исходный текст
Ответ на Re: [PATCH] Add function to_oct  (John Naylor <john.naylor@enterprisedb.com>)
Список pgsql-hackers
On Sat, Aug 19, 2023 at 11:41:56AM +0700, John Naylor wrote:
> This looks nicer, but still doesn't save the starting pointer, and so needs
> to lug around that big honking macro. This is what I mean:
> 
> static inline text *
> convert_to_base(uint64 value, int base)
> {
>   const char *digits = "0123456789abcdef";
>   /* We size the buffer for to_binary's longest possible return value. */
>   char    buf[sizeof(uint64) * BITS_PER_BYTE];
>   char     * const end =  buf + sizeof(buf);
>   char     *ptr = end;
> 
>   Assert(base > 1);
>   Assert(base <= 16);
> 
>   do
>   {
>     *--ptr = digits[value % base];
>     value /= base;
>   } while (ptr > buf && value);
> 
>   return cstring_to_text_with_len(ptr,  end - ptr);
> }

I will use this in v8.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PostgreSQL 16 RC1 + GA release dates
Следующее
От: Masahiko Sawada
Дата:
Сообщение: Re: [PoC] pg_upgrade: allow to upgrade publisher node