Re: [PATCH] Add function to_oct

From: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Kirk Wolak <wolakk(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Eric Radman <ericshane(at)eradman(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Add function to_oct
Date: 2023-08-17 05:35:54
Message-ID: CAFBsxsEVR_M4_eGgP_zdugerq8iTUHeVJP-DBRj7yPh2xcuh4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 16, 2023 at 9:24 PM Nathan Bossart <nathandbossart(at)gmail(dot)com>
wrote:
>
> On Wed, Aug 16, 2023 at 10:35:27AM +0700, John Naylor wrote:

> > Now I'm struggling to understand why each and every instance has its own
> > nominal buffer, passed down to the implementation. All we care about is
the
> > result -- is there some reason not to confine the buffer declaration to
the
> > general implementation?
>
> We can do that if we use a static variable, which is what I've done in v6.

That makes it a lexically-scoped global variable, which we don't need
either. Can we have the internal function allocate on the stack, then
call cstring_to_text() on that, returning the text result? That does its
own palloc.

Or maybe better, save the starting pointer, compute the length at the end,
and call cstring_to_text_with_len()? (It seems we wouldn't need
the nul-terminator then, either.)

--
John Naylor
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Luzanov 2023-08-17 05:37:28 Re: PG 16 draft release notes ready
Previous Message Michael Paquier 2023-08-17 05:22:13 Re: New WAL record to detect the checkpoint redo location