Re: Enumize logical replication message actions

Поиск
Список
Период
Сортировка
От Ashutosh Bapat
Тема Re: Enumize logical replication message actions
Дата
Msg-id CAG-ACPU2CuvedOF6_6=tGXWaQT=4Mfb6Pn2_rSyNuEx1XxG_JA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Enumize logical replication message actions  (Amit Kapila <amit.kapila16@gmail.com>)
Ответы Re: Enumize logical replication message actions  (Amit Kapila <amit.kapila16@gmail.com>)
Список pgsql-hackers


On Fri, 30 Oct 2020 at 09:16, Amit Kapila <amit.kapila16@gmail.com> wrote

1.
+ LOGICAL_REP_MSG_STREAM_ABORT = 'A',
+} LogicalRepMsgType;

There is no need for a comma after the last message.

Done. Thanks for noticing it. 
 
2.
+/*
+ * Logical message types
+ *
+ * Used by logical replication wire protocol.
+ *
+ * Note: though this is an enum it should fit a single byte and should be a
+ * printable character.
+ */
+typedef enum
+{

I think we can expand the comments to probably say why we need these
to fit in a single byte or what problem it can cause if that rule is
disobeyed. This is to make the next person clear why we are imposing
such a rule.

Done. Please check.
 

3.
+typedef enum
+{
..
+} LogicalRepMsgType;

There are places in code where we use the enum name
(LogicalRepMsgType) both in the start and end. See TypeCat,
CoercionMethod, CoercionCodes, etc. I see places where we use the way
you have in the code. I would prefer the way we have used at places
like TypeCat as that makes it easier to read.

Not my favourite style since changing the type name requires changing enum name to keep those consistent. But anyway done.
 

4.
  switch (action)
  {
- /* BEGIN */
- case 'B':
+ case LOGICAL_REP_MSG_BEGIN:
  apply_handle_begin(s);
- break;
- /* COMMIT */
- case 'C':
+ return;

I think we can simply use 'return apply_handle_begin;' instead of
adding return in another line. Again, I think we changed this handling
in apply_dispatch() to improve the case where we can detect at the
compile time any missing enum but at this stage it is not clear to me
if that is true.
 
I don't see much value in writing it like "return apply_handle_begin()"; gives an impression that apply_handle_begin() and apply_dispatch() are returning something which they are not. I would prefer return on separate line unless there's something more than style improvement.

I have added rationale behind Enum in the commit message as you suggested in one of the later mails.

PFA patch addressing your comments.
--
Best Wishes,
Ashutosh
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jürgen Purtz
Дата:
Сообщение: Re: Additional Chapter for Tutorial
Следующее
От: Ashutosh Bapat
Дата:
Сообщение: Re: Enumize logical replication message actions