rename and move AssertVariableIsOfType

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-01-26T12:17:15Z
Lists: pgsql-hackers

Attachments

I'm proposing two changes:

First, rename AssertVariableIsOfType to StaticAssertVariableIsOfType. 
The current name suggests that it is a run-time assertion (like 
"Assert"), but it's not.  The name change makes that clearer.

I doubt that the current name is used in many extensions, but if 
necessary, extension code could adapt to this quite easily with 
something like

#if PG_VERSION_NUM < ...
#define StaticAssertVariableIsOfType(x, y) AssertVariableIsOfType(x, y)
#endif

Second, change the underlying implementation of 
StaticAssertVariableIsOfType to use StaticAssertDecl instead of 
StaticAssertStmt.  This makes StaticAssertVariableIsOfType behave more 
like a normal static assertion, and in many cases we can move the 
current instances to a more natural position at file scope.  This is 
similar to previous commits like 493eb0da31b.

Commits

  1. Change remaining StaticAssertStmt() to StaticAssertDecl()

  2. Change StaticAssertVariableIsOfType to be a declaration

  3. Rename AssertVariableIsOfType to StaticAssertVariableIsOfType