Thread: Re: More CppAsString2() in psql's describe.c

Re: More CppAsString2() in psql's describe.c

From
Daniel Gustafsson
Date:
> On 28 Nov 2024, at 07:34, Michael Paquier <michael@paquier.xyz> wrote:
> 
> On Tue, Oct 22, 2024 at 09:49:10AM +0900, Michael Paquier wrote:
>> Note that there were a couple of value checks not part of the queries
>> that relied on values from the catalogs for some relpersistences and
>> replidents.  I've fixed them while on it.
>> 
>> Thoughts or comments are welcome.
> 
> So, this one has been sitting in the CF for a couple of weeks now.
> I've looked at it again and the queries are written the same.  There
> was one inconsistency with the ordering of the headers and one
> indentation issue with a query for extended stats.
> 
> Any objections against applying it?  This is the last area of the code
> where we rely on such hardcoded values rather than CppAsString2().
> Note also the pg_am.h inclusion which is incorrect.

LGTM, I didn't scan for omissions but the ones in the patch look right to me.
I sort of wish we had a shorter macro as CppAsString2() get's pretty verbose
when used frequently like this.

--
Daniel Gustafsson




Re: More CppAsString2() in psql's describe.c

From
Corey Huinker
Date:

LGTM, I didn't scan for omissions but the ones in the patch look right to me.
I sort of wish we had a shorter macro as CppAsString2() get's pretty verbose
when used frequently like this.

I don't quite understand the etymology of the name (it's some variation on C++'s std::to_string, plus...something), but if I did, I'd probably find the name less icky.

STR(), C_STR(), STRING(), and CSTRING() all seem to be available...
 

Re: More CppAsString2() in psql's describe.c

From
Daniel Gustafsson
Date:
On 28 Nov 2024, at 19:25, Corey Huinker <corey.huinker@gmail.com> wrote:

LGTM, I didn't scan for omissions but the ones in the patch look right to me.
I sort of wish we had a shorter macro as CppAsString2() get's pretty verbose
when used frequently like this.

I don't quite understand the etymology of the name (it's some variation on C++'s std::to_string, plus...something), but if I did, I'd probably find the name less icky.

AFAIK, Cpp stands for "C Pre Processor" as it is a preprocessor expansion into
a string, and the 2 is simply because CppAsString2() calls CppAsString().  The
reason for the call is perform macro expansion before converting to string.

I agree that it's not icky, it just get's very verbose as opposed how
translation of strings is done with _(<string>) as an example.

--
Daniel Gustafsson

Re: More CppAsString2() in psql's describe.c

From
Tom Lane
Date:
Daniel Gustafsson <daniel@yesql.se> writes:
> On 28 Nov 2024, at 19:25, Corey Huinker <corey.huinker@gmail.com> wrote:
>>> I sort of wish we had a shorter macro as CppAsString2() get's pretty verbose
>>> when used frequently like this.

>> I don't quite understand the etymology of the name (it's some variation on C++'s std::to_string, plus...something),
butif I did, I'd probably find the name less icky. 

> AFAIK, Cpp stands for "C Pre Processor" as it is a preprocessor expansion into
> a string, and the 2 is simply because CppAsString2() calls CppAsString().  The
> reason for the call is perform macro expansion before converting to string.

Yeah.  That name was fine when there were just a few occurrences,
but now it seems we've got hundreds, so +1 for something shorter.

I don't like suggestions as generic as STR() though; that's not very
meaningful and also seems like it might collide with some other usage.
How about something like SYM2LIT ("symbol to literal") or SYM2STR?

            regards, tom lane