Skip to content

Commit

Permalink
WL#411: Generated Columns
Browse files Browse the repository at this point in the history
Merge with trunk.
  • Loading branch information
BennyWang committed Dec 4, 2014
1 parent 5a8df4f commit 6eabb89
Show file tree
Hide file tree
Showing 863 changed files with 5,869 additions and 18,137 deletions.
1 change: 0 additions & 1 deletion .bzrignore
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,6 @@ mysql-test/var/*
mysql-test/windows_sys_vars.inc
mysql.kdevprj
mysql.proj
sql_priv.h
mysqlbinlog/*.ds?
mysqlbinlog/*.vcproj
mysqlcheck/*.ds?
Expand Down
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Win32
RelWithDebInfo
*~
.*.swp
./CMakeCache.txt
CMakeCache.txt
./MySql.ncb
./MySql.sln
./MySql.suo
Expand Down Expand Up @@ -1378,7 +1378,6 @@ mysql-test/var/*
mysql-test/windows_sys_vars.inc
mysql.kdevprj
mysql.proj
sql_priv.h
mysqlbinlog/*.ds?
mysqlbinlog/*.vcproj
mysqlcheck/*.ds?
Expand Down Expand Up @@ -1849,6 +1848,9 @@ scripts/mysqld_multi
scripts/mysqld_safe
scripts/mysqldumpslow
scripts/safe_mysqld
scripts/sql_commands_help_data.h
scripts/sql_commands_system_data.h
scripts/sql_commands_system_tables.h
select_test
server-tools/instance-manager/.deps/buffer.Po
server-tools/instance-manager/.deps/command.Po
Expand Down Expand Up @@ -3142,3 +3144,5 @@ sql/gen_lex_token
internal/plugin/thread_pool/src/thread_pool_config.h
internal/tests/innorwlocktest
packaging/solaris/postinstall-solaris
client/mysql_install_db
internal/tests/open_files_limit
3 changes: 2 additions & 1 deletion include/my_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ is the global server default. */
#define HA_ERR_SE_OUT_OF_MEMORY 194 /* Out of memory in storage engine */
#define HA_ERR_TABLE_CORRUPT 195 /* Table/Clustered index is corrupted. */
#define HA_ERR_QUERY_INTERRUPTED 196
#define HA_ERR_LAST 196 /* Copy of last error nr */
#define HA_ERR_TABLESPACE_MISSING 197 /* Missing Tablespace */
#define HA_ERR_LAST 197 /* Copy of last error nr */

/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
Expand Down
5 changes: 5 additions & 0 deletions include/my_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ inline unsigned long long my_double2ulonglong(double d)
#define SIZE_T_MAX (~((size_t) 0))
#endif

// Our ifdef trickery for my_isfinite does not work with gcc/solaris unless we:
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif

#if (__cplusplus >= 201103L)
/* For C++11 use the new std functions rather than C99 macros. */
#include <cmath>
Expand Down
4 changes: 1 addition & 3 deletions include/mysql/innodb_priv.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
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
Expand All @@ -18,8 +18,6 @@

/** @file Declaring server-internal functions that are used by InnoDB. */

#include <sql_priv.h>

class THD;

int get_quote_char_for_identifier(THD *thd, const char *name, size_t length);
Expand Down
7 changes: 7 additions & 0 deletions include/priority_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ class Priority_queue : public Less
build_heap();
}

/// Constructs a heap based on input argument.
void assign(const container_type &container)
{
m_container= container;
build_heap();
}

/**
Constructs a heap based on container contents.
Can also be used when many elements have changed.
Expand Down
55 changes: 36 additions & 19 deletions include/queues.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
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
Expand All @@ -13,16 +13,15 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#ifndef QUEUES_INCLUDED
#define QUEUES_INCLUDED

/*
Code for generell handling of priority Queues.
Code for handling of priority Queues.
Implemention of queues from "Algoritms in C" by Robert Sedgewick.
Copyright Monty Program KB.
By monty.
*/

