Re: Minor refactorings to eliminate some static buffers - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Minor refactorings to eliminate some static buffers
Date
Msg-id 37331ad2-8349-461e-bd47-bbb5d34073fa@iki.fi
Whole thread Raw
In response to Re: Minor refactorings to eliminate some static buffers  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On 06/08/2024 18:52, Andres Freund wrote:
> On 2024-08-06 18:13:56 +0300, Heikki Linnakangas wrote:
>> diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
>> index 702a6c3a0b..2732d6bfc9 100644
>> --- a/src/backend/tcop/utility.c
>> +++ b/src/backend/tcop/utility.c
>> @@ -1155,7 +1155,7 @@ ProcessUtilitySlow(ParseState *pstate,
>>                           {
>>                               CreateStmt *cstmt = (CreateStmt *) stmt;
>>                               Datum        toast_options;
>> -                            static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
>> +                            const char *validnsps[] = HEAP_RELOPT_NAMESPACES;
>>   
>>                               /* Remember transformed RangeVar for LIKE */
>>                               table_rv = cstmt->relation;
> 
> In the other places you used "const char * const", here just "const char *" - it
> doesn't look like that's a required difference?

Just an oversight.

I went back and forth on whether to use plain "char *validnps[]", "const 
char *validnsps[]" or "const char *const validnsps[]". The first form 
doesn't convey the fact it's read-only, like the "static" used to. The 
second form hints that, but only for the strings, not for the pointers 
in the array. The last form is what we want, but it's a bit verbose and 
ugly. I chose the last form in the end, but missed this one.

Fixed that and pushed. Thanks!

-- 
Heikki Linnakangas
Neon (https://neon.tech)




pgsql-hackers by date:

Previous
From: Maciek Sakrejda
Date:
Subject: Unused expression indexes
Next
From: Tom Lane
Date:
Subject: Re: Unused expression indexes