Thread: enum-ify resource manager's xl_info values
Hi, Would somebody object to making the rmgr's invo value #defines like: /* XLOG info values for XLOG rmgr */ #define XLOG_CHECKPOINT_SHUTDOWN 0x00 #define XLOG_CHECKPOINT_ONLINE 0x10 #define XLOG_NOOP 0x20 #define XLOG_NEXTOID 0x30 #define XLOG_SWITCH 0x40 #define XLOG_BACKUP_END 0x50 #define XLOG_PARAMETER_CHANGE 0x60 #define XLOG_RESTORE_POINT 0x70 #define XLOG_FPW_CHANGE 0x80 #define XLOG_END_OF_RECOVERY 0x90 #define XLOG_FPI 0xA0 into enums? We already have a bunch of places looking at those values and if/when changeset extraction makes it in, it's going to be one more. Having the compiler tell you where a new value should have been been added as well helps. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services
Andres Freund <andres@2ndquadrant.com> writes: > Would somebody object to making the rmgr's invo value #defines like: > into enums? I think that will create more problems than it fixes. For one thing, the same field is used to store values that would need to be multiple independent enum types; and we also store additional bits into that field. regards, tom lane
On 2013-07-22 08:53:53 -0400, Tom Lane wrote: > Andres Freund <andres@2ndquadrant.com> writes: > > Would somebody object to making the rmgr's invo value #defines like: > > into enums? > > I think that will create more problems than it fixes. For one thing, > the same field is used to store values that would need to be multiple > independent enum types; and we also store additional bits into that > field. Oh, I don't want to change the definition of XLogRecord or such. I just want to make the series of #defines an enum so you can write something like inf = record->xl_info & ~XLR_INFO_MASK; switch ((XLogXactRecordType) info) { case ....; } Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services
On 7/22/13 7:21 AM, Andres Freund wrote: > Would somebody object to making the rmgr's invo value #defines like: I'm suspicious of enums that are assigned specific values. Enums should stand by themselves, they shouldn't be a symbolic layer on top of some other numbering or bit-fiddling scheme.