Skip to content

Commit

Permalink
WL#8149 B-tree Index Support on non-materialized virtual columns
Browse files Browse the repository at this point in the history
WL#8114  Don't store virtual generated columns in database
WL#8227  Support SEs to create index on virtual generated columns
WL#8481  Callback for computation of virtual column index values
from InnoDB purge threads
All 4 worklogs are to support virtual column and virtual index on such
columns.

rb://8638
  • Loading branch information
Jimmy Yang committed Jul 3, 2015
1 parent 5c44df6 commit c47e175
Show file tree
Hide file tree
Showing 145 changed files with 12,074 additions and 1,356 deletions.
2 changes: 2 additions & 0 deletions include/my_base.h
Expand Up @@ -277,6 +277,8 @@ enum ha_base_keytype {
new definition.
*/
#define HA_KEY_RENAMED (1 << 17)
/** Set if a key is on any virtual generated columns */
#define HA_VIRTUAL_GEN_KEY (1 << 18)

/* Automatic bits in key-flag */

Expand Down
9 changes: 1 addition & 8 deletions include/mysql/thread_pool_priv.h
Expand Up @@ -37,6 +37,7 @@
#include <sql_profile.h>
#include <table.h>
#include "field.h"
#include "sql_thd_internal_api.h"
#include <set>

#ifdef __cplusplus
Expand Down Expand Up @@ -93,8 +94,6 @@ void inc_thread_created();

void thd_lock_thread_count(THD *thd);
void thd_unlock_thread_count(THD *thd);
/* Remove the THD from the set of global threads. */
void remove_global_thread(THD *thd);

#ifdef __cplusplus
}
Expand All @@ -116,10 +115,8 @@ void thd_set_psi(THD *thd, PSI_thread *psi);
/* Interface to THD variables and functions */
void thd_set_killed(THD *thd);
void thd_clear_errors(THD *thd);
void thd_set_thread_stack(THD *thd, char *stack_start);
void thd_close_connection(THD *thd);
THD *thd_get_current_thd();
void thd_new_connection_setup(THD *thd, char *stack_start);
void thd_lock_data(THD *thd);
void thd_unlock_data(THD *thd);
bool thd_is_transaction_active(THD *thd);
Expand Down Expand Up @@ -164,10 +161,6 @@ bool thd_is_connection_alive(THD *thd);
void close_connection(THD *thd, uint errcode);
/* End the connection before closing it */
void end_connection(THD *thd);
/* Release resources of the THD object */
void thd_release_resources(THD *thd);
/* Destroy THD object */
void destroy_thd(THD *thd);
/* Reset thread globals */
void reset_thread_globals(THD *thd);

Expand Down
6 changes: 4 additions & 2 deletions mysql-test/r/mysqlshow.result
Expand Up @@ -114,7 +114,7 @@ Database: information_schema
| INNODB_TRX |
| INNODB_SYS_DATAFILES |
| INNODB_FT_CONFIG |
| INNODB_SYS_TABLESTATS |
| INNODB_SYS_VIRTUAL |
| INNODB_CMP |
| INNODB_FT_BEING_DELETED |
| INNODB_CMP_RESET |
Expand All @@ -139,6 +139,7 @@ Database: information_schema
| INNODB_BUFFER_POOL_STATS |
| INNODB_SYS_COLUMNS |
| INNODB_SYS_FOREIGN |
| INNODB_SYS_TABLESTATS |
+---------------------------------------+
Database: INFORMATION_SCHEMA
+---------------------------------------+
Expand Down Expand Up @@ -179,7 +180,7 @@ Database: INFORMATION_SCHEMA
| INNODB_TRX |
| INNODB_SYS_DATAFILES |
| INNODB_FT_CONFIG |
| INNODB_SYS_TABLESTATS |
| INNODB_SYS_VIRTUAL |
| INNODB_CMP |
| INNODB_FT_BEING_DELETED |
| INNODB_CMP_RESET |
Expand All @@ -204,6 +205,7 @@ Database: INFORMATION_SCHEMA
| INNODB_BUFFER_POOL_STATS |
| INNODB_SYS_COLUMNS |
| INNODB_SYS_FOREIGN |
| INNODB_SYS_TABLESTATS |
+---------------------------------------+
Wildcard: inf_rmation_schema
+--------------------+
Expand Down
91 changes: 84 additions & 7 deletions mysql-test/suite/gcol/inc/gcol_column_def_options.inc
Expand Up @@ -45,10 +45,13 @@ create table t1 (a int);
alter table t1 add column b int generated always as (a+1) virtual null;
drop table t1;

