[Tarantool-patches] [PATCH] txn: convert flags to explicit bitfield
Cyrill Gorcunov
gorcunov at gmail.com
Thu Feb 18 00:45:56 MSK 2021
On Wed, Feb 17, 2021 at 10:15:30PM +0100, Vladislav Shpilevoy wrote:
> Hi! Thanks for the patch!
>
> > @@ -535,7 +535,7 @@ txn_complete_fail(struct txn *txn)
> > txn_rollback_one_stmt(txn, stmt);
> > if (txn->engine != NULL)
> > engine_rollback(txn->engine, txn);
> > - if (txn_has_flag(txn, TXN_HAS_TRIGGERS))
> > + if (txn->flags & TXN_HAS_TRIGGERS)
>
> 1. Did you do a self-review before sending this? Can you
> tell yourself what is wrong here?
Yes I did, and I don't get what's wrong with this line? Previously
we have `if (txn_has_flag(txn, TXN_HAS_TRIGGERS))` where txn_has_flag
get expanded to
return (txn->flags & TXN_HAS_TRIGGERS) != 0;
so where is an error?
> 2. What was wrong with the idea of having the helpers
> but operating on bitfields? And having has_flags() instead
> of has_flag() to check presense of all specified flags +
> clear_flags() to remove all specified flags.
>
> I don't understand. I think we discussed it already 2 or 3
> times and all seemed to agree?
The initial idea was to operate with flags directly, you pointed
that lines of code as if (!(txn->flags & mask)) violates our
code style. Then we thought of renaming the helpers to txn_x_flags
to operate with multiple flags, which lead us to a vague moment --
it is unclear how exactly txn_has_flag should operate: exact
matching or any matching?
Finlly I simply moved back to direct access to the fields
with explicit `!= 0` or `== 0` form.
More information about the Tarantool-patches
mailing list