Skip to content

Commit

Permalink
Improve found attribute handling in release builds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jnidzwetzki committed Apr 9, 2024
1 parent 9b6175a commit 25af8f4
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3389,7 +3389,9 @@ ts_chunk_set_name(Chunk *chunk, const char *newname)
{
FormData_chunk form;
ItemPointerData tid;
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
bool PG_USED_FOR_ASSERTS_ONLY found;

found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
Assert(found);

namestrcpy(&form.table_name, newname);
Expand All @@ -3403,7 +3405,9 @@ ts_chunk_set_schema(Chunk *chunk, const char *newschema)
{
FormData_chunk form;
ItemPointerData tid;
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
bool PG_USED_FOR_ASSERTS_ONLY found;

found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
Assert(found);

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

FormData_chunk form;
ItemPointerData tid;
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
bool PG_USED_FOR_ASSERTS_ONLY found;

found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
Assert(found);

/* applying the flags after locking the metadata tuple */
Expand Down Expand Up @@ -3515,7 +3521,9 @@ ts_chunk_add_status(Chunk *chunk, int32 status)
}
FormData_chunk form;
ItemPointerData tid;
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
bool PG_USED_FOR_ASSERTS_ONLY found;

found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
Assert(found);

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

FormData_chunk form;
ItemPointerData tid;
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
bool PG_USED_FOR_ASSERTS_ONLY found;

found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
Assert(found);

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

FormData_chunk form;
ItemPointerData tid;
bool found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
bool PG_USED_FOR_ASSERTS_ONLY found;

found = lock_chunk_tuple(chunk->fd.id, &tid, &form);
Assert(found);

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

0 comments on commit 25af8f4

Please sign in to comment.