--echo # Added columns mixed with virtual GC and other columns
--echo # Added columns mixed with virtual GC and other columns
create table t1 (a int);
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t1 add column (b int generated always as (a+1) virtual, c int);
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t1 add column (d int, e int generated always as (a+1) virtual);
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t1 add column (f int generated always as (a+1) virtual, g int as(5) stored);
alter table t1 add column (h int generated always as (a+1) virtual, i int as(5) virtual);
drop table t1;
Expand All @@ -70,24 +73,36 @@ alter table t1 add column b int generated always as (a+1) virtual AUTO_INCREMENT
drop table t1;

--echo # [PRIMARY] KEY
--error ER_KEY_BASED_ON_GENERATED_COLUMN
if ($support_virtual_index)
{
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
create table t1 (a int, b int generated always as (a+1) virtual key);
}
create table t1 (a int, b int generated always as (a+1) stored key);
insert into t1 (a) values (3),(1),(2);
select * from t1;
drop table t1;
--error ER_KEY_BASED_ON_GENERATED_COLUMN
if ($support_virtual_index)
{
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
create table t1 (a int, b int generated always as (a+1) virtual primary key);
}
create table t1 (a int, b int generated always as (a+1) stored primary key);
insert into t1 (a) values (3),(1),(2);
select * from t1;
drop table t1;
create table t1 (a int);
--error ER_KEY_BASED_ON_GENERATED_COLUMN
if ($support_virtual_index)
{
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t1 add column b int generated always as (a+1) virtual key;
}
alter table t1 add column b int generated always as (a+1) stored key;
--error ER_KEY_BASED_ON_GENERATED_COLUMN
if ($support_virtual_index)
{
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t1 add column c int generated always as (a+2) virtual primary key;
}
show create table t1;
--error 1068
alter table t1 add column c int generated always as (a+2) stored primary key;
Expand Down Expand Up @@ -144,8 +159,11 @@ create table t1(a int, b int as (a % 2), c int as (a) stored);
create table t2 (a int);
--error ER_KEY_COLUMN_DOES_NOT_EXITS
alter table t1 add constraint foreign key fk(d) references t2(a);
--error ER_KEY_BASED_ON_GENERATED_COLUMN
if ($support_virtual_index)
{
--error ER_CANNOT_ADD_FOREIGN
alter table t1 add constraint foreign key fk(b) references t2(a);
}
--error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
alter table t1 add constraint foreign key fk(c) references t2(a) on delete set null;
--error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
Expand Down Expand Up @@ -198,12 +216,33 @@ select * from t1;
select * from tt;
drop table t1,tt;

if (!$support_virtual_index)
{
--echo # Bug#20769299: INCORRECT KEY ERROR WHEN TRYING TO CREATE INDEX ON
--echo # VIRTUAL GC FOR MYISAM
--error ER_ILLEGAL_HA_CREATE_OPTION
CREATE TABLE A (
pk INTEGER AUTO_INCREMENT,
col_int_nokey INTEGER,
col_int_key INTEGER GENERATED ALWAYS AS (pk + col_int_nokey) VIRTUAL, KEY
(col_int_key));
}

--echo # Bug#20745142: GENERATED COLUMNS: ASSERTION FAILED:
--echo # THD->CHANGE_LIST.IS_EMPTY()
--echo #
--echo #
--error ER_GENERATED_COLUMN_NON_PRIOR
CREATE TABLE t1(a bigint AS (a between 1 and 1));

