Skip to content

Conversation

@SharonIV0x86
Copy link

@SharonIV0x86 SharonIV0x86 commented Dec 23, 2025

  • The Jira issue number for this PR is: MDEV-38144

Description

This PR aims to replace stl types with mariadb types. Thus introduces a Column_metadata struct to allocate values.

The Table_map_log_event::Optional_metadata_fields struct is full of std::vector types, one for each column option/type/attribute etc. Instead, it would be better to have an array of fields. This would allow us to allocate everything in one go (except column names) and would simplify a lot of the current functions.

The current build will fail as in log_client.cc the old STL types containers are being used and this file also requires refactoring.

Release Notes

There is no change to system variables or status variables, just how the table field values are stored and parsed is modified.

How can this PR be tested?

TODO: modify the automated test suite to verify that the PR causes MariaDB to behave as intended.
Consult the documentation on "Writing good test cases".

If the changes are not amenable to automated testing, please explain why not and carefully describe how to test manually.

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@CLAassistant
Copy link

CLAassistant commented Dec 23, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@bnestere bnestere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SharonIV0x86 !

Thanks for asking for early feedback on your contribution! I added a couple notes so far, but generally, it looks like things are in the right direction.

sql/log_event.cc Outdated
Dynamic_array<str_vector> enum_str_value(PSI_INSTRUMENT_MEM, 0, 0);
Dynamic_array<str_vector> set_str_value(PSI_INSTRUMENT_MEM, 0, 0);
Dynamic_array<unsigned int> geometry_type(PSI_INSTRUMENT_MEM, 0, 0);
Dynamic_array<uint_pair> primary_key(PSI_INSTRUMENT_MEM, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need these Dynamic_arrays. I think you can start the

m_columns = Dynamic_array<Column_metadata>(PSI_INSTRUMENT_MEM, 0, 0);

here, and then build up each Column_metadata one by one here. This would then change the signature of each parse_* function to take in a Column_metadata* type, which it would directly modify.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, i am working on it.

sql/log_event.cc Outdated
unsigned char *field, unsigned int length)
{
unsigned char* p= field;
unsigned char* p = field;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MariaDB coding standards actually dictate the original:

Assignments should not have a space on the left side of the equals, and one space on the right hand side. For example:

a= 1;  // Correct
a = 1; // Incorrect for the server code,

@SharonIV0x86
Copy link
Author

@bnestere

I have made the changes as you suggested. I had to add a new parser function, I split ENUM_AND_SET_COLUMN_CHARSET into a separate parser because, although the wire format is identical to COLUMN_CHARSET, the semantic destination is different (enum_set_charset vs charset). If needed i can revert back and adjust it into a single function.

And modified the parse_set_str_value function to accept a bool to add a condition check while parsing to indicate if its parsing enum values or a str value and the destination is chosen depending on it,.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants