Re: The PostgreSQL C Dialect - Mailing list pgsql-hackers

From jian he
Subject Re: The PostgreSQL C Dialect
Date
Msg-id CACJufxFkyibbUfR0fY+yzS+GcyyO-4aZ2TQ_Liu75sCi03Rawg@mail.gmail.com
Whole thread
Responses Re: The PostgreSQL C Dialect
Re: The PostgreSQL C Dialect
List pgsql-hackers
On Tue, Jun 23, 2026 at 3:39 AM Christophe Pettus <xof@thebuild.com> wrote:
>
> When I was writing my first PostgreSQL extension, I was at sea on a lot of the conventions that make up the
"PostgreSQLC Dialect."  I've taken my notes, added some additional things that confused me, and put it up on the wiki
forreview: 
>
>         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/



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Adding REPACK [concurrently]
Next
From: Heikki Linnakangas
Date:
Subject: Re: postgres_fdw: fix cumulative stats after imported foreign-table stats