Re: Enumize logical replication message actions
Ashutosh Bapat <ashutosh.bapat@2ndquadrant.com>
From: Ashutosh Bapat <ashutosh.bapat@2ndquadrant.com>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: Andres Freund <andres@anarazel.de>,
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>,
amit.kapila16@gmail.com
Date: 2020-10-23T12:50:36Z
Lists: pgsql-hackers
On Fri, 23 Oct 2020 at 06:50, Kyotaro Horiguchi <horikyota.ntt@gmail.com>
wrote:
>
> Those two switch()es are apparently redundant. That code is exactly
> equivalent to:
>
> apply_dispatch(s)
> {
> LogicalRepMsgType msgtype = pq_getmsgtype(s);
>
> switch (msgtype)
> {
> case LOGICAL_REP_MSG_BEGIN:
> apply_handle_begin();
> ! return;
> ...
> case LOGICAL_REP_MSG_STREAM_COMMIT:
> apply_handle_begin();
> ! return;
> }
>
> ereport(ERROR, (errmsg("invalid logical replication message type"..
> }
>
> which is smaller and fast.
>
Good idea. Implemented in the latest patch posted with the next mail.
--
Best Wishes,
Ashutosh
Commits
-
Use Enums for logical replication message types at more places.
- f3a8f73ec274 14.0 landed
-
Use Enum for top level logical replication message types.
- 644f0d7cc9c2 14.0 landed