Re: Minor refactorings to eliminate some static buffers

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Minor refactorings to eliminate some static buffers
Date: 2024-08-06 20:12:12
Message-ID: 37331ad2-8349-461e-bd47-bbb5d34073fa@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-08-06 20:25:12 Re: Unused expression indexes
Previous Message Maciek Sakrejda 2024-08-06 20:06:08 Unused expression indexes