Re: [PATCH] Add function to_oct
John Naylor <john.naylor@enterprisedb.com>
From: John Naylor <john.naylor@enterprisedb.com>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Kirk Wolak <wolakk@gmail.com>,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Eric Radman <ericshane@eradman.com>, pgsql-hackers@postgresql.org
Date: 2023-08-17T05:35:54Z
Lists: pgsql-hackers
On Wed, Aug 16, 2023 at 9:24 PM Nathan Bossart <nathandbossart@gmail.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
Commits
-
Add to_bin() and to_oct().
- 260a1f18dae8 17.0 landed