Proposal: Add more compile-time asserts to expose inconsistencies.

From: "Smith, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Proposal: Add more compile-time asserts to expose inconsistencies.
Date: 2019-09-18 06:46:24
Message-ID: 201DD0641B056142AC8C6645EC1B5F62014B8E8030@SYD1217
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Hackers,

I have identified some OSS code where more compile-time asserts could be added.

Mostly these are asserting that arrays have the necessary length to accommodate the enums that are used to index into them.

In general the code is already commented with warnings such as:
* "If you add a new entry, remember to ..."
* "When modifying this enum, update the table in ..."
* "Display names for enums in ..."
* etc.

But comments can be accidentally overlooked, so adding the compile-time asserts can help eliminate human error.

Please refer to the attached patch.

Kind Regards,
Peter Smith
---
Fujitsu Australia

Attachment Content-Type Size
0001-Add-compile-time-asserts.patch application/octet-stream 4.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Khandekar 2019-09-18 06:54:50 Re: logical decoding : exceeded maxAllocatedDescs for .spill files
Previous Message Amit Langote 2019-09-18 06:46:12 Re: pgbench - allow to create partitioned tables