You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-24 14:20:59 +03:00
MCOL-309 Implement Information Schema tables
This patch does the following: * Fix a year storage issue in the datestamp for the columnstore tables metadata table (note that any previous tables will still have the incorrect year stored). * Expose the table creation date in CalpontSystemCatalog::getTables() * Add an INFORMATION_SCHEMA table listing the tables in ColumnStore (similar to systable) * Add an INFORMATION_SCHEMA table listing the columns in ColumnStore (similar to syscolumn) * Add an INFORMATION_SCHEMA table listing the extents in ColumnStore (similar to the editem tool but with additional file information) * Modifies the build system and scripts to support the new tables
This commit is contained in:
113
dbcon/mysql/is_columnstore_tables.cpp
Normal file
113
dbcon/mysql/is_columnstore_tables.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/* c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil
|
||||
* vi: set shiftwidth=4 tabstop=4 expandtab:
|
||||
* :indentSize=4:tabSize=4:noTabs=true:
|
||||
*
|
||||
* Copyright (C) 2016 MariaDB Corporaton
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; version 2 of
|
||||
* the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "idb_mysql.h"
|
||||
#include <vector>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include "calpontsystemcatalog.h"
|
||||
#include "dataconvert.h"
|
||||
|
||||
|
||||
// Required declaration as it isn't in a MairaDB include
|
||||
bool schema_table_store_record(THD *thd, TABLE *table);
|
||||
|
||||
ST_FIELD_INFO is_columnstore_tables_fields[] =
|
||||
{
|
||||
{"TABLE_SCHEMA", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0},
|
||||
{"TABLE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0},
|
||||
{"OBJECT_ID", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0},
|
||||
{"CREATION_DATE", 0, MYSQL_TYPE_DATE, 0, 0, 0, 0},
|
||||
{"COLUMN_COUNT", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0},
|
||||
{"AUTOINCREMENT", 11, MYSQL_TYPE_LONG, 0, MY_I_S_MAYBE_NULL, 0, 0},
|
||||
{0, 0, MYSQL_TYPE_NULL, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static int is_columnstore_tables_fill(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
{
|
||||
CHARSET_INFO *cs = system_charset_info;
|
||||
TABLE *table = tables->table;
|
||||
|
||||
boost::shared_ptr<execplan::CalpontSystemCatalog> systemCatalogPtr =
|
||||
execplan::CalpontSystemCatalog::makeCalpontSystemCatalog(0);
|
||||
|
||||
const std::vector< std::pair<execplan::CalpontSystemCatalog::OID, execplan::CalpontSystemCatalog::TableName> > catalog_tables
|
||||
= systemCatalogPtr->getTables();
|
||||
|
||||
for (std::vector<std::pair<execplan::CalpontSystemCatalog::OID, execplan::CalpontSystemCatalog::TableName> >::const_iterator it = catalog_tables.begin();
|
||||
it != catalog_tables.end(); ++it)
|
||||
{
|
||||
execplan::CalpontSystemCatalog::TableInfo tb_info = systemCatalogPtr->tableInfo((*it).second);
|
||||
std::string create_date = dataconvert::DataConvert::dateToString((*it).second.create_date);
|
||||
table->field[0]->store((*it).second.schema.c_str(), (*it).second.schema.length(), cs);
|
||||
table->field[1]->store((*it).second.table.c_str(), (*it).second.table.length(), cs);
|
||||
table->field[2]->store((*it).first);
|
||||
table->field[3]->store(create_date.c_str(), create_date.length(), cs);
|
||||
table->field[4]->store(tb_info.numOfCols);
|
||||
if (tb_info.tablewithautoincr)
|
||||
{
|
||||
table->field[5]->set_notnull();
|
||||
table->field[5]->store(systemCatalogPtr->nextAutoIncrValue((*it).second));
|
||||
}
|
||||
else
|
||||
{
|
||||
table->field[5]->set_null();
|
||||
}
|
||||
table->field[5]->store(tb_info.tablewithautoincr);
|
||||
if (schema_table_store_record(thd, table))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_columnstore_tables_plugin_init(void *p)
|
||||
{
|
||||
ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE*) p;
|
||||
schema->fields_info = is_columnstore_tables_fields;
|
||||
schema->fill_table = is_columnstore_tables_fill;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct st_mysql_information_schema is_columnstore_tables_plugin_version =
|
||||
{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION };
|
||||
|
||||
maria_declare_plugin(is_columnstore_tables_plugin)
|
||||
{
|
||||
MYSQL_INFORMATION_SCHEMA_PLUGIN,
|
||||
&is_columnstore_tables_plugin_version,
|
||||
"COLUMNSTORE_TABLES",
|
||||
"MariaDB Corporaton",
|
||||
"An information schema plugin to list ColumnStore tables",
|
||||
PLUGIN_LICENSE_GPL,
|
||||
is_columnstore_tables_plugin_init,
|
||||
//is_columnstore_tables_plugin_deinit,
|
||||
NULL,
|
||||
0x0100,
|
||||
NULL,
|
||||
NULL,
|
||||
"1.0",
|
||||
MariaDB_PLUGIN_MATURITY_STABLE
|
||||
}
|
||||
maria_declare_plugin_end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user