#ifndef _queues_h
#define _queues_h

#include "my_global.h" /* uchar */

#ifdef __cplusplus
Expand All @@ -40,14 +39,23 @@ typedef struct st_queue {
uint auto_extent;
} QUEUE;

void _downheap(QUEUE *queue,uint idx);
void queue_fix(QUEUE *queue);

#define queue_top(queue) ((queue)->root[1])
#define queue_element(queue,index) ((queue)->root[index+1])
#define queue_end(queue) ((queue)->root[(queue)->elements])
#define queue_replaced(queue) _downheap(queue,1)
#define queue_set_compare(queue, cmp) (queue)->compare= cmp
#define queue_set_cmp_arg(queue, set_arg) (queue)->first_cmp_arg= set_arg
#define queue_set_max_at_top(queue, set_arg) \
(queue)->max_at_top= set_arg ? -1 : 1

static inline void queue_replaced(QUEUE *queue)
{
_downheap(queue, 1);
}

static inline void queue_set_max_at_top(QUEUE *queue, int set_arg)
{
queue->max_at_top= set_arg ? -1 : 1;
}

typedef int (*queue_compare)(void *,uchar *, uchar *);

int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
Expand All @@ -59,18 +67,27 @@ int init_queue_ex(QUEUE *queue,uint max_elements,uint offset_to_key,
int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
pbool max_at_top, queue_compare compare,
void *first_cmp_arg);
int resize_queue(QUEUE *queue, uint max_elements);
void delete_queue(QUEUE *queue);
void queue_insert(QUEUE *queue,uchar *element);
int queue_insert_safe(QUEUE *queue, uchar *element);
uchar *queue_remove(QUEUE *queue,uint idx);
#define queue_remove_all(queue) { (queue)->elements= 0; }
#define queue_is_full(queue) (queue->elements == queue->max_elements)
void _downheap(QUEUE *queue,uint idx);
void queue_fix(QUEUE *queue);
#define is_queue_inited(queue) ((queue)->root != 0)

static inline void queue_remove_all(QUEUE *queue)
{
queue->elements= 0;
}

static inline my_bool queue_is_full(QUEUE *queue)
{
return queue->elements == queue->max_elements;
}

static inline my_bool is_queue_inited(QUEUE *queue)
{
return queue->root != NULL;
}

#ifdef __cplusplus
}
#endif
#endif

#endif // QUEUES_INCLUDED
3 changes: 1 addition & 2 deletions libmysqld/emb_qcache.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
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
Expand All @@ -13,7 +13,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include "sql_priv.h"
#include "my_global.h" // HAVE_*

#include <mysql.h>
Expand Down
1 change: 0 additions & 1 deletion mysql-test/collections/default.experimental
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ rpl.rpl_show_slave_running # BUG#12346048 2011-04-11 sven fails sp
rpl.rpl_gtid_logs_without_rotate_or_stop_event @windows # Bug#16207800 2013-02-09 anitha Fails very frequently on windows
rpl.rpl_parallel # Bug#17506885 2013-09-30 agopi Fails for all runs with MTS
rpl.rpl_get_master_version_and_clock # Bug#18949165 2014-07-22 agopi Failes very frequently on PB2
rpl.rpl_parallel_change_master # Bug#19664931 2014-10-22 agopi Test became unstable after push for WL#1697
rpl.rpl_perfschema_applier_status # Bug#2008336 2014-11-27 agopi Failure started on Nov 16th after fix for BUG#20001250

