From: | ilmari(at)ilmari(dot)org (Dagfinn Ilmari Mannsåker ) |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | "Smith\, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Proposal: Add more compile-time asserts to expose inconsistencies. |
Date: | 2019-09-18 15:46:30 |
Message-ID: | d8j4l19sj3d.fsf@dalvik.ping.uio.no |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Michael Paquier <michael(at)paquier(dot)xyz> writes:
> On Wed, Sep 18, 2019 at 06:46:24AM +0000, Smith, Peter wrote:
>> 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.
>
> For some of them it could help, and we could think about a better
> location for that stuff than an unused routine.
Postgres doesn't seem to have it, but it would be possible to define a
StaticAssertDecl macro that can be used at the file level, outside any
function. See for example Perl's STATIC_ASSERT_DECL:
https://github.com/Perl/perl5/blob/v5.30.0/perl.h#L3455-L3488
- ilmari
--
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of." -- Skud's Meta-Law
From | Date | Subject | |
---|---|---|---|
Next Message | Fabien COELHO | 2019-09-18 17:03:02 | Re: pgbench - allow to create partitioned tables |
Previous Message | Konstantin Knizhnik | 2019-09-18 15:38:55 | Relation extension lock bottleneck |