summaryrefslogtreecommitdiff
path: root/storage/xtradb/dict
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-01-03 19:32:47 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-01-03 19:32:47 +0200
commit80d5d1452a4a6b7bd1627116f2a5a950003fc3cb (patch)
tree15a86eab06593ce0195a18172aac9d093c5a6651 /storage/xtradb/dict
parent3871477c40efc826805f4c4e35b006c2c233dd26 (diff)
downloadmariadb-git-80d5d1452a4a6b7bd1627116f2a5a950003fc3cb.tar.gz
MDEV-11694 InnoDB tries to create unused table SYS_ZIP_DICTbb-10.0-mdev-11694
MariaDB Server 10.0.28 and 10.1.19 merged code from Percona XtraDB that introduced support for compressed columns. Much but not all of this code was disabled by placing #ifdef HAVE_PERCONA_COMPRESSED_COLUMNS around it. Among the unused but not disabled code is code to access some new system tables related to compressed columns. The creation of these system tables SYS_ZIP_DICT and SYS_ZIP_DICT_COLS would cause a crash in --innodb-read-only mode when upgrading from an earlier version to 10.0.28 or 10.1.19. Let us remove all the dead code related to compressed columns. Users who already upgraded to 10.0.28 and 10.1.19 will have the two above mentioned empty tables in their InnoDB system tablespace. Subsequent versions of MariaDB Server will completely ignore those tables.
Diffstat (limited to 'storage/xtradb/dict')
-rw-r--r--storage/xtradb/dict/dict0boot.cc5
-rw-r--r--storage/xtradb/dict/dict0crea.cc583
-rw-r--r--storage/xtradb/dict/dict0dict.cc160
-rw-r--r--storage/xtradb/dict/dict0load.cc160
4 files changed, 5 insertions, 903 deletions
diff --git a/storage/xtradb/dict/dict0boot.cc b/storage/xtradb/dict/dict0boot.cc
index c0bb0298bea..20ab5d75205 100644
--- a/storage/xtradb/dict/dict0boot.cc
+++ b/storage/xtradb/dict/dict0boot.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
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
@@ -272,10 +273,6 @@ dict_boot(void)
ut_ad(DICT_NUM_FIELDS__SYS_FOREIGN_FOR_NAME == 2);
ut_ad(DICT_NUM_COLS__SYS_FOREIGN_COLS == 4);
ut_ad(DICT_NUM_FIELDS__SYS_FOREIGN_COLS == 6);
- ut_ad(DICT_NUM_COLS__SYS_ZIP_DICT == 3);
- ut_ad(DICT_NUM_FIELDS__SYS_ZIP_DICT == 5);
- ut_ad(DICT_NUM_COLS__SYS_ZIP_DICT_COLS == 3);
- ut_ad(DICT_NUM_FIELDS__SYS_ZIP_DICT_COLS == 5);
mtr_start(&mtr);
diff --git a/storage/xtradb/dict/dict0crea.cc b/storage/xtradb/dict/dict0crea.cc
index db0ca638de4..9a4040421d7 100644
--- a/storage/xtradb/dict/dict0crea.cc
+++ b/storage/xtradb/dict/dict0crea.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
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
@@ -1932,135 +1933,6 @@ dict_create_or_check_sys_tablespace(void)
return(err);
}
-/** Creates the zip_dict system table inside InnoDB
-at server bootstrap or server start if it is not found or is
-not of the right form.
-@return DB_SUCCESS or error code */
-UNIV_INTERN
-dberr_t
-dict_create_or_check_sys_zip_dict(void)
-{
- trx_t* trx;
- my_bool srv_file_per_table_backup;
- dberr_t err;
- dberr_t sys_zip_dict_err;
- dberr_t sys_zip_dict_cols_err;
-
- ut_a(srv_get_active_thread_type() == SRV_NONE);
-
- /* Note: The master thread has not been started at this point. */
-
- sys_zip_dict_err = dict_check_if_system_table_exists(
- "SYS_ZIP_DICT", DICT_NUM_FIELDS__SYS_ZIP_DICT + 1, 2);
- sys_zip_dict_cols_err = dict_check_if_system_table_exists(
- "SYS_ZIP_DICT_COLS", DICT_NUM_FIELDS__SYS_ZIP_DICT_COLS + 1,
- 1);
-
- if (sys_zip_dict_err == DB_SUCCESS &&
- sys_zip_dict_cols_err == DB_SUCCESS)
- return (DB_SUCCESS);
-
- trx = trx_allocate_for_mysql();
-
- trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
-
- trx->op_info = "creating zip_dict and zip_dict_cols sys tables";
-
- row_mysql_lock_data_dictionary(trx);
-
- /* Check which incomplete table definition to drop. */
-
- if (sys_zip_dict_err == DB_CORRUPTION) {
- ib_logf(IB_LOG_LEVEL_WARN,
- "Dropping incompletely created "
- "SYS_ZIP_DICT table.");
- row_drop_table_for_mysql("SYS_ZIP_DICT", trx, TRUE, TRUE);
- }
- if (sys_zip_dict_cols_err == DB_CORRUPTION) {
- ib_logf(IB_LOG_LEVEL_WARN,
- "Dropping incompletely created "
- "SYS_ZIP_DICT_COLS table.");
- row_drop_table_for_mysql("SYS_ZIP_DICT_COLS", trx, TRUE, TRUE);
- }
-
- ib_logf(IB_LOG_LEVEL_INFO,
- "Creating zip_dict and zip_dict_cols system tables.");
-
- /* We always want SYSTEM tables to be created inside the system
- tablespace. */
- srv_file_per_table_backup = srv_file_per_table;
- srv_file_per_table = 0;
-
- err = que_eval_sql(
- NULL,
- "PROCEDURE CREATE_SYS_ZIP_DICT_PROC () IS\n"
- "BEGIN\n"
- "CREATE TABLE SYS_ZIP_DICT(\n"
- " ID INT UNSIGNED NOT NULL,\n"
- " NAME CHAR("
- STRINGIFY_ARG(ZIP_DICT_MAX_NAME_LENGTH)
- ") NOT NULL,\n"
- " DATA BLOB NOT NULL\n"
- ");\n"
- "CREATE UNIQUE CLUSTERED INDEX SYS_ZIP_DICT_ID"
- " ON SYS_ZIP_DICT (ID);\n"
- "CREATE UNIQUE INDEX SYS_ZIP_DICT_NAME"
- " ON SYS_ZIP_DICT (NAME);\n"
- "CREATE TABLE SYS_ZIP_DICT_COLS(\n"
- " TABLE_ID INT UNSIGNED NOT NULL,\n"
- " COLUMN_POS INT UNSIGNED NOT NULL,\n"
- " DICT_ID INT UNSIGNED NOT NULL\n"
- ");\n"
- "CREATE UNIQUE CLUSTERED INDEX SYS_ZIP_DICT_COLS_COMPOSITE"
- " ON SYS_ZIP_DICT_COLS (TABLE_ID, COLUMN_POS);\n"
- "END;\n",
- FALSE, trx);
-
- if (err != DB_SUCCESS) {
- ib_logf(IB_LOG_LEVEL_ERROR,
- "Creation of SYS_ZIP_DICT and SYS_ZIP_DICT_COLS"
- "has failed with error %lu. Tablespace is full. "
- "Dropping incompletely created tables.",
- (ulong) err);
-
- ut_a(err == DB_OUT_OF_FILE_SPACE
- || err == DB_TOO_MANY_CONCURRENT_TRXS);
-
- row_drop_table_for_mysql("SYS_ZIP_DICT", trx, TRUE, TRUE);
- row_drop_table_for_mysql("SYS_ZIP_DICT_COLS", trx, TRUE, TRUE);
-
- if (err == DB_OUT_OF_FILE_SPACE) {
- err = DB_MUST_GET_MORE_FILE_SPACE;
- }
- }
-
- trx_commit_for_mysql(trx);
-
- row_mysql_unlock_data_dictionary(trx);
-
- trx_free_for_mysql(trx);
-
- srv_file_per_table = srv_file_per_table_backup;
-
- if (err == DB_SUCCESS) {
- ib_logf(IB_LOG_LEVEL_INFO,
- "zip_dict and zip_dict_cols system tables created.");
- }
-
- /* Note: The master thread has not been started at this point. */
- /* Confirm and move to the non-LRU part of the table LRU list. */
-
- sys_zip_dict_err = dict_check_if_system_table_exists(
- "SYS_ZIP_DICT", DICT_NUM_FIELDS__SYS_ZIP_DICT + 1, 2);
- ut_a(sys_zip_dict_err == DB_SUCCESS);
- sys_zip_dict_cols_err = dict_check_if_system_table_exists(
- "SYS_ZIP_DICT_COLS",
- DICT_NUM_FIELDS__SYS_ZIP_DICT_COLS + 1, 1);
- ut_a(sys_zip_dict_cols_err == DB_SUCCESS);
-
- return(err);
-}
-
/********************************************************************//**
Add a single tablespace definition to the data dictionary tables in the
database.
@@ -2114,456 +1986,3 @@ dict_create_add_tablespace_to_dictionary(
return(error);
}
-
-/** Add a single compression dictionary definition to the SYS_ZIP_DICT
-InnoDB system table.
-@return error code or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-dict_create_add_zip_dict(
- const char* name, /*!< in: dict name */
- ulint name_len, /*!< in: dict name length */
- const char* data, /*!< in: dict data */
- ulint data_len, /*!< in: dict data length */
- trx_t* trx) /*!< in/out: transaction */
-{
- ut_ad(name);
- ut_ad(data);
-
- pars_info_t* info = pars_info_create();
-
- pars_info_add_literal(info, "name", name, name_len,
- DATA_VARCHAR, DATA_ENGLISH);
- pars_info_add_literal(info, "data", data, data_len,
- DATA_BLOB, DATA_BINARY_TYPE | DATA_NOT_NULL);
-
- dberr_t error = que_eval_sql(info,
- "PROCEDURE P () IS\n"
- " max_id INT;\n"
- "DECLARE CURSOR cur IS\n"
- " SELECT ID FROM SYS_ZIP_DICT\n"
- " ORDER BY ID DESC;\n"
- "BEGIN\n"
- " max_id := 0;\n"
- " OPEN cur;\n"
- " FETCH cur INTO max_id;\n"
- " IF (cur % NOTFOUND) THEN\n"
- " max_id := 0;\n"
- " END IF;\n"
- " CLOSE cur;\n"
- " INSERT INTO SYS_ZIP_DICT VALUES"
- " (max_id + 1, :name, :data);\n"
- "END;\n",
- FALSE, trx);
-
- return error;
-}
-
-/** Fetch callback, just stores extracted zip_dict id in the external
-variable.
-@return TRUE if all OK */
-static
-ibool
-dict_create_extract_int_aux(
- void* row, /*!< in: sel_node_t* */
- void* user_arg) /*!< in: int32 id */
-{
- sel_node_t* node = static_cast<sel_node_t*>(row);
- dfield_t* dfield = que_node_get_val(node->select_list);
- dtype_t* type = dfield_get_type(dfield);
- ulint len = dfield_get_len(dfield);
-
- ut_a(dtype_get_mtype(type) == DATA_INT);
- ut_a(len == sizeof(ib_uint32_t));
-
- memcpy(user_arg, dfield_get_data(dfield), sizeof(ib_uint32_t));
-
- return(TRUE);
-}
-
-/** Add a single compression dictionary reference to the SYS_ZIP_DICT_COLS
-InnoDB system table.
-@return error code or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-dict_create_add_zip_dict_reference(
- ulint table_id, /*!< in: table id */
- ulint column_pos, /*!< in: column position */
- ulint dict_id, /*!< in: dict id */
- trx_t* trx) /*!< in/out: transaction */
-{
- pars_info_t* info = pars_info_create();
-
- pars_info_add_int4_literal(info, "table_id", table_id);
- pars_info_add_int4_literal(info, "column_pos", column_pos);
- pars_info_add_int4_literal(info, "dict_id", dict_id);
-
- dberr_t error = que_eval_sql(info,
- "PROCEDURE P () IS\n"
- "BEGIN\n"
- " INSERT INTO SYS_ZIP_DICT_COLS VALUES"
- " (:table_id, :column_pos, :dict_id);\n"
- "END;\n",
- FALSE, trx);
- return error;
-}
-
-/** Get a single compression dictionary id for the given
-(table id, column pos) pair.
-@return error code or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-dict_create_get_zip_dict_id_by_reference(
- ulint table_id, /*!< in: table id */
- ulint column_pos, /*!< in: column position */
- ulint* dict_id, /*!< out: dict id */
- trx_t* trx) /*!< in/out: transaction */
-{
- ut_ad(dict_id);
-
- pars_info_t* info = pars_info_create();
-
- ib_uint32_t dict_id_buf;
- mach_write_to_4(reinterpret_cast<byte*>(&dict_id_buf ),
- ULINT32_UNDEFINED);
-
- pars_info_add_int4_literal(info, "table_id", table_id);
- pars_info_add_int4_literal(info, "column_pos", column_pos);
- pars_info_bind_function(
- info, "my_func", dict_create_extract_int_aux, &dict_id_buf);
-
- dberr_t error = que_eval_sql(info,
- "PROCEDURE P () IS\n"
- "DECLARE FUNCTION my_func;\n"
- "DECLARE CURSOR cur IS\n"
- " SELECT DICT_ID FROM SYS_ZIP_DICT_COLS\n"
- " WHERE TABLE_ID = :table_id AND\n"
- " COLUMN_POS = :column_pos;\n"
- "BEGIN\n"
- " OPEN cur;\n"
- " FETCH cur INTO my_func();\n"
- " CLOSE cur;\n"
- "END;\n",
- FALSE, trx);
- if (error == DB_SUCCESS) {
- ib_uint32_t local_dict_id = mach_read_from_4(
- reinterpret_cast<const byte*>(&dict_id_buf));
- if (local_dict_id == ULINT32_UNDEFINED)
- error = DB_RECORD_NOT_FOUND;
- else
- *dict_id = local_dict_id;
- }
- return error;
-}
-
-/** Get compression dictionary id for the given name.
-@return error code or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-dict_create_get_zip_dict_id_by_name(
- const char* dict_name, /*!< in: dict name */
- ulint dict_name_len, /*!< in: dict name length */
- ulint* dict_id, /*!< out: dict id */
- trx_t* trx) /*!< in/out: transaction */
-{
- ut_ad(dict_name);
- ut_ad(dict_name_len);
- ut_ad(dict_id);
-
- pars_info_t* info = pars_info_create();
-
- pars_info_add_literal(info, "dict_name", dict_name, dict_name_len,
- DATA_VARCHAR, DATA_ENGLISH);
-
- ib_uint32_t dict_id_buf;
- mach_write_to_4(reinterpret_cast<byte*>(&dict_id_buf),
- ULINT32_UNDEFINED);
- pars_info_bind_function(
- info, "my_func", dict_create_extract_int_aux, &dict_id_buf);
-
- dberr_t error = que_eval_sql(info,
- "PROCEDURE P () IS\n"
- "DECLARE FUNCTION my_func;\n"
- "DECLARE CURSOR cur IS\n"
- " SELECT ID FROM SYS_ZIP_DICT\n"
- " WHERE NAME = :dict_name;\n"
- "BEGIN\n"
- " OPEN cur;\n"
- " FETCH cur INTO my_func();\n"
- " CLOSE cur;\n"
- "END;\n",
- FALSE, trx);
- if (error == DB_SUCCESS) {
- ib_uint32_t local_dict_id = mach_read_from_4(
- reinterpret_cast<const byte*>(&dict_id_buf));
- if (local_dict_id == ULINT32_UNDEFINED)
- error = DB_RECORD_NOT_FOUND;
- else
- *dict_id = local_dict_id;
- }
- return error;
-}
-
-/** Auxiliary enum used to indicate zip dict data extraction result code */
-enum zip_dict_info_aux_code {
- zip_dict_info_success, /*!< success */
- zip_dict_info_not_found, /*!< zip dict record not found */
- zip_dict_info_oom, /*!< out of memory */
- zip_dict_info_corrupted_name, /*!< corrupted zip dict name */
- zip_dict_info_corrupted_data /*!< corrupted zip dict data */
-};
-
-/** Auxiliary struct used to return zip dict info aling with result code */
-struct zip_dict_info_aux {
- LEX_STRING name; /*!< zip dict name */
- LEX_STRING data; /*!< zip dict data */
- int code; /*!< result code (0 - success) */
-};
-
-/** Fetch callback, just stores extracted zip_dict data in the external
-variable.
-@return always returns TRUE */
-static
-ibool
-dict_create_get_zip_dict_info_by_id_aux(
- void* row, /*!< in: sel_node_t* */
- void* user_arg) /*!< in: pointer to zip_dict_info_aux* */
-{
- sel_node_t* node = static_cast<sel_node_t*>(row);
- zip_dict_info_aux* result =
- static_cast<zip_dict_info_aux*>(user_arg);
-
- result->code = zip_dict_info_success;
- result->name.str = 0;
- result->name.length = 0;
- result->data.str = 0;
- result->data.length = 0;
-
- /* NAME field */
- que_node_t* exp = node->select_list;
- ut_a(exp != 0);
-
- dfield_t* dfield = que_node_get_val(exp);
- dtype_t* type = dfield_get_type(dfield);
- ut_a(dtype_get_mtype(type) == DATA_VARCHAR);
-
- ulint len = dfield_get_len(dfield);
- void* data = dfield_get_data(dfield);
-
-
- if (len == UNIV_SQL_NULL) {
- result->code = zip_dict_info_corrupted_name;
- }
- else {
- result->name.str =
- static_cast<char*>(my_malloc(len + 1, MYF(0)));
- if (result->name.str == 0) {
- result->code = zip_dict_info_oom;
- }
- else {
- memcpy(result->name.str, data, len);
- result->name.str[len] = '\0';
- result->name.length = len;
- }
- }
-
- /* DATA field */
- exp = que_node_get_next(exp);
- ut_a(exp != 0);
-
- dfield = que_node_get_val(exp);
- type = dfield_get_type(dfield);
- ut_a(dtype_get_mtype(type) == DATA_BLOB);
-
- len = dfield_get_len(dfield);
- data = dfield_get_data(dfield);
-
- if (len == UNIV_SQL_NULL) {
- result->code = zip_dict_info_corrupted_data;
- }
- else {
- result->data.str =
- static_cast<char*>(my_malloc(
- len == 0 ? 1 : len, MYF(0)));
- if (result->data.str == 0) {
- result->code = zip_dict_info_oom;
- }
- else {
- memcpy(result->data.str, data, len);
- result->data.length = len;
- }
- }
-
- ut_ad(que_node_get_next(exp) == 0);
-
- if (result->code != zip_dict_info_success) {
- if (result->name.str == 0) {
- mem_free(result->name.str);
- result->name.str = 0;
- result->name.length = 0;
- }
- if (result->data.str == 0) {
- mem_free(result->data.str);
- result->data.str = 0;
- result->data.length = 0;
- }
- }
-
- return TRUE;
-}
-
-/** Get compression dictionary info (name and data) for the given id.
-Allocates memory for name and data on success.
-Must be freed with mem_free().
-@return error code or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-dict_create_get_zip_dict_info_by_id(
- ulint dict_id, /*!< in: dict id */
- char** name, /*!< out: dict name */
- ulint* name_len, /*!< out: dict name length*/
- char** data, /*!< out: dict data */
- ulint* data_len, /*!< out: dict data length*/
- trx_t* trx) /*!< in/out: transaction */
-{
- ut_ad(name);
- ut_ad(data);
-
- zip_dict_info_aux rec;
- rec.code = zip_dict_info_not_found;
- pars_info_t* info = pars_info_create();
-
- pars_info_add_int4_literal(info, "id", dict_id);
- pars_info_bind_function(
- info, "my_func", dict_create_get_zip_dict_info_by_id_aux,
- &rec);
-
- dberr_t error = que_eval_sql(info,
- "PROCEDURE P () IS\n"
- "DECLARE FUNCTION my_func;\n"
- "DECLARE CURSOR cur IS\n"
- " SELECT NAME, DATA FROM SYS_ZIP_DICT\n"
- " WHERE ID = :id;\n"
- "BEGIN\n"
- " OPEN cur;\n"
- " FETCH cur INTO my_func();\n"
- " CLOSE cur;\n"
- "END;\n",
- FALSE, trx);
- if (error == DB_SUCCESS) {
- switch (rec.code) {
- case zip_dict_info_success:
- *name = rec.name.str;
- *name_len = rec.name.length;
- *data = rec.data.str;
- *data_len = rec.data.length;
- break;
- case zip_dict_info_not_found:
- error = DB_RECORD_NOT_FOUND;
- break;
- case zip_dict_info_oom:
- error = DB_OUT_OF_MEMORY;
- break;
- case zip_dict_info_corrupted_name:
- case zip_dict_info_corrupted_data:
- error = DB_INVALID_NULL;
- break;
- default:
- ut_error;
- }
- }
- return error;
-}
-
-/** Remove a single compression dictionary from the data dictionary
-tables in the database.
-@return error code or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-dict_create_remove_zip_dict(
- const char* name, /*!< in: dict name */
- ulint name_len, /*!< in: dict name length */
- trx_t* trx) /*!< in/out: transaction */
-{
- ut_ad(name);
-
- pars_info_t* info = pars_info_create();
-
- ib_uint32_t dict_id_buf;
- mach_write_to_4(reinterpret_cast<byte*>(&dict_id_buf),
- ULINT32_UNDEFINED);
- ib_uint32_t counter_buf;
- mach_write_to_4(reinterpret_cast<byte*>(&counter_buf),
- ULINT32_UNDEFINED);
-
- pars_info_add_literal(info, "name", name, name_len,
- DATA_VARCHAR, DATA_ENGLISH);
- pars_info_bind_int4_literal(info, "dict_id", &dict_id_buf);
- pars_info_bind_function(info, "find_dict_func",
- dict_create_extract_int_aux, &dict_id_buf);
- pars_info_bind_function(info, "count_func",
- dict_create_extract_int_aux, &counter_buf);
-
- dberr_t error = que_eval_sql(info,
- "PROCEDURE P () IS\n"
- "DECLARE FUNCTION find_dict_func;\n"
- "DECLARE FUNCTION count_func;\n"
- "DECLARE CURSOR dict_cur IS\n"
- " SELECT ID FROM SYS_ZIP_DICT\n"
- " WHERE NAME = :name\n"
- " FOR UPDATE;\n"
- "DECLARE CURSOR ref_cur IS\n"
- " SELECT 1 FROM SYS_ZIP_DICT_COLS\n"
- " WHERE DICT_ID = :dict_id;\n"
- "BEGIN\n"
- " OPEN dict_cur;\n"
- " FETCH dict_cur INTO find_dict_func();\n"
- " IF NOT (SQL % NOTFOUND) THEN\n"
- " OPEN ref_cur;\n"
- " FETCH ref_cur INTO count_func();\n"
- " IF SQL % NOTFOUND THEN\n"
- " DELETE FROM SYS_ZIP_DICT WHERE CURRENT OF dict_cur;\n"
- " END IF;\n"
- " CLOSE ref_cur;\n"
- " END IF;\n"
- " CLOSE dict_cur;\n"
- "END;\n",
- FALSE, trx);
- if (error == DB_SUCCESS) {
- ib_uint32_t local_dict_id = mach_read_from_4(
- reinterpret_cast<const byte*>(&dict_id_buf));
- if (local_dict_id == ULINT32_UNDEFINED) {
- error = DB_RECORD_NOT_FOUND;
- }
- else {
- ib_uint32_t local_counter = mach_read_from_4(
- reinterpret_cast<const byte*>(&counter_buf));
- if (local_counter != ULINT32_UNDEFINED)
- error = DB_ROW_IS_REFERENCED;
- }
- }
- return error;
-}
-
-/** Remove all compression dictionary references for the given table ID from
-the data dictionary tables in the database.
-@return error code or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-dict_create_remove_zip_dict_references_for_table(
- ulint table_id, /*!< in: table id */
- trx_t* trx) /*!< in/out: transaction */
-{
- pars_info_t* info = pars_info_create();
-
- pars_info_add_int4_literal(info, "table_id", table_id);
-
- dberr_t error = que_eval_sql(info,
- "PROCEDURE P () IS\n"
- "BEGIN\n"
- " DELETE FROM SYS_ZIP_DICT_COLS\n"
- " WHERE TABLE_ID = :table_id;\n"
- "END;\n",
- FALSE, trx);
- return error;
-}
diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc
index 3845138c8bf..339e5615bea 100644
--- a/storage/xtradb/dict/dict0dict.cc
+++ b/storage/xtradb/dict/dict0dict.cc
@@ -2,7 +2,7 @@
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2014, 2015, MariaDB Corporation.
+Copyright (c) 2014, 2017, MariaDB Corporation.
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
@@ -7288,161 +7288,3 @@ dict_tf_to_row_format_string(
return(0);
}
#endif /* !UNIV_HOTBACKUP */
-
-/** Insert a records into SYS_ZIP_DICT.
-@retval DB_SUCCESS if OK
-@retval dberr_t if the insert failed */
-UNIV_INTERN
-dberr_t
-dict_create_zip_dict(
- const char* name, /*!< in: zip_dict name */
- ulint name_len, /*!< in: zip_dict name length*/
- const char* data, /*!< in: zip_dict data */
- ulint data_len) /*!< in: zip_dict data length */
-{
- dberr_t err = DB_SUCCESS;
- trx_t* trx;
-
- ut_ad(name);
- ut_ad(data);
-
- rw_lock_x_lock(&dict_operation_lock);
- dict_mutex_enter_for_mysql();
-
- trx = trx_allocate_for_background();
- trx->op_info = "insert zip_dict";
- trx->dict_operation_lock_mode = RW_X_LATCH;
- trx_start_if_not_started(trx);
-
- err = dict_create_add_zip_dict(name, name_len, data, data_len, trx);
-
- if (err == DB_SUCCESS) {
- trx_commit_for_mysql(trx);
- }
- else {
- trx->op_info = "rollback of internal trx on zip_dict table";
- trx_rollback_to_savepoint(trx, NULL);
- ut_a(trx->error_state == DB_SUCCESS);
- }
- trx->op_info = "";
- trx->dict_operation_lock_mode = 0;
- trx_free_for_background(trx);
-
- dict_mutex_exit_for_mysql();
- rw_lock_x_unlock(&dict_operation_lock);
-
- return err;
-}
-/** Get single compression dictionary id for the given
-(table id, column pos) pair.
-@retval DB_SUCCESS if OK
-@retval DB_RECORD_NOT_FOUND if not found */
-UNIV_INTERN
-dberr_t
-dict_get_dictionary_id_by_key(
- ulint table_id, /*!< in: table id */
- ulint column_pos, /*!< in: column position */
- ulint* dict_id) /*!< out: zip_dict id */
-{
- dberr_t err = DB_SUCCESS;
- trx_t* trx;
-
- rw_lock_s_lock(&dict_operation_lock);
- dict_mutex_enter_for_mysql();
-
- trx = trx_allocate_for_background();
- trx->op_info = "get zip dict id by composite key";
- trx->dict_operation_lock_mode = RW_S_LATCH;
- trx_start_if_not_started(trx);
-
- err = dict_create_get_zip_dict_id_by_reference(table_id, column_pos,
- dict_id, trx);
-
- trx_commit_for_mysql(trx);
- trx->dict_operation_lock_mode = 0;
- trx_free_for_background(trx);
-
- dict_mutex_exit_for_mysql();
- rw_lock_s_unlock(&dict_operation_lock);
-
- return err;
-}
-/** Get compression dictionary info (name and data) for the given id.
-Allocates memory in name->str and data->str on success.
-Must be freed with mem_free().
-@retval DB_SUCCESS if OK
-@retval DB_RECORD_NOT_FOUND if not found */
-UNIV_INTERN
-dberr_t
-dict_get_dictionary_info_by_id(
- ulint dict_id, /*!< in: table name */
- char** name, /*!< out: dictionary name */
- ulint* name_len, /*!< out: dictionary name length*/
- char** data, /*!< out: dictionary data */
- ulint* data_len) /*!< out: dictionary data length*/
-{
- dberr_t err = DB_SUCCESS;
- trx_t* trx;
-
- rw_lock_s_lock(&dict_operation_lock);
- dict_mutex_enter_for_mysql();
-
- trx = trx_allocate_for_background();
- trx->op_info = "get zip dict name and data by id";
- trx->dict_operation_lock_mode = RW_S_LATCH;
- trx_start_if_not_started(trx);
-
- err = dict_create_get_zip_dict_info_by_id(dict_id, name, name_len,
- data, data_len, trx);
-
- trx_commit_for_mysql(trx);
- trx->dict_operation_lock_mode = 0;
- trx_free_for_background(trx);
-
- dict_mutex_exit_for_mysql();
- rw_lock_s_unlock(&dict_operation_lock);
-
- return err;
-}
-/** Delete a record in SYS_ZIP_DICT with the given name.
-@retval DB_SUCCESS if OK
-@retval DB_RECORD_NOT_FOUND if not found
-@retval DB_ROW_IS_REFERENCED if in use */
-UNIV_INTERN
-dberr_t
-dict_drop_zip_dict(
- const char* name, /*!< in: zip_dict name */
- ulint name_len) /*!< in: zip_dict name length*/
-{
- dberr_t err = DB_SUCCESS;
- trx_t* trx;
-
- ut_ad(name);
-
- rw_lock_x_lock(&dict_operation_lock);
- dict_mutex_enter_for_mysql();
-
- trx = trx_allocate_for_background();
- trx->op_info = "delete zip_dict";
- trx->dict_operation_lock_mode = RW_X_LATCH;
- trx_start_if_not_started(trx);
-
- err = dict_create_remove_zip_dict(name, name_len, trx);
-
- if (err == DB_SUCCESS) {
- trx_commit_for_mysql(trx);
- }
- else {
- trx->op_info = "rollback of internal trx on zip_dict table";
- trx_rollback_to_savepoint(trx, NULL);
- ut_a(trx->error_state == DB_SUCCESS);
- }
- trx->op_info = "";
- trx->dict_operation_lock_mode = 0;
- trx_free_for_background(trx);
-
- dict_mutex_exit_for_mysql();
- rw_lock_x_unlock(&dict_operation_lock);
-
- return err;
-}
diff --git a/storage/xtradb/dict/dict0load.cc b/storage/xtradb/dict/dict0load.cc
index 9ea4f4d873a..6cbd0a3d488 100644
--- a/storage/xtradb/dict/dict0load.cc
+++ b/storage/xtradb/dict/dict0load.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
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
@@ -56,9 +57,7 @@ static const char* SYSTEM_TABLE_NAME[] = {
"SYS_FOREIGN",
"SYS_FOREIGN_COLS",
"SYS_TABLESPACES",
- "SYS_DATAFILES",
- "SYS_ZIP_DICT",
- "SYS_ZIP_DICT_COLS"
+ "SYS_DATAFILES"
};
/* If this flag is TRUE, then we will load the cluster index's (and tables')
@@ -730,161 +729,6 @@ err_len:
return(NULL);
}
-/** This function parses a SYS_ZIP_DICT record, extracts necessary
-information from the record and returns to caller.
-@return error message, or NULL on success */
-UNIV_INTERN
-const char*
-dict_process_sys_zip_dict(
- mem_heap_t* heap, /*!< in/out: heap memory */
- ulint zip_size, /*!< in: nonzero=compressed BLOB page size */
- const rec_t* rec, /*!< in: current SYS_ZIP_DICT rec */
- ulint* id, /*!< out: dict id */
- const char** name, /*!< out: dict name */
- const char** data, /*!< out: dict data */
- ulint* data_len) /*!< out: dict data length */
-{
- ulint len;
- const byte* field;
-
- /* Initialize the output values */
- *id = ULINT_UNDEFINED;
- *name = NULL;
- *data = NULL;
- *data_len = 0;
-
- if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {
- return("delete-marked record in SYS_ZIP_DICT");
- }
-
- if (UNIV_UNLIKELY(
- rec_get_n_fields_old(rec)!= DICT_NUM_FIELDS__SYS_ZIP_DICT)) {
- return("wrong number of columns in SYS_ZIP_DICT record");
- }
-
- field = rec_get_nth_field_old(
- rec, DICT_FLD__SYS_ZIP_DICT__ID, &len);
- if (UNIV_UNLIKELY(len != DICT_FLD_LEN_SPACE)) {
- goto err_len;
- }
- *id = mach_read_from_4(field);
-
- rec_get_nth_field_offs_old(
- rec, DICT_FLD__SYS_ZIP_DICT__DB_TRX_ID, &len);
- if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
- goto err_len;
- }
-
- rec_get_nth_field_offs_old(
- rec, DICT_FLD__SYS_ZIP_DICT__DB_ROLL_PTR, &len);
- if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
- goto err_len;
- }
-
- field = rec_get_nth_field_old(
- rec, DICT_FLD__SYS_ZIP_DICT__NAME, &len);
- if (UNIV_UNLIKELY(len == 0 || len == UNIV_SQL_NULL)) {
- goto err_len;
- }
- *name = mem_heap_strdupl(heap, (char*) field, len);
-
- field = rec_get_nth_field_old(
- rec, DICT_FLD__SYS_ZIP_DICT__DATA, &len);
- if (UNIV_UNLIKELY(len == UNIV_SQL_NULL)) {
- goto err_len;
- }
-
- if (rec_get_1byte_offs_flag(rec) == 0 &&
- rec_2_is_field_extern(rec, DICT_FLD__SYS_ZIP_DICT__DATA)) {
- ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
-
- if (UNIV_UNLIKELY
- (!memcmp(field + len - BTR_EXTERN_FIELD_REF_SIZE,
- field_ref_zero,
- BTR_EXTERN_FIELD_REF_SIZE))) {
- goto err_len;
- }
- *data = reinterpret_cast<char*>(
- btr_copy_externally_stored_field(data_len, field,
- zip_size, len, heap, 0));
- }
- else {
- *data_len = len;
- *data = static_cast<char*>(mem_heap_dup(heap, field, len));
- }
-
- return(NULL);
-
-err_len:
- return("incorrect column length in SYS_ZIP_DICT");
-}
-
-/** This function parses a SYS_ZIP_DICT_COLS record, extracts necessary
-information from the record and returns to caller.
-@return error message, or NULL on success */
-UNIV_INTERN
-const char*
-dict_process_sys_zip_dict_cols(
- mem_heap_t* heap, /*!< in/out: heap memory */
- const rec_t* rec, /*!< in: current SYS_ZIP_DICT rec */
- ulint* table_id, /*!< out: table id */
- ulint* column_pos, /*!< out: column position */
- ulint* dict_id) /*!< out: dict id */
-{
- ulint len;
- const byte* field;
-
- /* Initialize the output values */
- *table_id = ULINT_UNDEFINED;
- *column_pos = ULINT_UNDEFINED;
- *dict_id = ULINT_UNDEFINED;
-
- if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {
- return("delete-marked record in SYS_ZIP_DICT_COLS");
- }
-
- if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) !=
- DICT_NUM_FIELDS__SYS_ZIP_DICT_COLS)) {
- return("wrong number of columns in SYS_ZIP_DICT_COLS"
- " record");
- }
-
- field = rec_get_nth_field_old(
- rec, DICT_FLD__SYS_ZIP_DICT_COLS__TABLE_ID, &len);
- if (UNIV_UNLIKELY(len != DICT_FLD_LEN_SPACE)) {
-err_len:
- return("incorrect column length in SYS_ZIP_DICT_COLS");
- }
- *table_id = mach_read_from_4(field);
-
- field = rec_get_nth_field_old(
- rec, DICT_FLD__SYS_ZIP_DICT_COLS__COLUMN_POS, &len);
- if (UNIV_UNLIKELY(len != DICT_FLD_LEN_SPACE)) {
- goto err_len;
- }
- *column_pos = mach_read_from_4(field);
-
- rec_get_nth_field_offs_old(
- rec, DICT_FLD__SYS_ZIP_DICT_COLS__DB_TRX_ID, &len);
- if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
- goto err_len;
- }
-
- rec_get_nth_field_offs_old(
- rec, DICT_FLD__SYS_ZIP_DICT_COLS__DB_ROLL_PTR, &len);
- if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
- goto err_len;
- }
-
- field = rec_get_nth_field_old(
- rec, DICT_FLD__SYS_ZIP_DICT_COLS__DICT_ID, &len);
- if (UNIV_UNLIKELY(len != DICT_FLD_LEN_SPACE)) {
- goto err_len;
- }
- *dict_id = mach_read_from_4(field);
-
- return(NULL);
-}
/********************************************************************//**
Determine the flags of a table as stored in SYS_TABLES.TYPE and N_COLS.
@return ULINT_UNDEFINED if error, else a valid dict_table_t::flags. */