perfschema.transaction_nested_events # Bug#17752288 2013-12-17 agopi Fails several times each day in PB2
Expand Down
17 changes: 16 additions & 1 deletion mysql-test/collections/default.push-ndbcluster
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-test-list=collections/disabled-per-push.list --unit-tests
# Run the standard 'n_mix' tests to check that none of those are affected
# by compiling MySQL Server with NDB. Including NDB adds two more storage engine,
# a few new information_schema tables, the ndbinfo database and more tables
# in the mysql database. This test run detects typical problems caused by these
# additions.
#
# NOTE! The debug mysqld is not enabled in order to speed up the tests. This
# causes some tests which require mysqld-debug to be skipped(those may later
# fail in MySQL Cluster build and test cycle). In addition since this is the only
# build which runs without debug mysqld enabled it will detect any test
# which does not source the necessary include to skip itself when not in debug mode.
#
perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-test-list=collections/disabled-per-push.list --unit-tests --skip-ndb

# Run the ndbcluster suite only(separately for better report in the CI tool).
perl mysql-test-run.pl --timer --force --parallel=auto --comment=ndbcluster --vardir=var-ndbcluster --experimental=collections/default.experimental --skip-test-list=collections/disabled-per-push.list --suite=ndbcluster
76 changes: 76 additions & 0 deletions mysql-test/include/group_by_fd.inc
Original file line number Diff line number Diff line change
Expand Up @@ -919,4 +919,80 @@ DROP TABLE t1;

DROP VIEW v1;

--echo #
--echo # Bug #20031708 ASSERT ON GROUP_CHECK::IS_FD_ON_SOURCE
--echo #

CREATE TABLE t1 (
col_varchar_10_utf8 VARCHAR(10) CHARACTER SET utf8,
col_int_key INT,
pk INT PRIMARY KEY
);

CREATE TABLE t2 (
col_varchar_10_utf8 VARCHAR(10) CHARACTER SET utf8 DEFAULT NULL,
col_int_key INT DEFAULT NULL,
pk INT PRIMARY KEY
);

CREATE VIEW v2 AS SELECT * FROM t2;

# The reporter's testcase:

let $query=
SELECT COUNT(*), t1.col_int_key
FROM v2 LEFT OUTER JOIN t1
ON v2.col_varchar_10_utf8 = t1.col_varchar_10_utf8
WHERE v2.pk = 4;

--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
eval $query;

DROP VIEW v2;

# A variant: one column is an expression:
CREATE VIEW v2 AS SELECT
CONCAT(col_varchar_10_utf8,' ') AS col_varchar_10_utf8,
col_int_key,
pk
FROM t2;

--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
eval $query;

DROP VIEW v2;

# Query used in the commit comment: view column involving two tables
CREATE VIEW v2 AS
SELECT t1.pk, t2.col_int_key+1 as c, t1.pk+t2.col_int_key as p
FROM t1, t2;

# FDs will be discovered in this order: {}->v2.pk, v2.pk->v2.c,
# v2.c->v2.p
SELECT COUNT(*), v2.p
FROM v2
WHERE v2.c=v2.p and v2.c=v2.pk AND v2.pk = 4;
DROP VIEW v2;

# Show that even if in a view a base table's pk is determined,
# a function of this base table's columns may not be determined when
# used in an outer query.
# In this view's result, pk->coa:
CREATE ALGORITHM=MERGE VIEW v2 AS
SELECT t2.pk, COALESCE(t2.pk, 3) AS coa
FROM t1 LEFT JOIN t2 ON 0;

# But pk->coa does not hold in the result of this query using the
# view, because the FD in the view is not NFFD; if there is
# NULL-complementing in the LEFT JOIN below then (pk,coa) will be
# (NULL,NULL) and if there is not it will be (NULL,3): v2.coa is not
# determined by v2.pk.
--error ER_WRONG_FIELD_WITH_GROUP
SELECT v2.pk, v2.coa
FROM t1 LEFT JOIN v2 AS v2 ON 0
GROUP BY v2.pk;

DROP VIEW v2;
DROP TABLE t1,t2;

DROP FUNCTION show_json_object;
4 changes: 2 additions & 2 deletions mysql-test/include/rpl_init.inc
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ if ($rpl_check_server_ids)
}

# Determine if we should use gtids or not.
if (!`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'GTID_MODE' AND VARIABLE_VALUE = 'ON'`)
if ($use_gtids == '')
{
--let $use_gtids=1
--let $use_gtids= `SELECT @@GLOBAL.GTID_MODE = 'ON'`
}


