Skip to content

Commit 25af8f4

Browse files
committed
Improve found attribute handling in release builds
The found attribute is not used in release builds when Asserts are not evaluated. This leads to unused attributes and compiler errors. This PR fixes this problem by adding PG_USED_FOR_ASSERTS_ONLY to the variable declaration.
1 parent 9b6175a commit 25af8f4

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/chunk.c

+18-6
Original file line numberDiff line numberDiff line change
@@ -3389,7 +3389,9 @@ ts_chunk_set_name(Chunk *chunk, const char *newname)
33893389
{
33903390
FormData_chunk form;
33913391
ItemPointerData tid;
3392-
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
3392+
bool PG_USED_FOR_ASSERTS_ONLY found;
3393+
3394+
found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
33933395
Assert(found);
33943396

33953397
namestrcpy(&form.table_name, newname);
@@ -3403,7 +3405,9 @@ ts_chunk_set_schema(Chunk *chunk, const char *newschema)
34033405
{
34043406
FormData_chunk form;
34053407
ItemPointerData tid;
3406-
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
3408+
bool PG_USED_FOR_ASSERTS_ONLY found;
3409+
3410+
found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
34073411
Assert(found);
34083412

34093413
namestrcpy(&form.schema_name, newschema);
@@ -3484,7 +3488,9 @@ ts_chunk_clear_status(Chunk *chunk, int32 status)
34843488

34853489
FormData_chunk form;
34863490
ItemPointerData tid;
3487-
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
3491+
bool PG_USED_FOR_ASSERTS_ONLY found;
3492+
3493+
found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
34883494
Assert(found);
34893495

34903496
/* applying the flags after locking the metadata tuple */
@@ -3515,7 +3521,9 @@ ts_chunk_add_status(Chunk *chunk, int32 status)
35153521
}
35163522
FormData_chunk form;
35173523
ItemPointerData tid;
3518-
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
3524+
bool PG_USED_FOR_ASSERTS_ONLY found;
3525+
3526+
found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
35193527
Assert(found);
35203528

35213529
/* Somebody could update the status before we are able to lock it so check again */
@@ -3563,7 +3571,9 @@ ts_chunk_set_compressed_chunk(Chunk *chunk, int32 compressed_chunk_id)
35633571

35643572
FormData_chunk form;
35653573
ItemPointerData tid;
3566-
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
3574+
bool PG_USED_FOR_ASSERTS_ONLY found;
3575+
3576+
found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
35673577
Assert(found);
35683578

35693579
/* Somebody could update the status before we are able to lock it so check again */
@@ -3611,7 +3621,9 @@ ts_chunk_clear_compressed_chunk(Chunk *chunk)
36113621

36123622
FormData_chunk form;
36133623
ItemPointerData tid;
3614-
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
3624+
bool PG_USED_FOR_ASSERTS_ONLY found;
3625+
3626+
found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
36153627
Assert(found);
36163628

36173629
/* Somebody could update the status before we are able to lock it so check again */

0 commit comments

Comments
 (0)