On Tue, Jun 23, 2026 at 3:39 AM Christophe Pettus <[email protected]> wrote:
>
> When I was writing my first PostgreSQL extension, I was at sea on a lot of 
> the conventions that make up the "PostgreSQL C Dialect."  I've taken my 
> notes, added some additional things that confused me, and put it up on the 
> wiki for review:
>
>         https://wiki.postgresql.org/wiki/The_PostgreSQL_C_Dialect
>

In many cases, we may need to add trailing commas to enum definitions.
See 
https://git.postgresql.org/cgit/postgresql.git/commit/?id=611806cd726fc92989ac918eac48fd8d684869c7

https://www.postgresql.org/docs/current/error-message-reporting.html
already mentioned that
```The extra parentheses were required before PostgreSQL version 12,
but are now optional.```.

Fewer parentheses are generally more readable, IMHO.
So https://wiki.postgresql.org/wiki/The_PostgreSQL_C_Dialect

ereport(ERROR,
        (errcode(ERRCODE_DIVISION_BY_ZERO),
         errmsg("division by zero")));

can be replaced by

ereport(ERROR,
        errcode(ERRCODE_DIVISION_BY_ZERO),
         errmsg("division by zero"));

````
The compiler‑attribute wrappers: pg_attribute_noreturn(),
pg_attribute_printf(), pg_attribute_unused(), pg_noinline,
pg_nodiscard, and pg_unreachable() — portable spellings with fallbacks
where a compiler lacks the underlying feature.
````
pg_attribute_noreturn is replaced by something else, probabaly by
pg_noreturn (i am not so sure).

```
Validity helpers such as PointerIsValid() and OidIsValid().
```
PointerIsValid() is removed.



--
jian
https://www.enterprisedb.com/


Reply via email to