--echo # Bug#20757211: GENERATED COLUMNS: ALTER TABLE CRASHES
--echo # IN FIND_FIELD_IN_TABLE
--echo #
CREATE TABLE t1(a int);
--error 1064
ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS
( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual;
DROP TABLE t1;

--echo # Bug#20566243: ERROR WHILE DOING CREATE TABLE T1 SELECT (QUERY ON GC COLUMNS)
CREATE TABLE t1(a int, b int as (a + 1),
c varchar(12) as ("aaaabb") stored, d blob as (c));
Expand All @@ -220,6 +259,21 @@ SHOW CREATE TABLE t4;
SELECT * FROM t4;
DROP TABLE t1,t2,t3,t4;

--echo # Bug#21025003:WL8149:ASSERTION `CTX->NUM_TO_DROP_FK
--echo # == HA_ALTER_INFO->ALTER_INFO-> FAILED
--echo #
CREATE TABLE t1 (
col1 int(11) DEFAULT NULL,
col2 int(11) DEFAULT NULL,
col3 int(11) DEFAULT NULL,
col4 int(11) DEFAULT NULL,
col5 int(11) GENERATED ALWAYS AS (col4 / col2) VIRTUAL,
col6 text
);
INSERT INTO t1(col1,col2,col3,col4,col6) VALUES(NULL,1,4,0,REPEAT(2,1000));
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1 DROP PRIMARY KEY , ADD KEY idx ( col5, col2 );
DROP TABLE t1;
--echo # Bug#20949226:i CAN ASSIGN NON-DEFAULT() VALUE TO GENERATED COLUMN
--echo #
--error ER_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
Expand All @@ -232,6 +286,29 @@ CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5;
SELECT * FROM t1;
DROP TABLE t1, t2;

if ($support_virtual_index)
{
--echo # Bug#21074624:i WL8149:SIG 11 INNOBASE_GET_COMPUTED_VALUE |
--echo # INNOBASE/HANDLER/HA_INNODB.CC:19082
CREATE TABLE t1 (
col1 int(11) NOT NULL,
col2 int(11) DEFAULT NULL,
col3 int(11) NOT NULL,
col4 int(11) DEFAULT NULL,
col5 int(11) GENERATED ALWAYS AS (col2 % col4) VIRTUAL,
col6 int(11) GENERATED ALWAYS AS (col3 + col3) VIRTUAL,
col7 int(11) GENERATED ALWAYS AS (col5 / col5) VIRTUAL,
col8 int(11) GENERATED ALWAYS AS (col6 / col5) VIRTUAL,
col9 text,
extra int(11) DEFAULT NULL,
KEY idx (col5)
);
INSERT INTO t1(col1,col2,col3,col4,col9,extra)
VALUES(0,6,3,4,REPEAT(4,1000),0);
ALTER TABLE t1 DROP COLUMN col1;
DROP TABLE t1;
}

--echo # Bug#20757211: GENERATED COLUMNS: ALTER TABLE CRASHES
--echo # IN FIND_FIELD_IN_TABLE
--echo #
Expand Down
18 changes: 18 additions & 0 deletions mysql-test/suite/gcol/inc/gcol_ins_upd.inc
Expand Up @@ -314,6 +314,24 @@ UPDATE t1 SET col7 = DEFAULT;
UPDATE t1 SET col8 = DEFAULT;
DROP TABLE t1;

if ($support_virtual_index)
{
--echo Bug#20797344: WL#8149: ALLOCATED SPACE FOR INDEXED BLOB VGC CAN BE
--echo OVERWRITTEN FOR UPDATE
--echo #
CREATE TABLE t (a varchar(100), b blob,
c blob GENERATED ALWAYS AS (concat(a,b)) VIRTUAL,
d blob GENERATED ALWAYS AS (b) VIRTUAL,
e int(11) GENERATED ALWAYS AS (10) VIRTUAL,
h int(11) NOT NULL, PRIMARY KEY (h), key(c(20)));
INSERT INTO t(a,b,h) VALUES('aaaaaaa','1111111', 11);
INSERT INTO t(a,b,h) VALUES('bbbbbbb','2222222', 22);
SELECT c FROM t;
UPDATE t SET a='ccccccc';
SELECT c FROM t;
DROP TABLE t;
}

--echo # Bug#21081742: ASSERTION !TABLE || (!TABLE->WRITE_SET ||
--echo # BITMAP_IS_SET(TABLE->WRITE_SET
--echo #
Expand Down

0 comments on commit c47e175

Please sign in to comment.