Hello Sergei! On Thu, 19 Oct 2023 at 23:45, Sergei Golubchik <serg@mariadb.org> wrote:
--- a/sql/handler.h +++ b/sql/handler.h @@ -903,6 +905,7 @@ struct xid_t { long gtrid_length; long bqual_length; char data[XIDDATASIZE]; // not \0-terminated ! + Online_alter_cache_list *online_alter_cache;
well, no, we've talked about it. Even the comment above the structure says that you cannot change it.
make a separate structure, xid_and_online_alter_cache_t or xid_t_internal or whatever.
but xid_t should be defined identically everywhere.
Sure check out commit 06cc655a55d115, which extends XID instead. I left it separate to be easier readable, as it contains many changes that just practically fix the build issue, that would noise up the subj commit. okay, now I've seen how you used it and I'd say it's _such a rare use case_
that you can store your online_alter_cache in the XID_cache_element and look it up there. Or even in a separate data structure, that will be empty most of the time anyway.
I think extending XID was a better alternative. I didn't read the XA protocol: as far as I understand, only xid_t is its part, and XID is our alias -- or, well, not an alias anymore. Having it as an extension of xid_t looks quite natural to me. Besides, even the handlerton abi is left compatible.
+ online_alter_hton->prepare= [](handlerton *hton, THD *thd, bool all) -> int
+ { + auto &cache_list= get_cache_list(hton, thd); + int res= 0; + if (ending_trans(thd, all)) + { + thd->transaction->xid_state.set_online_alter_cache(&cache_list); + thd_set_ha_data(thd, hton, NULL); + } + else + { + res= online_alter_end_trans(cache_list, thd, false, true);
is that possible?
that's what's called by the end of the statement in case of an XA transaction😐 -- Yours truly, Nikita Malyavin