summaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2025-12-12 08:58:34 +0100
committerPeter Eisentraut <peter@eisentraut.org>2025-12-12 10:06:40 +0100
commit493eb0da31be4520252e1af723342dc7ead0c3e5 (patch)
treeafb3274176a5b028929b3a47b51afd5228b2c0d2 /src/backend/access
parent87a350e1f284bb99591f9185c0be0ae28899f38a (diff)
Replace most StaticAssertStmt() with StaticAssertDecl()
Similar to commit 75f49221c22, it is preferable to use StaticAssertDecl() instead of StaticAssertStmt() when possible. Discussion: https://www.postgresql.org/message-id/flat/CA%2BhUKGKvr0x_oGmQTUkx%3DODgSksT2EtgCA6LmGx_jQFG%3DsDUpg%40mail.gmail.com
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/heap/vacuumlazy.c5
-rw-r--r--src/backend/access/table/tableam.c6
-rw-r--r--src/backend/access/transam/parallel.c7
3 files changed, 10 insertions, 8 deletions
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index e8c99c3773d..62035b7f9c3 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -3388,6 +3388,9 @@ lazy_truncate_heap(LVRelState *vacrel)
static BlockNumber
count_nondeletable_pages(LVRelState *vacrel, bool *lock_waiter_detected)
{
+ StaticAssertDecl((PREFETCH_SIZE & (PREFETCH_SIZE - 1)) == 0,
+ "prefetch size must be power of 2");
+
BlockNumber blkno;
BlockNumber prefetchedUntil;
instr_time starttime;
@@ -3402,8 +3405,6 @@ count_nondeletable_pages(LVRelState *vacrel, bool *lock_waiter_detected)
* in forward direction, so that OS-level readahead can kick in.
*/
blkno = vacrel->rel_pages;
- StaticAssertStmt((PREFETCH_SIZE & (PREFETCH_SIZE - 1)) == 0,
- "prefetch size must be power of 2");
prefetchedUntil = InvalidBlockNumber;
while (blkno > vacrel->nonempty_pages)
{
diff --git a/src/backend/access/table/tableam.c b/src/backend/access/table/tableam.c
index 1e099febdc8..73ebc01a08f 100644
--- a/src/backend/access/table/tableam.c
+++ b/src/backend/access/table/tableam.c
@@ -462,15 +462,15 @@ table_block_parallelscan_startblock_init(Relation rel,
BlockNumber startblock,
BlockNumber numblocks)
{
+ StaticAssertDecl(MaxBlockNumber <= 0xFFFFFFFE,
+ "pg_nextpower2_32 may be too small for non-standard BlockNumber width");
+
BlockNumber sync_startpage = InvalidBlockNumber;
BlockNumber scan_nblocks;
/* Reset the state we use for controlling allocation size. */
memset(pbscanwork, 0, sizeof(*pbscanwork));
- StaticAssertStmt(MaxBlockNumber <= 0xFFFFFFFE,
- "pg_nextpower2_32 may be too small for non-standard BlockNumber width");
-
retry:
/* Grab the spinlock. */
SpinLockAcquire(&pbscan->phs_mutex);
diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 8428103eba4..956b23816de 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -266,6 +266,10 @@ InitializeParallelDSM(ParallelContext *pcxt)
if (pcxt->nworkers > 0)
{
+ StaticAssertDecl(BUFFERALIGN(PARALLEL_ERROR_QUEUE_SIZE) ==
+ PARALLEL_ERROR_QUEUE_SIZE,
+ "parallel error queue size not buffer-aligned");
+
/* Estimate space for various kinds of state sharing. */
library_len = EstimateLibraryStateSpace();
shm_toc_estimate_chunk(&pcxt->estimator, library_len);
@@ -297,9 +301,6 @@ InitializeParallelDSM(ParallelContext *pcxt)
shm_toc_estimate_keys(&pcxt->estimator, 12);
/* Estimate space need for error queues. */
- StaticAssertStmt(BUFFERALIGN(PARALLEL_ERROR_QUEUE_SIZE) ==
- PARALLEL_ERROR_QUEUE_SIZE,
- "parallel error queue size not buffer-aligned");
shm_toc_estimate_chunk(&pcxt->estimator,
mul_size(PARALLEL_ERROR_QUEUE_SIZE,
pcxt->nworkers));