diff --git a/cpackEngineRPM.cmake b/cpackEngineRPM.cmake index 0290ea722..0a222978e 100644 --- a/cpackEngineRPM.cmake +++ b/cpackEngineRPM.cmake @@ -318,6 +318,15 @@ SET(CPACK_RPM_storage-engine_USER_FILELIST "/usr/local/mariadb/columnstore/lib/libudf_mysql.so.1.0.0" "/usr/local/mariadb/columnstore/lib/libudf_mysql.so.1" "/usr/local/mariadb/columnstore/lib/libudf_mysql.so" +"/usr/local/mariadb/columnstore/lib/is_columnstore_columns.so" +"/usr/local/mariadb/columnstore/lib/is_columnstore_columns.so.1" +"/usr/local/mariadb/columnstore/lib/is_columnstore_columns.so.1.0.0" +"/usr/local/mariadb/columnstore/lib/is_columnstore_extents.so" +"/usr/local/mariadb/columnstore/lib/is_columnstore_extents.so.1" +"/usr/local/mariadb/columnstore/lib/is_columnstore_extents.so.1.0.0" +"/usr/local/mariadb/columnstore/lib/is_columnstore_tables.so" +"/usr/local/mariadb/columnstore/lib/is_columnstore_tables.so.1" +"/usr/local/mariadb/columnstore/lib/is_columnstore_tables.so.1.0.0" "/usr/local/mariadb/columnstore/mysql/mysql-Columnstore" "/usr/local/mariadb/columnstore/mysql/install_calpont_mysql.sh" "/usr/local/mariadb/columnstore/mysql/syscatalog_mysql.sql" diff --git a/dbcon/execplan/calpontsystemcatalog.cpp b/dbcon/execplan/calpontsystemcatalog.cpp index ecec4fcf9..635927c7b 100644 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -2599,6 +2599,7 @@ const vector< pair > SimpleColumn *c1 = new SimpleColumn(CALPONT_SCHEMA+"."+SYSTABLE_TABLE+"."+TABLENAME_COL, fSessionID); SimpleColumn *c2 = new SimpleColumn(CALPONT_SCHEMA+"."+SYSTABLE_TABLE+"."+SCHEMA_COL, fSessionID); SimpleColumn *c3 = new SimpleColumn(CALPONT_SCHEMA+"."+SYSTABLE_TABLE+"."+OBJECTID_COL, fSessionID); + SimpleColumn *c4 = new SimpleColumn(CALPONT_SCHEMA+"."+SYSTABLE_TABLE+"."+CREATEDATE_COL, fSessionID); SRCP srcp; srcp.reset(c1); @@ -2607,6 +2608,8 @@ const vector< pair > colMap.insert(CMVT_(CALPONT_SCHEMA+"."+SYSTABLE_TABLE+"."+SCHEMA_COL, srcp)); srcp.reset(c3); colMap.insert(CMVT_(CALPONT_SCHEMA+"."+SYSTABLE_TABLE+"."+OBJECTID_COL, srcp)); + srcp.reset(c4); + colMap.insert(CMVT_(CALPONT_SCHEMA+"."+SYSTABLE_TABLE+"."+CREATEDATE_COL, srcp)); csep.columnMapNonStatic(colMap); srcp.reset(c1->clone()); @@ -2653,6 +2656,14 @@ const vector< pair > tables[i].second.schema = (*it)->GetStringData(i); } } + for (it = sysDataList.begin(); it != sysDataList.end(); it++) + { + if ((*it)->ColumnOID() == c4->oid()) + { + for (int i = 0; i < (*it)->dataCount(); i++) + tables[i].second.create_date = (*it)->GetData(i); + } + } for (it = sysDataList.begin(); it != sysDataList.end(); it++) { diff --git a/dbcon/execplan/calpontsystemcatalog.h b/dbcon/execplan/calpontsystemcatalog.h index 42b721d65..2936b2daa 100644 --- a/dbcon/execplan/calpontsystemcatalog.h +++ b/dbcon/execplan/calpontsystemcatalog.h @@ -431,6 +431,7 @@ public: TableName(const TableAliasName& tan): schema(tan.schema), table(tan.table) {} std::string schema; std::string table; + int64_t create_date; bool operator<(const TableName& rhs) const; bool operator>=(const TableName& rhs) const { return !(*this < rhs); } bool operator==(const TableName& rhs) const diff --git a/dbcon/mysql/CMakeLists.txt b/dbcon/mysql/CMakeLists.txt index 7dde5b208..7d9b012ca 100644 --- a/dbcon/mysql/CMakeLists.txt +++ b/dbcon/mysql/CMakeLists.txt @@ -17,7 +17,7 @@ SET ( libcalmysql_SRCS ha_view.cpp sm.cpp ha_window_function.cpp ha_calpont_partition.cpp - ha_pseudocolumn.cpp ) + ha_pseudocolumn.cpp) add_definitions(-DMYSQL_DYNAMIC_PLUGIN) @@ -29,7 +29,40 @@ target_link_libraries(calmysql ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} ${NETSNMP_ set_target_properties(calmysql PROPERTIES VERSION 1.0.0 SOVERSION 1) -install(TARGETS calmysql DESTINATION ${ENGINE_LIBDIR} COMPONENT storage-engine) +SET ( is_columnstore_tables_SRCS + is_columnstore_tables.cpp + ) +add_library(is_columnstore_tables SHARED ${is_columnstore_tables_SRCS}) + +target_link_libraries(is_columnstore_tables ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} threadpool) + +# Don't prepend .so file with 'lib' +set_target_properties(is_columnstore_tables PROPERTIES PREFIX "") +set_target_properties(is_columnstore_tables PROPERTIES VERSION 1.0.0 SOVERSION 1) + +SET ( is_columnstore_columns_SRCS + is_columnstore_columns.cpp + ) +add_library(is_columnstore_columns SHARED ${is_columnstore_columns_SRCS}) + +target_link_libraries(is_columnstore_columns ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} threadpool) + +# Don't prepend .so file with 'lib' +set_target_properties(is_columnstore_columns PROPERTIES PREFIX "") +set_target_properties(is_columnstore_columns PROPERTIES VERSION 1.0.0 SOVERSION 1) + +SET ( is_columnstore_extents_SRCS + is_columnstore_extents.cpp + ) +add_library(is_columnstore_extents SHARED ${is_columnstore_extents_SRCS}) + +target_link_libraries(is_columnstore_extents ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} threadpool) + +# Don't prepend .so file with 'lib' +set_target_properties(is_columnstore_extents PROPERTIES PREFIX "") +set_target_properties(is_columnstore_extents PROPERTIES VERSION 1.0.0 SOVERSION 1) + +install(TARGETS calmysql is_columnstore_tables is_columnstore_columns is_columnstore_extents DESTINATION ${ENGINE_LIBDIR} COMPONENT storage-engine) install(FILES syscatalog_mysql.sql dumpcat_mysql.sql calsetuserpriority.sql diff --git a/dbcon/mysql/install_calpont_mysql.sh b/dbcon/mysql/install_calpont_mysql.sh index 5b2b981df..d04bc3487 100755 --- a/dbcon/mysql/install_calpont_mysql.sh +++ b/dbcon/mysql/install_calpont_mysql.sh @@ -30,6 +30,9 @@ df=$installdir/mysql/my.cnf $installdir/mysql/bin/mysql --defaults-file=$df --force --user=root $pwprompt mysql 2>/tmp/mysql_install.log < +#include + +#include +#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_columns_fields[] = +{ + {"TABLE_SCHEMA", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {"TABLE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {"COLUMN_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {"OBJECT_ID", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, + {"DICTIONARY_OBJECT_ID", 11, MYSQL_TYPE_LONG, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"LIST_OBJECT_ID", 11, MYSQL_TYPE_LONG, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"TREE_OBJECT_ID", 11, MYSQL_TYPE_LONG, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"DATA_TYPE", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {"COLUMN_LENGTH", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, + {"COLUMN_POSITION", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, + {"COLUMN_DEFAULT", 0, MYSQL_TYPE_LONG_BLOB, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"IS_NULLABLE", 1, MYSQL_TYPE_TINY, 0, 0, 0, 0}, + {"NUMERIC_PRECISION", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, + {"NUMERIC_SCALE", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, + {"IS_AUTOINCREMENT", 1, MYSQL_TYPE_TINY, 0, 0, 0, 0}, + {"COMPRESSION_TYPE", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {0, 0, MYSQL_TYPE_NULL, 0, 0, 0, 0} + +}; + +static int is_columnstore_columns_fill(THD *thd, TABLE_LIST *tables, COND *cond) +{ + CHARSET_INFO *cs = system_charset_info; + TABLE *table = tables->table; + + boost::shared_ptr systemCatalogPtr = + execplan::CalpontSystemCatalog::makeCalpontSystemCatalog(0); + + const std::vector< std::pair > catalog_tables + = systemCatalogPtr->getTables(); + + for (std::vector >::const_iterator it = catalog_tables.begin(); + it != catalog_tables.end(); ++it) + { + execplan::CalpontSystemCatalog::RIDList column_rid_list = systemCatalogPtr->columnRIDs((*it).second); + for (size_t col_num = 0; col_num < column_rid_list.size(); col_num++) + { + execplan::CalpontSystemCatalog::TableColName tcn = systemCatalogPtr->colName(column_rid_list[col_num].objnum); + execplan::CalpontSystemCatalog::ColType ct = systemCatalogPtr->colType(column_rid_list[col_num].objnum); + + table->field[0]->store(tcn.schema.c_str(), tcn.schema.length(), cs); + table->field[1]->store(tcn.table.c_str(), tcn.table.length(), cs); + table->field[2]->store(tcn.column.c_str(), tcn.column.length(), cs); + table->field[3]->store(column_rid_list[col_num].objnum); + if (ct.ddn.dictOID == std::numeric_limits::min()) + { + table->field[4]->set_null(); + } + else + { + table->field[4]->set_notnull(); + table->field[4]->store(ct.ddn.dictOID); + } + if (ct.ddn.listOID == std::numeric_limits::min()) + { + table->field[5]->set_null(); + } + else + { + table->field[5]->set_notnull(); + table->field[5]->store(ct.ddn.listOID); + } + if (ct.ddn.treeOID == std::numeric_limits::min()) + { + table->field[6]->set_null(); + } + else + { + table->field[6]->set_notnull(); + table->field[6]->store(ct.ddn.treeOID); + } + std::string data_type = execplan::colDataTypeToString(ct.colDataType); + table->field[7]->store(data_type.c_str(), data_type.length(), cs); + table->field[8]->store(ct.colWidth); + table->field[9]->store(ct.colPosition); + if (ct.defaultValue.empty()) + { + table->field[10]->set_null(); + } + else + { + table->field[10]->set_notnull(); + table->field[10]->store(ct.defaultValue.c_str(), ct.defaultValue.length(), cs); + } + table->field[11]->store(ct.autoincrement); + table->field[12]->store(ct.precision); + table->field[13]->store(ct.scale); + if (ct.constraintType != execplan::CalpontSystemCatalog::NOTNULL_CONSTRAINT) + { + table->field[14]->store(true); + } + else + { + table->field[14]->store(false); + } + + std::string compression_type; + switch (ct.compressionType) + { + case 0: + compression_type = "None"; + break; + case 2: + compression_type = "Snappy"; + break; + default: + compression_type = "Unknown"; + break; + } + table->field[15]->store(compression_type.c_str(), compression_type.length(), cs); + if (schema_table_store_record(thd, table)) + return 1; + } + } + + + + return 0; +} + +static int is_columnstore_columns_plugin_init(void *p) +{ + ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE*) p; + schema->fields_info = is_columnstore_columns_fields; + schema->fill_table = is_columnstore_columns_fill; + return 0; +} + +static struct st_mysql_information_schema is_columnstore_columns_plugin_version = +{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; + +maria_declare_plugin(is_columnstore_columns_plugin) +{ + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &is_columnstore_columns_plugin_version, + "COLUMNSTORE_COLUMNS", + "MariaDB Corporaton", + "An information schema plugin to list ColumnStore columns", + PLUGIN_LICENSE_GPL, + is_columnstore_columns_plugin_init, + //is_columnstore_tables_plugin_deinit, + NULL, + 0x0100, + NULL, + NULL, + "1.0", + MariaDB_PLUGIN_MATURITY_STABLE +} +maria_declare_plugin_end; + + diff --git a/dbcon/mysql/is_columnstore_extents.cpp b/dbcon/mysql/is_columnstore_extents.cpp new file mode 100644 index 000000000..fa5835888 --- /dev/null +++ b/dbcon/mysql/is_columnstore_extents.cpp @@ -0,0 +1,222 @@ +/* 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 +#include + +#include +#include "dbrm.h" +#include "objectidmanager.h" +#include "we_convertor.h" +#include "we_define.h" +#include "IDBPolicy.h" +#include "we_config.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_extents_fields[] = +{ + {"OBJECT_ID", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, // 0 + {"OBJECT_TYPE", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0}, // 1 + {"LOGICAL_BLOCK_START", 19, MYSQL_TYPE_LONGLONG, 0, 0, 0, 0}, // 2 + {"LOGICAL_BLOCK_END", 19, MYSQL_TYPE_LONGLONG, 0, 0, 0, 0}, // 3 + {"MIN_VALUE", 19, MYSQL_TYPE_LONGLONG, 0, MY_I_S_MAYBE_NULL, 0, 0}, // 4 + {"MAX_VALUE", 19, MYSQL_TYPE_LONGLONG, 0, MY_I_S_MAYBE_NULL, 0, 0}, // 5 + {"WIDTH", 1, MYSQL_TYPE_TINY, 0, 0, 0, 0}, // 6 + {"DBROOT", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, // 7 + {"PARTITION_ID", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, // 8 + {"SEGMENT_ID", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, // 9 + {"BLOCK_OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, // 10 + {"MAX_BLOCKS", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, // 11 + {"HIGH_WATER_MARK", 11, MYSQL_TYPE_LONG, 0, 0, 0, 0}, // 12 + {"STATE", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0}, // 13 + {"STATUS", 64, MYSQL_TYPE_STRING, 0, 0, 0, 0}, // 14 + {"DATA_SIZE", 19, MYSQL_TYPE_LONGLONG, 0, 0, 0, 0}, // 15 + {"FILENAME", 1024, MYSQL_TYPE_STRING, 0, 0, 0, 0}, // 16 + {"FILE_SIZE", 19, MYSQL_TYPE_LONGLONG, 0, MY_I_S_MAYBE_NULL, 0, 0}, // 17 + {0, 0, MYSQL_TYPE_NULL, 0, 0, 0, 0} +}; + +static int is_columnstore_extents_fill(THD *thd, TABLE_LIST *tables, COND *cond) +{ + CHARSET_INFO *cs = system_charset_info; + TABLE *table = tables->table; + std::vector entries; + std::vector::iterator iter; + std::vector::iterator end; + char oidDirName[WriteEngine::FILE_NAME_SIZE]; + char fullFileName[WriteEngine::FILE_NAME_SIZE]; + char dbDir[WriteEngine::MAX_DB_DIR_LEVEL][WriteEngine::MAX_DB_DIR_NAME_SIZE]; + + BRM::DBRM *emp = new BRM::DBRM(); + if (!emp || !emp->isDBRMReady()) + { + return 1; + } + + execplan::ObjectIDManager oidm; + BRM::OID_t MaxOID = oidm.size(); + + for(BRM::OID_t oid = 0; oid <= MaxOID; oid++) + { + emp->getExtents(oid, entries, false, false, true); + if (entries.size() == 0) + continue; + + iter = entries.begin(); + end = entries.end(); + while (iter != end) + { + table->field[0]->store(oid); + if (iter->colWid > 0) + { + table->field[1]->store("Column", strlen("Column"), cs); + if (iter->partition.cprange.lo_val == std::numeric_limits::max() || + iter->partition.cprange.lo_val <= (std::numeric_limits::min() + 2)) + { + table->field[4]->set_null(); + } + else + { + table->field[4]->set_notnull(); + table->field[4]->store(iter->partition.cprange.lo_val); + } + if (iter->partition.cprange.hi_val == std::numeric_limits::max() || + iter->partition.cprange.hi_val <= (std::numeric_limits::min() + 2)) + { + table->field[5]->set_null(); + } + else + { + table->field[5]->set_notnull(); + table->field[5]->store(iter->partition.cprange.hi_val); + } + table->field[6]->store(iter->colWid); + + } + else + { + table->field[1]->store("Dictionary", strlen("Dictionary"), cs); + table->field[4]->set_null(); + table->field[5]->set_null(); + table->field[6]->store(8192); + } + table->field[2]->store(iter->range.start); + table->field[3]->store(iter->range.start + (iter->range.size * 1024) - 1); + + table->field[7]->store(iter->dbRoot); + table->field[8]->store(iter->partitionNum); + table->field[9]->store(iter->segmentNum); + table->field[10]->store(iter->blockOffset); + table->field[11]->store(iter->range.size * 1024); + table->field[12]->store(iter->HWM); + + switch (iter->partition.cprange.isValid) + { + case 0: + table->field[13]->store("Invalid", strlen("Invalid"), cs); + break; + case 1: + table->field[13]->store("Updating", strlen("Updating"), cs); + break; + case 2: + table->field[13]->store("Valid", strlen("Valid"), cs); + break; + default: + table->field[13]->store("Unknown", strlen("Unknown"), cs); + break; + } + switch (iter->status) + { + case BRM::EXTENTAVAILABLE: + table->field[14]->store("Available", strlen("Available"), cs); + break; + case BRM::EXTENTUNAVAILABLE: + table->field[14]->store("Unavailable", strlen("Unavailable"), cs); + break; + case BRM::EXTENTOUTOFSERVICE: + table->field[14]->store("Out of service", strlen("Out of service"), cs); + break; + default: + table->field[14]->store("Unknown", strlen("Unknown"), cs); + } + table->field[15]->store((iter->HWM + 1) * 8192); + + WriteEngine::Convertor::oid2FileName(oid, oidDirName, dbDir, iter->partitionNum, iter->segmentNum); + snprintf(fullFileName, WriteEngine::FILE_NAME_SIZE, "%s/%s", WriteEngine::Config::getDBRootByNum(iter->dbRoot).c_str(), oidDirName); + table->field[16]->store(fullFileName, strlen(fullFileName), cs); + + if (idbdatafile::IDBPolicy::exists(fullFileName)) + { + table->field[17]->set_notnull(); + table->field[17]->store(idbdatafile::IDBPolicy::size(fullFileName)); + } + else + { + table->field[17]->set_null(); + } + + if (schema_table_store_record(thd, table)) + return 1; + + iter++; + + } + } + + + return 0; +} + +static int is_columnstore_extents_plugin_init(void *p) +{ + ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE*) p; + schema->fields_info = is_columnstore_extents_fields; + schema->fill_table = is_columnstore_extents_fill; + return 0; +} + +static struct st_mysql_information_schema is_columnstore_extents_plugin_version = +{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; + +maria_declare_plugin(is_columnstore_extents_plugin) +{ + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &is_columnstore_extents_plugin_version, + "COLUMNSTORE_EXTENTS", + "MariaDB Corporaton", + "An information schema plugin to list ColumnStore extents", + PLUGIN_LICENSE_GPL, + is_columnstore_extents_plugin_init, + //is_columnstore_extents_plugin_deinit, + NULL, + 0x0100, + NULL, + NULL, + "1.0", + MariaDB_PLUGIN_MATURITY_STABLE +} +maria_declare_plugin_end; + + diff --git a/dbcon/mysql/is_columnstore_tables.cpp b/dbcon/mysql/is_columnstore_tables.cpp new file mode 100644 index 000000000..e38c8d5e7 --- /dev/null +++ b/dbcon/mysql/is_columnstore_tables.cpp @@ -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 + +#include +#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 systemCatalogPtr = + execplan::CalpontSystemCatalog::makeCalpontSystemCatalog(0); + + const std::vector< std::pair > catalog_tables + = systemCatalogPtr->getTables(); + + for (std::vector >::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; + + diff --git a/oam/install_scripts/post-mysqld-install b/oam/install_scripts/post-mysqld-install index 833f5f26c..92ea035fa 100755 --- a/oam/install_scripts/post-mysqld-install +++ b/oam/install_scripts/post-mysqld-install @@ -82,9 +82,15 @@ chown -R $user.$user $installdir/mysql if [ -f $installdir/lib/libcalmysql.so.1.0.0 ]; then libcalmysql=$installdir/lib/libcalmysql.so.1.0.0 libudfsdk=$installdir/lib/libudf_mysql.so.1.0.0 + is_columnstore_tables=$installdir/lib/is_columnstore_tables.so.1.0.0 + is_columnstore_columns=$installdir/lib/is_columnstore_columns.so.1.0.0 + is_columnstore_extents=$installdir/lib/is_columnstore_extents.so.1.0.0 elif [ -f $installdir/lib/libcalmysql.so.1 ]; then libcalmysql=$installdir/lib/libcalmysql.so.1 libudfsdk=$installdir/lib/libudf_mysql.so.1 + is_columnstore_tables=$installdir/lib/is_columnstore_tables.so.1 + is_columnstore_columns=$installdir/lib/is_columnstore_columns.so.1 + is_columnstore_extents=$installdir/lib/is_columnstore_extents.so.1 else libcalmysql= fi @@ -93,8 +99,11 @@ if [ -n "$libcalmysql" ]; then cd $installdir/mysql/lib/plugin ln -sf $libcalmysql libcalmysql.so - ln -sf $libcalmysql libcalmysqlent.so + ln -sf $libcalmysql libcalmysqlent.so ln -sf $libudfsdk libudf_mysql.so + ln -sf $is_columnstore_tables is_columnstore_tables.so + ln -sf $is_columnstore_columns is_columnstore_columns.so + ln -sf $is_columnstore_extents is_columnstore_extents.so fi # cleanup previous install mysql replication files diff --git a/writeengine/server/we_ddlcommandproc.cpp b/writeengine/server/we_ddlcommandproc.cpp index b896b25a3..2ccdd08ae 100644 --- a/writeengine/server/we_ddlcommandproc.cpp +++ b/writeengine/server/we_ddlcommandproc.cpp @@ -193,7 +193,7 @@ uint8_t WE_DDLCommandProc::writeSystable(ByteStream& bs, std::string &err) t = time(NULL); gmtime_r(&t, &tmp); - aDay.year = tmp.tm_year; + aDay.year = tmp.tm_year + 1900; aDay.month = tmp.tm_mon+1; aDay.day = tmp.tm_mday;