As a part of the refactoring work, modularize the partitioning support, by
makeing a package out of sql_partition.cc, partition_info.cc, including creating
interfaces against both the server as well as the handler (both the ha_partition
as well as natively partitioned handlers, such as NDB).
And then move the ha_partition handler to the storage directory, using the new
partitioning support package.
There will probably also be related work with normalizing the SE API regarding
TABLE, Field structs and more.
Example code
============
// This code demonstrates an approach to providing and maintaining an
// ABI in an straightforward manner. The basic idea is to provide an
// ABI in the form of a POD and inherit from it to produce the
// internal object.
// This prints:
// Internal_table::Internal_table(const char*)
// 0x8cb5008: foo
// 0x8cb500c: foo
// virtual Internal_table::~Internal_table()
#include <iostream>
// This is exported from the "server" in some header file. It
// represents a stable ABI and should only contain field that do not
// change often.
struct Table {
const char *name;
void *fields;
};
// This is in the plug-in code, which uses the Table struct. Note that
// it prints out the value of the pointer, which will be different
// from the value in the caller.
void callback(const Table *table) {
std::cout << (void*) table << ": " << table->name << std::endl;
}
// This is server internal structure that is used to work with the
// tables. Here extra fields, virtual functions, and whatever can be
// added.
class Internal_table : public Table {
public:
Internal_table(const char *n) {
name = n;
std::cout << __PRETTY_FUNCTION__ << std::endl;
}
virtual ~Internal_table() {
std::cout << __PRETTY_FUNCTION__ << std::endl;
}
virtual const char *get_name() const {
return name;
}
};
// This is an example of usage from inside the server. Note that the
// Internal_table is created and deleted as an Internal table, but
// passed to the callback, which will do an implicit cast to the base
// class, changing the value of the pointer in the process.
int main() {
Internal_table *table = new Internal_table("foo");
std::cout << (void*) table << ": " << table->get_name() << std::endl;
callback(table);
delete table;
}
