Re: rename and move AssertVariableIsOfType

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-02-16T08:40:28Z
Lists: pgsql-hackers
On 03.02.26 14:39, Bertrand Drouvot wrote:
> Yeah, I gave it a try and I did not choose the same place for all the files.
> 
> 1/ basebackup.c
> 
> Since changing the remaining StaticAssertStmt to StaticAssertDecl introduces
> a duplicate, I thought it would make sense to:
> 
> - remove the StaticAssertStmt
> - move the existing StaticAssertDecl at file scope
> 
> As it depends of the literal "2" also used in some computation then I introduced
> TAR_TERMINATION_BLOCKS and used it in the StaticAssertDecl and the functions.
> 
> 2/ deadlock.c
> 
> It makes sense to keep it near the related code, so:
> 
> - changed to StaticAssertDecl
> - Added new braces to avoid Wdeclaration-after-statement to trigger
> 
> 3/ aset.c
> 
> Changes the StaticAssertStmt to StaticAssertDecl and move it to file scope (that
> looks more appropriate).
> 
> Attached 3 patches to ease the review.
> 
> After there are no remaining usages of StaticAssertStmt() and we may want to
> deprecate it.

I have committed this.

I changed TAR_TERMINATION_BLOCKS to TAR_NUM_TERMINATION_BLOCKS for a 
little bit more clarity.  And then I added a comment in c.h that 
StaticAssertStmt() is deprecated.




Commits

  1. Change remaining StaticAssertStmt() to StaticAssertDecl()

  2. Change StaticAssertVariableIsOfType to be a declaration

  3. Rename AssertVariableIsOfType to StaticAssertVariableIsOfType