Expand Down
17 changes: 17 additions & 0 deletions mysql-test/include/select.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4339,3 +4339,20 @@ SELECT a, COUNT(*) FROM t1 WHERE 0;
DROP TABLE t1;

--echo # End of test BUG#13571700

--echo #
--echo # Bug #18766378: CRASH IN ITEM_SUM_BIT::RESET_FIELD
--echo #
CREATE TABLE t1(b int);
CREATE TABLE t2(a int);
INSERT INTO t1 VALUES (),();
INSERT INTO t2 VALUES (),();
SELECT
( SELECT 1 FROM t1 GROUP BY a
HAVING avg(distinct 1) ORDER BY max(a)
)
FROM t1, t2
GROUP BY a;

DROP TABLE t1,t2;
echo # End of test BUG#18766378
41 changes: 39 additions & 2 deletions mysql-test/r/alter_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,7 @@ HANDLER t1 CLOSE;
connection con2;
# Reaping ALTER TABLE IMPORT
# It should fail as no tablespace was copied after DISCARD.
ERROR 42S02: Table 'test.t1' doesn't exist
ERROR HY000: Tablespace is missing for table `test`.`t1`.
connection default;
DROP TABLE t1;
#
Expand Down Expand Up @@ -2516,7 +2516,7 @@ HANDLER t1 CLOSE;
connection con2;
# Reaping ALTER TABLE IMPORT
# It should fail as no tablespace was copied after DISCARD.
ERROR 42S02: Table 'test.t1' doesn't exist
ERROR HY000: Tablespace is missing for table `test`.`t1`.
UNLOCK TABLES;
connection default;
DROP TABLE t1;
Expand Down Expand Up @@ -2644,3 +2644,40 @@ TABLE_NAME INDEX_NAME INDEX_TYPE FIELD_NAME FIELD_POS
test/t1 b Primary b 0
test/t1 a Unique a 0
DROP TABLE t1;
#
# BUG#16886196 - ALTER TABLE FAILS TO CONVERT TO PREFIX INDEX IN
# ALTER_COLUMN_EQUAL_PACK_LENGTH
SET @orig_sql_mode = @@sql_mode;
SET sql_mode= '';
# Test with '767' as index size limit.
CREATE TABLE t1(fld1 VARCHAR(767), KEY a(fld1)) ENGINE= INNODB;
INSERT INTO t1 VALUES('a');
ALTER TABLE t1 CHANGE fld1 fld1 VARCHAR(768), ALGORITHM= INPLACE;
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
# Without patch, the below statement will assert in a debug build.
SELECT COUNT(*) FROM t1 WHERE fld1= 'a';
COUNT(*)
1
# Cleanup.
DROP TABLE t1;
# Test with innodb large prefix indexes(Upto 3072).
SET @old_innodb_file_format= @@global.innodb_file_format;
SET @old_innodb_large_prefix= @@global.innodb_large_prefix;
SET GLOBAL innodb_file_format= 'Barracuda';
SET GLOBAL innodb_large_prefix= 1;
CREATE TABLE t1(fld1 VARCHAR(3072), KEY a(fld1)) ENGINE= INNODB
ROW_FORMAT= DYNAMIC;
INSERT INTO t1 VALUES('a');
ALTER TABLE t1 CHANGE fld1 fld1 VARCHAR(3073), ALGORITHM= INPLACE;
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
# Without patch, the below statement will assert in a debug build.
SELECT COUNT(*) FROM t1 WHERE fld1= 'a';
COUNT(*)
1
# Cleanup.
DROP TABLE t1;
SET GLOBAL innodb_file_format= @old_innodb_file_format;
SET GLOBAL innodb_large_prefix= @old_innodb_large_prefix;
SET sql_mode= @orig_sql_mode;
Loading

0 comments on commit 6eabb89

Please sign in to comment.