Re: Using XLogFileNameP in critical section - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Using XLogFileNameP in critical section
Date
Msg-id 20191202155608.GA7029@alvherre.pgsql
Whole thread Raw
In response to Re: Using XLogFileNameP in critical section  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Using XLogFileNameP in critical section  (Masahiko Sawada <masahiko.sawada@2ndquadrant.com>)
List pgsql-hackers
On 2019-Dec-02, Michael Paquier wrote:

> I think that we had better just get rid of XLogFileNameP() (on HEAD)
> and just change those code paths so as they use a buffer of size
> MAXFNAMELEN, with XLogFileName() generating the file name.  This leads
> actually to some simplifications, see for example XLogWalRcvWrite..

+1, that function is a footgun and there's no possible way to fix it so
that it's never misused(*).  Also, put a comment atop XLogFileName
indicating never to create such a "helper" function again.

(*) unless there was a way to have a StaticAssert() that the function is
not called in a critical section -- have the compiler work for us.  I
don't think it's possible to write such a thing.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Proposal: Add more compile-time asserts to exposeinconsistencies.
Next
From: Peter Eisentraut
Date:
Subject: Re: Protocol problem with GSSAPI encryption?