Adding a New Data Type to MariaDB with Type_handler – Part 5

We are concluding our series related to new data types using the Type_handler framework, with some limitations that are not yet covered by the framework:

  • No custom indexing methods. A plugin type cannot introduce a new indexing method.
  • No custom hashing. Plugin types can’t provide their own function for hash-based operations. Things like MEMORY table indexes, GROUP BY, and partitioning fall back to the underlying type’s hash.
  • No new field attributes. Plugin types cannot define custom attributes beyond the existing ones: length, precision, scale, and GIS SRID.

Adding a New Data Type to MariaDB with Type_handler – Part 4

This is part 4 of a series related to extending MariaDB with a custom data type using the Type_handler framework.

You can find the previous articles below:

Overriding Existing Types

In the previous examples, our MONEY data type inherits from DOUBLE and then we override some methods.

Adding a New Data Type to MariaDB with Type_handler – Part 3

In the previous article, we wrote, compiled, and tested our first custom data type for MariaDB using the Type_handler framework.

But currently, aside from allowing the use of its new name (MONEY) and listing it in the metadata, our new data type behaves exactly like a DOUBLE, the class it inherits from.

In this article, we will extend our data type just a bit by transforming the result into a VARCHAR and adding a currency sign to it: the dollar sign ($).

This is the expected result:

MariaDB [test]insert into t1 (amount) values (41578.4); …

Adding a New Data Type to MariaDB with Type_handler – Part 2

After having discovered the Type_hander framework and learned how to build MariaDB Server from source, it’s time to code our first data type!

We will create a MariaDB plugin that registers a new MONEY type and instantiates a custom field object.

Our component won’t be exciting, but we want to understand how to use the framework and test it.

We want to prove that

  • the plugin loads,
  • the server sees the type hander,
  • a MONEY column can create a Field_money object.

Everything else comes later.

Adding a New Data Type to MariaDB with Type_handler – Part 1

This is the first part of the series about how to add a new data type to MariaDB using the Type_handler framework. A preliminary article has already been published to start the series; it covers how to set up your development environment and compile MariaDB Server: Adding a New Data Type to MariaDB with Type_handler – Part 0.

Understand Type_handler Before Writing Code

When you add a new type to MariaDB, you are not only adding a new SQL keyword. Historically, that kind of work required invasive changes across the parser, optimizer, protocol, replication, and type-conversion mechanisms.

Adding a New Data Type to MariaDB with Type_handler – Part 0

Welcome to this new series about extending MariaDB. This series covers the addition of a new data type using the Type_handler.

The goal of the entire series is to create a new plugin data type MONEY to store and display amounts with currency.

Something like:

MariaDB [test]> select * from t1;
+—-+————-+
| id | amount |
+—-+————-+
| 1 | $2,000.00 |
| 2 | $100,000.56 |
+—-+————-+
2 rows in set (0.002 sec)

Of course, the ultimate goal is to teach how to add data types in MariaDB, and we expect to see how creative our community developers are!

Know a MariaDB champion? Submit a nomination

One of the things I really like about open source is that a project is never only about the software.

Yes, code is important. Very important. But a project like MariaDB exists and grows because of people. People who contribute code, of course, but also people who help users, review bugs, write blog posts, speak at events, answer questions, test new features, build tools, and share knowledge with others.

This is exactly why I’m very happy to announce the MariaDB Foundation Sea Lion Champions program.

It’s a new initiative to recognize the people who help make the MariaDB ecosystem stronger.

Contributions As a Cost-saver

I came across an excellent paper by the Linux Foundation. In it I find solid economical evidence for a very fundamental idea: contributions are the life-blood of an open source project.

Contributions in the broader sense (code, documentation, quality assurance, marketing, education, financial support) are central to every project. Open source or not. Giving users what they need and want is what makes any project appealing. It’s just that with open source, the cost to procuring these is not that directly attached to the actual use. So, there is a gap to cross between passive use and active participation.