Skip to content

Commit

Permalink
Compressed columns functionality merged from 5.6 to 5.7.
Browse files Browse the repository at this point in the history
Blueprint:
https://blueprints.launchpad.net/percona-server/+spec/compressed-columns-5.7

'create_tmp_field()' modified to make sure that fields in temporary tables will never have compressed attributes. This eliminates unnecessary double compression/decompression in queries like 'INSERT INTO t SELECT * FROM t', where 't' has compressed columns. As the result 'CREATE TABLE t2 AS SELECT * FROM t1' statement, where 't1' has compressed columns, no longer duplicates 'COLUMN_FORMAT=COMPRESSED' attributes in 't2'. 'xtradb_compressed_columns*' MTR test cases reworked accordingly. This change also fixes lp:1633957 existing in 5.6.33.

Low level zip_dict functions now call 'trx_start_if_not_started()' with proper read-write mode.

'innobase_check_zip_dicts()'/'innobase_create_zip_dict_references()' refactored to return/get results in form of std::map with ut_allocator. This also allowed to eliminate unnecessary call to 'dict_table_open_on_name()' to get table id in 'create_table_info_t::create_table()' when table definition does not have any compression dictionary references.

Memory management functions extended with INSTRUMENTATION arguments which are now mandatory in 5.7.

'DATA_BIG_LEN_MTYPE()' extended with additional parameter 'extra' which is used in to take into account 2-bytes header required for compressed fields.

Removed UNIV_INTERN attribute from the merged functions.
Error messages are now printed via 'ib::fatal()'/'ib::error()'/'ib::warning()'/'ib::note()'.

Compressed columns consistency MTR test cases as marked with 'big-test' flag.

Suppressed warnings in 'xtradb_compressed_*' MTR test cases caused by stricter 'sql_mode' in 5.7.

'innodb_zip.zip' MTR test case modified to exclude new 'XTRADB_ZIP_DICT*' tables from 'information_schema.tables' SELECT query.
Please also notice that because of the fact that 'InnoDB' is the default temporary storage engine in 5.7 (in contrast to 5.6, where it was 'MyISAM'), "SELECT engine FROM information_schema.tables WHERE table_name = 'XTRADB_ZIP_DICT'" will produce different results between 5.6 and 5.7.

'main.opt_hints_pfs' and 'query_rewrite.optional_columns' MTR test cases re-recorded because of changed statement digests, which in turns are caused by SQL parser changes.

'sys_vars.innodb_compressed_columns_threshold_basic'/'sys_vars.innodb_compressed_columns_zip_level_basic' - modified and-recorded  to use 'PERFORMANCE_SCHEMA.(GLOBAL|SESSION)_VARIABLES' instead of deprecated 'INFORMATION_SCHEMA.(GLOBAL|SESSION)_VARIABLES'.

Other test cases re-recorded because of either new XTRADB_ZIP_DICT/XTRADB_ZIP_DICT_COLS InnoDB system tables or because of the new innodb_compressed_columns_threshold/innodb_compressed_columns_zip_level system variables.

'FIRST_SUPPORTED_COMPRESSED_COLUMNS_VERSION' left unchanged - 50633 (the same as in 5.6 branch).

Added new 'omit_compressed_columns_show_extensions' DBUG keyword which allows to disable compressed columns extensions in 'SHOW CREATE TABLE' output.

***
Added support for compressed JSON columns.
'innodb.xtradb_compressed_columns' MTR test case extended with checks for JSON data type as the one to which 'COLUMN_FORMAT COMPRESSED' attribute can be applied.

Reworked 'innodb.xtradb_compressed_columns_ibd_sizes' - it now shows that using compression dictionaries helps to archive better compression ratio not only for BLOBs but for TEXTs and JSONs as well.

The set of 'innodb.xtradb_compressed_columns_consistency_*' MTR test cases extended with additional checks for read-write correctness of data in compressed JSON columns.

***
Added support for indexes on virtual columns based on compressed fields.

'innobase_get_computed_value()' extended with additional 'prebuilt' parameter which is needed to calculate the values of virtual columns based on compressed fields.

Purge threads now also have a 'fake' prebuilt object which is only used to store 'compress_heap'. This 'fake' prebuilt object is created in 'trx_purge_graph_build()' and destroyed in 'trx_purge_sys_close()'. In addition, compress heap is now emptied in 'row_purge_step()' as well.

'innodb_session_t' class extended with additional member 'm_locked_from_callback' which is used by 'ha_innobase::update_field_defs_with_zip_dict_info()' to determine whether 'dict_sys' mutex is already locked or not. This value is updated just before calling 'handler::my_prepare_gcolumn_template()' / 'handler::my_eval_gcolumn_expr_with_open()'. 'thd_to_innodb_session()' is used to get access to the 'innodb_session' from the 'thd'.

Implemented 'thd_free_innodb_session()' auxiliary function which is used at the end of the 'srv_worker_thread()' and 'srv_purge_coordinator_thread()' to clean up innodb_session object.

Added new 'innodb.xtradb_compressed_columns_virtual' MTR test case which guarantees that the server is stable when working with generated columns based on compressed fields. In addition, this test checks for both STORED and VIRTUAL generated column types and for both indexed and scan generated row access. It also includes SQL samples grabbed from crashes revealed in the '--debug=d,enforce_all_compressed_columns,remove_compressed_attributes_for_keys,omit_compressed_columns_show_extensions' full suite run.

***
Added support for COMPRESSED attribute in STORED generated columns.
It is now possible to make generated columns compressed with optional compression dictionary. Please, notice that this makes sense only for STORED generated columns, for VIRTUAL ones the ER_UNSUPPORTED_COMPRESSED_COLUMN_TYPE error will be reported.

New generated column definition syntax:
col_name data_type [GENERATED ALWAYS] AS (expression)
  [VIRTUAL | STORED] [UNIQUE [KEY]] [COMMENT comment]
  [[NOT] NULL] [[PRIMARY] KEY]
  [COLUMN_FORMAT {DEFAULT|COMPRESSED} [WITH COMPRESSION_DICTIONARY dict_name]]

The new syntax is allowed in both 'CREATE TABLE' and 'ALTER TABLE' statements. The latter can also be used to apply/remove COMPRESSED attribute to/from an existing STORED generated column. For instance
ALTER TABLE t MODIFY g BLOB GENERATED ALWAYS AS (a) STORED COLUMN_FORMAT COMPRESSED
or
ALTER TABLE t MODIFY g BLOB GENERATED ALWAYS AS (a) STORED COLUMN_FORMAT DEFAULT

'innodb.xtradb_compressed_columns_virtual' MTR test case extended with new checks for generated columns with COMPRESSED attributes including syntax checks, checks for STORED vs VIRTUAL specifiers and new data consistency assertions.
  • Loading branch information
percona-ysorokin committed Nov 24, 2016
2 parents dd290a6 + 35d5d3f commit d142eb0
Show file tree
Hide file tree
Showing 134 changed files with 10,542 additions and 349 deletions.
3 changes: 3 additions & 0 deletions client/client_priv.h
Expand Up @@ -109,6 +109,9 @@ enum options_client
OPT_CONNECTION_SERVER_ID,
OPT_TLS_VERSION,
OPT_SSL_MODE,
OPT_ENABLE_COMPRESSED_COLUMNS,
OPT_ENABLE_COMPRESSED_COLUMNS_WITH_DICTIONARIES,
OPT_DROP_COMPRESSION_DICTIONARY,
/* Add new option above this */
OPT_MAX_CLIENT_OPTION
};
Expand Down

0 comments on commit d142eb0

Please sign in to comment.